@elastic/eui 113.2.1 → 113.3.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 (74) hide show
  1. package/es/components/basic_table/collapsed_item_actions.js +2 -0
  2. package/es/components/context_menu/context_menu_item.js +9 -3
  3. package/es/components/context_menu/context_menu_item.styles.js +6 -2
  4. package/es/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  5. package/es/components/flyout/const.js +10 -0
  6. package/es/components/flyout/flyout.component.js +47 -59
  7. package/es/components/flyout/flyout.js +1 -1
  8. package/es/components/flyout/flyout_menu.js +17 -4
  9. package/es/components/flyout/manager/actions.js +9 -5
  10. package/es/components/flyout/manager/flyout_child.js +8 -2
  11. package/es/components/flyout/manager/flyout_managed.js +24 -13
  12. package/es/components/flyout/manager/reducer.js +182 -44
  13. package/es/components/flyout/manager/store.js +67 -12
  14. package/es/components/flyout/use_flyout_menu.js +70 -0
  15. package/es/components/form/file_picker/file_picker.js +46 -18
  16. package/eui.d.ts +397 -15
  17. package/lib/components/basic_table/collapsed_item_actions.js +2 -0
  18. package/lib/components/context_menu/context_menu_item.js +9 -3
  19. package/lib/components/context_menu/context_menu_item.styles.js +5 -1
  20. package/lib/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  21. package/lib/components/flyout/const.js +11 -1
  22. package/lib/components/flyout/flyout.component.js +46 -58
  23. package/lib/components/flyout/flyout.js +6 -0
  24. package/lib/components/flyout/flyout_menu.js +17 -4
  25. package/lib/components/flyout/manager/actions.js +9 -5
  26. package/lib/components/flyout/manager/flyout_child.js +8 -2
  27. package/lib/components/flyout/manager/flyout_managed.js +16 -11
  28. package/lib/components/flyout/manager/reducer.js +181 -43
  29. package/lib/components/flyout/manager/store.js +67 -14
  30. package/lib/components/flyout/use_flyout_menu.js +75 -0
  31. package/lib/components/form/file_picker/file_picker.js +46 -18
  32. package/optimize/es/components/basic_table/collapsed_item_actions.js +2 -0
  33. package/optimize/es/components/context_menu/context_menu_item.js +3 -2
  34. package/optimize/es/components/context_menu/context_menu_item.styles.js +6 -2
  35. package/optimize/es/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  36. package/optimize/es/components/flyout/const.js +10 -0
  37. package/optimize/es/components/flyout/flyout.component.js +47 -59
  38. package/optimize/es/components/flyout/flyout.js +1 -1
  39. package/optimize/es/components/flyout/flyout_menu.js +5 -2
  40. package/optimize/es/components/flyout/manager/actions.js +9 -5
  41. package/optimize/es/components/flyout/manager/flyout_managed.js +16 -11
  42. package/optimize/es/components/flyout/manager/reducer.js +182 -44
  43. package/optimize/es/components/flyout/manager/store.js +62 -12
  44. package/optimize/es/components/flyout/use_flyout_menu.js +69 -0
  45. package/optimize/es/components/form/file_picker/file_picker.js +35 -18
  46. package/optimize/lib/components/basic_table/collapsed_item_actions.js +2 -0
  47. package/optimize/lib/components/context_menu/context_menu_item.js +3 -2
  48. package/optimize/lib/components/context_menu/context_menu_item.styles.js +5 -1
  49. package/optimize/lib/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  50. package/optimize/lib/components/flyout/const.js +11 -1
  51. package/optimize/lib/components/flyout/flyout.component.js +46 -58
  52. package/optimize/lib/components/flyout/flyout.js +6 -0
  53. package/optimize/lib/components/flyout/flyout_menu.js +5 -2
  54. package/optimize/lib/components/flyout/manager/actions.js +9 -5
  55. package/optimize/lib/components/flyout/manager/flyout_managed.js +16 -11
  56. package/optimize/lib/components/flyout/manager/reducer.js +181 -43
  57. package/optimize/lib/components/flyout/manager/store.js +63 -12
  58. package/optimize/lib/components/flyout/use_flyout_menu.js +74 -0
  59. package/optimize/lib/components/form/file_picker/file_picker.js +35 -18
  60. package/package.json +3 -3
  61. package/test-env/components/basic_table/collapsed_item_actions.js +2 -0
  62. package/test-env/components/context_menu/context_menu_item.js +9 -3
  63. package/test-env/components/context_menu/context_menu_item.styles.js +5 -1
  64. package/test-env/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  65. package/test-env/components/flyout/const.js +11 -1
  66. package/test-env/components/flyout/flyout.component.js +46 -58
  67. package/test-env/components/flyout/flyout_menu.js +17 -4
  68. package/test-env/components/flyout/manager/actions.js +9 -5
  69. package/test-env/components/flyout/manager/flyout_child.js +8 -2
  70. package/test-env/components/flyout/manager/flyout_managed.js +16 -11
  71. package/test-env/components/flyout/manager/reducer.js +181 -43
  72. package/test-env/components/flyout/manager/store.js +63 -12
  73. package/test-env/components/flyout/use_flyout_menu.js +74 -0
  74. package/test-env/components/form/file_picker/file_picker.js +46 -18
