@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.
- package/es/components/basic_table/collapsed_item_actions.js +2 -0
- package/es/components/button/split_button/split_button.js +13 -0
- package/es/components/button/split_button/split_button_actions.js +15 -0
- package/es/components/collapsible_nav/collapsible_nav.js +5 -0
- package/es/components/color_picker/color_picker.js +31 -8
- 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/datagrid/utils/scrolling.js +39 -10
- package/es/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
- package/es/components/flyout/_flyout_overlay.js +34 -4
- package/es/components/flyout/const.js +10 -0
- package/es/components/flyout/flyout.component.js +49 -57
- package/es/components/flyout/flyout.js +10 -2
- package/es/components/flyout/flyout.styles.js +2 -2
- package/es/components/flyout/flyout_menu.js +19 -5
- package/es/components/flyout/flyout_resizable.js +5 -0
- package/es/components/flyout/manager/actions.js +12 -5
- package/es/components/flyout/manager/flyout_child.js +9 -2
- package/es/components/flyout/manager/flyout_managed.js +27 -14
- package/es/components/flyout/manager/reducer.js +251 -54
- package/es/components/flyout/manager/store.js +74 -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/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
- package/es/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +172 -0
- package/es/components/overlay_mask/overlay_mask.js +10 -3
- package/es/components/tree_view/tree_view_item.styles.js +1 -1
- package/es/services/hooks/index.js +8 -8
- package/es/services/hooks/useIsPointerDown.js +6 -15
- package/es/services/index.js +1 -1
- package/eui.d.ts +477 -63
- package/i18ntokens.json +661 -643
- package/lib/components/basic_table/collapsed_item_actions.js +2 -0
- package/lib/components/button/split_button/split_button.js +13 -0
- package/lib/components/button/split_button/split_button_actions.js +15 -0
- package/lib/components/collapsible_nav/collapsible_nav.js +5 -0
- package/lib/components/color_picker/color_picker.js +30 -7
- 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/datagrid/utils/scrolling.js +37 -8
- package/lib/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
- package/lib/components/flyout/_flyout_overlay.js +33 -3
- package/lib/components/flyout/const.js +11 -1
- package/lib/components/flyout/flyout.component.js +48 -56
- package/lib/components/flyout/flyout.js +15 -1
- package/lib/components/flyout/flyout.styles.js +2 -2
- package/lib/components/flyout/flyout_menu.js +19 -5
- package/lib/components/flyout/flyout_resizable.js +5 -0
- package/lib/components/flyout/manager/actions.js +12 -5
- package/lib/components/flyout/manager/flyout_child.js +9 -2
- package/lib/components/flyout/manager/flyout_managed.js +19 -12
- package/lib/components/flyout/manager/reducer.js +250 -53
- package/lib/components/flyout/manager/store.js +74 -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/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
- package/lib/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +179 -0
- package/lib/components/overlay_mask/overlay_mask.js +10 -3
- package/lib/components/tree_view/tree_view_item.styles.js +1 -1
- package/lib/services/hooks/index.js +60 -91
- package/lib/services/hooks/useIsPointerDown.js +7 -14
- package/lib/services/index.js +70 -11
- package/optimize/es/components/basic_table/collapsed_item_actions.js +2 -0
- package/optimize/es/components/color_picker/color_picker.js +31 -8
- 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/datagrid/utils/scrolling.js +39 -10
- package/optimize/es/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
- package/optimize/es/components/flyout/_flyout_overlay.js +34 -4
- package/optimize/es/components/flyout/const.js +10 -0
- package/optimize/es/components/flyout/flyout.component.js +49 -57
- package/optimize/es/components/flyout/flyout.js +5 -2
- package/optimize/es/components/flyout/flyout.styles.js +2 -2
- package/optimize/es/components/flyout/flyout_menu.js +7 -3
- package/optimize/es/components/flyout/manager/actions.js +12 -5
- package/optimize/es/components/flyout/manager/flyout_managed.js +18 -12
- package/optimize/es/components/flyout/manager/reducer.js +251 -54
- package/optimize/es/components/flyout/manager/store.js +69 -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/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
- package/optimize/es/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +172 -0
- package/optimize/es/components/overlay_mask/overlay_mask.js +4 -2
- package/optimize/es/components/tree_view/tree_view_item.styles.js +1 -1
- package/optimize/es/services/hooks/index.js +8 -8
- package/optimize/es/services/hooks/useIsPointerDown.js +6 -10
- package/optimize/es/services/index.js +1 -1
- package/optimize/lib/components/basic_table/collapsed_item_actions.js +2 -0
- package/optimize/lib/components/color_picker/color_picker.js +30 -7
- 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/datagrid/utils/scrolling.js +37 -8
- package/optimize/lib/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
- package/optimize/lib/components/flyout/_flyout_overlay.js +33 -3
- package/optimize/lib/components/flyout/const.js +11 -1
- package/optimize/lib/components/flyout/flyout.component.js +48 -56
- package/optimize/lib/components/flyout/flyout.js +10 -1
- package/optimize/lib/components/flyout/flyout.styles.js +2 -2
- package/optimize/lib/components/flyout/flyout_menu.js +7 -3
- package/optimize/lib/components/flyout/manager/actions.js +12 -5
- package/optimize/lib/components/flyout/manager/flyout_managed.js +18 -12
- package/optimize/lib/components/flyout/manager/reducer.js +250 -53
- package/optimize/lib/components/flyout/manager/store.js +70 -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/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
- package/optimize/lib/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +179 -0
- package/optimize/lib/components/overlay_mask/overlay_mask.js +4 -2
- package/optimize/lib/components/tree_view/tree_view_item.styles.js +1 -1
- package/optimize/lib/services/hooks/index.js +60 -91
- package/optimize/lib/services/hooks/useIsPointerDown.js +5 -10
- package/optimize/lib/services/index.js +70 -11
- package/package.json +4 -4
- package/test-env/components/basic_table/collapsed_item_actions.js +2 -0
- package/test-env/components/button/split_button/split_button.js +13 -0
- package/test-env/components/button/split_button/split_button_actions.js +15 -0
- package/test-env/components/collapsible_nav/collapsible_nav.js +5 -0
- package/test-env/components/color_picker/color_picker.js +30 -7
- 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/datagrid/utils/scrolling.js +37 -8
- package/test-env/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
- package/test-env/components/flyout/_flyout_overlay.js +33 -3
- package/test-env/components/flyout/const.js +11 -1
- package/test-env/components/flyout/flyout.component.js +48 -56
- package/test-env/components/flyout/flyout.styles.js +2 -2
- package/test-env/components/flyout/flyout_menu.js +19 -5
- package/test-env/components/flyout/flyout_resizable.js +5 -0
- package/test-env/components/flyout/manager/actions.js +12 -5
- package/test-env/components/flyout/manager/flyout_child.js +9 -2
- package/test-env/components/flyout/manager/flyout_managed.js +19 -12
- package/test-env/components/flyout/manager/reducer.js +250 -53
- package/test-env/components/flyout/manager/store.js +70 -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/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
- package/test-env/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +179 -0
- package/test-env/components/overlay_mask/overlay_mask.js +10 -3
- package/test-env/components/tree_view/tree_view_item.styles.js +1 -1
- package/test-env/services/hooks/index.js +60 -91
- package/test-env/services/hooks/useIsPointerDown.js +5 -10
- package/test-env/services/index.js +70 -11
|
@@ -39,6 +39,28 @@ var initialState = exports.initialState = {
|
|
|
39
39
|
currentZIndex: 0,
|
|
40
40
|
unmanagedFlyouts: []
|
|
41
41
|
};
|
|
42
|
+
var addSessionFlyoutsToRemove = function addSessionFlyoutsToRemove(session, flyoutsToRemove) {
|
|
43
|
+
var _session$childHistory;
|
|
44
|
+
flyoutsToRemove.add(session.mainFlyoutId);
|
|
45
|
+
if (session.childFlyoutId) {
|
|
46
|
+
flyoutsToRemove.add(session.childFlyoutId);
|
|
47
|
+
}
|
|
48
|
+
((_session$childHistory = session.childHistory) !== null && _session$childHistory !== void 0 ? _session$childHistory : []).forEach(function (e) {
|
|
49
|
+
return flyoutsToRemove.add(e.flyoutId);
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
var moveHistoryGroupToTop = function moveHistoryGroupToTop(sessions, historyKey) {
|
|
53
|
+
var groupSessions = [];
|
|
54
|
+
var otherSessions = [];
|
|
55
|
+
sessions.forEach(function (session) {
|
|
56
|
+
if (session.historyKey === historyKey) {
|
|
57
|
+
groupSessions.push(session);
|
|
58
|
+
} else {
|
|
59
|
+
otherSessions.push(session);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return [].concat(otherSessions, groupSessions);
|
|
63
|
+
};
|
|
42
64
|
|
|
43
65
|
/**
|
|
44
66
|
* Reducer handling all flyout manager actions and state transitions.
|
|
@@ -82,16 +104,21 @@ function flyoutManagerReducer() {
|
|
|
82
104
|
// session exists, do nothing (invalid child without a parent).
|
|
83
105
|
case _actions.ACTION_ADD:
|
|
84
106
|
{
|
|
107
|
+
var _currentSession$child;
|
|
85
108
|
var flyoutId = action.flyoutId,
|
|
86
109
|
title = action.title,
|
|
87
110
|
level = action.level,
|
|
88
111
|
size = action.size,
|
|
112
|
+
historyKey = action.historyKey,
|
|
113
|
+
iconType = action.iconType,
|
|
89
114
|
minWidth = action.minWidth;
|
|
90
|
-
|
|
91
|
-
// Ignore duplicate registrations
|
|
92
|
-
if (state.flyouts.some(function (f) {
|
|
115
|
+
var isDuplicate = state.flyouts.some(function (f) {
|
|
93
116
|
return f.flyoutId === flyoutId;
|
|
94
|
-
})
|
|
117
|
+
});
|
|
118
|
+
var isIdempotentChild = level === _const.LEVEL_CHILD && state.sessions.length > 0 && state.sessions[state.sessions.length - 1].childFlyoutId === flyoutId;
|
|
119
|
+
|
|
120
|
+
// Ignore duplicate registrations (except idempotent child re-registration after goBack)
|
|
121
|
+
if (isDuplicate && !isIdempotentChild) {
|
|
95
122
|
return state;
|
|
96
123
|
}
|
|
97
124
|
var newFlyoutState = {
|
|
@@ -101,13 +128,16 @@ function flyoutManagerReducer() {
|
|
|
101
128
|
minWidth: minWidth,
|
|
102
129
|
activityStage: _const.STAGE_OPENING
|
|
103
130
|
};
|
|
104
|
-
var newFlyouts = [].concat(_toConsumableArray(state.flyouts), [newFlyoutState]);
|
|
131
|
+
var newFlyouts = isIdempotentChild ? state.flyouts : [].concat(_toConsumableArray(state.flyouts), [newFlyoutState]);
|
|
105
132
|
if (level === _const.LEVEL_MAIN) {
|
|
106
133
|
var newSession = {
|
|
107
134
|
mainFlyoutId: flyoutId,
|
|
108
135
|
title: title,
|
|
136
|
+
iconType: iconType,
|
|
109
137
|
childFlyoutId: null,
|
|
110
|
-
|
|
138
|
+
childHistory: [],
|
|
139
|
+
zIndex: state.currentZIndex,
|
|
140
|
+
historyKey: historyKey !== null && historyKey !== void 0 ? historyKey : Symbol()
|
|
111
141
|
};
|
|
112
142
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
113
143
|
sessions: [].concat(_toConsumableArray(state.sessions), [newSession]),
|
|
@@ -123,8 +153,52 @@ function flyoutManagerReducer() {
|
|
|
123
153
|
}
|
|
124
154
|
var updatedSessions = _toConsumableArray(state.sessions);
|
|
125
155
|
var currentSessionIndex = updatedSessions.length - 1;
|
|
126
|
-
|
|
127
|
-
|
|
156
|
+
var currentSession = updatedSessions[currentSessionIndex];
|
|
157
|
+
var childHistory = (_currentSession$child = currentSession.childHistory) !== null && _currentSession$child !== void 0 ? _currentSession$child : [];
|
|
158
|
+
|
|
159
|
+
// Idempotent re-registration (e.g. after goBack): flyout already in flyouts and session already points to it
|
|
160
|
+
if (state.flyouts.some(function (f) {
|
|
161
|
+
return f.flyoutId === flyoutId;
|
|
162
|
+
})) {
|
|
163
|
+
if (currentSession.childFlyoutId === flyoutId) {
|
|
164
|
+
updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
|
|
165
|
+
childTitle: title,
|
|
166
|
+
childIconType: iconType,
|
|
167
|
+
childHistory: childHistory
|
|
168
|
+
});
|
|
169
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
170
|
+
sessions: updatedSessions
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return state; // duplicate registration for a different child, ignore
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Session already has a child: push current child to history, then set new child (do not remove previous from flyouts)
|
|
177
|
+
if (currentSession.childFlyoutId) {
|
|
178
|
+
var _currentSession$child2;
|
|
179
|
+
var historyEntry = {
|
|
180
|
+
flyoutId: currentSession.childFlyoutId,
|
|
181
|
+
title: (_currentSession$child2 = currentSession.childTitle) !== null && _currentSession$child2 !== void 0 ? _currentSession$child2 : '',
|
|
182
|
+
iconType: currentSession.childIconType
|
|
183
|
+
};
|
|
184
|
+
updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
|
|
185
|
+
childHistory: [].concat(_toConsumableArray(childHistory), [historyEntry]),
|
|
186
|
+
childFlyoutId: flyoutId,
|
|
187
|
+
childTitle: title,
|
|
188
|
+
childIconType: iconType
|
|
189
|
+
});
|
|
190
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
191
|
+
sessions: updatedSessions,
|
|
192
|
+
flyouts: newFlyouts
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// First child in session
|
|
197
|
+
updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
|
|
198
|
+
childFlyoutId: flyoutId,
|
|
199
|
+
childTitle: title,
|
|
200
|
+
childIconType: iconType,
|
|
201
|
+
childHistory: childHistory
|
|
128
202
|
});
|
|
129
203
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
130
204
|
sessions: updatedSessions,
|
|
@@ -134,10 +208,11 @@ function flyoutManagerReducer() {
|
|
|
134
208
|
|
|
135
209
|
// Unregister a flyout and update sessions accordingly.
|
|
136
210
|
// - When closing a `main` flyout, drop its entire session and all associated flyouts.
|
|
137
|
-
// - When closing a `child` flyout,
|
|
138
|
-
//
|
|
211
|
+
// - When closing a `child` flyout, find the session that owns it (childFlyoutId or
|
|
212
|
+
// childHistory) and clear that session's child state so navigation back stays consistent.
|
|
139
213
|
case _actions.ACTION_CLOSE:
|
|
140
214
|
{
|
|
215
|
+
var _owningSession$childH;
|
|
141
216
|
var removedFlyout = state.flyouts.find(function (f) {
|
|
142
217
|
return f.flyoutId === action.flyoutId;
|
|
143
218
|
});
|
|
@@ -150,11 +225,15 @@ function flyoutManagerReducer() {
|
|
|
150
225
|
return session.mainFlyoutId === action.flyoutId;
|
|
151
226
|
});
|
|
152
227
|
if (sessionToRemove) {
|
|
153
|
-
|
|
228
|
+
var _sessionToRemove$chil;
|
|
229
|
+
// Remove all flyouts associated with this session (main + current child + child history)
|
|
154
230
|
var flyoutsToRemove = new Set([action.flyoutId]);
|
|
155
231
|
if (sessionToRemove.childFlyoutId) {
|
|
156
232
|
flyoutsToRemove.add(sessionToRemove.childFlyoutId);
|
|
157
233
|
}
|
|
234
|
+
((_sessionToRemove$chil = sessionToRemove.childHistory) !== null && _sessionToRemove$chil !== void 0 ? _sessionToRemove$chil : []).forEach(function (entry) {
|
|
235
|
+
return flyoutsToRemove.add(entry.flyoutId);
|
|
236
|
+
});
|
|
158
237
|
var _newFlyouts = state.flyouts.filter(function (f) {
|
|
159
238
|
return !flyoutsToRemove.has(f.flyoutId);
|
|
160
239
|
});
|
|
@@ -175,43 +254,80 @@ function flyoutManagerReducer() {
|
|
|
175
254
|
}
|
|
176
255
|
}
|
|
177
256
|
|
|
178
|
-
// Handle child flyout closing
|
|
179
|
-
|
|
180
|
-
return f.flyoutId !== action.flyoutId;
|
|
181
|
-
});
|
|
257
|
+
// Handle child flyout closing: find the session that owns this child and
|
|
258
|
+
// clear that session's child state (so we stay consistent when navigating back).
|
|
182
259
|
if (state.sessions.length === 0) {
|
|
183
260
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
184
|
-
flyouts:
|
|
261
|
+
flyouts: state.flyouts.filter(function (f) {
|
|
262
|
+
return f.flyoutId !== action.flyoutId;
|
|
263
|
+
})
|
|
185
264
|
});
|
|
186
265
|
}
|
|
187
|
-
var
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
266
|
+
var owningSessionIndex = state.sessions.findIndex(function (session) {
|
|
267
|
+
var _session$childHistory2;
|
|
268
|
+
return session.childFlyoutId === action.flyoutId || ((_session$childHistory2 = session.childHistory) !== null && _session$childHistory2 !== void 0 ? _session$childHistory2 : []).some(function (entry) {
|
|
269
|
+
return entry.flyoutId === action.flyoutId;
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
if (owningSessionIndex === -1) {
|
|
273
|
+
// Closed flyout not in any session's child state; just remove the one flyout
|
|
274
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
275
|
+
flyouts: state.flyouts.filter(function (f) {
|
|
276
|
+
return f.flyoutId !== action.flyoutId;
|
|
277
|
+
})
|
|
192
278
|
});
|
|
193
279
|
}
|
|
280
|
+
var owningSession = state.sessions[owningSessionIndex];
|
|
281
|
+
var childIds = new Set([owningSession.childFlyoutId].concat(_toConsumableArray(((_owningSession$childH = owningSession.childHistory) !== null && _owningSession$childH !== void 0 ? _owningSession$childH : []).map(function (e) {
|
|
282
|
+
return e.flyoutId;
|
|
283
|
+
}))).filter(Boolean));
|
|
284
|
+
var _newFlyouts2 = state.flyouts.filter(function (f) {
|
|
285
|
+
return !childIds.has(f.flyoutId);
|
|
286
|
+
});
|
|
287
|
+
var _updatedSessions = _toConsumableArray(state.sessions);
|
|
288
|
+
_updatedSessions[owningSessionIndex] = _objectSpread(_objectSpread({}, owningSession), {}, {
|
|
289
|
+
childFlyoutId: null,
|
|
290
|
+
childTitle: undefined,
|
|
291
|
+
childIconType: undefined,
|
|
292
|
+
childHistory: []
|
|
293
|
+
});
|
|
194
294
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
195
295
|
sessions: _updatedSessions,
|
|
196
296
|
flyouts: _newFlyouts2
|
|
197
297
|
});
|
|
198
298
|
}
|
|
199
299
|
|
|
200
|
-
// Unregister all flyouts.
|
|
300
|
+
// Unregister all flyouts (within the current history group only).
|
|
201
301
|
case _actions.ACTION_CLOSE_ALL:
|
|
202
302
|
{
|
|
203
303
|
if (state.sessions.length === 0) {
|
|
204
304
|
return state;
|
|
205
305
|
}
|
|
306
|
+
var _currentSessionIndex = state.sessions.length - 1;
|
|
307
|
+
var _currentSession = state.sessions[_currentSessionIndex];
|
|
308
|
+
var currentKey = _currentSession.historyKey;
|
|
206
309
|
|
|
207
|
-
//
|
|
310
|
+
// Remove all sessions that have the current historyKey (entire group)
|
|
311
|
+
var _newSessions = state.sessions.filter(function (s) {
|
|
312
|
+
return s.historyKey !== currentKey;
|
|
313
|
+
});
|
|
314
|
+
var _flyoutsToRemove = new Set();
|
|
315
|
+
state.sessions.forEach(function (session) {
|
|
316
|
+
if (session.historyKey === currentKey) {
|
|
317
|
+
addSessionFlyoutsToRemove(session, _flyoutsToRemove);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
var _newFlyouts3 = state.flyouts.filter(function (f) {
|
|
321
|
+
return !_flyoutsToRemove.has(f.flyoutId);
|
|
322
|
+
});
|
|
208
323
|
var _newCurrentZIndex2 = state.currentZIndex;
|
|
209
|
-
if (state.unmanagedFlyouts.length === 0) {
|
|
324
|
+
if (_newSessions.length === 0 && state.unmanagedFlyouts.length === 0) {
|
|
210
325
|
_newCurrentZIndex2 = 0;
|
|
211
326
|
}
|
|
212
|
-
return _objectSpread(_objectSpread({},
|
|
213
|
-
|
|
214
|
-
|
|
327
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
328
|
+
sessions: _newSessions,
|
|
329
|
+
flyouts: _newFlyouts3,
|
|
330
|
+
currentZIndex: _newCurrentZIndex2
|
|
215
331
|
});
|
|
216
332
|
}
|
|
217
333
|
|
|
@@ -270,59 +386,140 @@ function flyoutManagerReducer() {
|
|
|
270
386
|
});
|
|
271
387
|
}
|
|
272
388
|
|
|
273
|
-
// Go back
|
|
389
|
+
// Go back: pop child history when any, else pop current session (only within same historyKey).
|
|
274
390
|
case _actions.ACTION_GO_BACK:
|
|
275
391
|
{
|
|
392
|
+
var _currentSession2$chil;
|
|
276
393
|
if (state.sessions.length === 0) {
|
|
277
394
|
return state;
|
|
278
395
|
}
|
|
279
396
|
var _currentSessionIndex3 = state.sessions.length - 1;
|
|
280
|
-
var
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
397
|
+
var _currentSession2 = state.sessions[_currentSessionIndex3];
|
|
398
|
+
var _childHistory = (_currentSession2$chil = _currentSession2.childHistory) !== null && _currentSession2$chil !== void 0 ? _currentSession2$chil : [];
|
|
399
|
+
if (_childHistory.length > 0) {
|
|
400
|
+
// Pop one child: set current child to the last entry in history, remove the current child flyout
|
|
401
|
+
var popped = _childHistory[_childHistory.length - 1];
|
|
402
|
+
var newChildHistory = _childHistory.slice(0, -1);
|
|
403
|
+
var _updatedSessions3 = _toConsumableArray(state.sessions);
|
|
404
|
+
_updatedSessions3[_currentSessionIndex3] = _objectSpread(_objectSpread({}, _currentSession2), {}, {
|
|
405
|
+
childHistory: newChildHistory,
|
|
406
|
+
childFlyoutId: popped.flyoutId,
|
|
407
|
+
childTitle: popped.title,
|
|
408
|
+
childIconType: popped.iconType
|
|
409
|
+
});
|
|
410
|
+
var _newFlyouts4 = state.flyouts.filter(function (f) {
|
|
411
|
+
return f.flyoutId !== _currentSession2.childFlyoutId;
|
|
412
|
+
});
|
|
413
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
414
|
+
sessions: _updatedSessions3,
|
|
415
|
+
flyouts: _newFlyouts4
|
|
416
|
+
});
|
|
286
417
|
}
|
|
287
|
-
|
|
288
|
-
|
|
418
|
+
|
|
419
|
+
// No child history: pop current session (main + all its children)
|
|
420
|
+
var _flyoutsToRemove2 = new Set();
|
|
421
|
+
addSessionFlyoutsToRemove(_currentSession2, _flyoutsToRemove2);
|
|
422
|
+
var sessionsWithoutCurrent = state.sessions.slice(0, _currentSessionIndex3);
|
|
423
|
+
var hasRemainingInCurrentGroup = sessionsWithoutCurrent.some(function (s) {
|
|
424
|
+
return s.historyKey === _currentSession2.historyKey;
|
|
425
|
+
});
|
|
426
|
+
var _newSessions2 = hasRemainingInCurrentGroup ? moveHistoryGroupToTop(sessionsWithoutCurrent, _currentSession2.historyKey) : sessionsWithoutCurrent;
|
|
427
|
+
var _newFlyouts5 = state.flyouts.filter(function (f) {
|
|
428
|
+
return !_flyoutsToRemove2.has(f.flyoutId);
|
|
289
429
|
});
|
|
290
|
-
var _newSessions = state.sessions.slice(0, _currentSessionIndex3);
|
|
291
430
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
292
|
-
sessions:
|
|
293
|
-
flyouts:
|
|
431
|
+
sessions: _newSessions2,
|
|
432
|
+
flyouts: _newFlyouts5
|
|
294
433
|
});
|
|
295
434
|
}
|
|
296
435
|
|
|
297
|
-
// Navigate to a specific flyout (
|
|
436
|
+
// Navigate to a specific flyout (by main session or by child in current session's history)
|
|
298
437
|
case _actions.ACTION_GO_TO_FLYOUT:
|
|
299
438
|
{
|
|
300
|
-
var _flyoutId3 = action.flyoutId
|
|
439
|
+
var _flyoutId3 = action.flyoutId,
|
|
440
|
+
_level = action.level;
|
|
441
|
+
var _currentSessionIndex4 = state.sessions.length - 1;
|
|
442
|
+
if (_level === _const.LEVEL_CHILD && state.sessions.length > 0) {
|
|
443
|
+
var _currentSession3$chil;
|
|
444
|
+
var _currentSession3 = state.sessions[_currentSessionIndex4];
|
|
445
|
+
var _childHistory2 = (_currentSession3$chil = _currentSession3.childHistory) !== null && _currentSession3$chil !== void 0 ? _currentSession3$chil : [];
|
|
446
|
+
var targetIndex = _childHistory2.findIndex(function (entry) {
|
|
447
|
+
return entry.flyoutId === _flyoutId3;
|
|
448
|
+
});
|
|
449
|
+
if (targetIndex === -1) {
|
|
450
|
+
return state; // Target child not in history
|
|
451
|
+
}
|
|
452
|
+
var targetEntry = _childHistory2[targetIndex];
|
|
453
|
+
var _newChildHistory = _childHistory2.slice(0, targetIndex);
|
|
454
|
+
var _flyoutsToRemove3 = new Set();
|
|
455
|
+
if (_currentSession3.childFlyoutId) {
|
|
456
|
+
_flyoutsToRemove3.add(_currentSession3.childFlyoutId);
|
|
457
|
+
}
|
|
458
|
+
_childHistory2.slice(targetIndex + 1).forEach(function (e) {
|
|
459
|
+
_flyoutsToRemove3.add(e.flyoutId);
|
|
460
|
+
});
|
|
461
|
+
var _newFlyouts6 = state.flyouts.filter(function (f) {
|
|
462
|
+
return !_flyoutsToRemove3.has(f.flyoutId);
|
|
463
|
+
});
|
|
464
|
+
var _updatedSessions4 = _toConsumableArray(state.sessions);
|
|
465
|
+
_updatedSessions4[_currentSessionIndex4] = _objectSpread(_objectSpread({}, _currentSession3), {}, {
|
|
466
|
+
childHistory: _newChildHistory,
|
|
467
|
+
childFlyoutId: targetEntry.flyoutId,
|
|
468
|
+
childTitle: targetEntry.title,
|
|
469
|
+
childIconType: targetEntry.iconType
|
|
470
|
+
});
|
|
471
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
472
|
+
sessions: _updatedSessions4,
|
|
473
|
+
flyouts: _newFlyouts6
|
|
474
|
+
});
|
|
475
|
+
}
|
|
301
476
|
|
|
302
|
-
//
|
|
477
|
+
// Navigate by main flyout: remove all sessions after the target
|
|
303
478
|
var targetSessionIndex = state.sessions.findIndex(function (session) {
|
|
304
479
|
return session.mainFlyoutId === _flyoutId3;
|
|
305
480
|
});
|
|
306
481
|
if (targetSessionIndex === -1) {
|
|
307
482
|
return state; // Target flyout not found
|
|
308
483
|
}
|
|
484
|
+
var _currentSession4 = state.sessions[_currentSessionIndex4];
|
|
485
|
+
var targetSession = state.sessions[targetSessionIndex];
|
|
309
486
|
|
|
310
|
-
//
|
|
487
|
+
// Group-local navigation: keep other history groups, remove only newer sessions in target's group,
|
|
488
|
+
// then bring that group to the top.
|
|
489
|
+
if (targetSession.historyKey === _currentSession4.historyKey) {
|
|
490
|
+
var _flyoutsToRemove4 = new Set();
|
|
491
|
+
var sessionsAfterTargetInGroup = state.sessions.filter(function (session, index) {
|
|
492
|
+
return index > targetSessionIndex && session.historyKey === targetSession.historyKey;
|
|
493
|
+
});
|
|
494
|
+
sessionsAfterTargetInGroup.forEach(function (session) {
|
|
495
|
+
addSessionFlyoutsToRemove(session, _flyoutsToRemove4);
|
|
496
|
+
});
|
|
497
|
+
var sessionsWithoutRemoved = state.sessions.filter(function (session) {
|
|
498
|
+
return !sessionsAfterTargetInGroup.some(function (removed) {
|
|
499
|
+
return removed.mainFlyoutId === session.mainFlyoutId;
|
|
500
|
+
});
|
|
501
|
+
});
|
|
502
|
+
var reorderedSessions = moveHistoryGroupToTop(sessionsWithoutRemoved, targetSession.historyKey);
|
|
503
|
+
var _newFlyouts7 = state.flyouts.filter(function (f) {
|
|
504
|
+
return !_flyoutsToRemove4.has(f.flyoutId);
|
|
505
|
+
});
|
|
506
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
507
|
+
sessions: reorderedSessions,
|
|
508
|
+
flyouts: _newFlyouts7
|
|
509
|
+
});
|
|
510
|
+
}
|
|
311
511
|
var sessionsToClose = state.sessions.slice(targetSessionIndex + 1);
|
|
312
|
-
var
|
|
512
|
+
var _flyoutsToRemove5 = new Set();
|
|
313
513
|
sessionsToClose.forEach(function (session) {
|
|
314
|
-
|
|
315
|
-
if (session.childFlyoutId) {
|
|
316
|
-
_flyoutsToRemove2.add(session.childFlyoutId);
|
|
317
|
-
}
|
|
514
|
+
addSessionFlyoutsToRemove(session, _flyoutsToRemove5);
|
|
318
515
|
});
|
|
319
|
-
var
|
|
320
|
-
return !
|
|
516
|
+
var _newFlyouts8 = state.flyouts.filter(function (f) {
|
|
517
|
+
return !_flyoutsToRemove5.has(f.flyoutId);
|
|
321
518
|
});
|
|
322
|
-
var
|
|
519
|
+
var _newSessions3 = state.sessions.slice(0, targetSessionIndex + 1);
|
|
323
520
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
324
|
-
sessions:
|
|
325
|
-
flyouts:
|
|
521
|
+
sessions: _newSessions3,
|
|
522
|
+
flyouts: _newFlyouts8
|
|
326
523
|
});
|
|
327
524
|
}
|
|
328
525
|
|
|
@@ -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,75 @@ 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;
|
|
59
|
+
if (!currentSession) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
53
62
|
var previousSessions = currentState.sessions.slice(0, currentSessionIndex);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
// Only include sessions in the same history group (same historyKey reference)
|
|
64
|
+
var previousSessionsInGroup = previousSessions.filter(function (session) {
|
|
65
|
+
return session.historyKey === currentSession.historyKey;
|
|
66
|
+
});
|
|
67
|
+
var childHistory = (_currentSession$child = currentSession.childHistory) !== null && _currentSession$child !== void 0 ? _currentSession$child : [];
|
|
68
|
+
var childItems = _toConsumableArray(childHistory).reverse().map(function (entry) {
|
|
57
69
|
return {
|
|
58
|
-
title: title,
|
|
70
|
+
title: entry.title,
|
|
71
|
+
iconType: entry.iconType,
|
|
59
72
|
onClick: function onClick() {
|
|
60
|
-
|
|
73
|
+
dispatchFn((0, _actions.goToFlyout)(entry.flyoutId, 'child'));
|
|
61
74
|
}
|
|
62
75
|
};
|
|
63
76
|
});
|
|
77
|
+
|
|
78
|
+
// Previous sessions (same group): list each session's current child then its child history
|
|
79
|
+
var previousSessionItems = [];
|
|
80
|
+
var _loop = function _loop() {
|
|
81
|
+
var _session$childHistory;
|
|
82
|
+
var session = previousSessionsInGroup[i];
|
|
83
|
+
var mainTitle = session.title;
|
|
84
|
+
var mainFlyoutId = session.mainFlyoutId;
|
|
85
|
+
var history = (_session$childHistory = session.childHistory) !== null && _session$childHistory !== void 0 ? _session$childHistory : [];
|
|
86
|
+
var hasChildren = session.childFlyoutId != null && session.childTitle != null || history.length > 0;
|
|
87
|
+
if (session.childFlyoutId && session.childTitle) {
|
|
88
|
+
previousSessionItems.push({
|
|
89
|
+
title: session.childTitle,
|
|
90
|
+
iconType: session.childIconType,
|
|
91
|
+
onClick: function onClick() {
|
|
92
|
+
dispatchFn((0, _actions.goToFlyout)(mainFlyoutId, 'main'));
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
var _loop2 = function _loop2() {
|
|
97
|
+
var entry = history[h];
|
|
98
|
+
previousSessionItems.push({
|
|
99
|
+
title: entry.title,
|
|
100
|
+
iconType: entry.iconType,
|
|
101
|
+
onClick: function onClick() {
|
|
102
|
+
dispatchFn((0, _actions.goToFlyout)(mainFlyoutId, 'main'));
|
|
103
|
+
dispatchFn((0, _actions.goToFlyout)(entry.flyoutId, 'child'));
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
for (var h = history.length - 1; h >= 0; h--) {
|
|
108
|
+
_loop2();
|
|
109
|
+
}
|
|
110
|
+
if (!hasChildren) {
|
|
111
|
+
previousSessionItems.push({
|
|
112
|
+
title: mainTitle,
|
|
113
|
+
iconType: session.iconType,
|
|
114
|
+
onClick: function onClick() {
|
|
115
|
+
dispatchFn((0, _actions.goToFlyout)(mainFlyoutId, 'main'));
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
for (var i = previousSessionsInGroup.length - 1; i >= 0; i--) {
|
|
121
|
+
_loop();
|
|
122
|
+
}
|
|
123
|
+
return [].concat(_toConsumableArray(childItems), previousSessionItems);
|
|
64
124
|
};
|
|
65
125
|
var dispatch = function dispatch(action) {
|
|
66
126
|
var nextState = (0, _reducer.flyoutManagerReducer)(currentState, action);
|
|
@@ -71,7 +131,7 @@ function createStore() {
|
|
|
71
131
|
// Recompute history items eagerly if sessions changed
|
|
72
132
|
// This ensures stable references and avoids stale closures
|
|
73
133
|
if (nextState.sessions !== previousSessions) {
|
|
74
|
-
store.historyItems = computeHistoryItems();
|
|
134
|
+
store.historyItems = computeHistoryItems(dispatch);
|
|
75
135
|
|
|
76
136
|
// Detect removed sessions and emit CLOSE_SESSION events
|
|
77
137
|
var nextSessionIds = new Set(nextState.sessions.map(function (s) {
|
|
@@ -96,8 +156,8 @@ function createStore() {
|
|
|
96
156
|
subscribe: subscribe,
|
|
97
157
|
subscribeToEvents: subscribeToEvents,
|
|
98
158
|
dispatch: dispatch,
|
|
99
|
-
addFlyout: function addFlyout(flyoutId, title, level, size, minWidth) {
|
|
100
|
-
return dispatch((0, _actions.addFlyout)(flyoutId, title, level, size, minWidth));
|
|
159
|
+
addFlyout: function addFlyout(flyoutId, title, level, size, historyKey, iconType, minWidth) {
|
|
160
|
+
return dispatch((0, _actions.addFlyout)(flyoutId, title, level, size, historyKey, iconType, minWidth));
|
|
101
161
|
},
|
|
102
162
|
closeFlyout: function closeFlyout(flyoutId) {
|
|
103
163
|
return dispatch((0, _actions.closeFlyout)(flyoutId));
|
|
@@ -120,8 +180,8 @@ function createStore() {
|
|
|
120
180
|
goBack: function goBack() {
|
|
121
181
|
return dispatch((0, _actions.goBack)());
|
|
122
182
|
},
|
|
123
|
-
goToFlyout: function goToFlyout(flyoutId) {
|
|
124
|
-
return dispatch((0, _actions.goToFlyout)(flyoutId));
|
|
183
|
+
goToFlyout: function goToFlyout(flyoutId, level) {
|
|
184
|
+
return dispatch((0, _actions.goToFlyout)(flyoutId, level));
|
|
125
185
|
},
|
|
126
186
|
addUnmanagedFlyout: function addUnmanagedFlyout(flyoutId) {
|
|
127
187
|
return dispatch((0, _actions.addUnmanagedFlyout)(flyoutId));
|
|
@@ -129,7 +189,7 @@ function createStore() {
|
|
|
129
189
|
closeUnmanagedFlyout: function closeUnmanagedFlyout(flyoutId) {
|
|
130
190
|
return dispatch((0, _actions.closeUnmanagedFlyout)(flyoutId));
|
|
131
191
|
},
|
|
132
|
-
historyItems: computeHistoryItems() // Initialize with current state
|
|
192
|
+
historyItems: computeHistoryItems(dispatch) // Initialize with current state
|
|
133
193
|
};
|
|
134
194
|
return store;
|
|
135
195
|
}
|
|
@@ -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
|
+
};
|