@hitachivantara/app-shell-shared 2.0.0-next.1 → 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/hooks/useMenuItems.js +5 -5
- package/dist/index.d.ts +139 -32
- package/dist/index.js +7 -0
- package/package.json +7 -7
|
@@ -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
CHANGED
|
@@ -1,40 +1,71 @@
|
|
|
1
|
+
import { AsyncResult } from '@hitachivantara/app-shell-services';
|
|
1
2
|
import { ComponentType } from 'react';
|
|
2
3
|
import { Context } from 'react';
|
|
3
|
-
import {
|
|
4
|
+
import { FunctionComponentElement } from 'react';
|
|
4
5
|
import { HvBaseTheme } from '@hitachivantara/uikit-react-core';
|
|
5
6
|
import { HvContainerProps } from '@hitachivantara/uikit-react-core';
|
|
6
7
|
import { HvThemeColorMode } from '@hitachivantara/uikit-react-core';
|
|
7
8
|
import { i18n } from 'i18next';
|
|
8
|
-
import {
|
|
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 }
|
|
9
15
|
|
|
10
16
|
export declare const CONFIG_TRANSLATIONS_NAMESPACE = "configTranslations";
|
|
11
17
|
|
|
12
|
-
export declare
|
|
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 {
|
|
13
31
|
title?: string;
|
|
14
32
|
showLogo?: boolean;
|
|
15
33
|
apps: HvAppShellAppSwitcherItemConfig[];
|
|
16
|
-
}
|
|
34
|
+
}
|
|
17
35
|
|
|
18
|
-
export declare
|
|
36
|
+
export declare interface HvAppShellAppSwitcherItemConfig {
|
|
19
37
|
label: string;
|
|
20
38
|
description?: string;
|
|
21
39
|
url: string;
|
|
22
40
|
target: "NEW" | "SELF";
|
|
23
41
|
icon?: HvAppShellIcon;
|
|
24
|
-
}
|
|
42
|
+
}
|
|
25
43
|
|
|
26
44
|
export declare const HvAppShellCombinedProvidersContext: Context<HvAppShellCombinedProvidersContextValue | undefined>;
|
|
27
45
|
|
|
28
|
-
|
|
29
|
-
providers?:
|
|
30
|
-
component: ComponentType<{
|
|
31
|
-
children: ReactNode;
|
|
32
|
-
}>;
|
|
33
|
-
config?: Record<string, unknown>;
|
|
34
|
-
}>;
|
|
46
|
+
declare interface HvAppShellCombinedProvidersContextValue {
|
|
47
|
+
providers?: HvAppShellProvidersComponent[];
|
|
35
48
|
}
|
|
36
49
|
|
|
37
|
-
export declare
|
|
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 {
|
|
38
69
|
baseUrl?: string;
|
|
39
70
|
name?: string;
|
|
40
71
|
logo?: HvAppShellLogo | null;
|
|
@@ -45,61 +76,119 @@ export declare type HvAppShellConfig = {
|
|
|
45
76
|
mainPanel?: HvAppShellMainPanelConfig;
|
|
46
77
|
theming?: HvAppShellThemingConfig;
|
|
47
78
|
header?: HvAppShellHeader;
|
|
79
|
+
systemProviders?: HvAppShellSystemProvidersConfig[];
|
|
48
80
|
providers?: HvAppShellProvidersConfig[];
|
|
49
81
|
services?: HvAppShellServicesConfig;
|
|
50
|
-
}
|
|
82
|
+
}
|
|
51
83
|
|
|
52
84
|
export declare const HvAppShellContext: Context<HvAppShellConfig | undefined>;
|
|
53
85
|
|
|
54
86
|
export declare type HvAppShellContextValue = HvAppShellConfig;
|
|
55
87
|
|
|
56
|
-
export declare
|
|
88
|
+
export declare interface HvAppShellHeader {
|
|
57
89
|
actions: HvAppShellHeaderAction[];
|
|
58
|
-
}
|
|
90
|
+
}
|
|
59
91
|
|
|
60
|
-
export declare
|
|
92
|
+
export declare interface HvAppShellHeaderAction extends HvAppShellConditionalConfig {
|
|
61
93
|
bundle: string;
|
|
62
94
|
config?: HvAppShellHelp | HvAppShellAppSwitcherConfig | Record<string, unknown>;
|
|
63
|
-
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export declare interface HvAppShellHeaderActionModel extends HvAppShellConditionalModel, Omit<HvAppShellHeaderAction, "conditions"> {
|
|
98
|
+
}
|
|
64
99
|
|
|
65
|
-
export declare
|
|
100
|
+
export declare interface HvAppShellHeaderModel extends Omit<HvAppShellHeader, "actions"> {
|
|
101
|
+
actions: HvAppShellHeaderActionModel[];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export declare interface HvAppShellHelp {
|
|
66
105
|
url: string;
|
|
67
106
|
description?: string;
|
|
68
|
-
}
|
|
107
|
+
}
|
|
69
108
|
|
|
70
|
-
export declare
|
|
109
|
+
export declare interface HvAppShellIcon {
|
|
71
110
|
iconType: "uikit";
|
|
72
111
|
name: string;
|
|
73
|
-
}
|
|
112
|
+
}
|
|
74
113
|
|
|
75
|
-
export declare
|
|
114
|
+
export declare interface HvAppShellLogo {
|
|
76
115
|
name?: "LUMADA" | "HITACHI" | "PENTAHO+" | "PENTAHO";
|
|
77
116
|
description?: string;
|
|
78
|
-
}
|
|
117
|
+
}
|
|
79
118
|
|
|
80
119
|
export declare interface HvAppShellMainPanelConfig extends ViewHvContainerProps {
|
|
81
120
|
views?: HvAppShellTopViewConfig[];
|
|
82
121
|
}
|
|
83
122
|
|
|
84
|
-
export declare
|
|
123
|
+
export declare interface HvAppShellMainPanelModel extends Omit<HvAppShellMainPanelConfig, "views"> {
|
|
124
|
+
views?: HvAppShellTopViewModel[];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export declare interface HvAppShellMenuConfig extends HvAppShellConditionalConfig {
|
|
85
128
|
label: string;
|
|
86
129
|
icon?: HvAppShellIcon;
|
|
87
130
|
target?: string;
|
|
88
131
|
submenus?: HvAppShellMenuConfig[];
|
|
89
|
-
}
|
|
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
|
+
}
|
|
90
155
|
|
|
91
|
-
export declare
|
|
156
|
+
export declare interface HvAppShellProvidersBaseConfig {
|
|
92
157
|
bundle: string;
|
|
93
158
|
config?: Record<string, unknown>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export declare type HvAppShellProvidersComponent = Omit<HvAppShellProvidersModel, "bundle"> & {
|
|
162
|
+
component: ComponentType<PropsWithChildren>;
|
|
94
163
|
};
|
|
95
164
|
|
|
165
|
+
export declare interface HvAppShellProvidersConfig extends HvAppShellProvidersBaseConfig, HvAppShellConditionalConfig {
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export declare interface HvAppShellProvidersModel extends HvAppShellConditionalModel, Omit<HvAppShellProvidersConfig, "conditions"> {
|
|
169
|
+
}
|
|
170
|
+
|
|
96
171
|
export declare const HvAppShellRuntimeContext: Context<HvAppShellRuntimeContextValue | undefined>;
|
|
97
172
|
|
|
98
173
|
export declare interface HvAppShellRuntimeContextValue {
|
|
99
174
|
i18n: i18n;
|
|
100
175
|
}
|
|
101
176
|
|
|
102
|
-
export
|
|
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
|
+
};
|
|
103
192
|
|
|
104
193
|
export declare type HvAppShellThemingConfig = {
|
|
105
194
|
theme?: HvBaseTheme | (string & {});
|
|
@@ -109,18 +198,25 @@ export declare type HvAppShellThemingConfig = {
|
|
|
109
198
|
export declare interface HvAppShellTopViewConfig extends HvAppShellViewsConfig, ViewHvContainerProps {
|
|
110
199
|
}
|
|
111
200
|
|
|
201
|
+
export declare interface HvAppShellTopViewModel extends HvAppShellViewsModel, Omit<ViewHvContainerProps, "key"> {
|
|
202
|
+
}
|
|
203
|
+
|
|
112
204
|
export declare const HvAppShellViewContext: Context<HvAppShellViewContextValue | undefined>;
|
|
113
205
|
|
|
114
206
|
export declare interface HvAppShellViewContextValue {
|
|
115
207
|
id: string;
|
|
116
208
|
}
|
|
117
209
|
|
|
118
|
-
export declare
|
|
210
|
+
export declare interface HvAppShellViewsConfig extends HvAppShellConditionalConfig {
|
|
119
211
|
bundle: string;
|
|
120
212
|
route: RouteString;
|
|
121
213
|
config?: Record<string, unknown>;
|
|
122
214
|
views?: HvAppShellViewsConfig[];
|
|
123
|
-
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export declare interface HvAppShellViewsModel extends HvAppShellConditionalModel, Omit<HvAppShellViewsConfig, "conditions" | "views"> {
|
|
218
|
+
views: HvAppShellViewsModel[];
|
|
219
|
+
}
|
|
124
220
|
|
|
125
221
|
export declare interface MenuItem {
|
|
126
222
|
id: string;
|
|
@@ -137,14 +233,25 @@ export declare interface MenuItemsContext {
|
|
|
137
233
|
rootMenuItemId: string | undefined;
|
|
138
234
|
}
|
|
139
235
|
|
|
236
|
+
export declare type PreloadedBundles = Map<string, unknown>;
|
|
237
|
+
|
|
140
238
|
declare type RouteString = `/${string}`;
|
|
141
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
|
+
|
|
142
246
|
export declare const useHvAppShellCombinedProviders: () => HvAppShellCombinedProvidersContextValue;
|
|
143
247
|
|
|
144
248
|
export declare const useHvAppShellConfig: () => HvAppShellContextValue;
|
|
145
249
|
|
|
250
|
+
export declare const useHvAppShellModel: () => HvAppShellModel;
|
|
251
|
+
|
|
146
252
|
export declare const useHvMenuItems: () => MenuItemsContext;
|
|
147
253
|
|
|
148
|
-
declare
|
|
254
|
+
export declare interface ViewHvContainerProps extends Omit<HvContainerProps, "children"> {
|
|
255
|
+
}
|
|
149
256
|
|
|
150
257
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -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/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/app-shell-shared",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Hitachi Vantara UI Kit Team",
|
|
7
7
|
"description": "AppShell Shared",
|
|
8
|
-
"homepage": "https://github.com/
|
|
8
|
+
"homepage": "https://github.com/pentaho/hv-uikit-react",
|
|
9
9
|
"sideEffects": false,
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/
|
|
13
|
+
"url": "git+https://github.com/pentaho/hv-uikit-react.git",
|
|
14
14
|
"directory": "packages/app-shell-shared"
|
|
15
15
|
},
|
|
16
|
-
"bugs": "https://github.com/
|
|
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": "^6.0.0-next.
|
|
25
|
+
"@hitachivantara/uikit-react-core": "^6.0.0-next.3"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist"
|
|
@@ -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
45
|
"module": "dist/index.js"
|
|
46
46
|
}
|