@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
|
@@ -36,6 +36,7 @@ import { EuiFlyoutIsManagedProvider } from './context';
|
|
|
36
36
|
import { euiManagedFlyoutStyles } from './flyout_managed.styles';
|
|
37
37
|
import { useFlyoutManager as _useFlyoutManager, useFlyoutId } from './hooks';
|
|
38
38
|
import { useIsFlyoutRegistered } from './selectors';
|
|
39
|
+
import { getFlyoutManagerStore } from './store';
|
|
39
40
|
import { createValidationErrorMessage, isNamedSize, validateManagedFlyoutSize, validateSizeCombination } from './validation';
|
|
40
41
|
|
|
41
42
|
/**
|
|
@@ -165,18 +166,23 @@ export var EuiManagedFlyout = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
165
166
|
// Register with flyout manager context when open, remove when closed
|
|
166
167
|
// Using useLayoutEffect to run synchronously before DOM updates
|
|
167
168
|
useLayoutEffect(function () {
|
|
168
|
-
addFlyout(flyoutId, title, level, size, typeof minWidth === 'number' ? minWidth : undefined);
|
|
169
|
+
addFlyout(flyoutId, title, level, size, _flyoutMenuProps === null || _flyoutMenuProps === void 0 ? void 0 : _flyoutMenuProps.iconType, typeof minWidth === 'number' ? minWidth : undefined);
|
|
169
170
|
return function () {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
var currentStoreState = getFlyoutManagerStore().getState();
|
|
172
|
+
var stillInStore = currentStoreState.flyouts.some(function (f) {
|
|
173
|
+
return f.flyoutId === flyoutId;
|
|
174
|
+
});
|
|
175
|
+
if (stillInStore) {
|
|
176
|
+
// Normal cleanup (deps changed or explicit close via isOpen=false)
|
|
173
177
|
level === LEVEL_MAIN ? closeAllFlyouts() : closeFlyout(flyoutId);
|
|
178
|
+
} else if (wasRegisteredRef.current) {
|
|
179
|
+
var _onCloseCallbackRef$c;
|
|
180
|
+
// Cascade close: was registered but removed externally (e.g. main closed)
|
|
181
|
+
(_onCloseCallbackRef$c = onCloseCallbackRef.current) === null || _onCloseCallbackRef$c === void 0 || _onCloseCallbackRef$c.call(onCloseCallbackRef, new MouseEvent('navigation'));
|
|
174
182
|
}
|
|
175
|
-
|
|
176
|
-
// Reset navigation tracking when explicitly closed via isOpen=false
|
|
177
183
|
wasRegisteredRef.current = false;
|
|
178
184
|
};
|
|
179
|
-
}, [flyoutId, title, level, size, minWidth, addFlyout, closeFlyout, closeAllFlyouts]);
|
|
185
|
+
}, [flyoutId, title, level, size, minWidth, _flyoutMenuProps === null || _flyoutMenuProps === void 0 ? void 0 : _flyoutMenuProps.iconType, addFlyout, closeFlyout, closeAllFlyouts]);
|
|
180
186
|
|
|
181
187
|
// Detect when flyout has been removed from manager state (e.g., via Back button)
|
|
182
188
|
// and trigger onClose callback to notify the parent component
|
|
@@ -188,8 +194,8 @@ export var EuiManagedFlyout = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
188
194
|
// If flyout was previously registered, is marked as open, but no longer exists in manager state,
|
|
189
195
|
// it was removed via navigation (Back button) - trigger close callback
|
|
190
196
|
if (wasRegisteredRef.current && !flyoutExistsInManager) {
|
|
191
|
-
var _onCloseCallbackRef$
|
|
192
|
-
(_onCloseCallbackRef$
|
|
197
|
+
var _onCloseCallbackRef$c2;
|
|
198
|
+
(_onCloseCallbackRef$c2 = onCloseCallbackRef.current) === null || _onCloseCallbackRef$c2 === void 0 || _onCloseCallbackRef$c2.call(onCloseCallbackRef, new MouseEvent('navigation'));
|
|
193
199
|
wasRegisteredRef.current = false; // Reset to avoid repeated calls
|
|
194
200
|
}
|
|
195
201
|
}, [flyoutExistsInManager, flyoutId]);
|
|
@@ -221,8 +227,7 @@ export var EuiManagedFlyout = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
221
227
|
flushSync(function () {
|
|
222
228
|
level === LEVEL_MAIN ? closeAllFlyouts() : closeFlyout(flyoutId);
|
|
223
229
|
});
|
|
224
|
-
|
|
225
|
-
// trigger parent callback, unmounts the component
|
|
230
|
+
wasRegisteredRef.current = false; // Prevent cleanup from double-firing onClose
|
|
226
231
|
if (onCloseCallbackRef.current) {
|
|
227
232
|
var event = e || new MouseEvent('click');
|
|
228
233
|
onCloseCallbackRef.current(event);
|
|
@@ -302,8 +307,14 @@ EuiManagedFlyout.propTypes = {
|
|
|
302
307
|
*/
|
|
303
308
|
title: PropTypes.node,
|
|
304
309
|
/**
|
|
305
|
-
*
|
|
306
|
-
|
|
310
|
+
* An optional icon to display next to the session title in the history menu
|
|
311
|
+
*/
|
|
312
|
+
iconType: PropTypes.oneOfType([PropTypes.oneOf(["accessibility", "addDataApp", "advancedSettingsApp", "agentApp", "aggregate", "alignBottom", "alignBottomLeft", "alignBottomRight", "alignCenterHorizontal", "alignCenterVertical", "alignLeft", "alignRight", "alignTop", "alignTopLeft", "alignTopRight", "alert", "analyzeEvent", "annotation", "anomalyChart", "chartAnomaly", "anomalySwimLane", "apmApp", "apmTrace", "chartWaterfall", "appSearchApp", "apps", "arrowDown", "chevronSingleDown", "arrowLeft", "chevronSingleLeft", "arrowRight", "chevronSingleRight", "arrowUp", "chevronSingleUp", "arrowStart", "chevronLimitLeft", "arrowEnd", "chevronLimitRight", "article", "asterisk", "at", "archive", "axisX", "axisYLeft", "axisYRight", "auditbeatApp", "backgroundTask", "beaker", "bell", "bellSlash", "beta", "bolt", "boxesHorizontal", "boxesVertical", "branch", "briefcase", "branchUser", "broom", "brush", "bug", "bulb", "bullseye", "calendar", "canvasApp", "casesApp", "changePointDetection", "chartChangePoint", "chartArea", "chartAreaStack", "chartBarHorizontal", "chartBarHorizontalStack", "chartBarVertical", "chartBarVerticalStack", "chartGauge", "chartHeatmap", "chartLine", "chartPie", "chartTagCloud", "chartThreshold", "check", "checkCircle", "checkInCircleFilled", "checkCircleFill", "cheer", "popper", "classificationJob", "clickLeft", "clickRight", "clock", "clockCounter", "clockControl", "cloud", "cloudDrizzle", "cloudStormy", "cloudSunny", "cluster", "code", "codeApp", "color", "paintBucket", "commandLine", "comment", "compare", "compute", "processor", "console", "consoleApp", "container", "continuityAbove", "continuityAboveBelow", "continuityBelow", "continuityWithin", "contrast", "contrastHigh", "contrastFill", "controls", "controlsHorizontal", "controlsVertical", "copy", "copyClipboard", "crossProjectSearch", "createAdvancedJob", "createGenericJob", "createGeoJob", "createMultiMetricJob", "createPopulationJob", "createSingleMetricJob", "cross", "crossClusterReplicationApp", "crossInCircle", "crossCircle", "crosshair", "crosshairs", "currency", "money", "cut", "scissors", "dashboardApp", "dashedCircle", "dataVisualizer", "database", "desktop", "display", "devToolsApp", "diff", "discoverApp", "distributeHorizontal", "distributeVertical", "download", "drag", "dragHorizontal", "dragVertical", "discuss", "document", "documentEdit", "documentation", "documents", "dot", "dotInCircle", "doubleArrowLeft", "chevronDoubleLeft", "doubleArrowRight", "chevronDoubleRight", "ellipsis", "editorAlignCenter", "textAlignCenter", "editorAlignLeft", "textAlignLeft", "editorAlignRight", "textAlignRight", "editorBold", "textBold", "editorChecklist", "listCheck", "editorCodeBlock", "editorComment", "editorDistributeHorizontal", "editorDistributeVertical", "editorHeading", "textHeading", "editorItalic", "textItalic", "editorItemAlignBottom", "editorItemAlignCenter", "editorItemAlignLeft", "editorItemAlignMiddle", "editorItemAlignRight", "editorItemAlignTop", "editorLink", "editorOrderedList", "listNumber", "editorPositionBottomLeft", "editorPositionBottomRight", "editorPositionTopLeft", "editorPositionTopRight", "editorRedo", "redo", "editorStrike", "textStrike", "editorTable", "table", "editorUnderline", "textUnderline", "editorUndo", "undo", "editorUnorderedList", "listBullet", "email", "mail", "empty", "emsApp", "endpoint", "eql", "query", "eraser", "error", "errorFilled", "errorFill", "esqlVis", "exit", "logOut", "expand", "maximize", "expandMini", "export", "exportAction", "upload", "external", "eye", "eyeClosed", "eyeSlash", "faceHappy", "faceNeutral", "faceSad", "fieldStatistics", "tableInfo", "filebeatApp", "filter", "filterExclude", "filterIgnore", "filterInclude", "filterInCircle", "flask", "flag", "fleetApp", "fold", "folder", "folderClosed", "folderClose", "folderCheck", "folderExclamation", "folderOpen", "folderOpened", "frameNext", "framePrevious", "fullScreen", "fullScreenExit", "function", "gear", "gisApp", "glasses", "globe", "grab", "grabHorizontal", "grabOmnidirectional", "gradient", "graphApp", "grid", "grokApp", "heart", "heartbeatApp", "heatmap", "help", "home", "hourglass", "if", "info", "image", "importAction", "index", "indexClose", "indexEdit", "indexFlush", "indexManagementApp", "indexMapping", "mapping", "indexOpen", "indexPatternApp", "indexRollupApp", "indexRuntime", "indexSettings", "indexTemporary", "tableTime", "infinity", "inputOutput", "inspect", "invert", "ip", "key", "keyboard", "kqlField", "queryField", "kqlFunction", "kqlOperand", "queryOperand", "kqlSelector", "querySelector", "kqlValue", "queryValue", "kubernetesNode", "kubernetesPod", "launch", "rocket", "layers", "lensApp", "lettering", "text", "lineBreak", "lineBreakSlash", "lineDash", "lineDashed", "lineDot", "lineDotted", "lineSolid", "link", "linkSlash", "list", "listAdd", "lock", "lockOpen", "logPatternAnalysis", "pattern", "logRateAnalysis", "logoAWS", "logoAWSMono", "logoAerospike", "logoApache", "logoAppSearch", "logoAzure", "logoAzureMono", "logoBeats", "logoBusinessAnalytics", "logoCeph", "logoCloud", "logoCloudEnterprise", "logoCode", "logoCodesandbox", "logoCouchbase", "logoDocker", "logoDropwizard", "logoElastic", "logoElasticStack", "logoElasticsearch", "logoEnterpriseSearch", "logoEtcd", "logoGCP", "logoGCPMono", "logoGithub", "logoGmail", "logoGolang", "logoGoogleG", "logoHAproxy", "logoIBM", "logoIBMMono", "logoKafka", "logoKibana", "logoKubernetes", "logoLogging", "logoLogstash", "logoMaps", "logoMemcached", "logoMetrics", "logoMongodb", "logoMySQL", "logoNginx", "logoObservability", "logoOsquery", "logoPhp", "logoPostgres", "logoPrometheus", "logoRabbitmq", "logoRedis", "logoSecurity", "logoSiteSearch", "logoSketch", "logoSlack", "logoUptime", "logoVulnerabilityManagement", "logoWebhook", "logoWindows", "logoWorkplaceSearch", "logsApp", "logstashFilter", "logstashIf", "logstashInput", "logstashOutput", "logstashQueue", "queue", "machineLearningApp", "magnet", "magnify", "magnifyExclamation", "magnifyMinus", "magnifyPlus", "magnifyWithExclamation", "magnifyWithMinus", "magnifyWithPlus", "managementApp", "map", "mapMarker", "waypoint", "megaphone", "memory", "menu", "menuDown", "menuLeft", "menuRight", "menuUp", "merge", "metricbeatApp", "metricsApp", "minimize", "minus", "minusCircle", "minusInCircle", "minusInCircleFilled", "minusInSquare", "minusSquare", "mobile", "monitoringApp", "moon", "move", "namespace", "nested", "newChat", "node", "vectorTriangle", "notebookApp", "number", "offline", "wifiSlash", "online", "wifi", "outlierDetectionJob", "package", "packetbeatApp", "pageSelect", "pagesSelect", "palette", "paperClip", "partial", "pause", "payment", "pencil", "percent", "pin", "pinFill", "pinFilled", "pipeBreaks", "pipelineApp", "pipeNoBreaks", "pivot", "play", "playFilled", "plugs", "plus", "plusCircle", "plusInCircle", "plusInCircleFilled", "plusInSquare", "plusSquare", "popout", "presentation", "productRobot", "productAgent", "productCloudInfra", "productDashboard", "productDiscover", "productML", "productStreamsClassic", "productStreamsWired", "push", "send", "question", "quote", "radar", "readOnly", "recentlyViewedApp", "refresh", "regressionJob", "reporter", "reportingApp", "return", "returnKey", "save", "savedObjectsApp", "scale", "search", "searchProfilerApp", "section", "securityAnalyticsApp", "securityApp", "securitySignal", "securitySignalDetected", "securitySignalResolved", "server", "sessionViewer", "shard", "share", "singleMetricViewer", "snowflake", "sortAscending", "sortDescending", "sortDown", "sortLeft", "sortRight", "sortUp", "sortable", "spaces", "spacesApp", "sparkles", "sqlApp", "star", "starEmpty", "starEmptySpace", "starFill", "starFilled", "starFillSpace", "starFilledSpace", "starMinusEmpty", "starMinusFill", "starMinusFilled", "starPlusEmpty", "starPlusFill", "starPlusFilled", "stats", "stop", "stopFill", "stopFilled", "stopSlash", "storage", "streamsClassic", "streamsWired", "string", "submodule", "sun", "swatchInput", "symlink", "tableDensityCompact", "tableDensityHigh", "tableDensityExpanded", "tableDensityLow", "tableDensityNormal", "tableOfContents", "tag", "tear", "temperature", "thermometer", "thumbDown", "thumbUp", "timeline", "timelineWithArrow", "timelionApp", "timeRefresh", "refreshTime", "timeslider", "training", "transitionLeftIn", "transitionLeftOut", "transitionTopIn", "transitionTopOut", "trash", "unfold", "unlink", "upgradeAssistantApp", "uptimeApp", "user", "userAvatar", "users", "usersRolesApp", "unarchive", "vector", "vectorSquare", "videoPlayer", "visArea", "visAreaStacked", "visBarHorizontal", "visBarHorizontalStacked", "visBarVertical", "visBarVerticalStacked", "visGauge", "visGoal", "visLine", "visMapCoordinate", "visMapRegion", "visMetric", "chartMetric", "visPie", "visTable", "visTagCloud", "visText", "visTimelion", "visVega", "visVisualBuilder", "visualizeApp", "vulnerabilityManagementApp", "warning", "warningFilled", "warningFill", "watchesApp", "web", "wordWrap", "wordWrapDisabled", "workflowsApp", "workflow", "workplaceSearchApp", "wrench", "tokenAlias", "tokenAnnotation", "tokenArray", "tokenBinary", "tokenBoolean", "tokenClass", "tokenCompletionSuggester", "tokenConstant", "tokenDate", "tokenDimension", "tokenElement", "tokenEnum", "tokenEnumMember", "tokenEvent", "tokenException", "tokenField", "tokenFile", "tokenFlattened", "tokenFunction", "tokenGeo", "tokenHistogram", "tokenInterface", "tokenIP", "tokenJoin", "tokenKey", "tokenKeyword", "tokenMethod", "tokenMetricCounter", "tokenMetricGauge", "tokenModule", "tokenNamespace", "tokenNested", "tokenNull", "tokenNumber", "tokenObject", "tokenOperator", "tokenPackage", "tokenParameter", "tokenPercolator", "tokenProperty", "tokenRange", "tokenRankFeature", "tokenRankFeatures", "tokenRepo", "tokenSearchType", "tokenSemanticText", "tokenShape", "tokenString", "tokenStruct", "tokenSymbol", "tokenTag", "tokenText", "tokenTokenCount", "tokenVariable", "tokenVectorDense", "tokenDenseVector", "tokenVectorSparse"]).isRequired, PropTypes.string.isRequired, PropTypes.elementType.isRequired]),
|
|
313
|
+
/**
|
|
314
|
+
* Hides the title in the `EuiFlyoutMenu`.
|
|
315
|
+
* @default true
|
|
316
|
+
* @deprecated Use `EuiFlyoutHeader` for visible titles instead.
|
|
317
|
+
* `hideTitle` is still honored but may be removed in a future major version.
|
|
307
318
|
*/
|
|
308
319
|
hideTitle: PropTypes.bool,
|
|
309
320
|
/**
|
|
@@ -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
|
*/
|
|
@@ -77,16 +77,20 @@ export function flyoutManagerReducer() {
|
|
|
77
77
|
// session exists, do nothing (invalid child without a parent).
|
|
78
78
|
case ACTION_ADD:
|
|
79
79
|
{
|
|
80
|
+
var _currentSession$child;
|
|
80
81
|
var flyoutId = action.flyoutId,
|
|
81
82
|
title = action.title,
|
|
82
83
|
level = action.level,
|
|
83
84
|
size = action.size,
|
|
85
|
+
iconType = action.iconType,
|
|
84
86
|
minWidth = action.minWidth;
|
|
85
|
-
|
|
86
|
-
// Ignore duplicate registrations
|
|
87
|
-
if (state.flyouts.some(function (f) {
|
|
87
|
+
var isDuplicate = state.flyouts.some(function (f) {
|
|
88
88
|
return f.flyoutId === flyoutId;
|
|
89
|
-
})
|
|
89
|
+
});
|
|
90
|
+
var isIdempotentChild = level === LEVEL_CHILD && state.sessions.length > 0 && state.sessions[state.sessions.length - 1].childFlyoutId === flyoutId;
|
|
91
|
+
|
|
92
|
+
// Ignore duplicate registrations (except idempotent child re-registration after goBack)
|
|
93
|
+
if (isDuplicate && !isIdempotentChild) {
|
|
90
94
|
return state;
|
|
91
95
|
}
|
|
92
96
|
var newFlyoutState = {
|
|
@@ -96,12 +100,14 @@ export function flyoutManagerReducer() {
|
|
|
96
100
|
minWidth: minWidth,
|
|
97
101
|
activityStage: STAGE_OPENING
|
|
98
102
|
};
|
|
99
|
-
var newFlyouts = [].concat(_toConsumableArray(state.flyouts), [newFlyoutState]);
|
|
103
|
+
var newFlyouts = isIdempotentChild ? state.flyouts : [].concat(_toConsumableArray(state.flyouts), [newFlyoutState]);
|
|
100
104
|
if (level === LEVEL_MAIN) {
|
|
101
105
|
var newSession = {
|
|
102
106
|
mainFlyoutId: flyoutId,
|
|
103
107
|
title: title,
|
|
108
|
+
iconType: iconType,
|
|
104
109
|
childFlyoutId: null,
|
|
110
|
+
childHistory: [],
|
|
105
111
|
zIndex: state.currentZIndex
|
|
106
112
|
};
|
|
107
113
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
@@ -118,8 +124,52 @@ export function flyoutManagerReducer() {
|
|
|
118
124
|
}
|
|
119
125
|
var updatedSessions = _toConsumableArray(state.sessions);
|
|
120
126
|
var currentSessionIndex = updatedSessions.length - 1;
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
var currentSession = updatedSessions[currentSessionIndex];
|
|
128
|
+
var childHistory = (_currentSession$child = currentSession.childHistory) !== null && _currentSession$child !== void 0 ? _currentSession$child : [];
|
|
129
|
+
|
|
130
|
+
// Idempotent re-registration (e.g. after goBack): flyout already in flyouts and session already points to it
|
|
131
|
+
if (state.flyouts.some(function (f) {
|
|
132
|
+
return f.flyoutId === flyoutId;
|
|
133
|
+
})) {
|
|
134
|
+
if (currentSession.childFlyoutId === flyoutId) {
|
|
135
|
+
updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
|
|
136
|
+
childTitle: title,
|
|
137
|
+
childIconType: iconType,
|
|
138
|
+
childHistory: childHistory
|
|
139
|
+
});
|
|
140
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
141
|
+
sessions: updatedSessions
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return state; // duplicate registration for a different child, ignore
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Session already has a child: push current child to history, then set new child (do not remove previous from flyouts)
|
|
148
|
+
if (currentSession.childFlyoutId) {
|
|
149
|
+
var _currentSession$child2;
|
|
150
|
+
var historyEntry = {
|
|
151
|
+
flyoutId: currentSession.childFlyoutId,
|
|
152
|
+
title: (_currentSession$child2 = currentSession.childTitle) !== null && _currentSession$child2 !== void 0 ? _currentSession$child2 : '',
|
|
153
|
+
iconType: currentSession.childIconType
|
|
154
|
+
};
|
|
155
|
+
updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
|
|
156
|
+
childHistory: [].concat(_toConsumableArray(childHistory), [historyEntry]),
|
|
157
|
+
childFlyoutId: flyoutId,
|
|
158
|
+
childTitle: title,
|
|
159
|
+
childIconType: iconType
|
|
160
|
+
});
|
|
161
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
162
|
+
sessions: updatedSessions,
|
|
163
|
+
flyouts: newFlyouts
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// First child in session
|
|
168
|
+
updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
|
|
169
|
+
childFlyoutId: flyoutId,
|
|
170
|
+
childTitle: title,
|
|
171
|
+
childIconType: iconType,
|
|
172
|
+
childHistory: childHistory
|
|
123
173
|
});
|
|
124
174
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
125
175
|
sessions: updatedSessions,
|
|
@@ -129,10 +179,11 @@ export function flyoutManagerReducer() {
|
|
|
129
179
|
|
|
130
180
|
// Unregister a flyout and update sessions accordingly.
|
|
131
181
|
// - When closing a `main` flyout, drop its entire session and all associated flyouts.
|
|
132
|
-
// - When closing a `child` flyout,
|
|
133
|
-
//
|
|
182
|
+
// - When closing a `child` flyout, find the session that owns it (childFlyoutId or
|
|
183
|
+
// childHistory) and clear that session's child state so navigation back stays consistent.
|
|
134
184
|
case ACTION_CLOSE:
|
|
135
185
|
{
|
|
186
|
+
var _owningSession$childH;
|
|
136
187
|
var removedFlyout = state.flyouts.find(function (f) {
|
|
137
188
|
return f.flyoutId === action.flyoutId;
|
|
138
189
|
});
|
|
@@ -145,11 +196,15 @@ export function flyoutManagerReducer() {
|
|
|
145
196
|
return session.mainFlyoutId === action.flyoutId;
|
|
146
197
|
});
|
|
147
198
|
if (sessionToRemove) {
|
|
148
|
-
|
|
199
|
+
var _sessionToRemove$chil;
|
|
200
|
+
// Remove all flyouts associated with this session (main + current child + child history)
|
|
149
201
|
var flyoutsToRemove = new Set([action.flyoutId]);
|
|
150
202
|
if (sessionToRemove.childFlyoutId) {
|
|
151
203
|
flyoutsToRemove.add(sessionToRemove.childFlyoutId);
|
|
152
204
|
}
|
|
205
|
+
((_sessionToRemove$chil = sessionToRemove.childHistory) !== null && _sessionToRemove$chil !== void 0 ? _sessionToRemove$chil : []).forEach(function (entry) {
|
|
206
|
+
return flyoutsToRemove.add(entry.flyoutId);
|
|
207
|
+
});
|
|
153
208
|
var _newFlyouts = state.flyouts.filter(function (f) {
|
|
154
209
|
return !flyoutsToRemove.has(f.flyoutId);
|
|
155
210
|
});
|
|
@@ -170,22 +225,43 @@ export function flyoutManagerReducer() {
|
|
|
170
225
|
}
|
|
171
226
|
}
|
|
172
227
|
|
|
173
|
-
// Handle child flyout closing
|
|
174
|
-
|
|
175
|
-
return f.flyoutId !== action.flyoutId;
|
|
176
|
-
});
|
|
228
|
+
// Handle child flyout closing: find the session that owns this child and
|
|
229
|
+
// clear that session's child state (so we stay consistent when navigating back).
|
|
177
230
|
if (state.sessions.length === 0) {
|
|
178
231
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
179
|
-
flyouts:
|
|
232
|
+
flyouts: state.flyouts.filter(function (f) {
|
|
233
|
+
return f.flyoutId !== action.flyoutId;
|
|
234
|
+
})
|
|
180
235
|
});
|
|
181
236
|
}
|
|
182
|
-
var
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
237
|
+
var owningSessionIndex = state.sessions.findIndex(function (session) {
|
|
238
|
+
var _session$childHistory;
|
|
239
|
+
return session.childFlyoutId === action.flyoutId || ((_session$childHistory = session.childHistory) !== null && _session$childHistory !== void 0 ? _session$childHistory : []).some(function (entry) {
|
|
240
|
+
return entry.flyoutId === action.flyoutId;
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
if (owningSessionIndex === -1) {
|
|
244
|
+
// Closed flyout not in any session's child state; just remove the one flyout
|
|
245
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
246
|
+
flyouts: state.flyouts.filter(function (f) {
|
|
247
|
+
return f.flyoutId !== action.flyoutId;
|
|
248
|
+
})
|
|
187
249
|
});
|
|
188
250
|
}
|
|
251
|
+
var owningSession = state.sessions[owningSessionIndex];
|
|
252
|
+
var childIds = new Set([owningSession.childFlyoutId].concat(_toConsumableArray(((_owningSession$childH = owningSession.childHistory) !== null && _owningSession$childH !== void 0 ? _owningSession$childH : []).map(function (e) {
|
|
253
|
+
return e.flyoutId;
|
|
254
|
+
}))).filter(Boolean));
|
|
255
|
+
var _newFlyouts2 = state.flyouts.filter(function (f) {
|
|
256
|
+
return !childIds.has(f.flyoutId);
|
|
257
|
+
});
|
|
258
|
+
var _updatedSessions = _toConsumableArray(state.sessions);
|
|
259
|
+
_updatedSessions[owningSessionIndex] = _objectSpread(_objectSpread({}, owningSession), {}, {
|
|
260
|
+
childFlyoutId: null,
|
|
261
|
+
childTitle: undefined,
|
|
262
|
+
childIconType: undefined,
|
|
263
|
+
childHistory: []
|
|
264
|
+
});
|
|
189
265
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
190
266
|
sessions: _updatedSessions,
|
|
191
267
|
flyouts: _newFlyouts2
|
|
@@ -218,8 +294,8 @@ export function flyoutManagerReducer() {
|
|
|
218
294
|
return state;
|
|
219
295
|
}
|
|
220
296
|
var _updatedSessions2 = _toConsumableArray(state.sessions);
|
|
221
|
-
var
|
|
222
|
-
_updatedSessions2[
|
|
297
|
+
var _currentSessionIndex = _updatedSessions2.length - 1;
|
|
298
|
+
_updatedSessions2[_currentSessionIndex] = _objectSpread(_objectSpread({}, _updatedSessions2[_currentSessionIndex]), {}, {
|
|
223
299
|
childFlyoutId: action.flyoutId
|
|
224
300
|
});
|
|
225
301
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
@@ -265,59 +341,121 @@ export function flyoutManagerReducer() {
|
|
|
265
341
|
});
|
|
266
342
|
}
|
|
267
343
|
|
|
268
|
-
// Go back
|
|
344
|
+
// Go back: pop child history when any, else pop current session
|
|
269
345
|
case ACTION_GO_BACK:
|
|
270
346
|
{
|
|
347
|
+
var _currentSession$child3, _currentSession$child4;
|
|
271
348
|
if (state.sessions.length === 0) {
|
|
272
349
|
return state;
|
|
273
350
|
}
|
|
274
|
-
var
|
|
275
|
-
var
|
|
351
|
+
var _currentSessionIndex2 = state.sessions.length - 1;
|
|
352
|
+
var _currentSession = state.sessions[_currentSessionIndex2];
|
|
353
|
+
var _childHistory = (_currentSession$child3 = _currentSession.childHistory) !== null && _currentSession$child3 !== void 0 ? _currentSession$child3 : [];
|
|
354
|
+
if (_childHistory.length > 0) {
|
|
355
|
+
// Pop one child: set current child to the last entry in history, remove the current child flyout
|
|
356
|
+
var popped = _childHistory[_childHistory.length - 1];
|
|
357
|
+
var newChildHistory = _childHistory.slice(0, -1);
|
|
358
|
+
var _updatedSessions3 = _toConsumableArray(state.sessions);
|
|
359
|
+
_updatedSessions3[_currentSessionIndex2] = _objectSpread(_objectSpread({}, _currentSession), {}, {
|
|
360
|
+
childHistory: newChildHistory,
|
|
361
|
+
childFlyoutId: popped.flyoutId,
|
|
362
|
+
childTitle: popped.title,
|
|
363
|
+
childIconType: popped.iconType
|
|
364
|
+
});
|
|
365
|
+
var _newFlyouts3 = state.flyouts.filter(function (f) {
|
|
366
|
+
return f.flyoutId !== _currentSession.childFlyoutId;
|
|
367
|
+
});
|
|
368
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
369
|
+
sessions: _updatedSessions3,
|
|
370
|
+
flyouts: _newFlyouts3
|
|
371
|
+
});
|
|
372
|
+
}
|
|
276
373
|
|
|
277
|
-
//
|
|
278
|
-
var _flyoutsToRemove = new Set([
|
|
279
|
-
if (
|
|
280
|
-
_flyoutsToRemove.add(
|
|
374
|
+
// No child history: pop current session (main + all its children)
|
|
375
|
+
var _flyoutsToRemove = new Set([_currentSession.mainFlyoutId]);
|
|
376
|
+
if (_currentSession.childFlyoutId) {
|
|
377
|
+
_flyoutsToRemove.add(_currentSession.childFlyoutId);
|
|
281
378
|
}
|
|
282
|
-
|
|
379
|
+
((_currentSession$child4 = _currentSession.childHistory) !== null && _currentSession$child4 !== void 0 ? _currentSession$child4 : []).forEach(function (e) {
|
|
380
|
+
return _flyoutsToRemove.add(e.flyoutId);
|
|
381
|
+
});
|
|
382
|
+
var _newFlyouts4 = state.flyouts.filter(function (f) {
|
|
283
383
|
return !_flyoutsToRemove.has(f.flyoutId);
|
|
284
384
|
});
|
|
285
|
-
var _newSessions = state.sessions.slice(0,
|
|
385
|
+
var _newSessions = state.sessions.slice(0, _currentSessionIndex2);
|
|
286
386
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
287
387
|
sessions: _newSessions,
|
|
288
|
-
flyouts:
|
|
388
|
+
flyouts: _newFlyouts4
|
|
289
389
|
});
|
|
290
390
|
}
|
|
291
391
|
|
|
292
|
-
// Navigate to a specific flyout (
|
|
392
|
+
// Navigate to a specific flyout (by main session or by child in current session's history)
|
|
293
393
|
case ACTION_GO_TO_FLYOUT:
|
|
294
394
|
{
|
|
295
|
-
var _flyoutId3 = action.flyoutId
|
|
395
|
+
var _flyoutId3 = action.flyoutId,
|
|
396
|
+
_level = action.level;
|
|
397
|
+
var _currentSessionIndex3 = state.sessions.length - 1;
|
|
398
|
+
if (_level === LEVEL_CHILD && state.sessions.length > 0) {
|
|
399
|
+
var _currentSession2$chil;
|
|
400
|
+
var _currentSession2 = state.sessions[_currentSessionIndex3];
|
|
401
|
+
var _childHistory2 = (_currentSession2$chil = _currentSession2.childHistory) !== null && _currentSession2$chil !== void 0 ? _currentSession2$chil : [];
|
|
402
|
+
var targetIndex = _childHistory2.findIndex(function (entry) {
|
|
403
|
+
return entry.flyoutId === _flyoutId3;
|
|
404
|
+
});
|
|
405
|
+
if (targetIndex === -1) {
|
|
406
|
+
return state; // Target child not in history
|
|
407
|
+
}
|
|
408
|
+
var targetEntry = _childHistory2[targetIndex];
|
|
409
|
+
var _newChildHistory = _childHistory2.slice(0, targetIndex);
|
|
410
|
+
var _flyoutsToRemove2 = new Set();
|
|
411
|
+
if (_currentSession2.childFlyoutId) {
|
|
412
|
+
_flyoutsToRemove2.add(_currentSession2.childFlyoutId);
|
|
413
|
+
}
|
|
414
|
+
_childHistory2.slice(targetIndex + 1).forEach(function (e) {
|
|
415
|
+
_flyoutsToRemove2.add(e.flyoutId);
|
|
416
|
+
});
|
|
417
|
+
var _newFlyouts5 = state.flyouts.filter(function (f) {
|
|
418
|
+
return !_flyoutsToRemove2.has(f.flyoutId);
|
|
419
|
+
});
|
|
420
|
+
var _updatedSessions4 = _toConsumableArray(state.sessions);
|
|
421
|
+
_updatedSessions4[_currentSessionIndex3] = _objectSpread(_objectSpread({}, _currentSession2), {}, {
|
|
422
|
+
childHistory: _newChildHistory,
|
|
423
|
+
childFlyoutId: targetEntry.flyoutId,
|
|
424
|
+
childTitle: targetEntry.title,
|
|
425
|
+
childIconType: targetEntry.iconType
|
|
426
|
+
});
|
|
427
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
428
|
+
sessions: _updatedSessions4,
|
|
429
|
+
flyouts: _newFlyouts5
|
|
430
|
+
});
|
|
431
|
+
}
|
|
296
432
|
|
|
297
|
-
//
|
|
433
|
+
// Navigate by main flyout: remove all sessions after the target
|
|
298
434
|
var targetSessionIndex = state.sessions.findIndex(function (session) {
|
|
299
435
|
return session.mainFlyoutId === _flyoutId3;
|
|
300
436
|
});
|
|
301
437
|
if (targetSessionIndex === -1) {
|
|
302
438
|
return state; // Target flyout not found
|
|
303
439
|
}
|
|
304
|
-
|
|
305
|
-
// Close all sessions after the target session
|
|
306
440
|
var sessionsToClose = state.sessions.slice(targetSessionIndex + 1);
|
|
307
|
-
var
|
|
441
|
+
var _flyoutsToRemove3 = new Set();
|
|
308
442
|
sessionsToClose.forEach(function (session) {
|
|
309
|
-
|
|
443
|
+
var _session$childHistory2;
|
|
444
|
+
_flyoutsToRemove3.add(session.mainFlyoutId);
|
|
310
445
|
if (session.childFlyoutId) {
|
|
311
|
-
|
|
446
|
+
_flyoutsToRemove3.add(session.childFlyoutId);
|
|
312
447
|
}
|
|
448
|
+
((_session$childHistory2 = session.childHistory) !== null && _session$childHistory2 !== void 0 ? _session$childHistory2 : []).forEach(function (e) {
|
|
449
|
+
return _flyoutsToRemove3.add(e.flyoutId);
|
|
450
|
+
});
|
|
313
451
|
});
|
|
314
|
-
var
|
|
315
|
-
return !
|
|
452
|
+
var _newFlyouts6 = state.flyouts.filter(function (f) {
|
|
453
|
+
return !_flyoutsToRemove3.has(f.flyoutId);
|
|
316
454
|
});
|
|
317
455
|
var _newSessions2 = state.sessions.slice(0, targetSessionIndex + 1);
|
|
318
456
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
319
457
|
sessions: _newSessions2,
|
|
320
|
-
flyouts:
|
|
458
|
+
flyouts: _newFlyouts6
|
|
321
459
|
});
|
|
322
460
|
}
|
|
323
461
|
|
|
@@ -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,68 @@ 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;
|
|
47
55
|
var previousSessions = currentState.sessions.slice(0, currentSessionIndex);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
mainFlyoutId = _ref.mainFlyoutId;
|
|
56
|
+
var childHistory = (_currentSession$child = currentSession === null || currentSession === void 0 ? void 0 : currentSession.childHistory) !== null && _currentSession$child !== void 0 ? _currentSession$child : [];
|
|
57
|
+
var childItems = _toConsumableArray(childHistory).reverse().map(function (entry) {
|
|
51
58
|
return {
|
|
52
|
-
title: title,
|
|
59
|
+
title: entry.title,
|
|
60
|
+
iconType: entry.iconType,
|
|
53
61
|
onClick: function onClick() {
|
|
54
|
-
|
|
62
|
+
dispatchFn(goToFlyoutAction(entry.flyoutId, 'child'));
|
|
55
63
|
}
|
|
56
64
|
};
|
|
57
65
|
});
|
|
66
|
+
|
|
67
|
+
// Previous sessions: list each session's current child then its child history (so all travelled entries appear)
|
|
68
|
+
var previousSessionItems = [];
|
|
69
|
+
var _loop = function _loop() {
|
|
70
|
+
var _session$childHistory;
|
|
71
|
+
var session = previousSessions[i];
|
|
72
|
+
var mainTitle = session.title;
|
|
73
|
+
var mainFlyoutId = session.mainFlyoutId;
|
|
74
|
+
var history = (_session$childHistory = session.childHistory) !== null && _session$childHistory !== void 0 ? _session$childHistory : [];
|
|
75
|
+
var hasChildren = session.childFlyoutId != null && session.childTitle != null || history.length > 0;
|
|
76
|
+
if (session.childFlyoutId && session.childTitle) {
|
|
77
|
+
previousSessionItems.push({
|
|
78
|
+
title: session.childTitle,
|
|
79
|
+
iconType: session.childIconType,
|
|
80
|
+
onClick: function onClick() {
|
|
81
|
+
dispatchFn(goToFlyoutAction(mainFlyoutId, 'main'));
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
var _loop2 = function _loop2() {
|
|
86
|
+
var entry = history[h];
|
|
87
|
+
previousSessionItems.push({
|
|
88
|
+
title: entry.title,
|
|
89
|
+
iconType: entry.iconType,
|
|
90
|
+
onClick: function onClick() {
|
|
91
|
+
dispatchFn(goToFlyoutAction(mainFlyoutId, 'main'));
|
|
92
|
+
dispatchFn(goToFlyoutAction(entry.flyoutId, 'child'));
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
for (var h = history.length - 1; h >= 0; h--) {
|
|
97
|
+
_loop2();
|
|
98
|
+
}
|
|
99
|
+
if (!hasChildren) {
|
|
100
|
+
previousSessionItems.push({
|
|
101
|
+
title: mainTitle,
|
|
102
|
+
iconType: session.iconType,
|
|
103
|
+
onClick: function onClick() {
|
|
104
|
+
dispatchFn(goToFlyoutAction(mainFlyoutId, 'main'));
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
for (var i = previousSessions.length - 1; i >= 0; i--) {
|
|
110
|
+
_loop();
|
|
111
|
+
}
|
|
112
|
+
return [].concat(_toConsumableArray(childItems), previousSessionItems);
|
|
58
113
|
};
|
|
59
114
|
var dispatch = function dispatch(action) {
|
|
60
115
|
var nextState = flyoutManagerReducer(currentState, action);
|
|
@@ -65,7 +120,7 @@ function createStore() {
|
|
|
65
120
|
// Recompute history items eagerly if sessions changed
|
|
66
121
|
// This ensures stable references and avoids stale closures
|
|
67
122
|
if (nextState.sessions !== previousSessions) {
|
|
68
|
-
store.historyItems = computeHistoryItems();
|
|
123
|
+
store.historyItems = computeHistoryItems(dispatch);
|
|
69
124
|
|
|
70
125
|
// Detect removed sessions and emit CLOSE_SESSION events
|
|
71
126
|
var nextSessionIds = new Set(nextState.sessions.map(function (s) {
|
|
@@ -90,8 +145,8 @@ function createStore() {
|
|
|
90
145
|
subscribe: subscribe,
|
|
91
146
|
subscribeToEvents: subscribeToEvents,
|
|
92
147
|
dispatch: dispatch,
|
|
93
|
-
addFlyout: function addFlyout(flyoutId, title, level, size, minWidth) {
|
|
94
|
-
return dispatch(addFlyoutAction(flyoutId, title, level, size, minWidth));
|
|
148
|
+
addFlyout: function addFlyout(flyoutId, title, level, size, iconType, minWidth) {
|
|
149
|
+
return dispatch(addFlyoutAction(flyoutId, title, level, size, iconType, minWidth));
|
|
95
150
|
},
|
|
96
151
|
closeFlyout: function closeFlyout(flyoutId) {
|
|
97
152
|
return dispatch(closeFlyoutAction(flyoutId));
|
|
@@ -114,8 +169,8 @@ function createStore() {
|
|
|
114
169
|
goBack: function goBack() {
|
|
115
170
|
return dispatch(goBackAction());
|
|
116
171
|
},
|
|
117
|
-
goToFlyout: function goToFlyout(flyoutId) {
|
|
118
|
-
return dispatch(goToFlyoutAction(flyoutId));
|
|
172
|
+
goToFlyout: function goToFlyout(flyoutId, level) {
|
|
173
|
+
return dispatch(goToFlyoutAction(flyoutId, level));
|
|
119
174
|
},
|
|
120
175
|
addUnmanagedFlyout: function addUnmanagedFlyout(flyoutId) {
|
|
121
176
|
return dispatch(addUnmanagedFlyoutAction(flyoutId));
|
|
@@ -123,7 +178,7 @@ function createStore() {
|
|
|
123
178
|
closeUnmanagedFlyout: function closeUnmanagedFlyout(flyoutId) {
|
|
124
179
|
return dispatch(closeUnmanagedFlyoutAction(flyoutId));
|
|
125
180
|
},
|
|
126
|
-
historyItems: computeHistoryItems() // Initialize with current state
|
|
181
|
+
historyItems: computeHistoryItems(dispatch) // Initialize with current state
|
|
127
182
|
};
|
|
128
183
|
return store;
|
|
129
184
|
}
|
|
@@ -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
|
+
};
|