@@ -82,16 +82,20 @@ function flyoutManagerReducer() {
82
82
  // session exists, do nothing (invalid child without a parent).
83
83
  case _actions.ACTION_ADD:
84
84
  {
85
+ var _currentSession$child;
85
86
  var flyoutId = action.flyoutId,
86
87
  title = action.title,
87
88
  level = action.level,
88
89
  size = action.size,
90
+ iconType = action.iconType,
89
91
  minWidth = action.minWidth;
90
-
91
- // Ignore duplicate registrations
92
- if (state.flyouts.some(function (f) {
92
+ var isDuplicate = state.flyouts.some(function (f) {
93
93
  return f.flyoutId === flyoutId;
94
- })) {
94
+ });
95
+ var isIdempotentChild = level === _const.LEVEL_CHILD && state.sessions.length > 0 && state.sessions[state.sessions.length - 1].childFlyoutId === flyoutId;
96
+
97
+ // Ignore duplicate registrations (except idempotent child re-registration after goBack)
98
+ if (isDuplicate && !isIdempotentChild) {
95
99
  return state;
96
100
  }
97
101
  var newFlyoutState = {
@@ -101,12 +105,14 @@ function flyoutManagerReducer() {
101
105
  minWidth: minWidth,
102
106
  activityStage: _const.STAGE_OPENING
103
107
  };
104
- var newFlyouts = [].concat(_toConsumableArray(state.flyouts), [newFlyoutState]);
108
+ var newFlyouts = isIdempotentChild ? state.flyouts : [].concat(_toConsumableArray(state.flyouts), [newFlyoutState]);
105
109
  if (level === _const.LEVEL_MAIN) {
106
110
  var newSession = {
107
111
  mainFlyoutId: flyoutId,
108
112
  title: title,
113
+ iconType: iconType,
109
114
  childFlyoutId: null,
115
+ childHistory: [],
110
116
  zIndex: state.currentZIndex
111
117
  };
112
118
  return _objectSpread(_objectSpread({}, state), {}, {
@@ -123,8 +129,52 @@ function flyoutManagerReducer() {
123
129
  }
124
130
  var updatedSessions = _toConsumableArray(state.sessions);
125
131
  var currentSessionIndex = updatedSessions.length - 1;
126
- updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, updatedSessions[currentSessionIndex]), {}, {
127
- childFlyoutId: flyoutId
132
+ var currentSession = updatedSessions[currentSessionIndex];
133
+ var childHistory = (_currentSession$child = currentSession.childHistory) !== null && _currentSession$child !== void 0 ? _currentSession$child : [];
134
+
135
+ // Idempotent re-registration (e.g. after goBack): flyout already in flyouts and session already points to it
136
+ if (state.flyouts.some(function (f) {
137
+ return f.flyoutId === flyoutId;
138
+ })) {
139
+ if (currentSession.childFlyoutId === flyoutId) {
140
+ updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
141
+ childTitle: title,
142
+ childIconType: iconType,
143
+ childHistory: childHistory
144
+ });
145
+ return _objectSpread(_objectSpread({}, state), {}, {
146
+ sessions: updatedSessions
147
+ });
148
+ }
149
+ return state; // duplicate registration for a different child, ignore
150
+ }
151
+
152
+ // Session already has a child: push current child to history, then set new child (do not remove previous from flyouts)
153
+ if (currentSession.childFlyoutId) {
154
+ var _currentSession$child2;
155
+ var historyEntry = {
156
+ flyoutId: currentSession.childFlyoutId,
157
+ title: (_currentSession$child2 = currentSession.childTitle) !== null && _currentSession$child2 !== void 0 ? _currentSession$child2 : '',
158
+ iconType: currentSession.childIconType
159
+ };
160
+ updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
161
+ childHistory: [].concat(_toConsumableArray(childHistory), [historyEntry]),
162
+ childFlyoutId: flyoutId,
163
+ childTitle: title,
164
+ childIconType: iconType
165
+ });
166
+ return _objectSpread(_objectSpread({}, state), {}, {
167
+ sessions: updatedSessions,
168
+ flyouts: newFlyouts
169
+ });
170
+ }
171
+
172
+ // First child in session
173
+ updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
174
+ childFlyoutId: flyoutId,
175
+ childTitle: title,
176
+ childIconType: iconType,
177
+ childHistory: childHistory
128
178
  });
129
179
  return _objectSpread(_objectSpread({}, state), {}, {
130
180
  sessions: updatedSessions,
@@ -134,10 +184,11 @@ function flyoutManagerReducer() {
134
184
 
135
185
  // Unregister a flyout and update sessions accordingly.
136
186
  // - When closing a `main` flyout, drop its entire session and all associated flyouts.
137
- // - When closing a `child` flyout, clear the child pointer on the most
138
- // recent session if it matches.
187
+ // - When closing a `child` flyout, find the session that owns it (childFlyoutId or
188
+ // childHistory) and clear that session's child state so navigation back stays consistent.
139
189
  case _actions.ACTION_CLOSE:
140
190
  {
191
+ var _owningSession$childH;
141
192
  var removedFlyout = state.flyouts.find(function (f) {
142
193
  return f.flyoutId === action.flyoutId;
143
194
  });
@@ -150,11 +201,15 @@ function flyoutManagerReducer() {
150
201
  return session.mainFlyoutId === action.flyoutId;
151
202
  });
152
203
  if (sessionToRemove) {
153
- // Remove all flyouts associated with this session (main + child)
204
+ var _sessionToRemove$chil;
205
+ // Remove all flyouts associated with this session (main + current child + child history)
154
206
  var flyoutsToRemove = new Set([action.flyoutId]);
155
207
  if (sessionToRemove.childFlyoutId) {
156
208
  flyoutsToRemove.add(sessionToRemove.childFlyoutId);
157
209
  }
210
+ ((_sessionToRemove$chil = sessionToRemove.childHistory) !== null && _sessionToRemove$chil !== void 0 ? _sessionToRemove$chil : []).forEach(function (entry) {
211
+ return flyoutsToRemove.add(entry.flyoutId);
212
+ });
158
213
  var _newFlyouts = state.flyouts.filter(function (f) {
159
214
  return !flyoutsToRemove.has(f.flyoutId);
160
215
  });
@@ -175,22 +230,43 @@ function flyoutManagerReducer() {
175
230
  }
176
231
  }
177
232
 
178
- // Handle child flyout closing (existing logic)
179
- var _newFlyouts2 = state.flyouts.filter(function (f) {
180
- return f.flyoutId !== action.flyoutId;
181
- });
233
+ // Handle child flyout closing: find the session that owns this child and
234
+ // clear that session's child state (so we stay consistent when navigating back).
182
235
  if (state.sessions.length === 0) {
183
236
  return _objectSpread(_objectSpread({}, state), {}, {
184
- flyouts: _newFlyouts2
237
+ flyouts: state.flyouts.filter(function (f) {
238
+ return f.flyoutId !== action.flyoutId;
239
+ })
185
240
  });
186
241
  }
187
- var _updatedSessions = _toConsumableArray(state.sessions);
188
- var _currentSessionIndex = _updatedSessions.length - 1;
189
- if (_updatedSessions[_currentSessionIndex].childFlyoutId === action.flyoutId) {
190
- _updatedSessions[_currentSessionIndex] = _objectSpread(_objectSpread({}, _updatedSessions[_currentSessionIndex]), {}, {
191
- childFlyoutId: null
242
+ var owningSessionIndex = state.sessions.findIndex(function (session) {
243
+ var _session$childHistory;
244
+ return session.childFlyoutId === action.flyoutId || ((_session$childHistory = session.childHistory) !== null && _session$childHistory !== void 0 ? _session$childHistory : []).some(function (entry) {
245
+ return entry.flyoutId === action.flyoutId;
246
+ });
247
+ });
248
+ if (owningSessionIndex === -1) {
249
+ // Closed flyout not in any session's child state; just remove the one flyout
250
+ return _objectSpread(_objectSpread({}, state), {}, {
251
+ flyouts: state.flyouts.filter(function (f) {
252
+ return f.flyoutId !== action.flyoutId;
253
+ })
192
254
  });
193
255
  }
256
+ var owningSession = state.sessions[owningSessionIndex];
257
+ var childIds = new Set([owningSession.childFlyoutId].concat(_toConsumableArray(((_owningSession$childH = owningSession.childHistory) !== null && _owningSession$childH !== void 0 ? _owningSession$childH : []).map(function (e) {
258
+ return e.flyoutId;
259
+ }))).filter(Boolean));
260
+ var _newFlyouts2 = state.flyouts.filter(function (f) {
261
+ return !childIds.has(f.flyoutId);
262
+ });
263
+ var _updatedSessions = _toConsumableArray(state.sessions);
264
+ _updatedSessions[owningSessionIndex] = _objectSpread(_objectSpread({}, owningSession), {}, {
265
+ childFlyoutId: null,
266
+ childTitle: undefined,
267
+ childIconType: undefined,
268
+ childHistory: []
269
+ });
194
270
  return _objectSpread(_objectSpread({}, state), {}, {
195
271
  sessions: _updatedSessions,
196
272
  flyouts: _newFlyouts2
@@ -223,8 +299,8 @@ function flyoutManagerReducer() {
223
299
  return state;
224
300
  }
225
301
  var _updatedSessions2 = _toConsumableArray(state.sessions);
226
- var _currentSessionIndex2 = _updatedSessions2.length - 1;
227
- _updatedSessions2[_currentSessionIndex2] = _objectSpread(_objectSpread({}, _updatedSessions2[_currentSessionIndex2]), {}, {
302
+ var _currentSessionIndex = _updatedSessions2.length - 1;
303
+ _updatedSessions2[_currentSessionIndex] = _objectSpread(_objectSpread({}, _updatedSessions2[_currentSessionIndex]), {}, {
228
304
  childFlyoutId: action.flyoutId
229
305
  });
230
306
  return _objectSpread(_objectSpread({}, state), {}, {
@@ -270,59 +346,121 @@ function flyoutManagerReducer() {
270
346
  });
271
347
  }
272
348
 
273
- // Go back one session (remove current session from stack)
349
+ // Go back: pop child history when any, else pop current session
274
350
  case _actions.ACTION_GO_BACK:
275
351
  {
352
+ var _currentSession$child3, _currentSession$child4;
276
353
  if (state.sessions.length === 0) {
277
354
  return state;
278
355
  }
279
- var _currentSessionIndex3 = state.sessions.length - 1;
280
- var currentSession = state.sessions[_currentSessionIndex3];
356
+ var _currentSessionIndex2 = state.sessions.length - 1;
357
+ var _currentSession = state.sessions[_currentSessionIndex2];
358
+ var _childHistory = (_currentSession$child3 = _currentSession.childHistory) !== null && _currentSession$child3 !== void 0 ? _currentSession$child3 : [];
359
+ if (_childHistory.length > 0) {
360
+ // Pop one child: set current child to the last entry in history, remove the current child flyout
361
+ var popped = _childHistory[_childHistory.length - 1];
362
+ var newChildHistory = _childHistory.slice(0, -1);
363
+ var _updatedSessions3 = _toConsumableArray(state.sessions);
364
+ _updatedSessions3[_currentSessionIndex2] = _objectSpread(_objectSpread({}, _currentSession), {}, {
365
+ childHistory: newChildHistory,
366
+ childFlyoutId: popped.flyoutId,
367
+ childTitle: popped.title,
368
+ childIconType: popped.iconType
369
+ });
370
+ var _newFlyouts3 = state.flyouts.filter(function (f) {
371
+ return f.flyoutId !== _currentSession.childFlyoutId;
372
+ });
373
+ return _objectSpread(_objectSpread({}, state), {}, {
374
+ sessions: _updatedSessions3,
375
+ flyouts: _newFlyouts3
376
+ });
377
+ }
281
378
 
282
- // Close all flyouts in the current session
283
- var _flyoutsToRemove = new Set([currentSession.mainFlyoutId]);
284
- if (currentSession.childFlyoutId) {
285
- _flyoutsToRemove.add(currentSession.childFlyoutId);
379
+ // No child history: pop current session (main + all its children)
380
+ var _flyoutsToRemove = new Set([_currentSession.mainFlyoutId]);
381
+ if (_currentSession.childFlyoutId) {
382
+ _flyoutsToRemove.add(_currentSession.childFlyoutId);
286
383
  }
287
- var _newFlyouts3 = state.flyouts.filter(function (f) {
384
+ ((_currentSession$child4 = _currentSession.childHistory) !== null && _currentSession$child4 !== void 0 ? _currentSession$child4 : []).forEach(function (e) {
385
+ return _flyoutsToRemove.add(e.flyoutId);
386
+ });
387
+ var _newFlyouts4 = state.flyouts.filter(function (f) {
288
388
  return !_flyoutsToRemove.has(f.flyoutId);
289
389
  });
290
- var _newSessions = state.sessions.slice(0, _currentSessionIndex3);
390
+ var _newSessions = state.sessions.slice(0, _currentSessionIndex2);
291
391
  return _objectSpread(_objectSpread({}, state), {}, {
292
392
  sessions: _newSessions,
293
- flyouts: _newFlyouts3
393
+ flyouts: _newFlyouts4
294
394
  });
295
395
  }
296
396
 
297
- // Navigate to a specific flyout (remove all sessions after it)
397
+ // Navigate to a specific flyout (by main session or by child in current session's history)
298
398
  case _actions.ACTION_GO_TO_FLYOUT:
299
399
  {
300
- var _flyoutId3 = action.flyoutId;
400
+ var _flyoutId3 = action.flyoutId,
401
+ _level = action.level;
402
+ var _currentSessionIndex3 = state.sessions.length - 1;
403
+ if (_level === _const.LEVEL_CHILD && state.sessions.length > 0) {
404
+ var _currentSession2$chil;
405
+ var _currentSession2 = state.sessions[_currentSessionIndex3];
406
+ var _childHistory2 = (_currentSession2$chil = _currentSession2.childHistory) !== null && _currentSession2$chil !== void 0 ? _currentSession2$chil : [];
407
+ var targetIndex = _childHistory2.findIndex(function (entry) {
408
+ return entry.flyoutId === _flyoutId3;
409
+ });
410
+ if (targetIndex === -1) {
411
+ return state; // Target child not in history
412
+ }
413
+ var targetEntry = _childHistory2[targetIndex];
414
+ var _newChildHistory = _childHistory2.slice(0, targetIndex);
415
+ var _flyoutsToRemove2 = new Set();
416
+ if (_currentSession2.childFlyoutId) {
417
+ _flyoutsToRemove2.add(_currentSession2.childFlyoutId);
418
+ }
419
+ _childHistory2.slice(targetIndex + 1).forEach(function (e) {
420
+ _flyoutsToRemove2.add(e.flyoutId);
421
+ });
422
+ var _newFlyouts5 = state.flyouts.filter(function (f) {
423
+ return !_flyoutsToRemove2.has(f.flyoutId);
424
+ });
425
+ var _updatedSessions4 = _toConsumableArray(state.sessions);
426
+ _updatedSessions4[_currentSessionIndex3] = _objectSpread(_objectSpread({}, _currentSession2), {}, {
427
+ childHistory: _newChildHistory,
428
+ childFlyoutId: targetEntry.flyoutId,
429
+ childTitle: targetEntry.title,
430
+ childIconType: targetEntry.iconType
431
+ });
432
+ return _objectSpread(_objectSpread({}, state), {}, {
433
+ sessions: _updatedSessions4,
434
+ flyouts: _newFlyouts5
435
+ });
436
+ }
301
437
 
302
- // Find the session containing the target flyout
438
+ // Navigate by main flyout: remove all sessions after the target
303
439
  var targetSessionIndex = state.sessions.findIndex(function (session) {
304
440
  return session.mainFlyoutId === _flyoutId3;
305
441
  });
306
442
  if (targetSessionIndex === -1) {
307
443
  return state; // Target flyout not found
308
444
  }
309
-
310
- // Close all sessions after the target session
311
445
  var sessionsToClose = state.sessions.slice(targetSessionIndex + 1);
312
- var _flyoutsToRemove2 = new Set();
446
+ var _flyoutsToRemove3 = new Set();
313
447
  sessionsToClose.forEach(function (session) {
314
- _flyoutsToRemove2.add(session.mainFlyoutId);
448
+ var _session$childHistory2;
449
+ _flyoutsToRemove3.add(session.mainFlyoutId);
315
450
  if (session.childFlyoutId) {
316
- _flyoutsToRemove2.add(session.childFlyoutId);
451
+ _flyoutsToRemove3.add(session.childFlyoutId);
317
452
  }
453
+ ((_session$childHistory2 = session.childHistory) !== null && _session$childHistory2 !== void 0 ? _session$childHistory2 : []).forEach(function (e) {
454
+ return _flyoutsToRemove3.add(e.flyoutId);
455
+ });
318
456
  });
319
- var _newFlyouts4 = state.flyouts.filter(function (f) {
320
- return !_flyoutsToRemove2.has(f.flyoutId);
457
+ var _newFlyouts6 = state.flyouts.filter(function (f) {
458
+ return !_flyoutsToRemove3.has(f.flyoutId);
321
459
  });
322
460
  var _newSessions2 = state.sessions.slice(0, targetSessionIndex + 1);
323
461
  return _objectSpread(_objectSpread({}, state), {}, {
324
462
  sessions: _newSessions2,
325
- flyouts: _newFlyouts4
463
+ flyouts: _newFlyouts6
326
464
  });
327
465
  }
328
466
 
@@ -7,14 +7,18 @@ exports._resetFlyoutManagerStore = _resetFlyoutManagerStore;
7
7
  exports.getFlyoutManagerStore = getFlyoutManagerStore;
8
8
  var _actions = require("./actions");
9
9
  var _reducer = require("./reducer");
10
- /*
10
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
11
+ 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."); }
12
+ 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; } }
13
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
14
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
15
+ 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; } /*
11
16
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
12
17
  * or more contributor license agreements. Licensed under the Elastic License
13
18
  * 2.0 and the Server Side Public License, v 1; you may not use this file except
14
19
  * in compliance with, at your election, the Elastic License 2.0 or the Server
15
20
  * Side Public License, v 1.
16
21
  */
17
-
18
22
  /**
19
23
  * Events emitted by the flyout manager store for external consumers.
20
24
  */
@@ -48,19 +52,68 @@ function createStore() {
48
52
  // The onClick handlers won't execute until after store is fully assigned.
49
53
  // eslint-disable-next-line prefer-const -- Forward declaration requires 'let' not 'const'
50
54
  var store;
51
- var computeHistoryItems = function computeHistoryItems() {
55
+ var computeHistoryItems = function computeHistoryItems(dispatchFn) {
56
+ var _currentSession$child;
52
57
  var currentSessionIndex = currentState.sessions.length - 1;
58
+ var currentSession = currentSessionIndex >= 0 ? currentState.sessions[currentSessionIndex] : null;
53
59
  var previousSessions = currentState.sessions.slice(0, currentSessionIndex);
54
- return previousSessions.reverse().map(function (_ref) {
55
- var title = _ref.title,
56
- mainFlyoutId = _ref.mainFlyoutId;
60
+ var childHistory = (_currentSession$child = currentSession === null || currentSession === void 0 ? void 0 : currentSession.childHistory) !== null && _currentSession$child !== void 0 ? _currentSession$child : [];
61
+ var childItems = _toConsumableArray(childHistory).reverse().map(function (entry) {
57
62
  return {
58
- title: title,
63
+ title: entry.title,
64
+ iconType: entry.iconType,
59
65
  onClick: function onClick() {
60
- store.dispatch((0, _actions.goToFlyout)(mainFlyoutId));
66
+ dispatchFn((0, _actions.goToFlyout)(entry.flyoutId, 'child'));
61
67
  }
62
68
  };
63
69
  });
70
+
71
+ // Previous sessions: list each session's current child then its child history (so all travelled entries appear)
72
+ var previousSessionItems = [];
73
+ var _loop = function _loop() {
74
+ var _session$childHistory;
75
+ var session = previousSessions[i];
76
+ var mainTitle = session.title;
77
+ var mainFlyoutId = session.mainFlyoutId;
78
+ var history = (_session$childHistory = session.childHistory) !== null && _session$childHistory !== void 0 ? _session$childHistory : [];
79
+ var hasChildren = session.childFlyoutId != null && session.childTitle != null || history.length > 0;
80
+ if (session.childFlyoutId && session.childTitle) {
81
+ previousSessionItems.push({
82
+ title: session.childTitle,
83
+ iconType: session.childIconType,
84
+ onClick: function onClick() {
85
+ dispatchFn((0, _actions.goToFlyout)(mainFlyoutId, 'main'));
86
+ }
87
+ });
88
+ }
89
+ var _loop2 = function _loop2() {
90
+ var entry = history[h];
91
+ previousSessionItems.push({
92
+ title: entry.title,
93
+ iconType: entry.iconType,
94
+ onClick: function onClick() {
95
+ dispatchFn((0, _actions.goToFlyout)(mainFlyoutId, 'main'));
96
+ dispatchFn((0, _actions.goToFlyout)(entry.flyoutId, 'child'));
97
+ }
98
+ });
99
+ };
100
+ for (var h = history.length - 1; h >= 0; h--) {
101
+ _loop2();
102
+ }
103
+ if (!hasChildren) {
104
+ previousSessionItems.push({
105
+ title: mainTitle,
106
+ iconType: session.iconType,
107
+ onClick: function onClick() {
108
+ dispatchFn((0, _actions.goToFlyout)(mainFlyoutId, 'main'));
109
+ }
110
+ });
111
+ }
112
+ };
113
+ for (var i = previousSessions.length - 1; i >= 0; i--) {
114
+ _loop();
115
+ }
116
+ return [].concat(_toConsumableArray(childItems), previousSessionItems);
64
117
  };
65
118
  var dispatch = function dispatch(action) {
66
119
  var nextState = (0, _reducer.flyoutManagerReducer)(currentState, action);
@@ -71,7 +124,7 @@ function createStore() {
71
124
  // Recompute history items eagerly if sessions changed
72
125
  // This ensures stable references and avoids stale closures
73
126
  if (nextState.sessions !== previousSessions) {
74
- store.historyItems = computeHistoryItems();
127
+ store.historyItems = computeHistoryItems(dispatch);
75
128
 
76
129
  // Detect removed sessions and emit CLOSE_SESSION events
77
130
  var nextSessionIds = new Set(nextState.sessions.map(function (s) {
@@ -96,8 +149,8 @@ function createStore() {
96
149
  subscribe: subscribe,
97
150
  subscribeToEvents: subscribeToEvents,
98
151
  dispatch: dispatch,
99
- addFlyout: function addFlyout(flyoutId, title, level, size, minWidth) {
100
- return dispatch((0, _actions.addFlyout)(flyoutId, title, level, size, minWidth));
152
+ addFlyout: function addFlyout(flyoutId, title, level, size, iconType, minWidth) {
153
+ return dispatch((0, _actions.addFlyout)(flyoutId, title, level, size, iconType, minWidth));
101
154
  },
102
155
  closeFlyout: function closeFlyout(flyoutId) {
103
156
  return dispatch((0, _actions.closeFlyout)(flyoutId));
@@ -120,8 +173,8 @@ function createStore() {
120
173
  goBack: function goBack() {
121
174
  return dispatch((0, _actions.goBack)());
122
175
  },
123
- goToFlyout: function goToFlyout(flyoutId) {
124
- return dispatch((0, _actions.goToFlyout)(flyoutId));
176
+ goToFlyout: function goToFlyout(flyoutId, level) {
177
+ return dispatch((0, _actions.goToFlyout)(flyoutId, level));
125
178
  },
126
179
  addUnmanagedFlyout: function addUnmanagedFlyout(flyoutId) {
127
180
  return dispatch((0, _actions.addUnmanagedFlyout)(flyoutId));
@@ -129,7 +182,7 @@ function createStore() {
129
182
  closeUnmanagedFlyout: function closeUnmanagedFlyout(flyoutId) {
130
183
  return dispatch((0, _actions.closeUnmanagedFlyout)(flyoutId));
131
184
  },
132
- historyItems: computeHistoryItems() // Initialize with current state
185
+ historyItems: computeHistoryItems(dispatch) // Initialize with current state
133
186
  };
134
187
  return store;
135
188
  }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useEuiFlyoutMenu = void 0;
7
+ var _services = require("../../services");
8
+ var _const = require("./const");
9
+ var _react = require("react");
10
+ var _classnames = _interopRequireDefault(require("classnames"));
11
+ var _excluded = ["titleId"];
12
+ /*
13
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
14
+ * or more contributor license agreements. Licensed under the Elastic License
15
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
16
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
17
+ * Side Public License, v 1.
18
+ */
19
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
+ 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; }
21
+ 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; }
22
+ /**
23
+ * @internal
24
+ */
25
+
26
+ /**
27
+ * Hook to manage flyout menu state and rendering logic.
28
+ * Determines whether the menu should be rendered based on display mode
29
+ * and menu content, and computes the appropriate aria-labelledby value.
30
+ *
31
+ * @internal
32
+ */
33
+ var useEuiFlyoutMenu = exports.useEuiFlyoutMenu = function useEuiFlyoutMenu(_ref) {
34
+ var _flyoutMenuProps$hist, _flyoutMenuProps$hist2, _flyoutMenuProps$cust, _flyoutMenuProps$cust2;
35
+ var _flyoutMenuProps = _ref.flyoutMenuProps,
36
+ flyoutMenuDisplayMode = _ref.flyoutMenuDisplayMode,
37
+ _ariaLabelledBy = _ref.ariaLabelledBy;
38
+ var generatedMenuId = (0, _services.useGeneratedHtmlId)();
39
+ var _ref2 = _flyoutMenuProps || {},
40
+ _titleId = _ref2.titleId,
41
+ flyoutMenuProps = _objectWithoutProperties(_ref2, _excluded);
42
+ var hasMenu = !!_flyoutMenuProps;
43
+ var flyoutMenuId = (0, _react.useMemo)(function () {
44
+ if (!hasMenu) return undefined;
45
+ return _titleId || generatedMenuId;
46
+ }, [hasMenu, _titleId, generatedMenuId]);
47
+
48
+ // Determine if the menu has any content
49
+ // hasBackButton or hasHistory or hasCustomActions or hasVisibleTitle
50
+ 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 ||
51
+ // Component defaults to hiding the title, so only explicit false means the title will be visible
52
+ !!(flyoutMenuProps.title && flyoutMenuProps.hideTitle === false));
53
+
54
+ // Determine if the menu should be rendered based on the display mode and menu content
55
+ var shouldRenderMenu = (0, _react.useMemo)(function () {
56
+ if (!hasMenu) return false;
57
+ if (flyoutMenuDisplayMode === _const.MENU_DISPLAY_ALWAYS) return true;
58
+ if (flyoutMenuDisplayMode === _const.MENU_DISPLAY_AUTO) return menuHasContent;
59
+ return false;
60
+ }, [hasMenu, flyoutMenuDisplayMode, menuHasContent]);
61
+
62
+ // If the flyout menu is to be rendered, ensure the flyout has aria-labelledby referencing the menu's titleId
63
+ var ariaLabelledBy = (0, _react.useMemo)(function () {
64
+ if (flyoutMenuId && shouldRenderMenu) {
65
+ return (0, _classnames.default)(flyoutMenuId, _ariaLabelledBy);
66
+ }
67
+ return _ariaLabelledBy;
68
+ }, [flyoutMenuId, _ariaLabelledBy, shouldRenderMenu]);
69
+ return {
70
+ flyoutMenuId: flyoutMenuId,
71
+ flyoutMenuProps: flyoutMenuProps,
72
+ shouldRenderMenu: shouldRenderMenu,
73
+ ariaLabelledBy: ariaLabelledBy
74
+ };
75
+ };
@@ -18,7 +18,7 @@ var _validatable_control = require("../validatable_control");
18
18
  var _form_control_layout_clear_button = require("../form_control_layout/form_control_layout_clear_button");
19
19
  var _file_picker = require("./file_picker.styles");
20
20
  var _react2 = require("@emotion/react");
21
- var _excluded = ["stylesMemoizer", "id", "name", "initialPromptText", "className", "disabled", "compressed", "onChange", "isInvalid", "fullWidth", "isLoading", "display"];
21
+ var _excluded = ["stylesMemoizer", "id", "name", "initialPromptText", "className", "disabled", "compressed", "onChange", "isInvalid", "fullWidth", "isLoading", "display", "files"];
22
22
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
23
23
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
24
24
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -59,36 +59,41 @@ var EuiFilePickerClass = exports.EuiFilePickerClass = /*#__PURE__*/function (_Co
59
59
  args[_key] = arguments[_key];
60
60
  }
61
61
  _this = _callSuper(this, EuiFilePickerClass, [].concat(args));
62
+ _defineProperty(_this, "fileInput", null);
63
+ _defineProperty(_this, "generatedId", (0, _services.htmlIdGenerator)()());
64
+ _defineProperty(_this, "getPromptTextFromFileList", function (files) {
65
+ if (!files || files.length === 0) {
66
+ return null;
67
+ }
68
+ if (files.length > 1) {
69
+ return (0, _react2.jsx)(_i18n.EuiI18n, {
70
+ token: "euiFilePicker.filesSelected",
71
+ default: "{fileCount} files selected",
72
+ values: {
73
+ fileCount: files.length
74
+ }
75
+ });
76
+ }
77
+ return files[0].name;
78
+ });
62
79
  _defineProperty(_this, "state", {
63
- promptText: null,
80
+ promptText: _this.props.files ? _this.getPromptTextFromFileList(_this.props.files) : null,
64
81
  isHoveringDrop: false
65
82
  });
66
- _defineProperty(_this, "fileInput", null);
67
- _defineProperty(_this, "generatedId", (0, _services.htmlIdGenerator)()());
68
83
  _defineProperty(_this, "handleChange", function () {
69
84
  if (!_this.fileInput) return;
70
- if (_this.fileInput.files && _this.fileInput.files.length > 1) {
85
+ if (_this.fileInput.files && _this.fileInput.files.length === 1) {
71
86
  _this.setState({
72
- promptText: (0, _react2.jsx)(_i18n.EuiI18n, {
73
- token: "euiFilePicker.filesSelected",
74
- default: "{fileCount} files selected",
75
- values: {
76
- fileCount: _this.fileInput.files.length
77
- }
78
- })
79
- });
80
- } else if (_this.fileInput.files && _this.fileInput.files.length === 0) {
81
- _this.setState({
82
- promptText: null
87
+ promptText: _this.fileInput.value.split('\\').pop()
83
88
  });
84
89
  } else {
85
90
  _this.setState({
86
- promptText: _this.fileInput.value.split('\\').pop()
91
+ promptText: _this.getPromptTextFromFileList(_this.fileInput.files ? Array.from(_this.fileInput.files) : null)
87
92
  });
88
93
  }
89
94
  var onChange = _this.props.onChange;
90
95
  if (onChange) {
91
- onChange(_this.fileInput.files);
96
+ onChange(_this.fileInput.files && _this.fileInput.files.length > 0 ? _this.fileInput.files : null);
92
97
  }
93
98
  });
94
99
  _defineProperty(_this, "removeFiles", function (e) {
@@ -116,6 +121,17 @@ var EuiFilePickerClass = exports.EuiFilePickerClass = /*#__PURE__*/function (_Co
116
121
  }
117
122
  _inherits(EuiFilePickerClass, _Component);
118
123
  return _createClass(EuiFilePickerClass, [{
124
+ key: "componentDidUpdate",
125
+ value: function componentDidUpdate(prevProps) {
126
+ // Update prompt text when files prop changes
127
+ if (this.props.files !== prevProps.files) {
128
+ var _this$props$files;
129
+ this.setState({
130
+ promptText: this.getPromptTextFromFileList((_this$props$files = this.props.files) !== null && _this$props$files !== void 0 ? _this$props$files : null)
131
+ });
132
+ }
133
+ }
134
+ }, {
119
135
  key: "render",
120
136
  value: function render() {
121
137
  var _this2 = this;
@@ -139,6 +155,7 @@ var EuiFilePickerClass = exports.EuiFilePickerClass = /*#__PURE__*/function (_Co
139
155
  fullWidth = _this2$props$fullWidt === void 0 ? defaultFullWidth : _this2$props$fullWidt,
140
156
  isLoading = _this2$props.isLoading,
141
157
  display = _this2$props.display,
158
+ files = _this2$props.files,
142
159
  rest = _objectWithoutProperties(_this2$props, _excluded);
143
160
  var promptId = "".concat(id || _this2.generatedId, "-filePicker__prompt");
144
161
  var isOverridingInitialPrompt = _this2.state.promptText != null;
@@ -253,6 +270,17 @@ EuiFilePickerClass.propTypes = {
253
270
  * Use as a callback to access the HTML FileList API
254
271
  */
255
272
  onChange: _propTypes.default.func,
273
+ /**
274
+ * Optionally pass a `File[]` array to maintain the file picker's displayed
275
+ * state between re-renders. Useful for multi-step forms where the component
276
+ * may unmount and remount while the file data is still stored in context.
277
+ *
278
+ * Note: Due to browser security restrictions, the actual file input
279
+ * cannot be programmatically set with files. This prop only controls
280
+ * the displayed state (file names in the prompt). The actual file data
281
+ * should be stored and managed separately in your application state.
282
+ */
283
+ files: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.any.isRequired).isRequired, _propTypes.default.oneOf([null])]),
256
284
  /**
257
285
  * Reduces the size to a typical (compressed) input
258
286
  * @default false