@hitachivantara/app-shell-shared 1.7.11 → 2.0.0-next.2
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/AppShellModelContext.js +15 -0
- package/dist/bundles/app-shell-shared.esm.js +64 -5
- package/dist/components/DynamicHooksEvaluator/DynamicHooksEvaluator.js +48 -0
- package/dist/{esm/hooks → hooks}/useMenuItems.js +5 -5
- package/dist/index.d.ts +257 -0
- package/dist/{esm/index.js → index.js} +7 -0
- package/dist/types/index.d.ts +2 -149
- package/package.json +8 -8
- /package/dist/{esm/AppShellCombinedProvidersContext.js → AppShellCombinedProvidersContext.js} +0 -0
- /package/dist/{esm/AppShellContext.js → AppShellContext.js} +0 -0
- /package/dist/{esm/AppShellRuntimeContext.js → AppShellRuntimeContext.js} +0 -0
- /package/dist/{esm/AppShellViewContext.js → AppShellViewContext.js} +0 -0
- /package/dist/{esm/i18n → i18n}/index.js +0 -0
- /package/dist/{esm/utils → utils}/navigationUtils.js +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const HvAppShellModelContext = createContext(void 0);
|
|
3
|
+
const useHvAppShellModel = () => {
|
|
4
|
+
const context = useContext(HvAppShellModelContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error(
|
|
7
|
+
"useHvAppShellModel must be used within HvAppShellModelContext.Provider"
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
return context;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
HvAppShellModelContext,
|
|
14
|
+
useHvAppShellModel
|
|
15
|
+
};
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import { createContext, useContext, useMemo, useState, useEffect } from "react";
|
|
1
|
+
import { createContext, useContext, useMemo, useState, useEffect, useRef, useCallback, createElement } from "react";
|
|
2
|
+
import { useAsync } from "@hitachivantara/app-shell-services";
|
|
2
3
|
import { useLocation } from "react-router-dom";
|
|
3
4
|
const HvAppShellContext = createContext(void 0);
|
|
4
5
|
const useHvAppShellConfig = () => {
|
|
5
6
|
return useContext(HvAppShellContext);
|
|
6
7
|
};
|
|
8
|
+
const HvAppShellModelContext = createContext(void 0);
|
|
9
|
+
const useHvAppShellModel = () => {
|
|
10
|
+
const context = useContext(HvAppShellModelContext);
|
|
11
|
+
if (!context) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
"useHvAppShellModel must be used within HvAppShellModelContext.Provider"
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return context;
|
|
17
|
+
};
|
|
7
18
|
const HvAppShellViewContext = createContext(void 0);
|
|
8
19
|
const HvAppShellRuntimeContext = createContext(void 0);
|
|
9
20
|
const HvAppShellCombinedProvidersContext = createContext(void 0);
|
|
@@ -159,7 +170,7 @@ const findFirstLeafItem = (data) => {
|
|
|
159
170
|
const MAX_TOP_MENU_DEPTH = 2;
|
|
160
171
|
const useHvMenuItems = () => {
|
|
161
172
|
const { pathname, search, state: locationState } = useLocation();
|
|
162
|
-
const
|
|
173
|
+
const { navigationMode, menu } = useHvAppShellModel();
|
|
163
174
|
const { i18n } = useContext(HvAppShellRuntimeContext) ?? {};
|
|
164
175
|
const tConfig = useMemo(
|
|
165
176
|
() => i18n?.getFixedT(i18n.language, CONFIG_TRANSLATIONS_NAMESPACE) ?? // should not happen, but fallback if the i18n instance is not available
|
|
@@ -167,9 +178,9 @@ const useHvMenuItems = () => {
|
|
|
167
178
|
[i18n]
|
|
168
179
|
);
|
|
169
180
|
const items = useMemo(() => {
|
|
170
|
-
const menuItemsDepth =
|
|
171
|
-
return createMenuItems(tConfig,
|
|
172
|
-
}, [
|
|
181
|
+
const menuItemsDepth = navigationMode === "ONLY_TOP" ? MAX_TOP_MENU_DEPTH : void 0;
|
|
182
|
+
return createMenuItems(tConfig, menu, menuItemsDepth);
|
|
183
|
+
}, [navigationMode, menu, tConfig]);
|
|
173
184
|
const [selectedMenuItemId, setSelectedMenuItemId] = useState(searchHrefInMenuItems(items, addPrefixToHref(pathname), search));
|
|
174
185
|
const [rootMenuItemId, setRootMenuItemId] = useState(
|
|
175
186
|
getRootIdFromItemId(selectedMenuItemId)
|
|
@@ -208,13 +219,61 @@ const useHvMenuItems = () => {
|
|
|
208
219
|
rootMenuItemId
|
|
209
220
|
};
|
|
210
221
|
};
|
|
222
|
+
const generateKey = () => {
|
|
223
|
+
return `hooks-${Date.now()}-${Math.round(1e3 * Math.random())}`;
|
|
224
|
+
};
|
|
225
|
+
const DynamicHooksEvaluatorInner = ({
|
|
226
|
+
hooks,
|
|
227
|
+
onEvaluate
|
|
228
|
+
}) => {
|
|
229
|
+
const results = [];
|
|
230
|
+
for (const { hook, params = [] } of hooks) {
|
|
231
|
+
const result = hook(...params);
|
|
232
|
+
results.push(result);
|
|
233
|
+
}
|
|
234
|
+
useEffect(() => onEvaluate(results), []);
|
|
235
|
+
return null;
|
|
236
|
+
};
|
|
237
|
+
const DynamicHooksEvaluator = ({
|
|
238
|
+
hooks,
|
|
239
|
+
onEvaluate
|
|
240
|
+
}) => {
|
|
241
|
+
const skipRenderRef = useRef(false);
|
|
242
|
+
const keyRef = useRef(generateKey());
|
|
243
|
+
const hooksRef = useRef(hooks);
|
|
244
|
+
if (hooksRef.current !== hooks) {
|
|
245
|
+
skipRenderRef.current = false;
|
|
246
|
+
hooksRef.current = hooks;
|
|
247
|
+
}
|
|
248
|
+
if (skipRenderRef.current) {
|
|
249
|
+
skipRenderRef.current = false;
|
|
250
|
+
} else {
|
|
251
|
+
keyRef.current = generateKey();
|
|
252
|
+
}
|
|
253
|
+
const onEvaluateWrapper = useCallback(
|
|
254
|
+
(results) => {
|
|
255
|
+
skipRenderRef.current = true;
|
|
256
|
+
onEvaluate(results);
|
|
257
|
+
},
|
|
258
|
+
[onEvaluate]
|
|
259
|
+
);
|
|
260
|
+
return createElement(DynamicHooksEvaluatorInner, {
|
|
261
|
+
key: keyRef.current,
|
|
262
|
+
hooks,
|
|
263
|
+
onEvaluate: onEvaluateWrapper
|
|
264
|
+
});
|
|
265
|
+
};
|
|
211
266
|
export {
|
|
212
267
|
CONFIG_TRANSLATIONS_NAMESPACE,
|
|
268
|
+
DynamicHooksEvaluator,
|
|
213
269
|
HvAppShellCombinedProvidersContext,
|
|
214
270
|
HvAppShellContext,
|
|
271
|
+
HvAppShellModelContext,
|
|
215
272
|
HvAppShellRuntimeContext,
|
|
216
273
|
HvAppShellViewContext,
|
|
274
|
+
useAsync,
|
|
217
275
|
useHvAppShellCombinedProviders,
|
|
218
276
|
useHvAppShellConfig,
|
|
277
|
+
useHvAppShellModel,
|
|
219
278
|
useHvMenuItems
|
|
220
279
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useRef, useCallback, createElement, useEffect } from "react";
|
|
2
|
+
const generateKey = () => {
|
|
3
|
+
return `hooks-${Date.now()}-${Math.round(1e3 * Math.random())}`;
|
|
4
|
+
};
|
|
5
|
+
const DynamicHooksEvaluatorInner = ({
|
|
6
|
+
hooks,
|
|
7
|
+
onEvaluate
|
|
8
|
+
}) => {
|
|
9
|
+
const results = [];
|
|
10
|
+
for (const { hook, params = [] } of hooks) {
|
|
11
|
+
const result = hook(...params);
|
|
12
|
+
results.push(result);
|
|
13
|
+
}
|
|
14
|
+
useEffect(() => onEvaluate(results), []);
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
const DynamicHooksEvaluator = ({
|
|
18
|
+
hooks,
|
|
19
|
+
onEvaluate
|
|
20
|
+
}) => {
|
|
21
|
+
const skipRenderRef = useRef(false);
|
|
22
|
+
const keyRef = useRef(generateKey());
|
|
23
|
+
const hooksRef = useRef(hooks);
|
|
24
|
+
if (hooksRef.current !== hooks) {
|
|
25
|
+
skipRenderRef.current = false;
|
|
26
|
+
hooksRef.current = hooks;
|
|
27
|
+
}
|
|
28
|
+
if (skipRenderRef.current) {
|
|
29
|
+
skipRenderRef.current = false;
|
|
30
|
+
} else {
|
|
31
|
+
keyRef.current = generateKey();
|
|
32
|
+
}
|
|
33
|
+
const onEvaluateWrapper = useCallback(
|
|
34
|
+
(results) => {
|
|
35
|
+
skipRenderRef.current = true;
|
|
36
|
+
onEvaluate(results);
|
|
37
|
+
},
|
|
38
|
+
[onEvaluate]
|
|
39
|
+
);
|
|
40
|
+
return createElement(DynamicHooksEvaluatorInner, {
|
|
41
|
+
key: keyRef.current,
|
|
42
|
+
hooks,
|
|
43
|
+
onEvaluate: onEvaluateWrapper
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
DynamicHooksEvaluator
|
|
48
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useContext, useMemo, useState, useEffect } from "react";
|
|
2
2
|
import { useLocation } from "react-router-dom";
|
|
3
|
-
import {
|
|
3
|
+
import { useHvAppShellModel } from "../AppShellModelContext.js";
|
|
4
4
|
import { HvAppShellRuntimeContext } from "../AppShellRuntimeContext.js";
|
|
5
5
|
import { CONFIG_TRANSLATIONS_NAMESPACE } from "../i18n/index.js";
|
|
6
6
|
import { createMenuItems, searchHrefInMenuItems, addPrefixToHref, getRootIdFromItemId, findItemById, findFirstLeafItem } from "../utils/navigationUtils.js";
|
|
7
7
|
const MAX_TOP_MENU_DEPTH = 2;
|
|
8
8
|
const useHvMenuItems = () => {
|
|
9
9
|
const { pathname, search, state: locationState } = useLocation();
|
|
10
|
-
const
|
|
10
|
+
const { navigationMode, menu } = useHvAppShellModel();
|
|
11
11
|
const { i18n } = useContext(HvAppShellRuntimeContext) ?? {};
|
|
12
12
|
const tConfig = useMemo(
|
|
13
13
|
() => i18n?.getFixedT(i18n.language, CONFIG_TRANSLATIONS_NAMESPACE) ?? // should not happen, but fallback if the i18n instance is not available
|
|
@@ -15,9 +15,9 @@ const useHvMenuItems = () => {
|
|
|
15
15
|
[i18n]
|
|
16
16
|
);
|
|
17
17
|
const items = useMemo(() => {
|
|
18
|
-
const menuItemsDepth =
|
|
19
|
-
return createMenuItems(tConfig,
|
|
20
|
-
}, [
|
|
18
|
+
const menuItemsDepth = navigationMode === "ONLY_TOP" ? MAX_TOP_MENU_DEPTH : void 0;
|
|
19
|
+
return createMenuItems(tConfig, menu, menuItemsDepth);
|
|
20
|
+
}, [navigationMode, menu, tConfig]);
|
|
21
21
|
const [selectedMenuItemId, setSelectedMenuItemId] = useState(searchHrefInMenuItems(items, addPrefixToHref(pathname), search));
|
|
22
22
|
const [rootMenuItemId, setRootMenuItemId] = useState(
|
|
23
23
|
getRootIdFromItemId(selectedMenuItemId)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { AsyncResult } from '@hitachivantara/app-shell-services';
|
|
2
|
+
import { ComponentType } from 'react';
|
|
3
|
+
import { Context } from 'react';
|
|
4
|
+
import { FunctionComponentElement } from 'react';
|
|
5
|
+
import { HvBaseTheme } from '@hitachivantara/uikit-react-core';
|
|
6
|
+
import { HvContainerProps } from '@hitachivantara/uikit-react-core';
|
|
7
|
+
import { HvThemeColorMode } from '@hitachivantara/uikit-react-core';
|
|
8
|
+
import { i18n } from 'i18next';
|
|
9
|
+
import { PropsWithChildren } from 'react';
|
|
10
|
+
import { ServiceId } from '@hitachivantara/app-shell-services';
|
|
11
|
+
import { ServiceProviderConfig } from '@hitachivantara/app-shell-services';
|
|
12
|
+
import { useAsync } from '@hitachivantara/app-shell-services';
|
|
13
|
+
|
|
14
|
+
export { AsyncResult }
|
|
15
|
+
|
|
16
|
+
export declare const CONFIG_TRANSLATIONS_NAMESPACE = "configTranslations";
|
|
17
|
+
|
|
18
|
+
export declare const DynamicHooksEvaluator: <THook extends (...args: any[]) => TResult, TResult = ReturnType<THook>>({ hooks, onEvaluate, }: DynamicHooksEvaluatorProps<THook, TResult>) => FunctionComponentElement<DynamicHooksEvaluatorProps<THook, TResult>>;
|
|
19
|
+
|
|
20
|
+
declare interface DynamicHooksEvaluatorProps<THook extends (...args: any[]) => TResult, TResult> {
|
|
21
|
+
hooks: HookWithParams<THook, TResult>[];
|
|
22
|
+
onEvaluate: (results: TResult[]) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare interface HookWithParams<THook extends (...args: any[]) => TResult, TResult = ReturnType<THook>> {
|
|
26
|
+
hook: THook;
|
|
27
|
+
params?: Parameters<THook>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare interface HvAppShellAppSwitcherConfig {
|
|
31
|
+
title?: string;
|
|
32
|
+
showLogo?: boolean;
|
|
33
|
+
apps: HvAppShellAppSwitcherItemConfig[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export declare interface HvAppShellAppSwitcherItemConfig {
|
|
37
|
+
label: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
url: string;
|
|
40
|
+
target: "NEW" | "SELF";
|
|
41
|
+
icon?: HvAppShellIcon;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare const HvAppShellCombinedProvidersContext: Context<HvAppShellCombinedProvidersContextValue | undefined>;
|
|
45
|
+
|
|
46
|
+
declare interface HvAppShellCombinedProvidersContextValue {
|
|
47
|
+
providers?: HvAppShellProvidersComponent[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export declare interface HvAppShellConditionalConfig {
|
|
51
|
+
conditions?: HvAppShellConditionConfig[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export declare interface HvAppShellConditionalModel {
|
|
55
|
+
key: string;
|
|
56
|
+
conditions?: HvAppShellConditionModel[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export declare interface HvAppShellConditionConfig {
|
|
60
|
+
bundle: string;
|
|
61
|
+
config?: Record<string, unknown>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export declare interface HvAppShellConditionModel extends HvAppShellConditionConfig {
|
|
65
|
+
globalIndex: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export declare interface HvAppShellConfig {
|
|
69
|
+
baseUrl?: string;
|
|
70
|
+
name?: string;
|
|
71
|
+
logo?: HvAppShellLogo | null;
|
|
72
|
+
apps?: Record<string, string>;
|
|
73
|
+
menu?: HvAppShellMenuConfig[];
|
|
74
|
+
translations?: Record<string, object>;
|
|
75
|
+
navigationMode?: "TOP_AND_LEFT" | "ONLY_TOP" | "ONLY_LEFT";
|
|
76
|
+
mainPanel?: HvAppShellMainPanelConfig;
|
|
77
|
+
theming?: HvAppShellThemingConfig;
|
|
78
|
+
header?: HvAppShellHeader;
|
|
79
|
+
systemProviders?: HvAppShellSystemProvidersConfig[];
|
|
80
|
+
providers?: HvAppShellProvidersConfig[];
|
|
81
|
+
services?: HvAppShellServicesConfig;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export declare const HvAppShellContext: Context<HvAppShellConfig | undefined>;
|
|
85
|
+
|
|
86
|
+
export declare type HvAppShellContextValue = HvAppShellConfig;
|
|
87
|
+
|
|
88
|
+
export declare interface HvAppShellHeader {
|
|
89
|
+
actions: HvAppShellHeaderAction[];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export declare interface HvAppShellHeaderAction extends HvAppShellConditionalConfig {
|
|
93
|
+
bundle: string;
|
|
94
|
+
config?: HvAppShellHelp | HvAppShellAppSwitcherConfig | Record<string, unknown>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export declare interface HvAppShellHeaderActionModel extends HvAppShellConditionalModel, Omit<HvAppShellHeaderAction, "conditions"> {
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export declare interface HvAppShellHeaderModel extends Omit<HvAppShellHeader, "actions"> {
|
|
101
|
+
actions: HvAppShellHeaderActionModel[];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export declare interface HvAppShellHelp {
|
|
105
|
+
url: string;
|
|
106
|
+
description?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export declare interface HvAppShellIcon {
|
|
110
|
+
iconType: "uikit";
|
|
111
|
+
name: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export declare interface HvAppShellLogo {
|
|
115
|
+
name?: "LUMADA" | "HITACHI" | "PENTAHO+" | "PENTAHO";
|
|
116
|
+
description?: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export declare interface HvAppShellMainPanelConfig extends ViewHvContainerProps {
|
|
120
|
+
views?: HvAppShellTopViewConfig[];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export declare interface HvAppShellMainPanelModel extends Omit<HvAppShellMainPanelConfig, "views"> {
|
|
124
|
+
views?: HvAppShellTopViewModel[];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export declare interface HvAppShellMenuConfig extends HvAppShellConditionalConfig {
|
|
128
|
+
label: string;
|
|
129
|
+
icon?: HvAppShellIcon;
|
|
130
|
+
target?: string;
|
|
131
|
+
submenus?: HvAppShellMenuConfig[];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export declare interface HvAppShellMenuModel extends HvAppShellConditionalModel, Omit<HvAppShellMenuConfig, "conditions" | "submenus"> {
|
|
135
|
+
submenus?: HvAppShellMenuModel[];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export declare interface HvAppShellModel extends Omit<HvAppShellConfig, "menu" | "mainPanel" | "header" | "systemProviders" | "providers" | "services"> {
|
|
139
|
+
menu?: HvAppShellMenuModel[];
|
|
140
|
+
mainPanel?: HvAppShellMainPanelModel;
|
|
141
|
+
header?: HvAppShellHeaderModel;
|
|
142
|
+
systemProviders?: HvAppShellSystemProvidersModel[];
|
|
143
|
+
providers?: HvAppShellProvidersModel[];
|
|
144
|
+
services?: HvAppShellServicesModel;
|
|
145
|
+
/** All conditions present in the model, indexed by globalIndex */
|
|
146
|
+
allConditions: HvAppShellConditionModel[];
|
|
147
|
+
/** All preloaded bundles (conditions and providers) */
|
|
148
|
+
preloadedBundles: PreloadedBundles;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export declare const HvAppShellModelContext: Context<HvAppShellModelContextValue | undefined>;
|
|
152
|
+
|
|
153
|
+
export declare interface HvAppShellModelContextValue extends HvAppShellModel {
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export declare interface HvAppShellProvidersBaseConfig {
|
|
157
|
+
bundle: string;
|
|
158
|
+
config?: Record<string, unknown>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export declare type HvAppShellProvidersComponent = Omit<HvAppShellProvidersModel, "bundle"> & {
|
|
162
|
+
component: ComponentType<PropsWithChildren>;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export declare interface HvAppShellProvidersConfig extends HvAppShellProvidersBaseConfig, HvAppShellConditionalConfig {
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export declare interface HvAppShellProvidersModel extends HvAppShellConditionalModel, Omit<HvAppShellProvidersConfig, "conditions"> {
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export declare const HvAppShellRuntimeContext: Context<HvAppShellRuntimeContextValue | undefined>;
|
|
172
|
+
|
|
173
|
+
export declare interface HvAppShellRuntimeContextValue {
|
|
174
|
+
i18n: i18n;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export declare type HvAppShellServiceProviderConfig = ServiceProviderConfig & HvAppShellConditionalConfig;
|
|
178
|
+
|
|
179
|
+
export declare type HvAppShellServiceProviderModel = HvAppShellConditionalModel & ServiceProviderConfig;
|
|
180
|
+
|
|
181
|
+
export declare interface HvAppShellServicesConfig extends Record<ServiceId, HvAppShellServiceProviderConfig[]> {
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export declare type HvAppShellServicesModel = Record<ServiceId, HvAppShellServiceProviderModel[]>;
|
|
185
|
+
|
|
186
|
+
export declare interface HvAppShellSystemProvidersConfig extends HvAppShellProvidersBaseConfig {
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export declare type HvAppShellSystemProvidersModel = HvAppShellSystemProvidersConfig & {
|
|
190
|
+
key: string;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export declare type HvAppShellThemingConfig = {
|
|
194
|
+
theme?: HvBaseTheme | (string & {});
|
|
195
|
+
colorMode?: HvThemeColorMode;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export declare interface HvAppShellTopViewConfig extends HvAppShellViewsConfig, ViewHvContainerProps {
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export declare interface HvAppShellTopViewModel extends HvAppShellViewsModel, Omit<ViewHvContainerProps, "key"> {
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export declare const HvAppShellViewContext: Context<HvAppShellViewContextValue | undefined>;
|
|
205
|
+
|
|
206
|
+
export declare interface HvAppShellViewContextValue {
|
|
207
|
+
id: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export declare interface HvAppShellViewsConfig extends HvAppShellConditionalConfig {
|
|
211
|
+
bundle: string;
|
|
212
|
+
route: RouteString;
|
|
213
|
+
config?: Record<string, unknown>;
|
|
214
|
+
views?: HvAppShellViewsConfig[];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export declare interface HvAppShellViewsModel extends HvAppShellConditionalModel, Omit<HvAppShellViewsConfig, "conditions" | "views"> {
|
|
218
|
+
views: HvAppShellViewsModel[];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export declare interface MenuItem {
|
|
222
|
+
id: string;
|
|
223
|
+
label: string;
|
|
224
|
+
href?: string;
|
|
225
|
+
data?: MenuItem[];
|
|
226
|
+
icon?: HvAppShellIcon;
|
|
227
|
+
parent?: MenuItem;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export declare interface MenuItemsContext {
|
|
231
|
+
items: MenuItem[];
|
|
232
|
+
selectedMenuItemId: string | undefined;
|
|
233
|
+
rootMenuItemId: string | undefined;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export declare type PreloadedBundles = Map<string, unknown>;
|
|
237
|
+
|
|
238
|
+
declare type RouteString = `/${string}`;
|
|
239
|
+
|
|
240
|
+
export { useAsync }
|
|
241
|
+
|
|
242
|
+
export declare type UseCondition = (config?: Record<string, unknown>) => UseConditionResult;
|
|
243
|
+
|
|
244
|
+
export declare type UseConditionResult = AsyncResult<boolean, Error, "result">;
|
|
245
|
+
|
|
246
|
+
export declare const useHvAppShellCombinedProviders: () => HvAppShellCombinedProvidersContextValue;
|
|
247
|
+
|
|
248
|
+
export declare const useHvAppShellConfig: () => HvAppShellContextValue;
|
|
249
|
+
|
|
250
|
+
export declare const useHvAppShellModel: () => HvAppShellModel;
|
|
251
|
+
|
|
252
|
+
export declare const useHvMenuItems: () => MenuItemsContext;
|
|
253
|
+
|
|
254
|
+
export declare interface ViewHvContainerProps extends Omit<HvContainerProps, "children"> {
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export { }
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { HvAppShellContext, useHvAppShellConfig } from "./AppShellContext.js";
|
|
2
|
+
import { HvAppShellModelContext, useHvAppShellModel } from "./AppShellModelContext.js";
|
|
2
3
|
import { HvAppShellViewContext } from "./AppShellViewContext.js";
|
|
3
4
|
import { HvAppShellRuntimeContext } from "./AppShellRuntimeContext.js";
|
|
4
5
|
import { HvAppShellCombinedProvidersContext, useHvAppShellCombinedProviders } from "./AppShellCombinedProvidersContext.js";
|
|
6
|
+
import { useAsync } from "@hitachivantara/app-shell-services";
|
|
5
7
|
import { CONFIG_TRANSLATIONS_NAMESPACE } from "./i18n/index.js";
|
|
6
8
|
import { useHvMenuItems } from "./hooks/useMenuItems.js";
|
|
9
|
+
import { DynamicHooksEvaluator } from "./components/DynamicHooksEvaluator/DynamicHooksEvaluator.js";
|
|
7
10
|
export {
|
|
8
11
|
CONFIG_TRANSLATIONS_NAMESPACE,
|
|
12
|
+
DynamicHooksEvaluator,
|
|
9
13
|
HvAppShellCombinedProvidersContext,
|
|
10
14
|
HvAppShellContext,
|
|
15
|
+
HvAppShellModelContext,
|
|
11
16
|
HvAppShellRuntimeContext,
|
|
12
17
|
HvAppShellViewContext,
|
|
18
|
+
useAsync,
|
|
13
19
|
useHvAppShellCombinedProviders,
|
|
14
20
|
useHvAppShellConfig,
|
|
21
|
+
useHvAppShellModel,
|
|
15
22
|
useHvMenuItems
|
|
16
23
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,149 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { ServicesConfig as HvAppShellServicesConfig } from '@hitachivantara/app-shell-services';
|
|
4
|
-
import { HvContainerProps } from '@hitachivantara/uikit-react-core';
|
|
5
|
-
import { i18n } from 'i18next';
|
|
6
|
-
import { ReactNode } from 'react';
|
|
7
|
-
|
|
8
|
-
export declare const CONFIG_TRANSLATIONS_NAMESPACE = "configTranslations";
|
|
9
|
-
|
|
10
|
-
export declare type HvAppShellAppSwitcherConfig = {
|
|
11
|
-
title?: string;
|
|
12
|
-
showLogo?: boolean;
|
|
13
|
-
apps: HvAppShellAppSwitcherItemConfig[];
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export declare type HvAppShellAppSwitcherItemConfig = {
|
|
17
|
-
label: string;
|
|
18
|
-
description?: string;
|
|
19
|
-
url: string;
|
|
20
|
-
target: "NEW" | "SELF";
|
|
21
|
-
icon?: HvAppShellIcon;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export declare const HvAppShellCombinedProvidersContext: Context<HvAppShellCombinedProvidersContextValue | undefined>;
|
|
25
|
-
|
|
26
|
-
export declare interface HvAppShellCombinedProvidersContextValue {
|
|
27
|
-
providers?: Array<{
|
|
28
|
-
component: ComponentType<{
|
|
29
|
-
children: ReactNode;
|
|
30
|
-
}>;
|
|
31
|
-
config?: Record<string, unknown>;
|
|
32
|
-
}>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export declare type HvAppShellConfig = {
|
|
36
|
-
baseUrl?: string;
|
|
37
|
-
name?: string;
|
|
38
|
-
logo?: HvAppShellLogo | null;
|
|
39
|
-
apps?: Record<string, string>;
|
|
40
|
-
menu?: HvAppShellMenuConfig[];
|
|
41
|
-
translations?: Record<string, object>;
|
|
42
|
-
navigationMode?: "TOP_AND_LEFT" | "ONLY_TOP" | "ONLY_LEFT";
|
|
43
|
-
mainPanel?: HvAppShellMainPanelConfig;
|
|
44
|
-
theming?: HvAppShellThemingConfig;
|
|
45
|
-
header?: HvAppShellHeader;
|
|
46
|
-
providers?: HvAppShellProvidersConfig[];
|
|
47
|
-
services?: HvAppShellServicesConfig;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export declare const HvAppShellContext: Context<HvAppShellConfig | undefined>;
|
|
51
|
-
|
|
52
|
-
export declare type HvAppShellContextValue = HvAppShellConfig;
|
|
53
|
-
|
|
54
|
-
export declare type HvAppShellHeader = {
|
|
55
|
-
actions: HvAppShellHeaderAction[];
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export declare type HvAppShellHeaderAction = {
|
|
59
|
-
bundle: string;
|
|
60
|
-
config?: HvAppShellHelp | HvAppShellAppSwitcherConfig | Record<string, unknown>;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export declare type HvAppShellHelp = {
|
|
64
|
-
url: string;
|
|
65
|
-
description?: string;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export declare type HvAppShellIcon = {
|
|
69
|
-
iconType: "uikit";
|
|
70
|
-
name: string;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export declare type HvAppShellLogo = {
|
|
74
|
-
name?: "LUMADA" | "HITACHI" | "PENTAHO+" | "PENTAHO";
|
|
75
|
-
description?: string;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export declare interface HvAppShellMainPanelConfig extends ViewHvContainerProps {
|
|
79
|
-
views?: HvAppShellTopViewConfig[];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export declare type HvAppShellMenuConfig = {
|
|
83
|
-
label: string;
|
|
84
|
-
icon?: HvAppShellIcon;
|
|
85
|
-
target?: string;
|
|
86
|
-
submenus?: HvAppShellMenuConfig[];
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export declare type HvAppShellProvidersConfig = {
|
|
90
|
-
bundle: string;
|
|
91
|
-
config?: Record<string, unknown>;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export declare const HvAppShellRuntimeContext: Context<HvAppShellRuntimeContextValue | undefined>;
|
|
95
|
-
|
|
96
|
-
export declare interface HvAppShellRuntimeContextValue {
|
|
97
|
-
i18n: i18n;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export { HvAppShellServicesConfig }
|
|
101
|
-
|
|
102
|
-
export declare type HvAppShellThemingConfig = {
|
|
103
|
-
themes?: string[];
|
|
104
|
-
theme?: string;
|
|
105
|
-
colorMode?: string;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export declare interface HvAppShellTopViewConfig extends HvAppShellViewsConfig, ViewHvContainerProps {
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export declare const HvAppShellViewContext: Context<HvAppShellViewContextValue | undefined>;
|
|
112
|
-
|
|
113
|
-
export declare interface HvAppShellViewContextValue {
|
|
114
|
-
id: string;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export declare type HvAppShellViewsConfig = {
|
|
118
|
-
bundle: string;
|
|
119
|
-
route: RouteString;
|
|
120
|
-
config?: Record<string, unknown>;
|
|
121
|
-
views?: HvAppShellViewsConfig[];
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export declare interface MenuItem {
|
|
125
|
-
id: string;
|
|
126
|
-
label: string;
|
|
127
|
-
href?: string;
|
|
128
|
-
data?: MenuItem[];
|
|
129
|
-
icon?: HvAppShellIcon;
|
|
130
|
-
parent?: MenuItem;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export declare interface MenuItemsContext {
|
|
134
|
-
items: MenuItem[];
|
|
135
|
-
selectedMenuItemId: string | undefined;
|
|
136
|
-
rootMenuItemId: string | undefined;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
declare type RouteString = `/${string}`;
|
|
140
|
-
|
|
141
|
-
export declare const useHvAppShellCombinedProviders: () => HvAppShellCombinedProvidersContextValue;
|
|
142
|
-
|
|
143
|
-
export declare const useHvAppShellConfig: () => HvAppShellContextValue;
|
|
144
|
-
|
|
145
|
-
export declare const useHvMenuItems: () => MenuItemsContext;
|
|
146
|
-
|
|
147
|
-
declare type ViewHvContainerProps = Omit<HvContainerProps, "children">;
|
|
148
|
-
|
|
149
|
-
export { }
|
|
1
|
+
export * from '../packages/app-shell-shared/src/index'
|
|
2
|
+
export {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/app-shell-shared",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-next.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Hitachi Vantara UI Kit Team",
|
|
@@ -15,23 +15,23 @@
|
|
|
15
15
|
},
|
|
16
16
|
"bugs": "https://github.com/pentaho/hv-uikit-react/issues",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@hitachivantara/app-shell-services": "^
|
|
18
|
+
"@hitachivantara/app-shell-services": "^2.0.0-next.2"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"react": "^18.2.0",
|
|
22
22
|
"react-router-dom": "^6.9.0"
|
|
23
23
|
},
|
|
24
24
|
"optionalDependencies": {
|
|
25
|
-
"@hitachivantara/uikit-react-core": "^
|
|
25
|
+
"@hitachivantara/uikit-react-core": "^6.0.0-next.3"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"exports": {
|
|
31
31
|
".": {
|
|
32
|
-
"types": "./dist/
|
|
33
|
-
"import": "./dist/
|
|
34
|
-
"default": "./dist/
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
35
|
},
|
|
36
36
|
"./package.json": "./package.json",
|
|
37
37
|
"./bundles/*": "./dist/bundles/*"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"access": "public",
|
|
41
41
|
"directory": "package"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "f404f47dd2c0a9d4033b9acccc87282aa9e42119",
|
|
44
44
|
"types": "./dist/types/index.d.ts",
|
|
45
|
-
"module": "dist/
|
|
45
|
+
"module": "dist/index.js"
|
|
46
46
|
}
|
/package/dist/{esm/AppShellCombinedProvidersContext.js → AppShellCombinedProvidersContext.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|