@hitachivantara/app-shell-ui 2.1.1 → 2.1.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.
Files changed (22) hide show
  1. package/dist/components/AppShell/AppShell.js +5 -6
  2. package/dist/components/AppShell/AppShellContainer.js +50 -0
  3. package/dist/components/{AppShellRoutes/AppShellRoutes.js → AppShell/AppShellRouter.js} +4 -4
  4. package/dist/components/AppShellProvider/AppShellProvider.js +15 -43
  5. package/dist/components/layout/Header/Header.js +2 -2
  6. package/dist/components/layout/{Header/HeaderActions/InternalActions → HeaderActions}/AppSwitcherToggle/AppSwitcherToggle.js +4 -4
  7. package/dist/components/layout/{Header/HeaderActions/InternalActions → HeaderActions}/ColorModeSwitcher.js +1 -1
  8. package/dist/components/layout/{Header/HeaderActions → HeaderActions}/HeaderActions.js +1 -1
  9. package/dist/components/layout/{Header/HeaderActions/InternalActions → HeaderActions}/HelpButton/HelpButton.js +1 -1
  10. package/dist/components/layout/{Header/HeaderActions/InternalActions → HeaderActions}/InternalAction/InternalAction.js +2 -2
  11. package/dist/components/layout/Main/Main.js +1 -1
  12. package/dist/components/layout/VerticalNavigation/NavigationHeader.js +1 -1
  13. package/dist/index.d.ts +15 -5
  14. package/dist/pages/Root/Root.js +2 -2
  15. package/dist/providers/NavigationProvider.js +1 -1
  16. package/package.json +7 -7
  17. package/dist/components/hoc/withGlobalProvider.js +0 -42
  18. package/dist/components/layout/Header/HeaderActions/InternalActions/AppSwitcherToggle/index.js +0 -4
  19. package/dist/components/layout/Header/HeaderActions/InternalActions/HelpButton/index.js +0 -4
  20. package/dist/components/layout/Header/HeaderActions/index.js +0 -4
  21. /package/dist/components/layout/{Header/HeaderActions/InternalActions → HeaderActions}/AppSwitcherToggle/styles.js +0 -0
  22. /package/dist/components/layout/{Header/HeaderActions → HeaderActions}/DynamicAction.js +0 -0
@@ -1,10 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import withGlobalProvider from "../hoc/withGlobalProvider.js";
3
- import AppShellRoutes from "../AppShellRoutes/AppShellRoutes.js";
4
- const AppShell = () => {
5
- return /* @__PURE__ */ jsx(AppShellRoutes, {});
6
- };
7
- const HvAppShell = withGlobalProvider(AppShell);
2
+ import { HvAppShellContainer } from "./AppShellContainer.js";
3
+ import { HvAppShellRouter } from "./AppShellRouter.js";
4
+ function HvAppShell({ config, configUrl }) {
5
+ return /* @__PURE__ */ jsx(HvAppShellContainer, { config, configUrl, children: /* @__PURE__ */ jsx(HvAppShellRouter, {}) });
6
+ }
8
7
  export {
9
8
  HvAppShell as default
10
9
  };
