@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.
Files changed (62) hide show
  1. package/dist/components/AppShell/AppShell.js +16 -5
  2. package/dist/components/AppShell/AppShellContainer.js +75 -66
  3. package/dist/components/AppShell/AppShellRouter.js +98 -109
  4. package/dist/components/AppShellI18nProvider/AppShellI18nProvider.js +19 -25
  5. package/dist/components/AppShellProvider/AppShellProvider.js +84 -91
  6. package/dist/components/AppShellViewProvider/AppShellViewProvider.js +10 -7
  7. package/dist/components/ConfigIcon.js +13 -15
  8. package/dist/components/CustomHooksInitializer/CustomHooksInitializer.js +7 -7
  9. package/dist/components/GlobalStyles.js +11 -9
  10. package/dist/components/IconUiKit/IconUiKit.js +10 -8
  11. package/dist/components/InitErrorFallback/InitErrorFallback.js +31 -23
  12. package/dist/components/SnackbarProvider/SnackbarProvider.js +17 -20
  13. package/dist/components/layout/AppShellLayout.js +50 -65
  14. package/dist/components/layout/BrandLogo/BrandLogo.js +25 -35
  15. package/dist/components/layout/BrandLogo/logos.js +38 -55
  16. package/dist/components/layout/Header/Header.js +55 -74
  17. package/dist/components/layout/HeaderActions/AppSwitcherToggle/AppSwitcherToggle.js +66 -74
  18. package/dist/components/layout/HeaderActions/AppSwitcherToggle/styles.js +12 -12
  19. package/dist/components/layout/HeaderActions/ColorModeSwitcher.js +23 -26
  20. package/dist/components/layout/HeaderActions/DynamicAction.js +22 -21
  21. package/dist/components/layout/HeaderActions/HeaderActions.js +15 -22
  22. package/dist/components/layout/HeaderActions/HelpButton/HelpButton.js +22 -31
  23. package/dist/components/layout/HeaderActions/InternalAction/InternalAction.js +25 -36
  24. package/dist/components/layout/VerticalNavigation/NavigationCollapse.js +29 -34
  25. package/dist/components/layout/VerticalNavigation/NavigationHeader.js +18 -20
  26. package/dist/components/layout/VerticalNavigation/VerticalNavigation.js +96 -130
  27. package/dist/hooks/useClearLocationState.js +10 -12
  28. package/dist/hooks/useConditionsEvaluator.js +67 -81
  29. package/dist/hooks/useCustomEventListener.js +16 -28
  30. package/dist/hooks/useFilteredModel.js +30 -27
  31. package/dist/hooks/useLocalStorage.js +26 -26
  32. package/dist/hooks/useModelFromConfig.js +43 -39
  33. package/dist/hooks/useNavigationMenuItems.js +27 -30
  34. package/dist/hooks/useNotificationsEventListener.js +35 -42
  35. package/dist/hooks/useResizeObserver.js +13 -13
  36. package/dist/hooks/useThemeEventListener.js +17 -18
  37. package/dist/i18n/constants.js +5 -6
  38. package/dist/i18n/index.js +26 -20
  39. package/dist/i18n/useI18nInit.js +72 -66
  40. package/dist/index.js +4 -3
  41. package/dist/pages/ErrorPage/ErrorPage.js +33 -32
  42. package/dist/pages/ErrorPage/Footer.js +46 -55
  43. package/dist/pages/GenericError/CatServer.js +585 -569
  44. package/dist/pages/GenericError/GenericError.js +25 -26
  45. package/dist/pages/LoadingPage/LoadingPage.js +9 -17
  46. package/dist/pages/LoadingPage/index.js +4 -3
  47. package/dist/pages/NotFound/DogeSpace.js +505 -540
  48. package/dist/pages/NotFound/NotFound.js +17 -20
  49. package/dist/pages/NotFound/index.js +2 -4
  50. package/dist/pages/RootRoute.js +32 -19
  51. package/dist/providers/BannerProvider.js +98 -123
  52. package/dist/providers/LayoutProvider.js +26 -32
  53. package/dist/providers/NavigationProvider.js +96 -107
  54. package/dist/utils/CombinedProviders.js +12 -18
  55. package/dist/utils/documentUtil.js +12 -12
  56. package/dist/utils/filterModel.js +134 -170
  57. package/dist/utils/lazyImport.js +31 -36
  58. package/dist/utils/navigationUtil.js +68 -53
  59. package/dist/utils/processConfig.js +119 -153
  60. package/package.json +8 -8
  61. package/dist/components/IconUiKit/index.js +0 -6
  62. package/dist/pages/LoadingPage/styles.js +0 -30
