@hitachivantara/app-shell-ui 2.3.2 → 2.3.3
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/dist/components/AppShell/AppShell.js +16 -5
- package/dist/components/AppShell/AppShellContainer.js +75 -66
- package/dist/components/AppShell/AppShellRouter.js +98 -109
- package/dist/components/AppShellI18nProvider/AppShellI18nProvider.js +19 -25
- package/dist/components/AppShellProvider/AppShellProvider.js +84 -91
- package/dist/components/AppShellViewProvider/AppShellViewProvider.js +10 -7
- package/dist/components/ConfigIcon.js +13 -15
- package/dist/components/CustomHooksInitializer/CustomHooksInitializer.js +7 -7
- package/dist/components/GlobalStyles.js +11 -9
- package/dist/components/IconUiKit/IconUiKit.js +10 -8
- package/dist/components/InitErrorFallback/InitErrorFallback.js +31 -23
- package/dist/components/SnackbarProvider/SnackbarProvider.js +17 -20
- package/dist/components/layout/AppShellLayout.js +50 -65
- package/dist/components/layout/BrandLogo/BrandLogo.js +25 -35
- package/dist/components/layout/BrandLogo/logos.js +38 -55
- package/dist/components/layout/Header/Header.js +55 -74
- package/dist/components/layout/HeaderActions/AppSwitcherToggle/AppSwitcherToggle.js +66 -74
- package/dist/components/layout/HeaderActions/AppSwitcherToggle/styles.js +12 -12
- package/dist/components/layout/HeaderActions/ColorModeSwitcher.js +23 -26
- package/dist/components/layout/HeaderActions/DynamicAction.js +22 -21
- package/dist/components/layout/HeaderActions/HeaderActions.js +15 -22
- package/dist/components/layout/HeaderActions/HelpButton/HelpButton.js +22 -31
- package/dist/components/layout/HeaderActions/InternalAction/InternalAction.js +25 -36
- package/dist/components/layout/VerticalNavigation/NavigationCollapse.js +29 -34
- package/dist/components/layout/VerticalNavigation/NavigationHeader.js +18 -20
- package/dist/components/layout/VerticalNavigation/VerticalNavigation.js +96 -130
- package/dist/hooks/useClearLocationState.js +10 -12
- package/dist/hooks/useConditionsEvaluator.js +67 -81
- package/dist/hooks/useCustomEventListener.js +16 -28
- package/dist/hooks/useFilteredModel.js +30 -27
- package/dist/hooks/useLocalStorage.js +26 -26
- package/dist/hooks/useModelFromConfig.js +43 -39
- package/dist/hooks/useNavigationMenuItems.js +27 -30
- package/dist/hooks/useNotificationsEventListener.js +35 -42
- package/dist/hooks/useResizeObserver.js +13 -13
- package/dist/hooks/useThemeEventListener.js +17 -18
- package/dist/i18n/constants.js +5 -6
- package/dist/i18n/index.js +26 -20
- package/dist/i18n/useI18nInit.js +72 -66
- package/dist/index.js +4 -3
- package/dist/pages/ErrorPage/ErrorPage.js +33 -32
- package/dist/pages/ErrorPage/Footer.js +46 -55
- package/dist/pages/GenericError/CatServer.js +585 -569
- package/dist/pages/GenericError/GenericError.js +25 -26
- package/dist/pages/LoadingPage/LoadingPage.js +9 -17
- package/dist/pages/LoadingPage/index.js +4 -3
- package/dist/pages/NotFound/DogeSpace.js +505 -540
- package/dist/pages/NotFound/NotFound.js +17 -20
- package/dist/pages/NotFound/index.js +2 -4
- package/dist/pages/RootRoute.js +32 -19
- package/dist/providers/BannerProvider.js +98 -123
- package/dist/providers/LayoutProvider.js +26 -32
- package/dist/providers/NavigationProvider.js +96 -107
- package/dist/utils/CombinedProviders.js +12 -18
- package/dist/utils/documentUtil.js +12 -12
- package/dist/utils/filterModel.js +134 -170
- package/dist/utils/lazyImport.js +31 -36
- package/dist/utils/navigationUtil.js +68 -53
- package/dist/utils/processConfig.js +119 -153
- package/package.json +8 -8
- package/dist/components/IconUiKit/index.js +0 -6
- package/dist/pages/LoadingPage/styles.js +0 -30
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
createAppContainerElement as default
|
|
1
|
+
//#region src/utils/documentUtil.ts
|
|
2
|
+
var createAppContainerElement = (id) => {
|
|
3
|
+
const panelContainerId = "app-shell-panel-container";
|
|
4
|
+
let panelContainerElement = document.getElementById(id ?? panelContainerId);
|
|
5
|
+
if (!panelContainerElement) {
|
|
6
|
+
panelContainerElement = document.createElement("div");
|
|
7
|
+
panelContainerElement.id = panelContainerId;
|
|
8
|
+
document.body.appendChild(panelContainerElement);
|
|
9
|
+
}
|
|
10
|
+
return panelContainerElement;
|
|
13
11
|
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { createAppContainerElement as default };
|
|
@@ -1,178 +1,142 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (!conditionResults[condition.globalIndex]) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
return true;
|
|
1
|
+
//#region src/utils/filterModel.ts
|
|
2
|
+
var shouldInclude = (conditions, conditionResults) => {
|
|
3
|
+
if (!conditions || conditions.length === 0) return true;
|
|
4
|
+
for (const condition of conditions) if (!conditionResults[condition.globalIndex]) return false;
|
|
5
|
+
return true;
|
|
11
6
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return [hasChanged ? filteredViews : views, hasChanged];
|
|
7
|
+
var filterViews = (views, conditionResults) => {
|
|
8
|
+
const filteredViews = [];
|
|
9
|
+
let hasChanged = false;
|
|
10
|
+
for (const view of views) {
|
|
11
|
+
if (!shouldInclude(view.conditions, conditionResults)) {
|
|
12
|
+
hasChanged = true;
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (!view.views) {
|
|
16
|
+
filteredViews.push(view);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const [filteredSubViews, subViewsChanged] = filterViews(view.views, conditionResults);
|
|
20
|
+
if (subViewsChanged) {
|
|
21
|
+
filteredViews.push({
|
|
22
|
+
...view,
|
|
23
|
+
views: filteredSubViews
|
|
24
|
+
});
|
|
25
|
+
hasChanged = true;
|
|
26
|
+
} else filteredViews.push(view);
|
|
27
|
+
}
|
|
28
|
+
return [hasChanged ? filteredViews : views, hasChanged];
|
|
37
29
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Recursively filters menu entries based on condition results and structural validity.
|
|
32
|
+
*
|
|
33
|
+
* A menu is excluded when:
|
|
34
|
+
* 1. Its conditions evaluate to false (condition-based filtering), or
|
|
35
|
+
* 2. It has no `target` and no `submenus` (invalid config guard), or
|
|
36
|
+
* 3. It is a parent whose children were all filtered out, leaving it empty.
|
|
37
|
+
*
|
|
38
|
+
* Preserves object references when no changes occur to minimize re-renders.
|
|
39
|
+
*/
|
|
40
|
+
var filterMenus = (menus, conditionResults) => {
|
|
41
|
+
const filteredMenus = [];
|
|
42
|
+
let hasChanged = false;
|
|
43
|
+
for (const menu of menus) {
|
|
44
|
+
const include = shouldInclude(menu.conditions, conditionResults);
|
|
45
|
+
const hasSubmenus = menu.submenus && menu.submenus.length > 0;
|
|
46
|
+
if (!include || !menu.target && !hasSubmenus) {
|
|
47
|
+
hasChanged = true;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (!hasSubmenus) {
|
|
51
|
+
filteredMenus.push(menu);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const [filteredSubmenus, submenusChanged] = filterMenus(menu.submenus, conditionResults);
|
|
55
|
+
if (filteredSubmenus.length === 0) {
|
|
56
|
+
hasChanged = true;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (submenusChanged) {
|
|
60
|
+
filteredMenus.push({
|
|
61
|
+
...menu,
|
|
62
|
+
submenus: filteredSubmenus
|
|
63
|
+
});
|
|
64
|
+
hasChanged = true;
|
|
65
|
+
} else filteredMenus.push(menu);
|
|
66
|
+
}
|
|
67
|
+
return [hasChanged ? filteredMenus : menus, hasChanged];
|
|
71
68
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
const hasChanged = filteredHeaderActions.length !== actions.length;
|
|
79
|
-
return [hasChanged ? filteredHeaderActions : actions, hasChanged];
|
|
69
|
+
var filterActions = (actions, conditionResults) => {
|
|
70
|
+
const filteredHeaderActions = [];
|
|
71
|
+
for (const action of actions) if (shouldInclude(action.conditions, conditionResults)) filteredHeaderActions.push(action);
|
|
72
|
+
const hasChanged = filteredHeaderActions.length !== actions.length;
|
|
73
|
+
return [hasChanged ? filteredHeaderActions : actions, hasChanged];
|
|
80
74
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
const hasChanged = filteredProviders.length !== providers.length;
|
|
88
|
-
return [hasChanged ? filteredProviders : providers, hasChanged];
|
|
75
|
+
var filterProviders = (providers, conditionResults) => {
|
|
76
|
+
const filteredProviders = [];
|
|
77
|
+
for (const provider of providers) if (shouldInclude(provider.conditions, conditionResults)) filteredProviders.push(provider);
|
|
78
|
+
const hasChanged = filteredProviders.length !== providers.length;
|
|
79
|
+
return [hasChanged ? filteredProviders : providers, hasChanged];
|
|
89
80
|
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
);
|
|
104
|
-
if (include) {
|
|
105
|
-
result.push(serviceConfigModel);
|
|
106
|
-
} else {
|
|
107
|
-
localChanged = true;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (localChanged) hasChanged = true;
|
|
111
|
-
filteredServices[serviceId] = localChanged ? result : serviceProviderModels;
|
|
112
|
-
}
|
|
113
|
-
return [hasChanged ? filteredServices : services, hasChanged];
|
|
81
|
+
var filterServices = (services, conditionResults) => {
|
|
82
|
+
if (!services) return [services, false];
|
|
83
|
+
const filteredServices = {};
|
|
84
|
+
let hasChanged = false;
|
|
85
|
+
for (const [serviceId, serviceProviderModels] of Object.entries(services)) {
|
|
86
|
+
const result = [];
|
|
87
|
+
let localChanged = false;
|
|
88
|
+
for (const serviceConfigModel of serviceProviderModels) if (shouldInclude(serviceConfigModel.conditions, conditionResults)) result.push(serviceConfigModel);
|
|
89
|
+
else localChanged = true;
|
|
90
|
+
if (localChanged) hasChanged = true;
|
|
91
|
+
filteredServices[serviceId] = localChanged ? result : serviceProviderModels;
|
|
92
|
+
}
|
|
93
|
+
return [hasChanged ? filteredServices : services, hasChanged];
|
|
114
94
|
};
|
|
115
95
|
function filterModel(model, conditionResults) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
filtered.providers = filteredProviders;
|
|
161
|
-
hasChanged = true;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
if (model.services) {
|
|
165
|
-
const [filteredServices, servicesChanged] = filterServices(
|
|
166
|
-
model.services,
|
|
167
|
-
conditionResults
|
|
168
|
-
);
|
|
169
|
-
if (servicesChanged) {
|
|
170
|
-
filtered.services = filteredServices;
|
|
171
|
-
hasChanged = true;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return hasChanged ? filtered : model;
|
|
96
|
+
let hasChanged = false;
|
|
97
|
+
const filtered = { ...model };
|
|
98
|
+
if (model.mainPanel?.views) {
|
|
99
|
+
const [filteredViews, viewsChanged] = filterViews(model.mainPanel.views, conditionResults);
|
|
100
|
+
if (viewsChanged) {
|
|
101
|
+
filtered.mainPanel = {
|
|
102
|
+
...model.mainPanel,
|
|
103
|
+
views: filteredViews
|
|
104
|
+
};
|
|
105
|
+
hasChanged = true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (model.menu) {
|
|
109
|
+
const [filteredMenus, menusChanged] = filterMenus(model.menu, conditionResults);
|
|
110
|
+
if (menusChanged) {
|
|
111
|
+
filtered.menu = filteredMenus;
|
|
112
|
+
hasChanged = true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (model.header?.actions) {
|
|
116
|
+
const [filteredActions, actionsChanged] = filterActions(model.header.actions, conditionResults);
|
|
117
|
+
if (actionsChanged) {
|
|
118
|
+
filtered.header = {
|
|
119
|
+
...model.header,
|
|
120
|
+
actions: filteredActions
|
|
121
|
+
};
|
|
122
|
+
hasChanged = true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (model.providers) {
|
|
126
|
+
const [filteredProviders, providersChanged] = filterProviders(model.providers, conditionResults);
|
|
127
|
+
if (providersChanged) {
|
|
128
|
+
filtered.providers = filteredProviders;
|
|
129
|
+
hasChanged = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (model.services) {
|
|
133
|
+
const [filteredServices, servicesChanged] = filterServices(model.services, conditionResults);
|
|
134
|
+
if (servicesChanged) {
|
|
135
|
+
filtered.services = filteredServices;
|
|
136
|
+
hasChanged = true;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return hasChanged ? filtered : model;
|
|
175
140
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
};
|
|
141
|
+
//#endregion
|
|
142
|
+
export { filterModel as default };
|
package/dist/utils/lazyImport.js
CHANGED
|
@@ -1,40 +1,35 @@
|
|
|
1
|
+
//#region src/utils/lazyImport.ts
|
|
1
2
|
async function lazyImport(bundle) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
}
|
|
3
|
+
try {
|
|
4
|
+
return {
|
|
5
|
+
isPending: false,
|
|
6
|
+
error: null,
|
|
7
|
+
module: (await import(
|
|
8
|
+
/* @vite-ignore */
|
|
9
|
+
bundle
|
|
10
|
+
)).default
|
|
11
|
+
};
|
|
12
|
+
} catch (err) {
|
|
13
|
+
return {
|
|
14
|
+
isPending: false,
|
|
15
|
+
error: err instanceof Error ? err : new Error(String(err)),
|
|
16
|
+
module: void 0
|
|
17
|
+
};
|
|
18
|
+
}
|
|
20
19
|
}
|
|
21
20
|
async function importAllBundles(bundles) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
return preloadedBundles;
|
|
21
|
+
const results = await Promise.all(bundles.map((bundle) => lazyImport(bundle)));
|
|
22
|
+
const preloadedBundles = /* @__PURE__ */ new Map();
|
|
23
|
+
for (let i = 0; i < results.length; i++) {
|
|
24
|
+
const result = results[i];
|
|
25
|
+
const bundle = bundles[i];
|
|
26
|
+
if (result.error) {
|
|
27
|
+
console.error(`Failed to load bundle ${bundle}:`, result.error);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
preloadedBundles.set(bundle, result.module);
|
|
31
|
+
}
|
|
32
|
+
return preloadedBundles;
|
|
36
33
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
lazyImport
|
|
40
|
-
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { importAllBundles };
|
|
@@ -1,58 +1,73 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
1
|
import { ConfigIcon } from "../components/ConfigIcon.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (childData && childData.length > 0) {
|
|
27
|
-
foundItem = findItemById(childData, itemId);
|
|
28
|
-
return foundItem !== null;
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
});
|
|
32
|
-
return foundItem;
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/utils/navigationUtil.tsx
|
|
4
|
+
/**
|
|
5
|
+
* Creates a navigation data structure ({@link MenuItem}) from the provided menu configuration ({@link NavigationMenuItem}).
|
|
6
|
+
*
|
|
7
|
+
* @param t
|
|
8
|
+
* @param menuItems The set of menu items from configuration.
|
|
9
|
+
* @param maxDepth The maximum depth up until the recursiveness should occur for the creation of the menu items.
|
|
10
|
+
*
|
|
11
|
+
* @returns An array of {@link MenuItem}.
|
|
12
|
+
*/
|
|
13
|
+
var createNavigationMenuItems = (t, menuItems, maxDepth) => {
|
|
14
|
+
if (maxDepth !== void 0 && maxDepth <= 0) return [];
|
|
15
|
+
return menuItems?.reduce((accumulator, currentValue) => {
|
|
16
|
+
const updatedDepth = maxDepth !== void 0 ? maxDepth - 1 : void 0;
|
|
17
|
+
const navItem = {
|
|
18
|
+
...currentValue,
|
|
19
|
+
icon: currentValue.icon && /* @__PURE__ */ jsx(ConfigIcon, { icon: currentValue.icon }),
|
|
20
|
+
data: currentValue.data ? createNavigationMenuItems(t, currentValue.data, updatedDepth) : void 0
|
|
21
|
+
};
|
|
22
|
+
accumulator.push(navItem);
|
|
23
|
+
return accumulator;
|
|
24
|
+
}, []) ?? [];
|
|
33
25
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Searches for an item with the specified id.
|
|
28
|
+
*
|
|
29
|
+
* @param {NavigationMenuItem[]} data - The navigation data structure.
|
|
30
|
+
* @param {string} itemId - The item id.
|
|
31
|
+
* @returns The item with matching id.
|
|
32
|
+
*/
|
|
33
|
+
var findItemById = (data, itemId) => {
|
|
34
|
+
let foundItem = null;
|
|
35
|
+
data.some((obj) => {
|
|
36
|
+
const { id: objId, data: childData } = obj;
|
|
37
|
+
if (objId === itemId) {
|
|
38
|
+
foundItem = obj;
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
if (childData && childData.length > 0) {
|
|
42
|
+
foundItem = findItemById(childData, itemId);
|
|
43
|
+
return foundItem !== null;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
});
|
|
47
|
+
return foundItem;
|
|
43
48
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return item;
|
|
51
|
-
});
|
|
49
|
+
var getAppIdFromBundle = (bundle) => {
|
|
50
|
+
const bundleTokens = bundle.split("/");
|
|
51
|
+
let appId;
|
|
52
|
+
if (bundleTokens[0].startsWith("@")) appId = `${bundleTokens[0]}/${bundleTokens[1]}`;
|
|
53
|
+
else [appId] = bundleTokens;
|
|
54
|
+
return appId;
|
|
52
55
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Recursively removes the href property from items in the array if they have a non-empty data property.
|
|
58
|
+
*
|
|
59
|
+
* @param items - The array of items.
|
|
60
|
+
* @returns The new array with the href property removed from items with children.
|
|
61
|
+
*/
|
|
62
|
+
var removeHrefFromMenuItemsWithChildren = (items) => {
|
|
63
|
+
return items.map((item) => {
|
|
64
|
+
const { href, data, ...rest } = item;
|
|
65
|
+
if (data && data.length > 0) return {
|
|
66
|
+
...rest,
|
|
67
|
+
data: removeHrefFromMenuItemsWithChildren(data)
|
|
68
|
+
};
|
|
69
|
+
return item;
|
|
70
|
+
});
|
|
58
71
|
};
|
|
72
|
+
//#endregion
|
|
73
|
+
export { createNavigationMenuItems, findItemById, getAppIdFromBundle, removeHrefFromMenuItemsWithChildren };
|