@@ -0,0 +1,50 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState, useEffect, useMemo } from "react";
3
+ import { ErrorBoundary } from "react-error-boundary";
4
+ import { HelmetProvider } from "react-helmet-async";
5
+ import { I18nextProvider } from "react-i18next";
6
+ import { HvProvider } from "@hitachivantara/uikit-react-core";
7
+ import createI18Next from "../../i18n/index.js";
8
+ import { LayoutProvider } from "../../providers/LayoutProvider.js";
9
+ import { HvAppShellProvider } from "../AppShellProvider/AppShellProvider.js";
10
+ import GlobalStyles from "../GlobalStyles/GlobalStyles.js";
11
+ import SnackbarProvider from "../SnackbarProvider/SnackbarProvider.js";
12
+ import GenericError from "../../pages/GenericError/GenericError.js";
13
+ const { i18n } = createI18Next();
14
+ function HvAppShellContainer({
15
+ config: configProp,
16
+ configUrl,
17
+ children
18
+ }) {
19
+ const [loadedConfig, setLoadedConfig] = useState();
20
+ const [hasError, setHasError] = useState(false);
21
+ useEffect(() => {
22
+ if (configProp || !configUrl) return;
23
+ fetch(new URL(configUrl)).then((result) => result.json()).then((data) => setLoadedConfig(data)).catch((e) => {
24
+ console.error(`Failed to obtain the context from: ${configUrl}`, e);
25
+ setLoadedConfig(void 0);
26
+ setHasError(true);
27
+ });
28
+ }, [configProp, configUrl]);
29
+ const config = useMemo(
30
+ () => configProp ?? loadedConfig,
31
+ [configProp, loadedConfig]
32
+ );
33
+ if (hasError) {
34
+ throw Error("Failed to obtain the configuration");
35
+ }
36
+ return /* @__PURE__ */ jsx(HelmetProvider, { children: /* @__PURE__ */ jsxs(HvProvider, { children: [
37
+ /* @__PURE__ */ jsx(GlobalStyles, {}),
38
+ /* @__PURE__ */ jsx(I18nextProvider, { i18n, children: /* @__PURE__ */ jsx(
39
+ ErrorBoundary,
40
+ {
41
+ fallback: /* @__PURE__ */ jsx(GenericError, { fullPage: true, includeFooter: false }),
42
+ children: /* @__PURE__ */ jsx(HvAppShellProvider, { config, children: /* @__PURE__ */ jsx(LayoutProvider, { children: /* @__PURE__ */ jsx(SnackbarProvider, { children }) }) })
43
+ },
44
+ "general"
45
+ ) })
46
+ ] }) });
47
+ }
48
+ export {
49
+ HvAppShellContainer
50
+ };
@@ -5,9 +5,9 @@ import { matchRoutes, RouterProvider, createBrowserRouter, Outlet } from "react-
5
5
  import { useHvAppShellModel } from "@hitachivantara/app-shell-shared";
6
6
  import { HvContainer } from "@hitachivantara/uikit-react-core";
7
7
  import LoadingPage from "../../pages/LoadingPage/LoadingPage.js";
8
+ import Root from "../../pages/Root/Root.js";
8
9
  import { getAppIdFromBundle } from "../../utils/navigationUtil.js";
9
10
  import GenericError from "../../pages/GenericError/GenericError.js";
10
- import Root from "../../pages/Root/Root.js";
11
11
  import AppShellViewProvider from "../AppShellViewProvider/AppShellViewProvider.js";
12
12
  const NotFound = lazy(() => import("../../pages/NotFound/index.js"));
13
13
  function renderNestedRoutes(views) {
@@ -87,7 +87,7 @@ function renderErrorRoutes(mainPanel) {
87
87
  }
88
88
  ];
89
89
  }
90
- const AppShellRoutes = () => {
90
+ function HvAppShellRouter() {
91
91
  const { baseUrl, mainPanel } = useHvAppShellModel();
92
92
  const prevRoutesRef = useRef([]);
93
93
  const [routerKey, setRouterKey] = useState("router-initial");
@@ -127,7 +127,7 @@ const AppShellRoutes = () => {
127
127
  },
128
128
  routerKey
129
129
  );
130
- };
130
+ }
131
131
  export {
132
- AppShellRoutes as default
132
+ HvAppShellRouter
133
133
  };
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { useState, useEffect, useMemo, useContext } from "react";
2
+ import { useMemo, useContext, useState, useEffect } from "react";
3
3
  import { I18nContext } from "react-i18next";
4
4
  import { HvAppShellContext, HvAppShellModelContext, HvAppShellRuntimeContext, HvAppShellCombinedProvidersContext, CONFIG_TRANSLATIONS_NAMESPACE } from "@hitachivantara/app-shell-shared";
5
5
  import { themes, HvProvider } from "@hitachivantara/uikit-react-core";