@@ -1,78 +1,59 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { Helmet } from "react-helmet-async";
3
- import { useTranslation } from "react-i18next";
4
- import { useHvNavigation } from "@hitachivantara/app-shell-navigation";
5
- import { useHvAppShellRuntimeContext, CONFIG_TRANSLATIONS_NAMESPACE, useHvAppShellModel } from "@hitachivantara/app-shell-shared";
6
- import { useTheme, HvHeader, HvButton, HvHeaderBrand, HvHeaderNavigation } from "@hitachivantara/uikit-react-core";
1
+ import IconUiKit_default from "../../IconUiKit/IconUiKit.js";
7
2
  import { useNavigationContext } from "../../../providers/NavigationProvider.js";
8
- import IconUiKit from "../../IconUiKit/index.js";
9
3
  import { BrandLogo } from "../BrandLogo/BrandLogo.js";
10
4
  import HeaderActions from "../HeaderActions/HeaderActions.js";
11
- const Header = () => {
12
- const { i18n } = useHvAppShellRuntimeContext();
13
- const { t } = useTranslation(void 0, {
14
- i18n,
15
- keyPrefix: "header.navigation"
16
- });
17
- const { t: tConfig } = useTranslation(CONFIG_TRANSLATIONS_NAMESPACE, {
18
- i18n
19
- });
20
- const { navigationMode, name, logo } = useHvAppShellModel();
21
- const { activeTheme } = useTheme();
22
- const { navigate } = useHvNavigation();
23
- const {
24
- items,
25
- selectedMenuItemId,
26
- rootMenuItemId,
27
- isCompactMode,
28
- switchVerticalNavigationMode,
29
- verticalNavigationMode,
30
- verticalNavigationItems
31
- } = useNavigationContext();
32
- const isOnlyTopMode = navigationMode === "ONLY_TOP";
33
- const showNavigation = !isCompactMode && navigationMode !== "ONLY_LEFT" && items.length > 0;
34
- const isVerticalNavigationClosed = verticalNavigationMode === "CLOSED";
35
- const showVerticalNavigationButton = isCompactMode && verticalNavigationItems.length > 0;
36
- const handleNavigationChange = (event, selectedItem) => {
37
- if (selectedItem.href) {
38
- navigate(selectedItem.href, {
39
- state: { selectedItemId: selectedItem.id }
40
- });
41
- }
42
- };
43
- const isPentahoTheme = activeTheme?.name === "pentahoPlus";
44
- const appName = name ? tConfig(name) : "";
45
- return /* @__PURE__ */ jsxs(HvHeader, { position: "relative", style: { gridArea: "header" }, children: [
46
- /* @__PURE__ */ jsx(Helmet, { children: /* @__PURE__ */ jsx("title", { children: appName }) }),
47
- showVerticalNavigationButton && /* @__PURE__ */ jsx(
48
- HvButton,
49
- {
50
- icon: true,
51
- "aria-label": isVerticalNavigationClosed ? t("openNavigationPanel") : t("closeNavigationPanel"),
52
- "aria-expanded": !isVerticalNavigationClosed,
53
- onClick: switchVerticalNavigationMode,
54
- children: /* @__PURE__ */ jsx(IconUiKit, { name: isVerticalNavigationClosed ? "Menu" : "Close" })
55
- }
56
- ),
57
- /* @__PURE__ */ jsx(
58
- HvHeaderBrand,
59
- {
60
- logo: isPentahoTheme ? void 0 : /* @__PURE__ */ jsx(BrandLogo, { logo }),
61
- name: appName
62
- }
63
- ),
64
- showNavigation && /* @__PURE__ */ jsx(
65
- HvHeaderNavigation,
66
- {
67
- data: items,
68
- selected: isOnlyTopMode ? selectedMenuItemId : rootMenuItemId,
69
- onClick: handleNavigationChange,
70
- levels: isOnlyTopMode ? 2 : 1
71
- }
72
- ),
73
- /* @__PURE__ */ jsx(HeaderActions, {})
74
- ] });
75
- };
76
- export {
77
- Header
5
+ import { Helmet } from "react-helmet-async";
6
+ import { useTranslation } from "react-i18next";
7
+ import { HvButton, HvHeader, HvHeaderBrand, HvHeaderNavigation, useTheme } from "@hitachivantara/uikit-react-core";
8
+ import { CONFIG_TRANSLATIONS_NAMESPACE, useHvAppShellModel, useHvAppShellRuntimeContext } from "@hitachivantara/app-shell-shared";
9
+ import { useHvNavigation } from "@hitachivantara/app-shell-navigation";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ //#region src/components/layout/Header/Header.tsx
12
+ var Header = () => {
13
+ const { i18n } = useHvAppShellRuntimeContext();
14
+ const { t } = useTranslation(void 0, {
15
+ i18n,
16
+ keyPrefix: "header.navigation"
17
+ });
18
+ const { t: tConfig } = useTranslation(CONFIG_TRANSLATIONS_NAMESPACE, { i18n });
19
+ const { navigationMode, name, logo } = useHvAppShellModel();
20
+ const { activeTheme } = useTheme();
21
+ const { navigate } = useHvNavigation();
22
+ const { items, selectedMenuItemId, rootMenuItemId, isCompactMode, switchVerticalNavigationMode, verticalNavigationMode, verticalNavigationItems } = useNavigationContext();
23
+ const isOnlyTopMode = navigationMode === "ONLY_TOP";
24
+ const showNavigation = !isCompactMode && navigationMode !== "ONLY_LEFT" && items.length > 0;
25
+ const isVerticalNavigationClosed = verticalNavigationMode === "CLOSED";
26
+ const showVerticalNavigationButton = isCompactMode && verticalNavigationItems.length > 0;
27
+ const handleNavigationChange = (event, selectedItem) => {
28
+ if (selectedItem.href) navigate(selectedItem.href, { state: { selectedItemId: selectedItem.id } });
29
+ };
30
+ const isPentahoTheme = activeTheme?.name === "pentahoPlus";
31
+ const appName = name ? tConfig(name) : "";
32
+ return /* @__PURE__ */ jsxs(HvHeader, {
33
+ position: "relative",
34
+ style: { gridArea: "header" },
35
+ children: [
36
+ /* @__PURE__ */ jsx(Helmet, { children: /* @__PURE__ */ jsx("title", { children: appName }) }),
37
+ showVerticalNavigationButton && /* @__PURE__ */ jsx(HvButton, {
38
+ icon: true,
39
+ "aria-label": isVerticalNavigationClosed ? t("openNavigationPanel") : t("closeNavigationPanel"),
40
+ "aria-expanded": !isVerticalNavigationClosed,
41
+ onClick: switchVerticalNavigationMode,
42
+ children: /* @__PURE__ */ jsx(IconUiKit_default, { name: isVerticalNavigationClosed ? "Menu" : "Close" })
43
+ }),
44
+ /* @__PURE__ */ jsx(HvHeaderBrand, {
45
+ logo: isPentahoTheme ? void 0 : /* @__PURE__ */ jsx(BrandLogo, { logo }),
46
+ name: appName
47
+ }),
48
+ showNavigation && /* @__PURE__ */ jsx(HvHeaderNavigation, {
49
+ data: items,
50
+ selected: isOnlyTopMode ? selectedMenuItemId : rootMenuItemId,
51
+ onClick: handleNavigationChange,
52
+ levels: isOnlyTopMode ? 2 : 1
53
+ }),
54
+ /* @__PURE__ */ jsx(HeaderActions, {})
55
+ ]
56
+ });
78
57
  };
58
+ //#endregion
59
+ export { Header };
@@ -1,78 +1,70 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useState, useId, useMemo } from "react";
3
- import { createPortal } from "react-dom";
4
- import { useTranslation } from "react-i18next";
5
- import ClickAwayListener from "@mui/material/ClickAwayListener";
6
- import { useHvAppShellRuntimeContext, CONFIG_TRANSLATIONS_NAMESPACE, useHvAppShellModel } from "@hitachivantara/app-shell-shared";
7
- import { HvIconButton, theme, HvAppSwitcher, HvTypography } from "@hitachivantara/uikit-react-core";
8
- import { AppSwitcher } from "@hitachivantara/uikit-react-icons";
9
- import createAppContainerElement from "../../../../utils/documentUtil.js";
10
1
  import { ConfigIcon } from "../../../ConfigIcon.js";
