@luigi-project/core-modular 0.0.7-dev.20260520101 → 0.0.7-dev.202605270112
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 +66 -26
- package/luigi.js.map +1 -1
- package/package.json +1 -1
- 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 +1 -1
- 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 +17 -3
- package/utilities/helpers/generic-helpers.d.ts +1 -1
- package/utilities/helpers/i18n-helpers.d.ts +3 -0
- package/utilities/helpers/navigation-helpers.d.ts +1 -2
- package/utilities/helpers/routing-helpers.d.ts +135 -3
package/package.json
CHANGED
|
@@ -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
|
|
@@ -26,7 +26,7 @@ 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;
|
|
@@ -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
|
@@ -5,7 +5,7 @@ export interface TopNavData {
|
|
|
5
5
|
productSwitcher?: ProductSwitcher;
|
|
6
6
|
profile?: ProfileSettings;
|
|
7
7
|
appSwitcher?: AppSwitcher;
|
|
8
|
-
navClick?: (item: NavItem) => void
|
|
8
|
+
navClick?: (item: NavItem) => Promise<void>;
|
|
9
9
|
}
|
|
10
10
|
export interface AppSwitcher {
|
|
11
11
|
showMainAppEntry?: boolean;
|
|
@@ -33,8 +33,13 @@ export interface ProfileSettings {
|
|
|
33
33
|
items?: ProfileItem[];
|
|
34
34
|
staticUserInfoFn?: () => Promise<UserInfo>;
|
|
35
35
|
onUserInfoUpdate: (fn: (uInfo: UserInfo) => void) => void;
|
|
36
|
+
settings: UserSettingsProfileMenuEntry;
|
|
36
37
|
itemClick: (item: ProfileItem) => void;
|
|
37
38
|
}
|
|
39
|
+
export interface UserSettingsProfileMenuEntry {
|
|
40
|
+
label?: string;
|
|
41
|
+
link?: string;
|
|
42
|
+
}
|
|
38
43
|
export interface ProfileLogout {
|
|
39
44
|
label?: string;
|
|
40
45
|
icon?: string;
|
|
@@ -63,7 +68,7 @@ export interface LeftNavData {
|
|
|
63
68
|
items: NavItem[];
|
|
64
69
|
basePath: string;
|
|
65
70
|
sideNavFooterText?: string;
|
|
66
|
-
navClick?: (item: NavItem) => void
|
|
71
|
+
navClick?: (item: NavItem) => Promise<void>;
|
|
67
72
|
}
|
|
68
73
|
export interface PathData {
|
|
69
74
|
context?: Record<string, any>;
|
|
@@ -98,9 +103,11 @@ export interface Node {
|
|
|
98
103
|
hideFromNav?: boolean;
|
|
99
104
|
hideSideNav?: boolean;
|
|
100
105
|
icon?: string;
|
|
106
|
+
intendToHaveEmptyViewUrl?: boolean;
|
|
101
107
|
isRootNode?: boolean;
|
|
102
108
|
keepSelectedForChildren?: boolean;
|
|
103
109
|
label?: string;
|
|
110
|
+
link?: string;
|
|
104
111
|
loadingIndicator?: {
|
|
105
112
|
enabled: boolean;
|
|
106
113
|
};
|
|
@@ -128,6 +135,7 @@ export interface Node {
|
|
|
128
135
|
_virtualTree?: Node;
|
|
129
136
|
_virtualPathIndex?: number;
|
|
130
137
|
_virtualViewUrl?: string;
|
|
138
|
+
_rawContext?: Record<string, any>;
|
|
131
139
|
}
|
|
132
140
|
export interface PageErrorHandler {
|
|
133
141
|
timeout: number;
|
|
@@ -158,6 +166,7 @@ export interface BreadcrumbItem {
|
|
|
158
166
|
export interface NavItem {
|
|
159
167
|
altText?: string;
|
|
160
168
|
category?: Category;
|
|
169
|
+
href?: string;
|
|
161
170
|
icon?: string;
|
|
162
171
|
node?: Node;
|
|
163
172
|
label?: string;
|
|
@@ -168,7 +177,7 @@ export interface TabNavData {
|
|
|
168
177
|
selectedNode?: any;
|
|
169
178
|
items?: NavItem[];
|
|
170
179
|
basePath?: string;
|
|
171
|
-
navClick?: (item: NavItem) => void
|
|
180
|
+
navClick?: (item: NavItem) => Promise<void>;
|
|
172
181
|
}
|
|
173
182
|
export interface BreadcrumbData {
|
|
174
183
|
basePath?: string;
|
|
@@ -229,6 +238,7 @@ export interface NavigationRequestBase {
|
|
|
229
238
|
}
|
|
230
239
|
export interface NavigationRequestParams extends NavigationRequestBase {
|
|
231
240
|
drawerSettings?: any;
|
|
241
|
+
intent?: boolean;
|
|
232
242
|
modalSettings?: any;
|
|
233
243
|
newTab?: boolean;
|
|
234
244
|
path: string;
|
|
@@ -465,4 +475,8 @@ export interface TitleResolver {
|
|
|
465
475
|
/** @internal runtime cache – not user-configured */
|
|
466
476
|
_cache?: TitleResolverCache;
|
|
467
477
|
}
|
|
478
|
+
export interface ViewGroupSettings {
|
|
479
|
+
preloadUrl?: string;
|
|
480
|
+
loadOnStartup?: boolean;
|
|
481
|
+
}
|
|
468
482
|
export type HistoryMethod = 'pushState' | 'replaceState';
|
|
@@ -124,7 +124,7 @@ export declare const GenericHelpers: {
|
|
|
124
124
|
* @param parenthesis
|
|
125
125
|
* @returns
|
|
126
126
|
*/
|
|
127
|
-
replaceVars(inputString: string, params: Record<string, any>, prefix: string, parenthesis?: boolean): string;
|
|
127
|
+
replaceVars(inputString: string, params: Record<string, any>, prefix: string, parenthesis?: boolean, slashStop?: boolean): string;
|
|
128
128
|
/**
|
|
129
129
|
* Escapes special characters in a string for use in a regular expression.
|
|
130
130
|
* @param string
|
|
@@ -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.
|
|
@@ -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
|
};
|