@@ -92,52 +92,24 @@ const AppShellProviderInner = ({
92
92
  }
93
93
  ) }) }) });
94
94
  };
95
- const AppShellProvider = ({
95
+ function HvAppShellProvider({
96
96
  children,
97
- config: localConfig,
98
- configUrl
99
- }) => {
100
- const [loadedConfig, setLoadedConfig] = useState();
101
- const [hasError, setHasError] = useState(false);
102
- useEffect(() => {
103
- if (!localConfig && configUrl) {
104
- fetch(new URL(configUrl)).then((result) => result.json()).then((data) => setLoadedConfig(data)).catch((e) => {
105
- console.error(`Failed to obtain the context from: ${configUrl}`, e);
106
- setLoadedConfig(void 0);
107
- setHasError(true);
108
- });
109
- }
110
- }, [localConfig, configUrl]);
111
- const rawConfig = useMemo(
112
- () => localConfig ?? loadedConfig,
113
- [localConfig, loadedConfig]
114
- );
115
- const { model, isPending: areBundlesLoading } = useModelFromConfig(rawConfig);
97
+ config: configProp
98
+ }) {
99
+ const { model, isPending: areBundlesLoading } = useModelFromConfig(configProp);
116
100
  const systemProviders = useMemo(() => {
117
- if (!model?.systemProviders) {
118
- return void 0;
119
- }
120
- const providersComponents = [];
121
- for (const provider of model.systemProviders) {
122
- const component = model.preloadedBundles.get(
123
- provider.bundle
124
- );
125
- providersComponents.push({
126
- key: provider.key,
127
- component,
128
- config: provider.config
129
- });
130
- }
131
- return providersComponents;
101
+ if (!model?.systemProviders) return void 0;
102
+ return model.systemProviders.map(({ key, bundle, config }) => ({
103
+ key,
104
+ component: model.preloadedBundles.get(bundle),
105
+ config
106
+ }));
132
107
  }, [model?.systemProviders, model?.preloadedBundles]);
133
- if (hasError) {
134
- throw Error("Failed to obtain the configuration");
135
- }
136
- if (!rawConfig || !model || areBundlesLoading) {
108
+ if (!configProp || !model || areBundlesLoading) {
137
109
  return null;
138
110
  }
139
- return /* @__PURE__ */ jsx(CombinedProviders, { providers: systemProviders, children: /* @__PURE__ */ jsx(AppShellProviderInner, { config: rawConfig, model, children }) });
140
- };
111
+ return /* @__PURE__ */ jsx(CombinedProviders, { providers: systemProviders, children: /* @__PURE__ */ jsx(AppShellProviderInner, { config: configProp, model, children }) });
112
+ }
141
113
  export {
142
- AppShellProvider as default
114
+ HvAppShellProvider
143
115
  };
@@ -8,9 +8,9 @@ import { useTheme, HvHeader, HvButton, HvHeaderBrand, HvHeaderNavigation } from
8
8
  import { useLayoutContext } from "../../../providers/LayoutProvider.js";
9
9
  import { useNavigationContext } from "../../../providers/NavigationProvider.js";
10
10
  import IconUiKit from "../../IconUiKit/index.js";
11
- import HeaderActions from "./HeaderActions/HeaderActions.js";
12
- import StyledIconWrapper from "./styles.js";
13
11
  import BrandLogo from "../BrandLogo/BrandLogo.js";
12
+ import HeaderActions from "../HeaderActions/HeaderActions.js";
13
+ import StyledIconWrapper from "./styles.js";
14
14
  const Header = () => {
15
15
  const { t } = useTranslation(void 0, { keyPrefix: "header.navigation" });
16
16
  const { t: tConfig } = useTranslation(CONFIG_TRANSLATIONS_NAMESPACE);
@@ -5,11 +5,11 @@ import { useTranslation } from "react-i18next";
5
5
  import ClickAwayListener from "@mui/material/ClickAwayListener";
6
6
  import { CONFIG_TRANSLATIONS_NAMESPACE, useHvAppShellModel } from "@hitachivantara/app-shell-shared";
7
7
  import { HvIconButton, theme, HvAppSwitcher, HvTypography } from "@hitachivantara/uikit-react-core";
8
- import createAppContainerElement from "../../../../../../utils/documentUtil.js";
9
- import IconUiKit from "../../../../../IconUiKit/index.js";
10
- import StyledIconWrapper from "../../../styles.js";
8
+ import createAppContainerElement from "../../../../utils/documentUtil.js";
9
+ import IconUiKit from "../../../IconUiKit/index.js";
10
+ import BrandLogo from "../../BrandLogo/BrandLogo.js";
11
+ import StyledIconWrapper from "../../Header/styles.js";
11
12
  import StyledAppShellPanelWrapper from "./styles.js";
12
- import BrandLogo from "../../../../BrandLogo/BrandLogo.js";
13
13
  const AppSwitcherToggle = ({
14
14
  title,
15
15
  apps,
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { useTranslation } from "react-i18next";
3
3
  import { HvAppShellEventThemeTrigger } from "@hitachivantara/app-shell-events";
4
4
  import { useTheme, HvIconButton } from "@hitachivantara/uikit-react-core";
5
- import IconUiKit from "../../../../IconUiKit/index.js";
5
+ import IconUiKit from "../../IconUiKit/index.js";
6
6
  const ColorModeSwitcher = () => {
7
7
  const { t } = useTranslation(void 0, {
8
8
  keyPrefix: "header.colorModeSwitcher"
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { useHvAppShellModel } from "@hitachivantara/app-shell-shared";
3
3
  import { HvHeaderActions } from "@hitachivantara/uikit-react-core";
4
4
  import DynamicAction from "./DynamicAction.js";
5
- import InternalAction, { internalActions } from "./InternalActions/InternalAction/InternalAction.js";
5
+ import InternalAction, { internalActions } from "./InternalAction/InternalAction.js";
6
6
  const HeaderActions = () => {
7
7
  const { header } = useHvAppShellModel();
8
8
  return /* @__PURE__ */ jsx(HvHeaderActions, { children: header?.actions.map((action) => {
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { useTranslation } from "react-i18next";
3
3
  import { CONFIG_TRANSLATIONS_NAMESPACE } from "@hitachivantara/app-shell-shared";
4
4
  import { HvIconButton } from "@hitachivantara/uikit-react-core";
5
- import IconUiKit from "../../../../../IconUiKit/index.js";
5
+ import IconUiKit from "../../../IconUiKit/index.js";
6
6
  const HelpButton = ({ url, description }) => {
7
7
  const { t } = useTranslation(void 0, { keyPrefix: "header.helpUrl" });
8
8
  const { t: tConfig } = useTranslation(CONFIG_TRANSLATIONS_NAMESPACE);
@@ -9,13 +9,13 @@ const internalActions = [
9
9
  },
10
10
  {
11
11
  bundle: "@hv/help-client/button.js",
12
- component: () => import("../HelpButton/index.js").then((module) => ({
12
+ component: () => import("../HelpButton/HelpButton.js").then((module) => ({
13
13
  default: module.default
14
14
  }))
15
15
  },
16
16
  {
17
17
  bundle: "@hv/app-switcher-client/toggle.js",
18
- component: () => import("../AppSwitcherToggle/index.js").then((module) => ({
18
+ component: () => import("../AppSwitcherToggle/AppSwitcherToggle.js").then((module) => ({
19
19
  default: module.default
20
20
  }))
21
21
  }
@@ -3,8 +3,8 @@ import { css } from "@emotion/css";
3
3
  import { useTheme, theme } from "@hitachivantara/uikit-react-core";
4
4
  import { useLayoutContext } from "../../../providers/LayoutProvider.js";
5
5
  import { useNavigationContext } from "../../../providers/NavigationProvider.js";
6
- import { StyledContainer, StyledMain } from "./styles.js";
7
6
  import VerticalNavigation from "../VerticalNavigation/VerticalNavigation.js";
7
+ import { StyledContainer, StyledMain } from "./styles.js";
8
8
  const Main = ({ children }) => {
9
9
  const {
10
10
  hasVerticalNavigation,
@@ -1,8 +1,8 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useHvAppShellModel } from "@hitachivantara/app-shell-shared";
3
3
  import { AppSwitcher } from "@hitachivantara/uikit-react-icons";
4
- import { classes } from "./styles.js";
5
4
  import BrandLogo from "../BrandLogo/BrandLogo.js";
5
+ import { classes } from "./styles.js";
6
6
  const NavigationHeader = ({ isOpen }) => {
7
7
  const { logo } = useHvAppShellModel();
8
8
  return /* @__PURE__ */ jsxs("div", { className: classes.navigationHeader, children: [
package/dist/index.d.ts CHANGED
@@ -1,9 +1,19 @@
1
+ import { HvAppShellConfig } from '@hitachivantara/app-shell-shared';
1
2
  import { JSX as JSX_2 } from 'react/jsx-runtime';
2
3
 
3
- declare const _default: {
4
- ({ ...wrappedProps }: any): JSX_2.Element;
5
- displayName: string;
6
- };
7
- export default _default;
4
+ /**
5
+ * The main App Shell UI component that:
6
+ * - Loads the configuration via `config` or `configUrl`
7
+ * - Instantiates Global Providers (i18n, theming, error boundary, etc)
8
+ * - Renders the App Shell Header & Vertical Navigation Layout
9
+ * - Instantiates the App Shell Router for the given configuration
10
+ */
11
+ declare function HvAppShell({ config, configUrl }: HvAppShellProps): JSX_2.Element;
12
+ export default HvAppShell;
13
+
14
+ declare interface HvAppShellProps {
15
+ config?: Partial<HvAppShellConfig>;
16
+ configUrl?: string;
17
+ }
8
18
 
9
19
  export { }
@@ -4,13 +4,13 @@ import { ErrorBoundary } from "react-error-boundary";
4
4
  import { Outlet } from "react-router-dom";
5
5
  import ServiceManagerProvider from "@hitachivantara/app-shell-services";
6
6
  import { useHvAppShellModel, useHvAppShellCombinedProviders } from "@hitachivantara/app-shell-shared";
7
+ import Header from "../../components/layout/Header/Header.js";
8
+ import Main from "../../components/layout/Main/Main.js";
7
9
  import { BannerProvider } from "../../providers/BannerProvider.js";
8
10
  import { NavigationProvider } from "../../providers/NavigationProvider.js";
9
11
  import CombinedProviders from "../../utils/CombinedProviders.js";
10
12
  import LoadingPage from "../LoadingPage/LoadingPage.js";
11
13
  import CustomHooksInitializer from "../../components/CustomHooksInitializer/CustomHooksInitializer.js";
12
- import Header from "../../components/layout/Header/Header.js";
13
- import Main from "../../components/layout/Main/Main.js";
14
14
  import GenericError from "../GenericError/GenericError.js";
15
15
  const Root = () => {
16
16
  const { services } = useHvAppShellModel();
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { useContext, createContext, useState, useMemo, useEffect, useCallback } from "react";
2
+ import { useState, useMemo, useEffect, useCallback, createContext, useContext } from "react";
3
3
  import { useTheme } from "@mui/material/styles";
4
4
  import useMediaQuery from "@mui/material/useMediaQuery";
5
5
  import { useHvAppShellConfig } from "@hitachivantara/app-shell-shared";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitachivantara/app-shell-ui",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "author": "Hitachi Vantara UI Kit Team",
@@ -18,11 +18,11 @@
18
18
  "@emotion/css": "^11.10.5",
19
19
  "@emotion/react": "^11.10.5",
20
20
  "@emotion/styled": "^11.10.5",
21
- "@hitachivantara/app-shell-events": "^2.0.1",
22
- "@hitachivantara/app-shell-navigation": "^2.1.1",
23
- "@hitachivantara/app-shell-services": "^2.0.1",
24
- "@hitachivantara/app-shell-shared": "^2.1.1",
25
- "@hitachivantara/uikit-react-core": "^6.2.0",
21
+ "@hitachivantara/app-shell-events": "^2.0.2",
22
+ "@hitachivantara/app-shell-navigation": "^2.1.2",
23
+ "@hitachivantara/app-shell-services": "^2.0.2",
24
+ "@hitachivantara/app-shell-shared": "^2.1.2",
25
+ "@hitachivantara/uikit-react-core": "^6.3.0",
26
26
  "@hitachivantara/uikit-react-icons": "^6.0.2",
27
27
  "@mui/material": "^7.0.2",
28
28
  "i18next": "^24.2.2",
@@ -44,7 +44,7 @@
44
44
  "access": "public",
45
45
  "directory": "package"
46
46
  },
47
- "gitHead": "7815bbc4041430fbc4fda437e7359ec6cfcb0b32",
47
+ "gitHead": "f2b8a9e107bc8886231d527b37b30716d891105c",
48
48
  "exports": {
49
49
  ".": {
50
50
  "types": "./dist/index.d.ts",
@@ -1,42 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { ErrorBoundary } from "react-error-boundary";
3
- import { HelmetProvider } from "react-helmet-async";
4
- import { I18nextProvider } from "react-i18next";
5
- import { HvProvider } from "@hitachivantara/uikit-react-core";
6
- import createI18Next from "../../i18n/index.js";
7
- import { LayoutProvider } from "../../providers/LayoutProvider.js";
8
- import AppShellProvider from "../AppShellProvider/AppShellProvider.js";
9
- import GlobalStyles from "../GlobalStyles/GlobalStyles.js";
10
- import SnackbarProvider from "../SnackbarProvider/SnackbarProvider.js";
11
- import GenericError from "../../pages/GenericError/GenericError.js";
12
- const withGlobalProvider = (WrappedComponent) => {
13
- const displayName = WrappedComponent.displayName ?? WrappedComponent.name;
14
- const { i18n } = createI18Next();
15
- const ComponentWithGlobalProvider = ({
16
- ...wrappedProps
17
- }) => {
18
- return /* @__PURE__ */ jsx(HelmetProvider, { children: /* @__PURE__ */ jsxs(HvProvider, { children: [
19
- /* @__PURE__ */ jsx(GlobalStyles, {}),
20
- /* @__PURE__ */ jsx(I18nextProvider, { i18n, children: /* @__PURE__ */ jsx(
21
- ErrorBoundary,
22
- {
23
- fallback: /* @__PURE__ */ jsx(GenericError, { fullPage: true, includeFooter: false }),
24
- children: /* @__PURE__ */ jsx(
25
- AppShellProvider,
26
- {
27
- config: wrappedProps.config,
28
- configUrl: wrappedProps.configUrl,
29
- children: /* @__PURE__ */ jsx(LayoutProvider, { children: /* @__PURE__ */ jsx(SnackbarProvider, { children: /* @__PURE__ */ jsx(WrappedComponent, { ...wrappedProps }) }) })
30
- }
31
- )
32
- },
33
- "general"
34
- ) })
35
- ] }) });
36
- };
37
- ComponentWithGlobalProvider.displayName = `withGlobalProvider(${displayName})`;
38
- return ComponentWithGlobalProvider;
39
- };
40
- export {
41
- withGlobalProvider as default
42
- };
@@ -1,4 +0,0 @@
1
- import AppSwitcherToggle from "./AppSwitcherToggle.js";
2
- export {
3
- AppSwitcherToggle as default
4
- };
@@ -1,4 +0,0 @@
1
- import HelpButton from "./HelpButton.js";
2
- export {
3
- HelpButton as default
4
- };
@@ -1,4 +0,0 @@
1
- import HeaderActions from "./HeaderActions.js";
2
- export {
3
- HeaderActions as default
4
- };