11
2
  import { BrandLogo } from "../../BrandLogo/BrandLogo.js";
3
+ import createAppContainerElement from "../../../../utils/documentUtil.js";
12
4
  import StyledAppShellPanelWrapper from "./styles.js";
13
- const AppSwitcherToggle = ({
14
- title,
15
- apps,
16
- showLogo = false
17
- }) => {
18
- const { i18n } = useHvAppShellRuntimeContext();
19
- const { t } = useTranslation(void 0, {
20
- i18n,
21
- keyPrefix: "header.appSwitcher"
22
- });
23
- const { t: tConfig } = useTranslation(CONFIG_TRANSLATIONS_NAMESPACE, {
24
- i18n
25
- });
26
- const [isPanelOpen, setIsPanelOpen] = useState(false);
27
- const appSwitcherPanelId = useId();
28
- const { logo } = useHvAppShellModel();
29
- const appsList = useMemo(() => {
30
- if (!apps) return [];
31
- return apps.map((app) => ({
32
- name: tConfig(app.label),
33
- description: app.description ? tConfig(app.description).toString() : void 0,
34
- url: app.url?.includes(":") ? app.url : tConfig(app.url).toString(),
35
- target: app.target === "NEW" ? "_blank" : "_top",
36
- iconElement: app.icon && /* @__PURE__ */ jsx(ConfigIcon, { icon: app.icon })
37
- }));
38
- }, [apps, tConfig]);
39
- if (!apps || apps.length === 0) return null;
40
- const finalTitle = title ? tConfig(title) : t("title");
41
- return /* @__PURE__ */ jsx(ClickAwayListener, { onClickAway: () => setIsPanelOpen(false), children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", margin: 0 }, children: [
42
- /* @__PURE__ */ jsxs(
43
- HvIconButton,
44
- {
45
- title: finalTitle,
46
- "aria-expanded": isPanelOpen,
47
- onClick: () => setIsPanelOpen(!isPanelOpen),
48
- ...isPanelOpen && { "aria-controls": appSwitcherPanelId },
49
- children: [
50
- /* @__PURE__ */ jsx(AppSwitcher, {}),
51
- showLogo && /* @__PURE__ */ jsx(BrandLogo, { logo, style: { paddingRight: theme.space.xs } })
52
- ]
53
- }
54
- ),
55
- isPanelOpen && createPortal(
56
- /* @__PURE__ */ jsx(
57
- StyledAppShellPanelWrapper,
58
- {
59
- id: appSwitcherPanelId,
60
- role: "region",
61
- "aria-label": t("ariaLabel"),
62
- children: /* @__PURE__ */ jsx(
63
- HvAppSwitcher,
64
- {
65
- applications: appsList,
66
- onActionClickedCallback: () => setIsPanelOpen(false),
67
- header: /* @__PURE__ */ jsx(HvTypography, { variant: "label", children: finalTitle })
68
- }
69
- )
70
- }
71
- ),
72
- createAppContainerElement()
73
- )
74
- ] }) });
75
- };
76
- export {
77
- AppSwitcherToggle as default
5
+ import { useId, useMemo, useState } from "react";
6
+ import { useTranslation } from "react-i18next";
7
+ import { HvAppSwitcher, HvIconButton, HvTypography, theme } from "@hitachivantara/uikit-react-core";
8
+ import { CONFIG_TRANSLATIONS_NAMESPACE, useHvAppShellModel, useHvAppShellRuntimeContext } from "@hitachivantara/app-shell-shared";
9
+ import { AppSwitcher } from "@hitachivantara/uikit-react-icons";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ import ClickAwayListener from "@mui/material/ClickAwayListener";
12
+ import { createPortal } from "react-dom";
13
+ //#region src/components/layout/HeaderActions/AppSwitcherToggle/AppSwitcherToggle.tsx
14
+ var AppSwitcherToggle = ({ title, apps, showLogo = false }) => {
15
+ const { i18n } = useHvAppShellRuntimeContext();
16
+ const { t } = useTranslation(void 0, {
17
+ i18n,
18
+ keyPrefix: "header.appSwitcher"
19
+ });
20
+ const { t: tConfig } = useTranslation(CONFIG_TRANSLATIONS_NAMESPACE, { i18n });
21
+ const [isPanelOpen, setIsPanelOpen] = useState(false);
22
+ const appSwitcherPanelId = useId();
23
+ const { logo } = useHvAppShellModel();
24
+ /** Creates the apps list to be sent to the HvAppSwitcherPanel. */
25
+ const appsList = useMemo(() => {
26
+ if (!apps) return [];
27
+ return apps.map((app) => ({
28
+ name: tConfig(app.label),
29
+ description: app.description ? tConfig(app.description).toString() : void 0,
30
+ url: app.url?.includes(":") ? app.url : tConfig(app.url).toString(),
31
+ target: app.target === "NEW" ? "_blank" : "_top",
32
+ iconElement: app.icon && /* @__PURE__ */ jsx(ConfigIcon, { icon: app.icon })
33
+ }));
34
+ }, [apps, tConfig]);
35
+ if (!apps || apps.length === 0) return null;
36
+ const finalTitle = title ? tConfig(title) : t("title");
37
+ return /* @__PURE__ */ jsx(ClickAwayListener, {
38
+ onClickAway: () => setIsPanelOpen(false),
39
+ children: /* @__PURE__ */ jsxs("div", {
40
+ style: {
41
+ display: "flex",
42
+ margin: 0
43
+ },
44
+ children: [/* @__PURE__ */ jsxs(HvIconButton, {
45
+ title: finalTitle,
46
+ "aria-expanded": isPanelOpen,
47
+ onClick: () => setIsPanelOpen(!isPanelOpen),
48
+ ...isPanelOpen && { "aria-controls": appSwitcherPanelId },
49
+ children: [/* @__PURE__ */ jsx(AppSwitcher, {}), showLogo && /* @__PURE__ */ jsx(BrandLogo, {
50
+ logo,
51
+ style: { paddingRight: theme.space.xs }
52
+ })]
53
+ }), isPanelOpen && createPortal(/* @__PURE__ */ jsx(StyledAppShellPanelWrapper, {
54
+ id: appSwitcherPanelId,
55
+ role: "region",
56
+ "aria-label": t("ariaLabel"),
57
+ children: /* @__PURE__ */ jsx(HvAppSwitcher, {
58
+ applications: appsList,
59
+ onActionClickedCallback: () => setIsPanelOpen(false),
60
+ header: /* @__PURE__ */ jsx(HvTypography, {
61
+ variant: "label",
62
+ children: finalTitle
63
+ })
64
+ })
65
+ }), createAppContainerElement())]
66
+ })
67
+ });
78
68
  };
69
+ //#endregion
70
+ export { AppSwitcherToggle as default };
@@ -1,14 +1,14 @@
1
- import styled from "@emotion/styled";
2
1
  import { theme } from "@hitachivantara/uikit-react-core";
3
- const StyledAppShellPanelWrapper = styled("div")({
4
- position: "fixed",
5
- maxHeight: `calc(100vh - ${theme.header.height})`,
6
- top: theme.header.height,
7
- right: 0,
8
- display: "flex",
9
- boxShadow: theme.colors.shadow,
10
- zIndex: `calc(${theme.zIndices.banner} - 1)`
2
+ import styled from "@emotion/styled";
3
+ //#region src/components/layout/HeaderActions/AppSwitcherToggle/styles.ts
4
+ var StyledAppShellPanelWrapper = styled("div")({
5
+ position: "fixed",
6
+ maxHeight: `calc(100vh - ${theme.header.height})`,
7
+ top: theme.header.height,
8
+ right: 0,
9
+ display: "flex",
10
+ boxShadow: theme.colors.shadow,
11
+ zIndex: `calc(${theme.zIndices.banner} - 1)`
11
12
  });
12
- export {
13
- StyledAppShellPanelWrapper as default
14
- };
13
+ //#endregion
14
+ export { StyledAppShellPanelWrapper as default };
@@ -1,29 +1,26 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import IconUiKit_default from "../../IconUiKit/IconUiKit.js";
2
2
  import { useTranslation } from "react-i18next";
3
- import { HvAppShellEventThemeTrigger } from "@hitachivantara/app-shell-events";
3
+ import { HvIconButton, useTheme } from "@hitachivantara/uikit-react-core";
4
4
  import { useHvAppShellRuntimeContext } from "@hitachivantara/app-shell-shared";
5
- import { useTheme, HvIconButton } from "@hitachivantara/uikit-react-core";
6
- import IconUiKit from "../../IconUiKit/index.js";
7
- const ColorModeSwitcher = () => {
8
- const { i18n } = useHvAppShellRuntimeContext();
9
- const { t } = useTranslation(void 0, {
10
- i18n,
11
- keyPrefix: "header.colorModeSwitcher"
12
- });
13
- const { colorModes } = useTheme();
14
- const changeColorModeHandler = () => {
15
- const customEvent = new CustomEvent(
16
- HvAppShellEventThemeTrigger,
17
- {
18
- detail: {
19
- colorMode: void 0
20
- }
21
- }
22
- );
23
- globalThis.dispatchEvent(customEvent);
24
- };
25
- return colorModes.length > 1 ? /* @__PURE__ */ jsx(HvIconButton, { onClick: changeColorModeHandler, title: t("ariaLabel"), children: /* @__PURE__ */ jsx(IconUiKit, { name: "ThemeSwitcher" }) }) : null;
26
- };
27
- export {
28
- ColorModeSwitcher as default
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { HvAppShellEventThemeTrigger } from "@hitachivantara/app-shell-events";
7
+ //#region src/components/layout/HeaderActions/ColorModeSwitcher.tsx
8
+ var ColorModeSwitcher = () => {
9
+ const { i18n } = useHvAppShellRuntimeContext();
10
+ const { t } = useTranslation(void 0, {
11
+ i18n,
12
+ keyPrefix: "header.colorModeSwitcher"
13
+ });
14
+ const { colorModes } = useTheme();
15
+ const changeColorModeHandler = () => {
16
+ const customEvent = new CustomEvent(HvAppShellEventThemeTrigger, { detail: { colorMode: void 0 } });
17
+ globalThis.dispatchEvent(customEvent);
18
+ };
19
+ return colorModes.length > 1 ? /* @__PURE__ */ jsx(HvIconButton, {
20
+ onClick: changeColorModeHandler,
21
+ title: t("ariaLabel"),
22
+ children: /* @__PURE__ */ jsx(IconUiKit_default, { name: "ThemeSwitcher" })
23
+ }) : null;
29
24
  };
25
+ //#endregion
26
+ export { ColorModeSwitcher as default };
@@ -1,23 +1,24 @@
1
+ import { Suspense, lazy, memo, useEffect, useState } from "react";
1
2
  import { jsx } from "react/jsx-runtime";
2
- import { memo, useState, useEffect, lazy, Suspense } from "react";
3
- const DynamicAction = ({ bundle, ...others }) => {
4
- const [loadError, setLoadError] = useState(null);
5
- useEffect(() => {
6
- setLoadError(null);
7
- }, [bundle]);
8
- const Action = lazy(
9
- () => import(
10
- /* @vite-ignore */
11
- bundle
12
- ).catch((error) => {
13
- console.error(error);
14
- setLoadError(error);
15
- return { default: () => null };
16
- })
17
- );
18
- return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: !loadError && /* @__PURE__ */ jsx(Action, { ...others }) });
19
- };
20
- const DynamicAction$1 = memo(DynamicAction);
21
- export {
22
- DynamicAction$1 as default
3
+ //#region src/components/layout/HeaderActions/DynamicAction.tsx
4
+ var DynamicAction = ({ bundle, ...others }) => {
5
+ const [loadError, setLoadError] = useState(null);
6
+ useEffect(() => {
7
+ setLoadError(null);
8
+ }, [bundle]);
9
+ const Action = lazy(() => import(
10
+ /* @vite-ignore */
11
+ bundle
12
+ ).catch((error) => {
13
+ console.error(error);
14
+ setLoadError(error);
15
+ return { default: () => null };
16
+ }));
17
+ return /* @__PURE__ */ jsx(Suspense, {
18
+ fallback: null,
19
+ children: !loadError && /* @__PURE__ */ jsx(Action, { ...others })
20
+ });
23
21
  };
22
+ var DynamicAction_default = memo(DynamicAction);
23
+ //#endregion
24
+ export { DynamicAction_default as default };
@@ -1,24 +1,17 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useHvAppShellModel } from "@hitachivantara/app-shell-shared";
1
+ import DynamicAction_default from "./DynamicAction.js";
2
+ import InternalAction_default, { internalActions } from "./InternalAction/InternalAction.js";
3
3
  import { HvHeaderActions } from "@hitachivantara/uikit-react-core";
4
- import DynamicAction from "./DynamicAction.js";
5
- import InternalAction, { internalActions } from "./InternalAction/InternalAction.js";
6
- const HeaderActions = () => {
7
- const { header } = useHvAppShellModel();
8
- return /* @__PURE__ */ jsx(HvHeaderActions, { children: header?.actions.map((action) => {
9
- const Component = internalActions.some(
10
- (a) => a.bundle === action.bundle
11
- ) ? InternalAction : DynamicAction;
12
- return /* @__PURE__ */ jsx(
13
- Component,
14
- {
15
- bundle: action.bundle,
16
- ...action.config
17
- },
18
- action.key
19
- );
20
- }) });
21
- };
22
- export {
23
- HeaderActions as default
4
+ import { useHvAppShellModel } from "@hitachivantara/app-shell-shared";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/components/layout/HeaderActions/HeaderActions.tsx
7
+ var HeaderActions = () => {
8
+ const { header } = useHvAppShellModel();
9
+ return /* @__PURE__ */ jsx(HvHeaderActions, { children: header?.actions.map((action) => {
10
+ return /* @__PURE__ */ jsx(internalActions.some((a) => a.bundle === action.bundle) ? InternalAction_default : DynamicAction_default, {
11
+ bundle: action.bundle,
12
+ ...action.config
13
+ }, action.key);
14
+ }) });
24
15
  };
16
+ //#endregion
17
+ export { HeaderActions as default };
@@ -1,34 +1,25 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import IconUiKit_default from "../../../IconUiKit/IconUiKit.js";
2
2
  import { useTranslation } from "react-i18next";
3
- import { useHvAppShellRuntimeContext, CONFIG_TRANSLATIONS_NAMESPACE } from "@hitachivantara/app-shell-shared";
4
3
  import { HvIconButton } from "@hitachivantara/uikit-react-core";
5
- import IconUiKit from "../../../IconUiKit/index.js";
6
- const HelpButton = ({ url, description }) => {
7
- const { i18n } = useHvAppShellRuntimeContext();
8
- const { t } = useTranslation(void 0, {
9
- i18n,
10
- keyPrefix: "header.helpUrl"
11
- });
12
- const { t: tConfig } = useTranslation(CONFIG_TRANSLATIONS_NAMESPACE, {
13
- i18n
14
- });
15
- if (!url) {
16
- return null;
17
- }
18
- const finalUrl = url.includes(":") ? url : tConfig(url);
19
- const finalDescription = description ? tConfig(description) : t("documentationLink");
20
- return /* @__PURE__ */ jsx(
21
- HvIconButton,
22
- {
23
- component: "a",
24
- href: finalUrl,
25
- target: "_blank",
26
- title: finalDescription,
27
- rel: "noopener,noreferrer",
28
- children: /* @__PURE__ */ jsx(IconUiKit, { name: "Help" })
29
- }
30
- );
31
- };
32
- export {
33
- HelpButton as default
4
+ import { CONFIG_TRANSLATIONS_NAMESPACE, useHvAppShellRuntimeContext } from "@hitachivantara/app-shell-shared";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/components/layout/HeaderActions/HelpButton/HelpButton.tsx
7
+ var HelpButton = ({ url, description }) => {
8
+ const { i18n } = useHvAppShellRuntimeContext();
9
+ const { t } = useTranslation(void 0, {
10
+ i18n,
11
+ keyPrefix: "header.helpUrl"
12
+ });
13
+ const { t: tConfig } = useTranslation(CONFIG_TRANSLATIONS_NAMESPACE, { i18n });
14
+ if (!url) return null;
15
+ return /* @__PURE__ */ jsx(HvIconButton, {
16
+ component: "a",
17
+ href: url.includes(":") ? url : tConfig(url),
18
+ target: "_blank",
19
+ title: description ? tConfig(description) : t("documentationLink"),
20
+ rel: "noopener,noreferrer",
21
+ children: /* @__PURE__ */ jsx(IconUiKit_default, { name: "Help" })
22
+ });
34
23
  };
24
+ //#endregion
25
+ export { HelpButton as default };
@@ -1,39 +1,28 @@
1
+ import { Suspense, lazy, memo } from "react";
1
2
  import { jsx } from "react/jsx-runtime";
2
- import { memo, lazy, Suspense } from "react";
3
- const internalActions = [
4
- {
5
- bundle: "@hv/theming-client/colorModeSwitcher.js",
6
- component: () => import("../ColorModeSwitcher.js").then((module) => ({
7
- default: module.default
8
- }))
9
- },
10
- {
11
- bundle: "@hv/help-client/button.js",
12
- component: () => import("../HelpButton/HelpButton.js").then((module) => ({
13
- default: module.default
14
- }))
15
- },
16
- {
17
- bundle: "@hv/app-switcher-client/toggle.js",
18
- component: () => import("../AppSwitcherToggle/AppSwitcherToggle.js").then((module) => ({
19
- default: module.default
20
- }))
21
- }
3
+ //#region src/components/layout/HeaderActions/InternalAction/InternalAction.tsx
4
+ var internalActions = [
5
+ {
6
+ bundle: "@hv/theming-client/colorModeSwitcher.js",
7
+ component: () => import("../ColorModeSwitcher.js").then((module) => ({ default: module.default }))
8
+ },
9
+ {
10
+ bundle: "@hv/help-client/button.js",
11
+ component: () => import("../HelpButton/HelpButton.js").then((module) => ({ default: module.default }))
12
+ },
13
+ {
14
+ bundle: "@hv/app-switcher-client/toggle.js",
15
+ component: () => import("../AppSwitcherToggle/AppSwitcherToggle.js").then((module) => ({ default: module.default }))
16
+ }
22
17
  ];
23
- const InternalAction = ({ bundle, ...others }) => {
24
- const { component } = internalActions.find(
25
- (internalAction) => internalAction.bundle === bundle
26
- ) ?? {};
27
- if (!component) {
28
- return null;
29
- }
30
- const Action = lazy(
31
- () => component()
32
- );
33
- return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(Action, { ...others }) });
34
- };
35
- const InternalAction$1 = memo(InternalAction);
36
- export {
37
- InternalAction$1 as default,
38
- internalActions
18
+ var InternalAction = ({ bundle, ...others }) => {
19
+ const { component } = internalActions.find((internalAction) => internalAction.bundle === bundle) ?? {};
20
+ if (!component) return null;
21
+ return /* @__PURE__ */ jsx(Suspense, {
22
+ fallback: null,
23
+ children: /* @__PURE__ */ jsx(lazy(() => component()), { ...others })
24
+ });
39
25
  };
26
+ var InternalAction_default = memo(InternalAction);
27
+ //#endregion
28
+ export { InternalAction_default as default, internalActions };