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