@luigi-project/core-modular 0.0.7 → 0.0.8
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/core-api/luigi.d.ts +31 -0
- package/core-api/navigation.d.ts +9 -0
- package/luigi.js +69 -29
- package/luigi.js.map +1 -1
- package/package.json +1 -1
- package/services/auth-layer.service.d.ts +1 -0
- package/services/dirty-status.service.d.ts +5 -1
- package/services/i18n.service.d.ts +1 -2
- package/services/modal.service.d.ts +1 -0
- package/services/navigation.service.d.ts +5 -3
- package/services/preloading.service.d.ts +58 -0
- package/services/routing.service.d.ts +12 -0
- package/types/connector.d.ts +2 -1
- package/types/navigation.d.ts +66 -5
- package/utilities/helpers/context-switcher-helpers.d.ts +17 -0
- package/utilities/helpers/generic-helpers.d.ts +13 -1
- package/utilities/helpers/i18n-helpers.d.ts +3 -0
- package/utilities/helpers/navigation-helpers.d.ts +21 -3
- package/utilities/helpers/routing-helpers.d.ts +135 -3
package/package.json
CHANGED
|
@@ -19,6 +19,7 @@ declare class AuthLayerSvcClass {
|
|
|
19
19
|
getIdpProviderInstance(idpProviderName: string, idpProviderSettings: any): Promise<any>;
|
|
20
20
|
unload(): void;
|
|
21
21
|
resetExpirationChecks(): void;
|
|
22
|
+
broadcastAuthData(authData: any): void;
|
|
22
23
|
}
|
|
23
24
|
export declare const AuthLayerSvc: AuthLayerSvcClass;
|
|
24
25
|
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Luigi } from '../core-api/luigi';
|
|
1
2
|
export declare class DirtyStatusService {
|
|
3
|
+
private luigi;
|
|
2
4
|
unsavedChanges: {
|
|
3
5
|
isDirty?: boolean;
|
|
4
6
|
persistUrl?: string | null;
|
|
@@ -8,7 +10,7 @@ export declare class DirtyStatusService {
|
|
|
8
10
|
* Initializes the `unsavedChanges` property with default values.
|
|
9
11
|
* Sets `isDirty` to `false` and `persistUrl` to `null`, indicating that there are no unsaved changes initially.
|
|
10
12
|
*/
|
|
11
|
-
constructor();
|
|
13
|
+
constructor(luigi: Luigi);
|
|
12
14
|
/**
|
|
13
15
|
* Updates the dirty status of a given source and manages the set of unsaved changes.
|
|
14
16
|
*
|
|
@@ -38,4 +40,6 @@ export declare class DirtyStatusService {
|
|
|
38
40
|
* @returns {boolean} `true` if there are unsaved changes, otherwise `false`.
|
|
39
41
|
*/
|
|
40
42
|
readDirtyStatus(): boolean;
|
|
43
|
+
getUnsavedChangesModalPromise(source?: any): Promise<void>;
|
|
44
|
+
shouldShowUnsavedChangesModal(source?: any): boolean;
|
|
41
45
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LuigiContainer, LuigiCompoundContainer } from '@luigi-project/container';
|
|
2
1
|
import { Luigi } from '../core-api/luigi';
|
|
3
2
|
/**
|
|
4
3
|
* Localization-related functions
|
|
@@ -21,7 +20,7 @@ export declare class i18nService {
|
|
|
21
20
|
* Sets current locale to the specified one.
|
|
22
21
|
* @param {string} locale locale to be set as the current locale
|
|
23
22
|
*/
|
|
24
|
-
setCurrentLocale(locale: string
|
|
23
|
+
setCurrentLocale(locale: string): void;
|
|
25
24
|
/**
|
|
26
25
|
* Registers a listener for locale changes.
|
|
27
26
|
* @param {Function} listener function called on every locale change with the new locale as argument
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Luigi } from '../core-api/luigi';
|
|
2
2
|
import { AppSwitcher, BreadcrumbData, LeftNavData, NavigationOptions, NavigationRequestParams, NavItem, Node, PathData, TabNavData, TopNavData } from '../types/navigation';
|
|
3
|
-
import { NodeDataManagementService } from './node-data-management.service';
|
|
4
3
|
import { ModalService } from './modal.service';
|
|
4
|
+
import { NodeDataManagementService } from './node-data-management.service';
|
|
5
5
|
export declare class NavigationService {
|
|
6
6
|
private luigi;
|
|
7
7
|
modalService?: ModalService;
|
|
@@ -26,12 +26,13 @@ export declare class NavigationService {
|
|
|
26
26
|
getTruncatedChildren(children: Node[]): Node[];
|
|
27
27
|
applyNavGroups(items: NavItem[]): NavItem[];
|
|
28
28
|
getLeftNavData(path: string, pData?: PathData): Promise<LeftNavData>;
|
|
29
|
-
navItemClick(node: Node, pathData?: PathData): void
|
|
29
|
+
navItemClick(node: Node, pathData?: PathData): Promise<void>;
|
|
30
30
|
getTopNavData(path: string, pData?: PathData): Promise<TopNavData>;
|
|
31
31
|
getParentNode(node: Node | undefined, pathData: PathData): Node | undefined;
|
|
32
32
|
getAppSwitcherData(appSwitcherData: AppSwitcher, headerSettings: any): AppSwitcher | undefined;
|
|
33
33
|
getTabNavData(path: string, pData?: PathData): Promise<TabNavData>;
|
|
34
|
-
getBreadcrumbData(path: string, pData?: PathData): Promise<BreadcrumbData>;
|
|
34
|
+
getBreadcrumbData(path: string, pData?: PathData, onResolve?: (data: BreadcrumbData) => void): Promise<BreadcrumbData>;
|
|
35
|
+
private resolveBreadcrumbTitles;
|
|
35
36
|
/**
|
|
36
37
|
* Handles changes between navigation nodes by invoking a configured hook function.
|
|
37
38
|
*
|
|
@@ -108,4 +109,5 @@ export declare class NavigationService {
|
|
|
108
109
|
* @returns The constructed path string.
|
|
109
110
|
*/
|
|
110
111
|
buildPath(incomingPath: string, options: NavigationOptions): Promise<string>;
|
|
112
|
+
private buildContextSwitcher;
|
|
111
113
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Luigi } from '../core-api/luigi';
|
|
2
|
+
import { ViewGroupSettings } from '../types/navigation';
|
|
3
|
+
/**
|
|
4
|
+
* Service responsible for preloading view group containers in the background.
|
|
5
|
+
*
|
|
6
|
+
* Preloading creates hidden luigi-container elements for configured view groups
|
|
7
|
+
* so that navigating to those groups later is near-instant (the MFE is already initialized).
|
|
8
|
+
* The service adapts its batch size dynamically based on observed MFE load times.
|
|
9
|
+
*/
|
|
10
|
+
export declare class PreloadingService {
|
|
11
|
+
private luigi;
|
|
12
|
+
private preloadBatchSize;
|
|
13
|
+
shouldPreload: boolean;
|
|
14
|
+
constructor(luigi: Luigi);
|
|
15
|
+
/**
|
|
16
|
+
* Preloads view group containers based on the `navigation.viewGroupSettings` configuration.
|
|
17
|
+
* Skips view groups that already have a container in the DOM or are currently being preloaded.
|
|
18
|
+
*
|
|
19
|
+
* @param batchSize - Maximum number of view groups to preload in this cycle (default: 3).
|
|
20
|
+
* @param backgroundMfeOnly - If true, only preloads view groups with `loadOnStartup: true`.
|
|
21
|
+
* Used during application init to load critical MFEs without competing with the main navigation.
|
|
22
|
+
*/
|
|
23
|
+
preloadViewGroups(batchSize?: number, backgroundMfeOnly?: boolean): void;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a hidden luigi-container for the given view group and appends it to the DOM.
|
|
26
|
+
* The container loads the `preloadUrl` MFE in the background with `display: none`.
|
|
27
|
+
*
|
|
28
|
+
* @param settings - The view group settings containing the preloadUrl.
|
|
29
|
+
* @param name - The view group name (used as identifier on the container).
|
|
30
|
+
* @param containerWrapper - The DOM element to append the hidden container to.
|
|
31
|
+
*/
|
|
32
|
+
preloadContainerOnBackground(settings: ViewGroupSettings, name: string, containerWrapper: HTMLElement): void;
|
|
33
|
+
/**
|
|
34
|
+
* Schedules a preload cycle. Uses a flag-based mechanism to skip the very first invocation
|
|
35
|
+
* and only trigger preloading from the second call onwards.
|
|
36
|
+
*
|
|
37
|
+
* @param backgroundMfeOnly - If true, only `loadOnStartup` view groups are preloaded.
|
|
38
|
+
* Passed through to `preloadViewGroups`.
|
|
39
|
+
*/
|
|
40
|
+
preload(backgroundMfeOnly?: boolean): void;
|
|
41
|
+
/**
|
|
42
|
+
* Called when a preloaded container has finished initializing (INITIALIZED event).
|
|
43
|
+
* Measures load time and adapts the batch size for subsequent preload cycles:
|
|
44
|
+
* - < 500ms → batchSize 3 (fast connection)
|
|
45
|
+
* - 500–1000ms → batchSize 2
|
|
46
|
+
* - > 1000ms → batchSize 1 (slow, be conservative)
|
|
47
|
+
*
|
|
48
|
+
* Also schedules clearing the `_luigiPreloading` flag after a short delay,
|
|
49
|
+
* freeing the container for the next preload cycle.
|
|
50
|
+
*
|
|
51
|
+
* @param container - The container element that finished loading.
|
|
52
|
+
*/
|
|
53
|
+
viewGroupLoaded(container: any): void;
|
|
54
|
+
/**
|
|
55
|
+
* Returns all containers in the wrapper that are currently in a preloading state.
|
|
56
|
+
*/
|
|
57
|
+
private getPreloadingContainers;
|
|
58
|
+
}
|
|
@@ -2,9 +2,11 @@ import { Luigi } from '../core-api/luigi';
|
|
|
2
2
|
import { Route } from '../types/routing';
|
|
3
3
|
import { ModalSettings, Node, PathData } from '../types/navigation';
|
|
4
4
|
import { NavigationService } from './navigation.service';
|
|
5
|
+
import { DirtyStatusService } from './dirty-status.service';
|
|
5
6
|
export declare class RoutingService {
|
|
6
7
|
private luigi;
|
|
7
8
|
navigationService?: NavigationService;
|
|
9
|
+
dirtyStatusService?: DirtyStatusService;
|
|
8
10
|
previousNode: Node | undefined;
|
|
9
11
|
currentRoute?: Route;
|
|
10
12
|
modalSettings?: ModalSettings;
|
|
@@ -123,4 +125,14 @@ export declare class RoutingService {
|
|
|
123
125
|
* @returns {Promise<void>} A promise that resolves when error handling is complete.
|
|
124
126
|
*/
|
|
125
127
|
showPageNotFoundError(pathToRedirect: string, notFoundPath: string, isAnyPathMatched?: boolean): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Handles viewUrl misconfiguration scenario. If a node has no viewUrl, no children,
|
|
130
|
+
* and is not a compound node, it redirects to the root default child node.
|
|
131
|
+
* @param node - active node data
|
|
132
|
+
* @param viewUrl - the url of the current mf view
|
|
133
|
+
* @param previousPathData - previous path data
|
|
134
|
+
* @param pathUrlRaw - path url without hash
|
|
135
|
+
* @returns true if misconfiguration was detected and handled
|
|
136
|
+
*/
|
|
137
|
+
handleViewUrlMisconfigured(node: Node, viewUrl: string, previousPathData: PathData, pathUrlRaw: string): Promise<boolean>;
|
|
126
138
|
}
|
package/types/connector.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface LuigiConnector {
|
|
|
6
6
|
renderLeftNav(data: LeftNavData): void;
|
|
7
7
|
getContainerWrapper(): HTMLElement;
|
|
8
8
|
renderModal(content: HTMLElement, modalSettings: ModalSettings, onCloseCallback?: () => void, onCloseRequest?: () => void): any;
|
|
9
|
-
renderDrawer(content: HTMLElement,
|
|
9
|
+
renderDrawer(content: HTMLElement, drawerSettings: DrawerSettings, onCloseCallback?: () => void, onCloseRequest?: () => void): any;
|
|
10
10
|
renderTabNav(data: TabNavData): void;
|
|
11
11
|
renderBreadcrumbs(data: BreadcrumbData): void;
|
|
12
12
|
renderAlert(alertSettings: AlertSettings, alertHandler: AlertHandler): void;
|
|
@@ -29,5 +29,6 @@ export interface LuigiConnector {
|
|
|
29
29
|
getLuigiContainer(): HTMLElement | null;
|
|
30
30
|
getNavFooterContainer(): HTMLElement | null;
|
|
31
31
|
};
|
|
32
|
+
unload(): void;
|
|
32
33
|
}
|
|
33
34
|
export type { Node };
|
package/types/navigation.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export interface TopNavData {
|
|
2
|
+
appSwitcher?: AppSwitcher;
|
|
2
3
|
appTitle: string;
|
|
4
|
+
contextSwitcher?: ContextSwitcher;
|
|
3
5
|
logo: string;
|
|
4
|
-
|
|
6
|
+
navClick?: (item: NavItem) => Promise<void>;
|
|
5
7
|
productSwitcher?: ProductSwitcher;
|
|
6
8
|
profile?: ProfileSettings;
|
|
7
|
-
|
|
8
|
-
navClick?: (item: NavItem) => void;
|
|
9
|
+
topNodes: NavItem[];
|
|
9
10
|
}
|
|
10
11
|
export interface AppSwitcher {
|
|
11
12
|
showMainAppEntry?: boolean;
|
|
@@ -18,6 +19,25 @@ export interface AppSwitcherItem {
|
|
|
18
19
|
link?: string;
|
|
19
20
|
selectionConditions?: selectionConditions;
|
|
20
21
|
}
|
|
22
|
+
export interface ContextSwitcher {
|
|
23
|
+
actions?: any[];
|
|
24
|
+
config?: any;
|
|
25
|
+
options?: ContextSwitcherItem[];
|
|
26
|
+
selectedLabel?: string;
|
|
27
|
+
selectedNodePath?: any;
|
|
28
|
+
selectedOption?: ContextSwitcherItem;
|
|
29
|
+
switcherChange?: (selectedValue: string, selectedType?: string | undefined) => void;
|
|
30
|
+
}
|
|
31
|
+
export interface ContextSwitcherItem {
|
|
32
|
+
clickHandler?: any;
|
|
33
|
+
customRendererCategory?: any;
|
|
34
|
+
id?: string;
|
|
35
|
+
label?: string;
|
|
36
|
+
link?: string;
|
|
37
|
+
linkFromPath?: null | string;
|
|
38
|
+
position?: 'bottom' | 'top';
|
|
39
|
+
testId?: string;
|
|
40
|
+
}
|
|
21
41
|
export interface selectionConditions {
|
|
22
42
|
route?: string;
|
|
23
43
|
contextCriteria?: ContextCriteria[];
|
|
@@ -33,8 +53,13 @@ export interface ProfileSettings {
|
|
|
33
53
|
items?: ProfileItem[];
|
|
34
54
|
staticUserInfoFn?: () => Promise<UserInfo>;
|
|
35
55
|
onUserInfoUpdate: (fn: (uInfo: UserInfo) => void) => void;
|
|
56
|
+
settings: UserSettingsProfileMenuEntry;
|
|
36
57
|
itemClick: (item: ProfileItem) => void;
|
|
37
58
|
}
|
|
59
|
+
export interface UserSettingsProfileMenuEntry {
|
|
60
|
+
label?: string;
|
|
61
|
+
link?: string;
|
|
62
|
+
}
|
|
38
63
|
export interface ProfileLogout {
|
|
39
64
|
label?: string;
|
|
40
65
|
icon?: string;
|
|
@@ -63,7 +88,7 @@ export interface LeftNavData {
|
|
|
63
88
|
items: NavItem[];
|
|
64
89
|
basePath: string;
|
|
65
90
|
sideNavFooterText?: string;
|
|
66
|
-
navClick?: (item: NavItem) => void
|
|
91
|
+
navClick?: (item: NavItem) => Promise<void>;
|
|
67
92
|
}
|
|
68
93
|
export interface PathData {
|
|
69
94
|
context?: Record<string, any>;
|
|
@@ -98,9 +123,11 @@ export interface Node {
|
|
|
98
123
|
hideFromNav?: boolean;
|
|
99
124
|
hideSideNav?: boolean;
|
|
100
125
|
icon?: string;
|
|
126
|
+
intendToHaveEmptyViewUrl?: boolean;
|
|
101
127
|
isRootNode?: boolean;
|
|
102
128
|
keepSelectedForChildren?: boolean;
|
|
103
129
|
label?: string;
|
|
130
|
+
link?: string;
|
|
104
131
|
loadingIndicator?: {
|
|
105
132
|
enabled: boolean;
|
|
106
133
|
};
|
|
@@ -113,6 +140,7 @@ export interface Node {
|
|
|
113
140
|
runTimeErrorHandler?: RunTimeErrorHandler;
|
|
114
141
|
showBreadcrumbs?: boolean;
|
|
115
142
|
tabNav?: boolean;
|
|
143
|
+
titleResolver?: TitleResolver;
|
|
116
144
|
tooltipText?: string;
|
|
117
145
|
userSettingsGroup?: string;
|
|
118
146
|
viewUrl?: string;
|
|
@@ -127,6 +155,7 @@ export interface Node {
|
|
|
127
155
|
_virtualTree?: Node;
|
|
128
156
|
_virtualPathIndex?: number;
|
|
129
157
|
_virtualViewUrl?: string;
|
|
158
|
+
_rawContext?: Record<string, any>;
|
|
130
159
|
}
|
|
131
160
|
export interface PageErrorHandler {
|
|
132
161
|
timeout: number;
|
|
@@ -157,6 +186,8 @@ export interface BreadcrumbItem {
|
|
|
157
186
|
export interface NavItem {
|
|
158
187
|
altText?: string;
|
|
159
188
|
category?: Category;
|
|
189
|
+
externalLink?: ExternalLink;
|
|
190
|
+
href?: string;
|
|
160
191
|
icon?: string;
|
|
161
192
|
node?: Node;
|
|
162
193
|
label?: string;
|
|
@@ -167,7 +198,7 @@ export interface TabNavData {
|
|
|
167
198
|
selectedNode?: any;
|
|
168
199
|
items?: NavItem[];
|
|
169
200
|
basePath?: string;
|
|
170
|
-
navClick?: (item: NavItem) => void
|
|
201
|
+
navClick?: (item: NavItem) => Promise<void>;
|
|
171
202
|
}
|
|
172
203
|
export interface BreadcrumbData {
|
|
173
204
|
basePath?: string;
|
|
@@ -197,6 +228,7 @@ export interface ProductSwitcher {
|
|
|
197
228
|
items?: [ProductSwitcherItem];
|
|
198
229
|
label?: string;
|
|
199
230
|
testId?: string;
|
|
231
|
+
productSwitcherItemClick?: (item: ProductSwitcherItem) => void;
|
|
200
232
|
}
|
|
201
233
|
export interface ProductSwitcherItem {
|
|
202
234
|
altText?: string;
|
|
@@ -228,6 +260,7 @@ export interface NavigationRequestBase {
|
|
|
228
260
|
}
|
|
229
261
|
export interface NavigationRequestParams extends NavigationRequestBase {
|
|
230
262
|
drawerSettings?: any;
|
|
263
|
+
intent?: boolean;
|
|
231
264
|
modalSettings?: any;
|
|
232
265
|
newTab?: boolean;
|
|
233
266
|
path: string;
|
|
@@ -440,4 +473,32 @@ export interface RendererConfig {
|
|
|
440
473
|
maxWidth?: number;
|
|
441
474
|
}>;
|
|
442
475
|
}
|
|
476
|
+
export interface TitleResolverCache {
|
|
477
|
+
key: string;
|
|
478
|
+
value: {
|
|
479
|
+
label: string;
|
|
480
|
+
icon?: string;
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
export interface TitleResolver {
|
|
484
|
+
request: {
|
|
485
|
+
method: string;
|
|
486
|
+
url: string;
|
|
487
|
+
headers?: Record<string, string>;
|
|
488
|
+
body?: any;
|
|
489
|
+
};
|
|
490
|
+
titlePropertyChain: string;
|
|
491
|
+
titleDecorator?: string;
|
|
492
|
+
iconPropertyChain?: string;
|
|
493
|
+
prerenderFallback?: boolean;
|
|
494
|
+
responsePath?: string;
|
|
495
|
+
fallbackTitle?: string;
|
|
496
|
+
fallbackIcon?: string;
|
|
497
|
+
/** @internal runtime cache – not user-configured */
|
|
498
|
+
_cache?: TitleResolverCache;
|
|
499
|
+
}
|
|
500
|
+
export interface ViewGroupSettings {
|
|
501
|
+
preloadUrl?: string;
|
|
502
|
+
loadOnStartup?: boolean;
|
|
503
|
+
}
|
|
443
504
|
export type HistoryMethod = 'pushState' | 'replaceState';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Luigi } from '../../core-api/luigi';
|
|
2
|
+
export declare const ContextSwitcherHelpers: {
|
|
3
|
+
_fallbackLabels: Map<any, any>;
|
|
4
|
+
resetFallbackLabelCache(): void;
|
|
5
|
+
getPreparedParentNodePath(config: Record<string, any>): string;
|
|
6
|
+
generateSwitcherNav(config: Record<string, any>, rawOptions: any[]): any[];
|
|
7
|
+
getNodePathFromCurrentPath(option: Record<string, any>, selectedOption: Record<string, any>, luigi: Luigi): string;
|
|
8
|
+
getOptionById(options: any[], id: string): any;
|
|
9
|
+
getLabelFromOptions(options: any[], id: string): string;
|
|
10
|
+
isContextSwitcherDetailsView(currentPath: string, parentNodePath: string): boolean;
|
|
11
|
+
getFallbackLabel(fallbackLabelResolver: any, id: string, luigi: Luigi): Promise<string>;
|
|
12
|
+
getSelectedId(currentPath: string, options: any[], parentNodePath: string): string | undefined;
|
|
13
|
+
getSelectedOption(currentPath: string, options: any[], parentNodePath: string): any;
|
|
14
|
+
getSelectedLabel(currentPath: string, options: any[], parentNodePath: string, fallbackLabelResolver: any, luigi: Luigi): Promise<string | undefined>;
|
|
15
|
+
getSelectedNode(currentPath: string, options: any[], parentNodePath: string): string | undefined;
|
|
16
|
+
fetchOptions(luigi: Luigi, existingOptions?: never[]): Promise<any[]>;
|
|
17
|
+
};
|
|
@@ -65,12 +65,24 @@ export declare const GenericHelpers: {
|
|
|
65
65
|
* @returns {string} string without leading slash
|
|
66
66
|
*/
|
|
67
67
|
trimLeadingSlash: (str: string) => string;
|
|
68
|
+
/**
|
|
69
|
+
* Adds a trailing slash to a string if it has none
|
|
70
|
+
* @param {string} str string to be checked
|
|
71
|
+
* @returns {string} string with a trailing slash
|
|
72
|
+
*/
|
|
73
|
+
addTrailingSlash: (str: string) => string;
|
|
68
74
|
/**
|
|
69
75
|
* Prepend current url to redirect_uri, if it is a relative path
|
|
70
76
|
* @param {string} str string from which any number of trailing slashes should be removed
|
|
71
77
|
* @returns {string} string without any trailing slash
|
|
72
78
|
*/
|
|
73
79
|
trimTrailingSlash: (str: string) => string;
|
|
80
|
+
/**
|
|
81
|
+
* Returns a path that starts and end with one (and only one) slash, regardless of the slashes being already present in the path given as input
|
|
82
|
+
* @param {string} str path to normalize
|
|
83
|
+
* @returns {string} path that starts and ends with a slash
|
|
84
|
+
*/
|
|
85
|
+
normalizePath: (str: string) => string;
|
|
74
86
|
/**
|
|
75
87
|
* Checks if HTML element is visible
|
|
76
88
|
* @param {Element} element to be checked in DOM
|
|
@@ -124,7 +136,7 @@ export declare const GenericHelpers: {
|
|
|
124
136
|
* @param parenthesis
|
|
125
137
|
* @returns
|
|
126
138
|
*/
|
|
127
|
-
replaceVars(inputString: string, params: Record<string, any>, prefix: string, parenthesis?: boolean): string;
|
|
139
|
+
replaceVars(inputString: string, params: Record<string, any>, prefix: string, parenthesis?: boolean, slashStop?: boolean): string;
|
|
128
140
|
/**
|
|
129
141
|
* Escapes special characters in a string for use in a regular expression.
|
|
130
142
|
* @param string
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FeatureToggles } from '../../core-api/feature-toggles';
|
|
2
2
|
import { Luigi } from '../../core-api/luigi';
|
|
3
|
-
import { AppSwitcher, Node, PathData } from '../../types/navigation';
|
|
3
|
+
import { AppSwitcher, ExternalLink, Node, PathData, TitleResolver } from '../../types/navigation';
|
|
4
4
|
export declare const NavigationHelpers: {
|
|
5
5
|
normalizePath: (raw: string) => string;
|
|
6
6
|
segmentMatches: (linkSegment: string, pathSegment: string, pathParams: Record<string, any>) => boolean;
|
|
@@ -8,10 +8,9 @@ export declare const NavigationHelpers: {
|
|
|
8
8
|
checkVisibleForFeatureToggles: (nodeToCheckPermission: any, featureToggles: FeatureToggles) => boolean;
|
|
9
9
|
generateTooltipText: (node: Node, translation: string, luigi: Luigi) => string;
|
|
10
10
|
isNodeAccessPermitted: (nodeToCheckPermissionFor: Node, parentNode: Node | undefined, currentContext: Record<string, any>, luigi: Luigi) => boolean;
|
|
11
|
-
applyContext: (context: Record<string, any>, addition: Record<string, any>, navigationContext: any) => Record<string, any>;
|
|
12
11
|
updateHeaderTitle: (appSwitcherData: AppSwitcher, pathData: PathData) => string | undefined;
|
|
13
12
|
buildPath(pathToLeftNavParent: Node[], pathData?: PathData): string;
|
|
14
|
-
mergeContext(
|
|
13
|
+
mergeContext(base: Record<string, any>, addition?: Record<string, any>, navigationContext?: string): Record<string, any>;
|
|
15
14
|
prepareForTests(...parts: string[]): string;
|
|
16
15
|
/**
|
|
17
16
|
* Finds the virtual tree root node for a given node by traversing up the node hierarchy until it finds a node with the virtualTree property set to true. If no such node is found, it returns undefined.
|
|
@@ -27,4 +26,23 @@ export declare const NavigationHelpers: {
|
|
|
27
26
|
* @returns The redirect path if valid, undefined otherwise
|
|
28
27
|
*/
|
|
29
28
|
validatePathAndGetRedirect: (path: string, luigi: Luigi) => Promise<string | undefined>;
|
|
29
|
+
fetchNodeTitleData(node: Node, context: any): Promise<{
|
|
30
|
+
label: string;
|
|
31
|
+
icon?: string;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Returns a nested property value defined by a chain string
|
|
35
|
+
* @param {*} obj - the object
|
|
36
|
+
* @param {*} propChain - a string defining the property chain
|
|
37
|
+
* @param {*} fallback - fallback value if resolution fails
|
|
38
|
+
* @returns the value or fallback
|
|
39
|
+
*/
|
|
40
|
+
getPropertyChainValue(obj: Record<string, unknown>, propChain?: string, fallback?: any): any;
|
|
41
|
+
substituteVars(resolver: TitleResolver, context: Record<string, unknown>): TitleResolver;
|
|
42
|
+
_fetch(url: string, options: RequestInit): Promise<Response>;
|
|
43
|
+
processTitleData(data: Record<string, unknown>, resolver: TitleResolver): {
|
|
44
|
+
label: string;
|
|
45
|
+
icon?: string;
|
|
46
|
+
};
|
|
47
|
+
openExternalLink(externalLink: ExternalLink, pathParams?: Record<string, any>): void;
|
|
30
48
|
};
|
|
@@ -80,19 +80,100 @@ export declare const RoutingHelpers: {
|
|
|
80
80
|
* @returns An object containing only the permitted search parameters for the client.
|
|
81
81
|
*/
|
|
82
82
|
prepareSearchParamsForClient(currentNode: Node, luigi: Luigi): {};
|
|
83
|
+
/**
|
|
84
|
+
* Checks if given path contains intent navigation special syntax
|
|
85
|
+
* @param {string} path - path to be checked
|
|
86
|
+
*/
|
|
87
|
+
hasIntent(path: string): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* This function takes an intentLink and parses it conforming certain limitations in characters usage.
|
|
90
|
+
* Limitations include:
|
|
91
|
+
* - `semanticObject` allows only alphanumeric characters
|
|
92
|
+
* - `action` allows alphanumeric characters and the '_' sign
|
|
93
|
+
*
|
|
94
|
+
* Example of resulting output:
|
|
95
|
+
* ```
|
|
96
|
+
* {
|
|
97
|
+
* semanticObject: "Sales",
|
|
98
|
+
* action: "order",
|
|
99
|
+
* params: {param1: "value1",param2: "value2"}
|
|
100
|
+
* };
|
|
101
|
+
* ```
|
|
102
|
+
* @param {string} intentLink - the intent link represents the semantic intent defined by the user, i.e.: #?intent=semanticObject-action?param=value
|
|
103
|
+
*/
|
|
104
|
+
getIntentObject(intentLink: string): Record<string, any> | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* This function compares the intentLink parameter with the configuration intentMapping
|
|
107
|
+
* and returns the path segment that is matched together with the parameters, if any
|
|
108
|
+
*
|
|
109
|
+
* Example:
|
|
110
|
+
*
|
|
111
|
+
* For intentLink = `#?intent=Sales-order?foo=bar`
|
|
112
|
+
* and Luigi configuration:
|
|
113
|
+
* ```
|
|
114
|
+
* intentMapping: [{
|
|
115
|
+
* semanticObject: 'Sales',
|
|
116
|
+
* action: 'order',
|
|
117
|
+
* pathSegment: '/projects/pr2/order'
|
|
118
|
+
* }]
|
|
119
|
+
*
|
|
120
|
+
* ```
|
|
121
|
+
* the given intentLink is matched with the configuration's same semanticObject and action,
|
|
122
|
+
* resulting in pathSegment `/projects/pr2/order` being returned. The parameter is also added in
|
|
123
|
+
* this case resulting in: `/projects/pr2/order?~foo=bar`
|
|
124
|
+
*
|
|
125
|
+
* Or for external intent links: intentLink = `#?intent=External-view`
|
|
126
|
+
* and Luigi configuration:
|
|
127
|
+
* ```
|
|
128
|
+
* intentMapping: [{
|
|
129
|
+
* semanticObject: 'External',
|
|
130
|
+
* action: 'view',
|
|
131
|
+
* externalLink: { url: 'https://www.sap.com', openInNewTab: true }
|
|
132
|
+
* }]
|
|
133
|
+
* ```
|
|
134
|
+
* The resulting will be returned from this function:
|
|
135
|
+
* ```
|
|
136
|
+
* {
|
|
137
|
+
* url: 'https://www.sap.com',
|
|
138
|
+
* openInNewTab: true,
|
|
139
|
+
* external: true
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
142
|
+
* @param {string} intentLink - the intentLink represents the semantic intent defined by the user, i.e.: #?intent=semanticObject-action?param=value
|
|
143
|
+
* @param luigi - Luigi instance used to access configuration values
|
|
144
|
+
*/
|
|
145
|
+
getIntentPath(intentLink: string, luigi: Luigi): boolean | string | Record<string, any>;
|
|
146
|
+
/**
|
|
147
|
+
* This function takes a path which contains dynamic parameters and a list parameters and replaces the dynamic parameters
|
|
148
|
+
* with the given parameters if any. The input path remains unchanged if the parameters list
|
|
149
|
+
* does not contain the respective dynamic parameter name.
|
|
150
|
+
* e.g.:
|
|
151
|
+
* Assume either of these two calls are made:
|
|
152
|
+
* 1. `LuigiClient.linkManager().navigateToIntent('Sales-settings', {project: 'pr2', user: 'john'})`
|
|
153
|
+
* 2. `LuigiClient.linkManager().navigate('/#?intent=Sales-settings?project=pr2&user=john')`
|
|
154
|
+
* For both 1. and 2., the following dynamic input path: `/projects/:project/details/:user`
|
|
155
|
+
* is resolved through this method to `/projects/pr2/details/john`
|
|
156
|
+
*
|
|
157
|
+
* @param {string} path - the path containing the potential dynamic parameter
|
|
158
|
+
* @param {Object} parameters - a list of objects consisting of passed parameters
|
|
159
|
+
*/
|
|
160
|
+
resolveDynamicIntentPath(path: string, parameters: object): string;
|
|
83
161
|
/**
|
|
84
162
|
* Retrieves the current path and query string from the browser's location hash.
|
|
85
163
|
*
|
|
164
|
+
* @param hashRouting - true if hash routing is active, false if path routing is active
|
|
165
|
+
* @param luigi - Luigi instance used to access configuration values
|
|
86
166
|
* @returns An object containing the normalized path and the query string.
|
|
87
167
|
* @remarks
|
|
88
168
|
* - The path is normalized using `NavigationHelpers.normalizePath`.
|
|
89
169
|
* - The query string is extracted from the portion after the '?' in the hash.
|
|
90
170
|
* - If there is no query string, `query` will be `undefined`.
|
|
91
171
|
*/
|
|
92
|
-
getCurrentPath(hashRouting?: boolean): {
|
|
172
|
+
getCurrentPath(luigi: Luigi, hashRouting?: boolean, checkIntent?: boolean): {
|
|
93
173
|
path: string;
|
|
94
174
|
query: string;
|
|
95
175
|
};
|
|
176
|
+
handleExternalIntentPath(intentPath: Record<string, any>): void;
|
|
96
177
|
/**
|
|
97
178
|
* Retrieves the modal path from the current URL's query parameters based on the provided Luigi instance.
|
|
98
179
|
*
|
|
@@ -163,7 +244,7 @@ export declare const RoutingHelpers: {
|
|
|
163
244
|
getModalParamsFromPath(luigi: Luigi): any;
|
|
164
245
|
/**
|
|
165
246
|
* Get the query param separator which is used with hashRouting
|
|
166
|
-
* Default:
|
|
247
|
+
* Default:
|
|
167
248
|
* @example /home?modal=(urlencoded)/some-modal?modalParams=(urlencoded){...}&otherParam=hmhm
|
|
168
249
|
* @returns the first query param separator (like ? for path routing)
|
|
169
250
|
*/
|
|
@@ -323,7 +404,31 @@ export declare const RoutingHelpers: {
|
|
|
323
404
|
* @returns a string representing the full route from the root to the given node, including query parameters if provided.
|
|
324
405
|
*/
|
|
325
406
|
buildRoute(node: Node, path: string, params?: string): string;
|
|
326
|
-
|
|
407
|
+
/**
|
|
408
|
+
* Resolves the final view URL for a given node by substituting dynamic placeholders with actual values.
|
|
409
|
+
*
|
|
410
|
+
* Performs the following substitutions in order:
|
|
411
|
+
* 1. Removes `{virtualTreePath}` if the node is a virtual tree.
|
|
412
|
+
* 2. Replaces path parameters (e.g. `:id`) with their concrete values from `pathParams`.
|
|
413
|
+
* 3. Replaces context variables (e.g. `{context.myVar}`) with values from `node.context`.
|
|
414
|
+
* 4. Replaces node parameter variables (e.g. `{nodeParams.myParam}`) with values from `nodeParams`.
|
|
415
|
+
* 5. Replaces `{i18n.currentLocale}` with the current locale.
|
|
416
|
+
* 6. Replaces `{routing.queryParams.<key>}` with the corresponding search parameter value,
|
|
417
|
+
* or removes the query parameter from the URL if the value is not present.
|
|
418
|
+
*
|
|
419
|
+
* @param node - The navigation node containing the `viewUrl` template and optional `context`/`virtualTree` properties.
|
|
420
|
+
* @param pathParams - A map of path parameter names to their resolved values (e.g. `{ id: '42' }`).
|
|
421
|
+
* @param nodeParams - A map of node-specific parameters passed to the micro frontend.
|
|
422
|
+
* @param luigi - The Luigi instance used to access i18n, routing, and configuration.
|
|
423
|
+
* @returns The fully resolved view URL string, or an empty string if `node.viewUrl` is not defined.
|
|
424
|
+
*/
|
|
425
|
+
substituteViewUrl(node: Node, pathParams: Record<string, string>, nodeParams: Record<string, any>, luigi: Luigi): string;
|
|
426
|
+
/**
|
|
427
|
+
* Returns the viewUrl with current locale, e.g. luigi/{i18n.currentLocale}/ -> luigi/en
|
|
428
|
+
* if viewUrl contains {i18n.currentLocale} term, it will be replaced by current locale
|
|
429
|
+
* @param viewUrl
|
|
430
|
+
*/
|
|
431
|
+
getI18nViewUrl(viewUrl: string, luigi: Luigi): string;
|
|
327
432
|
/**
|
|
328
433
|
* Generates a sub-path for a given node by replacing dynamic parameters in the node's path with actual values from pathParams.
|
|
329
434
|
* @param node - The node for which to generate the sub-path. It is expected to have a `pathSegment` property and optionally a `parent` property pointing to its parent node.
|
|
@@ -343,4 +448,31 @@ export declare const RoutingHelpers: {
|
|
|
343
448
|
* @returns A string representing the concatenated path, with exactly one '/' character between the base and relative paths.
|
|
344
449
|
*/
|
|
345
450
|
concatenatePath(basePath: any, relativePath?: any): string;
|
|
451
|
+
/**
|
|
452
|
+
* Returns the resolved route link for a navigation node. If the node has an external link, its URL is returned directly.
|
|
453
|
+
* If the node has an internal link, the prefix is prepended. Otherwise, the full route is built from the node's path
|
|
454
|
+
* segments and path parameters are substituted.
|
|
455
|
+
* @param node - The navigation node to resolve the link for
|
|
456
|
+
* @param pathParams - Dynamic path parameters to substitute in the route
|
|
457
|
+
* @param relativePathPrefix - Prefix to prepend to relative paths (e.g. '#' for hash routing)
|
|
458
|
+
* @returns The resolved route link as a string
|
|
459
|
+
*/
|
|
460
|
+
getRouteLink(node: Node, pathParams: Record<string, any>, relativePathPrefix: string): string;
|
|
461
|
+
/**
|
|
462
|
+
* Calculates the full href for a navigation node, taking hash routing and i18n view URLs into account.
|
|
463
|
+
* @param node - The navigation node to calculate the href for
|
|
464
|
+
* @param pathParams - Dynamic path parameters to substitute in the route
|
|
465
|
+
* @param luigi - The Luigi instance used to read routing configuration
|
|
466
|
+
* @returns The fully resolved href string for the node
|
|
467
|
+
*/
|
|
468
|
+
calculateNodeHref(node: Node, pathParams: Record<string, any>, luigi: Luigi): string;
|
|
469
|
+
/**
|
|
470
|
+
* Returns the href for a navigation node if the `navigation.addNavHrefs` configuration is enabled.
|
|
471
|
+
* This is used to populate anchor `href` attributes for accessibility and native browser behavior.
|
|
472
|
+
* @param node - The navigation node to get the href for
|
|
473
|
+
* @param pathParams - Dynamic path parameters to substitute in the route
|
|
474
|
+
* @param luigi - The Luigi instance used to read configuration
|
|
475
|
+
* @returns The node href string if `addNavHrefs` is enabled, otherwise `undefined`
|
|
476
|
+
*/
|
|
477
|
+
getNodeHref(node: Node, pathParams: Record<string, any>, luigi: Luigi): string | undefined;
|
|
346
478
|
};
|