@elastic/eui 113.2.0 → 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.
- package/es/components/basic_table/collapsed_item_actions.js +2 -0
- package/es/components/context_menu/context_menu_item.js +9 -3
- package/es/components/context_menu/context_menu_item.styles.js +6 -2
- package/es/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
- package/es/components/flyout/const.js +10 -0
- package/es/components/flyout/flyout.component.js +47 -59
- package/es/components/flyout/flyout.js +1 -1
- package/es/components/flyout/flyout_menu.js +17 -4
- package/es/components/flyout/manager/actions.js +9 -5
- package/es/components/flyout/manager/flyout_child.js +8 -2
- package/es/components/flyout/manager/flyout_managed.js +24 -13
- package/es/components/flyout/manager/reducer.js +182 -44
- package/es/components/flyout/manager/store.js +67 -12
- package/es/components/flyout/use_flyout_menu.js +70 -0
- package/es/components/form/file_picker/file_picker.js +46 -18
- package/es/components/table/table_row_cell.js +2 -2
- package/eui.d.ts +397 -15
- package/lib/components/basic_table/collapsed_item_actions.js +2 -0
- package/lib/components/context_menu/context_menu_item.js +9 -3
- package/lib/components/context_menu/context_menu_item.styles.js +5 -1
- package/lib/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
- package/lib/components/flyout/const.js +11 -1
- package/lib/components/flyout/flyout.component.js +46 -58
- package/lib/components/flyout/flyout.js +6 -0
- package/lib/components/flyout/flyout_menu.js +17 -4
- package/lib/components/flyout/manager/actions.js +9 -5
- package/lib/components/flyout/manager/flyout_child.js +8 -2
- package/lib/components/flyout/manager/flyout_managed.js +16 -11
- package/lib/components/flyout/manager/reducer.js +181 -43
- package/lib/components/flyout/manager/store.js +67 -14
- package/lib/components/flyout/use_flyout_menu.js +75 -0
- package/lib/components/form/file_picker/file_picker.js +46 -18
- package/lib/components/table/table_row_cell.js +2 -2
- package/optimize/es/components/basic_table/collapsed_item_actions.js +2 -0
- package/optimize/es/components/context_menu/context_menu_item.js +3 -2
- package/optimize/es/components/context_menu/context_menu_item.styles.js +6 -2
- package/optimize/es/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
- package/optimize/es/components/flyout/const.js +10 -0
- package/optimize/es/components/flyout/flyout.component.js +47 -59
- package/optimize/es/components/flyout/flyout.js +1 -1
- package/optimize/es/components/flyout/flyout_menu.js +5 -2
- package/optimize/es/components/flyout/manager/actions.js +9 -5
- package/optimize/es/components/flyout/manager/flyout_managed.js +16 -11
- package/optimize/es/components/flyout/manager/reducer.js +182 -44
- package/optimize/es/components/flyout/manager/store.js +62 -12
- package/optimize/es/components/flyout/use_flyout_menu.js +69 -0
- package/optimize/es/components/form/file_picker/file_picker.js +35 -18
- package/optimize/es/components/table/table_row_cell.js +2 -2
- package/optimize/lib/components/basic_table/collapsed_item_actions.js +2 -0
- package/optimize/lib/components/context_menu/context_menu_item.js +3 -2
- package/optimize/lib/components/context_menu/context_menu_item.styles.js +5 -1
- package/optimize/lib/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
- package/optimize/lib/components/flyout/const.js +11 -1
- package/optimize/lib/components/flyout/flyout.component.js +46 -58
- package/optimize/lib/components/flyout/flyout.js +6 -0
- package/optimize/lib/components/flyout/flyout_menu.js +5 -2
- package/optimize/lib/components/flyout/manager/actions.js +9 -5
- package/optimize/lib/components/flyout/manager/flyout_managed.js +16 -11
- package/optimize/lib/components/flyout/manager/reducer.js +181 -43
- package/optimize/lib/components/flyout/manager/store.js +63 -12
- package/optimize/lib/components/flyout/use_flyout_menu.js +74 -0
- package/optimize/lib/components/form/file_picker/file_picker.js +35 -18
- package/optimize/lib/components/table/table_row_cell.js +2 -2
- package/package.json +3 -3
- package/test-env/components/basic_table/collapsed_item_actions.js +2 -0
- package/test-env/components/context_menu/context_menu_item.js +9 -3
- package/test-env/components/context_menu/context_menu_item.styles.js +5 -1
- package/test-env/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
- package/test-env/components/flyout/const.js +11 -1
- package/test-env/components/flyout/flyout.component.js +46 -58
- package/test-env/components/flyout/flyout_menu.js +17 -4
- package/test-env/components/flyout/manager/actions.js +9 -5
- package/test-env/components/flyout/manager/flyout_child.js +8 -2
- package/test-env/components/flyout/manager/flyout_managed.js +16 -11
- package/test-env/components/flyout/manager/reducer.js +181 -43
- package/test-env/components/flyout/manager/store.js +63 -12
- package/test-env/components/flyout/use_flyout_menu.js +74 -0
- package/test-env/components/form/file_picker/file_picker.js +46 -18
- package/test-env/components/table/table_row_cell.js +2 -2
|
@@ -75,16 +75,20 @@ function flyoutManagerReducer() {
|
|
|
75
75
|
// session exists, do nothing (invalid child without a parent).
|
|
76
76
|
case _actions.ACTION_ADD:
|
|
77
77
|
{
|
|
78
|
+
var _currentSession$child;
|
|
78
79
|
var flyoutId = action.flyoutId,
|
|
79
80
|
title = action.title,
|
|
80
81
|
level = action.level,
|
|
81
82
|
size = action.size,
|
|
83
|
+
iconType = action.iconType,
|
|
82
84
|
minWidth = action.minWidth;
|
|
83
|
-
|
|
84
|
-
// Ignore duplicate registrations
|
|
85
|
-
if (state.flyouts.some(function (f) {
|
|
85
|
+
var isDuplicate = state.flyouts.some(function (f) {
|
|
86
86
|
return f.flyoutId === flyoutId;
|
|
87
|
-
})
|
|
87
|
+
});
|
|
88
|
+
var isIdempotentChild = level === _const.LEVEL_CHILD && state.sessions.length > 0 && state.sessions[state.sessions.length - 1].childFlyoutId === flyoutId;
|
|
89
|
+
|
|
90
|
+
// Ignore duplicate registrations (except idempotent child re-registration after goBack)
|
|
91
|
+
if (isDuplicate && !isIdempotentChild) {
|
|
88
92
|
return state;
|
|
89
93
|
}
|
|
90
94
|
var newFlyoutState = {
|
|
@@ -94,12 +98,14 @@ function flyoutManagerReducer() {
|
|
|
94
98
|
minWidth: minWidth,
|
|
95
99
|
activityStage: _const.STAGE_OPENING
|
|
96
100
|
};
|
|
97
|
-
var newFlyouts = [].concat((0, _toConsumableArray2.default)(state.flyouts), [newFlyoutState]);
|
|
101
|
+
var newFlyouts = isIdempotentChild ? state.flyouts : [].concat((0, _toConsumableArray2.default)(state.flyouts), [newFlyoutState]);
|
|
98
102
|
if (level === _const.LEVEL_MAIN) {
|
|
99
103
|
var newSession = {
|
|
100
104
|
mainFlyoutId: flyoutId,
|
|
101
105
|
title: title,
|
|
106
|
+
iconType: iconType,
|
|
102
107
|
childFlyoutId: null,
|
|
108
|
+
childHistory: [],
|
|
103
109
|
zIndex: state.currentZIndex
|
|
104
110
|
};
|
|
105
111
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
@@ -116,8 +122,52 @@ function flyoutManagerReducer() {
|
|
|
116
122
|
}
|
|
117
123
|
var updatedSessions = (0, _toConsumableArray2.default)(state.sessions);
|
|
118
124
|
var currentSessionIndex = updatedSessions.length - 1;
|
|
119
|
-
|
|
120
|
-
|
|
125
|
+
var currentSession = updatedSessions[currentSessionIndex];
|
|
126
|
+
var childHistory = (_currentSession$child = currentSession.childHistory) !== null && _currentSession$child !== void 0 ? _currentSession$child : [];
|
|
127
|
+
|
|
128
|
+
// Idempotent re-registration (e.g. after goBack): flyout already in flyouts and session already points to it
|
|
129
|
+
if (state.flyouts.some(function (f) {
|
|
130
|
+
return f.flyoutId === flyoutId;
|
|
131
|
+
})) {
|
|
132
|
+
if (currentSession.childFlyoutId === flyoutId) {
|
|
133
|
+
updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
|
|
134
|
+
childTitle: title,
|
|
135
|
+
childIconType: iconType,
|
|
136
|
+
childHistory: childHistory
|
|
137
|
+
});
|
|
138
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
139
|
+
sessions: updatedSessions
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return state; // duplicate registration for a different child, ignore
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Session already has a child: push current child to history, then set new child (do not remove previous from flyouts)
|
|
146
|
+
if (currentSession.childFlyoutId) {
|
|
147
|
+
var _currentSession$child2;
|
|
148
|
+
var historyEntry = {
|
|
149
|
+
flyoutId: currentSession.childFlyoutId,
|
|
150
|
+
title: (_currentSession$child2 = currentSession.childTitle) !== null && _currentSession$child2 !== void 0 ? _currentSession$child2 : '',
|
|
151
|
+
iconType: currentSession.childIconType
|
|
152
|
+
};
|
|
153
|
+
updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
|
|
154
|
+
childHistory: [].concat((0, _toConsumableArray2.default)(childHistory), [historyEntry]),
|
|
155
|
+
childFlyoutId: flyoutId,
|
|
156
|
+
childTitle: title,
|
|
157
|
+
childIconType: iconType
|
|
158
|
+
});
|
|
159
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
160
|
+
sessions: updatedSessions,
|
|
161
|
+
flyouts: newFlyouts
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// First child in session
|
|
166
|
+
updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
|
|
167
|
+
childFlyoutId: flyoutId,
|
|
168
|
+
childTitle: title,
|
|
169
|
+
childIconType: iconType,
|
|
170
|
+
childHistory: childHistory
|
|
121
171
|
});
|
|
122
172
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
123
173
|
sessions: updatedSessions,
|
|
@@ -127,10 +177,11 @@ function flyoutManagerReducer() {
|
|
|
127
177
|
|
|
128
178
|
// Unregister a flyout and update sessions accordingly.
|
|
129
179
|
// - When closing a `main` flyout, drop its entire session and all associated flyouts.
|
|
130
|
-
// - When closing a `child` flyout,
|
|
131
|
-
//
|
|
180
|
+
// - When closing a `child` flyout, find the session that owns it (childFlyoutId or
|
|
181
|
+
// childHistory) and clear that session's child state so navigation back stays consistent.
|
|
132
182
|
case _actions.ACTION_CLOSE:
|
|
133
183
|
{
|
|
184
|
+
var _owningSession$childH;
|
|
134
185
|
var removedFlyout = state.flyouts.find(function (f) {
|
|
135
186
|
return f.flyoutId === action.flyoutId;
|
|
136
187
|
});
|
|
@@ -143,11 +194,15 @@ function flyoutManagerReducer() {
|
|
|
143
194
|
return session.mainFlyoutId === action.flyoutId;
|
|
144
195
|
});
|
|
145
196
|
if (sessionToRemove) {
|
|
146
|
-
|
|
197
|
+
var _sessionToRemove$chil;
|
|
198
|
+
// Remove all flyouts associated with this session (main + current child + child history)
|
|
147
199
|
var flyoutsToRemove = new Set([action.flyoutId]);
|
|
148
200
|
if (sessionToRemove.childFlyoutId) {
|
|
149
201
|
flyoutsToRemove.add(sessionToRemove.childFlyoutId);
|
|
150
202
|
}
|
|
203
|
+
((_sessionToRemove$chil = sessionToRemove.childHistory) !== null && _sessionToRemove$chil !== void 0 ? _sessionToRemove$chil : []).forEach(function (entry) {
|
|
204
|
+
return flyoutsToRemove.add(entry.flyoutId);
|
|
205
|
+
});
|
|
151
206
|
var _newFlyouts = state.flyouts.filter(function (f) {
|
|
152
207
|
return !flyoutsToRemove.has(f.flyoutId);
|
|
153
208
|
});
|
|
@@ -168,22 +223,43 @@ function flyoutManagerReducer() {
|
|
|
168
223
|
}
|
|
169
224
|
}
|
|
170
225
|
|
|
171
|
-
// Handle child flyout closing
|
|
172
|
-
|
|
173
|
-
return f.flyoutId !== action.flyoutId;
|
|
174
|
-
});
|
|
226
|
+
// Handle child flyout closing: find the session that owns this child and
|
|
227
|
+
// clear that session's child state (so we stay consistent when navigating back).
|
|
175
228
|
if (state.sessions.length === 0) {
|
|
176
229
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
177
|
-
flyouts:
|
|
230
|
+
flyouts: state.flyouts.filter(function (f) {
|
|
231
|
+
return f.flyoutId !== action.flyoutId;
|
|
232
|
+
})
|
|
178
233
|
});
|
|
179
234
|
}
|
|
180
|
-
var
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
235
|
+
var owningSessionIndex = state.sessions.findIndex(function (session) {
|
|
236
|
+
var _session$childHistory;
|
|
237
|
+
return session.childFlyoutId === action.flyoutId || ((_session$childHistory = session.childHistory) !== null && _session$childHistory !== void 0 ? _session$childHistory : []).some(function (entry) {
|
|
238
|
+
return entry.flyoutId === action.flyoutId;
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
if (owningSessionIndex === -1) {
|
|
242
|
+
// Closed flyout not in any session's child state; just remove the one flyout
|
|
243
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
244
|
+
flyouts: state.flyouts.filter(function (f) {
|
|
245
|
+
return f.flyoutId !== action.flyoutId;
|
|
246
|
+
})
|
|
185
247
|
});
|
|
186
248
|
}
|
|
249
|
+
var owningSession = state.sessions[owningSessionIndex];
|
|
250
|
+
var childIds = new Set([owningSession.childFlyoutId].concat((0, _toConsumableArray2.default)(((_owningSession$childH = owningSession.childHistory) !== null && _owningSession$childH !== void 0 ? _owningSession$childH : []).map(function (e) {
|
|
251
|
+
return e.flyoutId;
|
|
252
|
+
}))).filter(Boolean));
|
|
253
|
+
var _newFlyouts2 = state.flyouts.filter(function (f) {
|
|
254
|
+
return !childIds.has(f.flyoutId);
|
|
255
|
+
});
|
|
256
|
+
var _updatedSessions = (0, _toConsumableArray2.default)(state.sessions);
|
|
257
|
+
_updatedSessions[owningSessionIndex] = _objectSpread(_objectSpread({}, owningSession), {}, {
|
|
258
|
+
childFlyoutId: null,
|
|
259
|
+
childTitle: undefined,
|
|
260
|
+
childIconType: undefined,
|
|
261
|
+
childHistory: []
|
|
262
|
+
});
|
|
187
263
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
188
264
|
sessions: _updatedSessions,
|
|
189
265
|
flyouts: _newFlyouts2
|
|
@@ -216,8 +292,8 @@ function flyoutManagerReducer() {
|
|
|
216
292
|
return state;
|
|
217
293
|
}
|
|
218
294
|
var _updatedSessions2 = (0, _toConsumableArray2.default)(state.sessions);
|
|
219
|
-
var
|
|
220
|
-
_updatedSessions2[
|
|
295
|
+
var _currentSessionIndex = _updatedSessions2.length - 1;
|
|
296
|
+
_updatedSessions2[_currentSessionIndex] = _objectSpread(_objectSpread({}, _updatedSessions2[_currentSessionIndex]), {}, {
|
|
221
297
|
childFlyoutId: action.flyoutId
|
|
222
298
|
});
|
|
223
299
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
@@ -263,59 +339,121 @@ function flyoutManagerReducer() {
|
|
|
263
339
|
});
|
|
264
340
|
}
|
|
265
341
|
|
|
266
|
-
// Go back
|
|
342
|
+
// Go back: pop child history when any, else pop current session
|
|
267
343
|
case _actions.ACTION_GO_BACK:
|
|
268
344
|
{
|
|
345
|
+
var _currentSession$child3, _currentSession$child4;
|
|
269
346
|
if (state.sessions.length === 0) {
|
|
270
347
|
return state;
|
|
271
348
|
}
|
|
272
|
-
var
|
|
273
|
-
var
|
|
349
|
+
var _currentSessionIndex2 = state.sessions.length - 1;
|
|
350
|
+
var _currentSession = state.sessions[_currentSessionIndex2];
|
|
351
|
+
var _childHistory = (_currentSession$child3 = _currentSession.childHistory) !== null && _currentSession$child3 !== void 0 ? _currentSession$child3 : [];
|
|
352
|
+
if (_childHistory.length > 0) {
|
|
353
|
+
// Pop one child: set current child to the last entry in history, remove the current child flyout
|
|
354
|
+
var popped = _childHistory[_childHistory.length - 1];
|
|
355
|
+
var newChildHistory = _childHistory.slice(0, -1);
|
|
356
|
+
var _updatedSessions3 = (0, _toConsumableArray2.default)(state.sessions);
|
|
357
|
+
_updatedSessions3[_currentSessionIndex2] = _objectSpread(_objectSpread({}, _currentSession), {}, {
|
|
358
|
+
childHistory: newChildHistory,
|
|
359
|
+
childFlyoutId: popped.flyoutId,
|
|
360
|
+
childTitle: popped.title,
|
|
361
|
+
childIconType: popped.iconType
|
|
362
|
+
});
|
|
363
|
+
var _newFlyouts3 = state.flyouts.filter(function (f) {
|
|
364
|
+
return f.flyoutId !== _currentSession.childFlyoutId;
|
|
365
|
+
});
|
|
366
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
367
|
+
sessions: _updatedSessions3,
|
|
368
|
+
flyouts: _newFlyouts3
|
|
369
|
+
});
|
|
370
|
+
}
|
|
274
371
|
|
|
275
|
-
//
|
|
276
|
-
var _flyoutsToRemove = new Set([
|
|
277
|
-
if (
|
|
278
|
-
_flyoutsToRemove.add(
|
|
372
|
+
// No child history: pop current session (main + all its children)
|
|
373
|
+
var _flyoutsToRemove = new Set([_currentSession.mainFlyoutId]);
|
|
374
|
+
if (_currentSession.childFlyoutId) {
|
|
375
|
+
_flyoutsToRemove.add(_currentSession.childFlyoutId);
|
|
279
376
|
}
|
|
280
|
-
|
|
377
|
+
((_currentSession$child4 = _currentSession.childHistory) !== null && _currentSession$child4 !== void 0 ? _currentSession$child4 : []).forEach(function (e) {
|
|
378
|
+
return _flyoutsToRemove.add(e.flyoutId);
|
|
379
|
+
});
|
|
380
|
+
var _newFlyouts4 = state.flyouts.filter(function (f) {
|
|
281
381
|
return !_flyoutsToRemove.has(f.flyoutId);
|
|
282
382
|
});
|
|
283
|
-
var _newSessions = state.sessions.slice(0,
|
|
383
|
+
var _newSessions = state.sessions.slice(0, _currentSessionIndex2);
|
|
284
384
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
285
385
|
sessions: _newSessions,
|
|
286
|
-
flyouts:
|
|
386
|
+
flyouts: _newFlyouts4
|
|
287
387
|
});
|
|
288
388
|
}
|
|
289
389
|
|
|
290
|
-
// Navigate to a specific flyout (
|
|
390
|
+
// Navigate to a specific flyout (by main session or by child in current session's history)
|
|
291
391
|
case _actions.ACTION_GO_TO_FLYOUT:
|
|
292
392
|
{
|
|
293
|
-
var _flyoutId3 = action.flyoutId
|
|
393
|
+
var _flyoutId3 = action.flyoutId,
|
|
394
|
+
_level = action.level;
|
|
395
|
+
var _currentSessionIndex3 = state.sessions.length - 1;
|
|
396
|
+
if (_level === _const.LEVEL_CHILD && state.sessions.length > 0) {
|
|
397
|
+
var _currentSession2$chil;
|
|
398
|
+
var _currentSession2 = state.sessions[_currentSessionIndex3];
|
|
399
|
+
var _childHistory2 = (_currentSession2$chil = _currentSession2.childHistory) !== null && _currentSession2$chil !== void 0 ? _currentSession2$chil : [];
|
|
400
|
+
var targetIndex = _childHistory2.findIndex(function (entry) {
|
|
401
|
+
return entry.flyoutId === _flyoutId3;
|
|
402
|
+
});
|
|
403
|
+
if (targetIndex === -1) {
|
|
404
|
+
return state; // Target child not in history
|
|
405
|
+
}
|
|
406
|
+
var targetEntry = _childHistory2[targetIndex];
|
|
407
|
+
var _newChildHistory = _childHistory2.slice(0, targetIndex);
|
|
408
|
+
var _flyoutsToRemove2 = new Set();
|
|
409
|
+
if (_currentSession2.childFlyoutId) {
|
|
410
|
+
_flyoutsToRemove2.add(_currentSession2.childFlyoutId);
|
|
411
|
+
}
|
|
412
|
+
_childHistory2.slice(targetIndex + 1).forEach(function (e) {
|
|
413
|
+
_flyoutsToRemove2.add(e.flyoutId);
|
|
414
|
+
});
|
|
415
|
+
var _newFlyouts5 = state.flyouts.filter(function (f) {
|
|
416
|
+
return !_flyoutsToRemove2.has(f.flyoutId);
|
|
417
|
+
});
|
|
418
|
+
var _updatedSessions4 = (0, _toConsumableArray2.default)(state.sessions);
|
|
419
|
+
_updatedSessions4[_currentSessionIndex3] = _objectSpread(_objectSpread({}, _currentSession2), {}, {
|
|
420
|
+
childHistory: _newChildHistory,
|
|
421
|
+
childFlyoutId: targetEntry.flyoutId,
|
|
422
|
+
childTitle: targetEntry.title,
|
|
423
|
+
childIconType: targetEntry.iconType
|
|
424
|
+
});
|
|
425
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
426
|
+
sessions: _updatedSessions4,
|
|
427
|
+
flyouts: _newFlyouts5
|
|
428
|
+
});
|
|
429
|
+
}
|
|
294
430
|
|
|
295
|
-
//
|
|
431
|
+
// Navigate by main flyout: remove all sessions after the target
|
|
296
432
|
var targetSessionIndex = state.sessions.findIndex(function (session) {
|
|
297
433
|
return session.mainFlyoutId === _flyoutId3;
|
|
298
434
|
});
|
|
299
435
|
if (targetSessionIndex === -1) {
|
|
300
436
|
return state; // Target flyout not found
|
|
301
437
|
}
|
|
302
|
-
|
|
303
|
-
// Close all sessions after the target session
|
|
304
438
|
var sessionsToClose = state.sessions.slice(targetSessionIndex + 1);
|
|
305
|
-
var
|
|
439
|
+
var _flyoutsToRemove3 = new Set();
|
|
306
440
|
sessionsToClose.forEach(function (session) {
|
|
307
|
-
|
|
441
|
+
var _session$childHistory2;
|
|
442
|
+
_flyoutsToRemove3.add(session.mainFlyoutId);
|
|
308
443
|
if (session.childFlyoutId) {
|
|
309
|
-
|
|
444
|
+
_flyoutsToRemove3.add(session.childFlyoutId);
|
|
310
445
|
}
|
|
446
|
+
((_session$childHistory2 = session.childHistory) !== null && _session$childHistory2 !== void 0 ? _session$childHistory2 : []).forEach(function (e) {
|
|
447
|
+
return _flyoutsToRemove3.add(e.flyoutId);
|
|
448
|
+
});
|
|
311
449
|
});
|
|
312
|
-
var
|
|
313
|
-
return !
|
|
450
|
+
var _newFlyouts6 = state.flyouts.filter(function (f) {
|
|
451
|
+
return !_flyoutsToRemove3.has(f.flyoutId);
|
|
314
452
|
});
|
|
315
453
|
var _newSessions2 = state.sessions.slice(0, targetSessionIndex + 1);
|
|
316
454
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
317
455
|
sessions: _newSessions2,
|
|
318
|
-
flyouts:
|
|
456
|
+
flyouts: _newFlyouts6
|
|
319
457
|
});
|
|
320
458
|
}
|
|
321
459
|
|
|
@@ -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,68 @@ 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;
|
|
53
57
|
var previousSessions = currentState.sessions.slice(0, currentSessionIndex);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
mainFlyoutId = _ref.mainFlyoutId;
|
|
58
|
+
var childHistory = (_currentSession$child = currentSession === null || currentSession === void 0 ? void 0 : currentSession.childHistory) !== null && _currentSession$child !== void 0 ? _currentSession$child : [];
|
|
59
|
+
var childItems = (0, _toConsumableArray2.default)(childHistory).reverse().map(function (entry) {
|
|
57
60
|
return {
|
|
58
|
-
title: title,
|
|
61
|
+
title: entry.title,
|
|
62
|
+
iconType: entry.iconType,
|
|
59
63
|
onClick: function onClick() {
|
|
60
|
-
|
|
64
|
+
dispatchFn((0, _actions.goToFlyout)(entry.flyoutId, 'child'));
|
|
61
65
|
}
|
|
62
66
|
};
|
|
63
67
|
});
|
|
68
|
+
|
|
69
|
+
// Previous sessions: list each session's current child then its child history (so all travelled entries appear)
|
|
70
|
+
var previousSessionItems = [];
|
|
71
|
+
var _loop = function _loop() {
|
|
72
|
+
var _session$childHistory;
|
|
73
|
+
var session = previousSessions[i];
|
|
74
|
+
var mainTitle = session.title;
|
|
75
|
+
var mainFlyoutId = session.mainFlyoutId;
|
|
76
|
+
var history = (_session$childHistory = session.childHistory) !== null && _session$childHistory !== void 0 ? _session$childHistory : [];
|
|
77
|
+
var hasChildren = session.childFlyoutId != null && session.childTitle != null || history.length > 0;
|
|
78
|
+
if (session.childFlyoutId && session.childTitle) {
|
|
79
|
+
previousSessionItems.push({
|
|
80
|
+
title: session.childTitle,
|
|
81
|
+
iconType: session.childIconType,
|
|
82
|
+
onClick: function onClick() {
|
|
83
|
+
dispatchFn((0, _actions.goToFlyout)(mainFlyoutId, 'main'));
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
var _loop2 = function _loop2() {
|
|
88
|
+
var entry = history[h];
|
|
89
|
+
previousSessionItems.push({
|
|
90
|
+
title: entry.title,
|
|
91
|
+
iconType: entry.iconType,
|
|
92
|
+
onClick: function onClick() {
|
|
93
|
+
dispatchFn((0, _actions.goToFlyout)(mainFlyoutId, 'main'));
|
|
94
|
+
dispatchFn((0, _actions.goToFlyout)(entry.flyoutId, 'child'));
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
for (var h = history.length - 1; h >= 0; h--) {
|
|
99
|
+
_loop2();
|
|
100
|
+
}
|
|
101
|
+
if (!hasChildren) {
|
|
102
|
+
previousSessionItems.push({
|
|
103
|
+
title: mainTitle,
|
|
104
|
+
iconType: session.iconType,
|
|
105
|
+
onClick: function onClick() {
|
|
106
|
+
dispatchFn((0, _actions.goToFlyout)(mainFlyoutId, 'main'));
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
for (var i = previousSessions.length - 1; i >= 0; i--) {
|
|
112
|
+
_loop();
|
|
113
|
+
}
|
|
114
|
+
return [].concat((0, _toConsumableArray2.default)(childItems), previousSessionItems);
|
|
64
115
|
};
|
|
65
116
|
var dispatch = function dispatch(action) {
|
|
66
117
|
var nextState = (0, _reducer.flyoutManagerReducer)(currentState, action);
|
|
@@ -71,7 +122,7 @@ function createStore() {
|
|
|
71
122
|
// Recompute history items eagerly if sessions changed
|
|
72
123
|
// This ensures stable references and avoids stale closures
|
|
73
124
|
if (nextState.sessions !== previousSessions) {
|
|
74
|
-
store.historyItems = computeHistoryItems();
|
|
125
|
+
store.historyItems = computeHistoryItems(dispatch);
|
|
75
126
|
|
|
76
127
|
// Detect removed sessions and emit CLOSE_SESSION events
|
|
77
128
|
var nextSessionIds = new Set(nextState.sessions.map(function (s) {
|
|
@@ -96,8 +147,8 @@ function createStore() {
|
|
|
96
147
|
subscribe: subscribe,
|
|
97
148
|
subscribeToEvents: subscribeToEvents,
|
|
98
149
|
dispatch: dispatch,
|
|
99
|
-
addFlyout: function addFlyout(flyoutId, title, level, size, minWidth) {
|
|
100
|
-
return dispatch((0, _actions.addFlyout)(flyoutId, title, level, size, minWidth));
|
|
150
|
+
addFlyout: function addFlyout(flyoutId, title, level, size, iconType, minWidth) {
|
|
151
|
+
return dispatch((0, _actions.addFlyout)(flyoutId, title, level, size, iconType, minWidth));
|
|
101
152
|
},
|
|
102
153
|
closeFlyout: function closeFlyout(flyoutId) {
|
|
103
154
|
return dispatch((0, _actions.closeFlyout)(flyoutId));
|
|
@@ -120,8 +171,8 @@ function createStore() {
|
|
|
120
171
|
goBack: function goBack() {
|
|
121
172
|
return dispatch((0, _actions.goBack)());
|
|
122
173
|
},
|
|
123
|
-
goToFlyout: function goToFlyout(flyoutId) {
|
|
124
|
-
return dispatch((0, _actions.goToFlyout)(flyoutId));
|
|
174
|
+
goToFlyout: function goToFlyout(flyoutId, level) {
|
|
175
|
+
return dispatch((0, _actions.goToFlyout)(flyoutId, level));
|
|
125
176
|
},
|
|
126
177
|
addUnmanagedFlyout: function addUnmanagedFlyout(flyoutId) {
|
|
127
178
|
return dispatch((0, _actions.addUnmanagedFlyout)(flyoutId));
|
|
@@ -129,7 +180,7 @@ function createStore() {
|
|
|
129
180
|
closeUnmanagedFlyout: function closeUnmanagedFlyout(flyoutId) {
|
|
130
181
|
return dispatch((0, _actions.closeUnmanagedFlyout)(flyoutId));
|
|
131
182
|
},
|
|
132
|
-
historyItems: computeHistoryItems() // Initialize with current state
|
|
183
|
+
historyItems: computeHistoryItems(dispatch) // Initialize with current state
|
|
133
184
|
};
|
|
134
185
|
return store;
|
|
135
186
|
}
|
|
@@ -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
|
+
};
|
|
@@ -28,7 +28,7 @@ var _validatable_control = require("../validatable_control");
|
|
|
28
28
|
var _form_control_layout_clear_button = require("../form_control_layout/form_control_layout_clear_button");
|
|
29
29
|
var _file_picker = require("./file_picker.styles");
|
|
30
30
|
var _react2 = require("@emotion/react");
|
|
31
|
-
var _excluded = ["stylesMemoizer", "id", "name", "initialPromptText", "className", "disabled", "compressed", "onChange", "isInvalid", "fullWidth", "isLoading", "display"];
|
|
31
|
+
var _excluded = ["stylesMemoizer", "id", "name", "initialPromptText", "className", "disabled", "compressed", "onChange", "isInvalid", "fullWidth", "isLoading", "display", "files"];
|
|
32
32
|
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); }
|
|
33
33
|
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; }
|
|
34
34
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
@@ -47,36 +47,41 @@ var EuiFilePickerClass = exports.EuiFilePickerClass = /*#__PURE__*/function (_Co
|
|
|
47
47
|
args[_key] = arguments[_key];
|
|
48
48
|
}
|
|
49
49
|
_this = _callSuper(this, EuiFilePickerClass, [].concat(args));
|
|
50
|
+
(0, _defineProperty2.default)(_this, "fileInput", null);
|
|
51
|
+
(0, _defineProperty2.default)(_this, "generatedId", (0, _services.htmlIdGenerator)()());
|
|
52
|
+
(0, _defineProperty2.default)(_this, "getPromptTextFromFileList", function (files) {
|
|
53
|
+
if (!files || files.length === 0) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
if (files.length > 1) {
|
|
57
|
+
return (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
58
|
+
token: "euiFilePicker.filesSelected",
|
|
59
|
+
default: "{fileCount} files selected",
|
|
60
|
+
values: {
|
|
61
|
+
fileCount: files.length
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return files[0].name;
|
|
66
|
+
});
|
|
50
67
|
(0, _defineProperty2.default)(_this, "state", {
|
|
51
|
-
promptText: null,
|
|
68
|
+
promptText: _this.props.files ? _this.getPromptTextFromFileList(_this.props.files) : null,
|
|
52
69
|
isHoveringDrop: false
|
|
53
70
|
});
|
|
54
|
-
(0, _defineProperty2.default)(_this, "fileInput", null);
|
|
55
|
-
(0, _defineProperty2.default)(_this, "generatedId", (0, _services.htmlIdGenerator)()());
|
|
56
71
|
(0, _defineProperty2.default)(_this, "handleChange", function () {
|
|
57
72
|
if (!_this.fileInput) return;
|
|
58
|
-
if (_this.fileInput.files && _this.fileInput.files.length
|
|
59
|
-
_this.setState({
|
|
60
|
-
promptText: (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
61
|
-
token: "euiFilePicker.filesSelected",
|
|
62
|
-
default: "{fileCount} files selected",
|
|
63
|
-
values: {
|
|
64
|
-
fileCount: _this.fileInput.files.length
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
});
|
|
68
|
-
} else if (_this.fileInput.files && _this.fileInput.files.length === 0) {
|
|
73
|
+
if (_this.fileInput.files && _this.fileInput.files.length === 1) {
|
|
69
74
|
_this.setState({
|
|
70
|
-
promptText:
|
|
75
|
+
promptText: _this.fileInput.value.split('\\').pop()
|
|
71
76
|
});
|
|
72
77
|
} else {
|
|
73
78
|
_this.setState({
|
|
74
|
-
promptText: _this.fileInput.
|
|
79
|
+
promptText: _this.getPromptTextFromFileList(_this.fileInput.files ? Array.from(_this.fileInput.files) : null)
|
|
75
80
|
});
|
|
76
81
|
}
|
|
77
82
|
var onChange = _this.props.onChange;
|
|
78
83
|
if (onChange) {
|
|
79
|
-
onChange(_this.fileInput.files);
|
|
84
|
+
onChange(_this.fileInput.files && _this.fileInput.files.length > 0 ? _this.fileInput.files : null);
|
|
80
85
|
}
|
|
81
86
|
});
|
|
82
87
|
(0, _defineProperty2.default)(_this, "removeFiles", function (e) {
|
|
@@ -104,6 +109,17 @@ var EuiFilePickerClass = exports.EuiFilePickerClass = /*#__PURE__*/function (_Co
|
|
|
104
109
|
}
|
|
105
110
|
(0, _inherits2.default)(EuiFilePickerClass, _Component);
|
|
106
111
|
return (0, _createClass2.default)(EuiFilePickerClass, [{
|
|
112
|
+
key: "componentDidUpdate",
|
|
113
|
+
value: function componentDidUpdate(prevProps) {
|
|
114
|
+
// Update prompt text when files prop changes
|
|
115
|
+
if (this.props.files !== prevProps.files) {
|
|
116
|
+
var _this$props$files;
|
|
117
|
+
this.setState({
|
|
118
|
+
promptText: this.getPromptTextFromFileList((_this$props$files = this.props.files) !== null && _this$props$files !== void 0 ? _this$props$files : null)
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
107
123
|
key: "render",
|
|
108
124
|
value: function render() {
|
|
109
125
|
var _this2 = this;
|
|
@@ -127,6 +143,7 @@ var EuiFilePickerClass = exports.EuiFilePickerClass = /*#__PURE__*/function (_Co
|
|
|
127
143
|
fullWidth = _this2$props$fullWidt === void 0 ? defaultFullWidth : _this2$props$fullWidt,
|
|
128
144
|
isLoading = _this2$props.isLoading,
|
|
129
145
|
display = _this2$props.display,
|
|
146
|
+
files = _this2$props.files,
|
|
130
147
|
rest = (0, _objectWithoutProperties2.default)(_this2$props, _excluded);
|
|
131
148
|
var promptId = "".concat(id || _this2.generatedId, "-filePicker__prompt");
|
|
132
149
|
var isOverridingInitialPrompt = _this2.state.promptText != null;
|
|
@@ -68,9 +68,9 @@ var EuiTableRowCell = exports.EuiTableRowCell = function EuiTableRowCell(_ref) {
|
|
|
68
68
|
return defaultWidth;
|
|
69
69
|
};
|
|
70
70
|
var inlineWidthStyles = (0, _utils.resolveWidthPropsAsStyle)(_style, {
|
|
71
|
-
width: getResponsiveWidth(width, mobileOptions === null || mobileOptions === void 0 ? void 0 : mobileOptions.
|
|
71
|
+
width: getResponsiveWidth(width, mobileOptions === null || mobileOptions === void 0 ? void 0 : mobileOptions.width),
|
|
72
72
|
minWidth: getResponsiveWidth(minWidth, mobileOptions === null || mobileOptions === void 0 ? void 0 : mobileOptions.minWidth),
|
|
73
|
-
maxWidth: getResponsiveWidth(maxWidth, mobileOptions === null || mobileOptions === void 0 ? void 0 : mobileOptions.
|
|
73
|
+
maxWidth: getResponsiveWidth(maxWidth, mobileOptions === null || mobileOptions === void 0 ? void 0 : mobileOptions.maxWidth)
|
|
74
74
|
});
|
|
75
75
|
var Element = setScopeRow ? 'th' : 'td';
|
|
76
76
|
var sharedProps = _objectSpread({
|