@hitachivantara/app-shell-ui 2.2.0 → 2.2.1

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.
@@ -34,7 +34,12 @@ const { useClasses } = createClasses("HvAppShellLayout", {
34
34
  overflowY: "auto"
35
35
  }
36
36
  });
37
- function HvAppShellLayout({ children }) {
37
+ function HvAppShellLayout({
38
+ children,
39
+ style,
40
+ className,
41
+ ...others
42
+ }) {
38
43
  const { classes, cx } = useClasses();
39
44
  const { activeTheme } = useTheme();
40
45
  const {
@@ -49,15 +54,16 @@ function HvAppShellLayout({ children }) {
49
54
  return /* @__PURE__ */ jsxs(
50
55
  "div",
51
56
  {
52
- className: cx(classes.root, {
57
+ className: cx(classes.root, className, {
53
58
  // order (priority) of these classes is very important
54
59
  [classes.pentaho]: isPentahoTheme,
55
60
  [classes.compact]: isCompactMode || !showVerticalNavigation
56
61
  }),
57
- style: mergeStyles(void 0, {
62
+ style: mergeStyles(style, {
58
63
  "--vNavWidth": `${verticalNavigationWidth}px`,
59
64
  "--headerHeight": showHeaderSubMenu && !isCompactMode ? `calc(${theme.header.height} + ${theme.header.secondLevelHeight})` : theme.header.height
60
65
  }),
66
+ ...others,
61
67
  children: [
62
68
  /* @__PURE__ */ jsx(Header, {}),
63
69
  showVerticalNavigation && /* @__PURE__ */ jsx(VerticalNavigation, {}),
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useState, useId } from "react";
2
+ import { useState, useId, useMemo } from "react";
3
3
  import { createPortal } from "react-dom";
4
4
  import { useTranslation } from "react-i18next";
5
5
  import ClickAwayListener from "@mui/material/ClickAwayListener";
@@ -19,36 +19,25 @@ const AppSwitcherToggle = ({
19
19
  const [isPanelOpen, setIsPanelOpen] = useState(false);
20
20
  const appSwitcherPanelId = useId();
21
21
  const { logo } = useHvAppShellModel();
22
- const createAppsList = () => {
23
- return apps ? apps.map((app) => ({
22
+ const appsList = useMemo(() => {
23
+ if (!apps) return [];
24
+ return apps.map((app) => ({
24
25
  name: tConfig(app.label),
25
26
  description: app.description ? tConfig(app.description).toString() : void 0,
26
- url: app.url.includes(":") ? app.url : tConfig(app.url).toString(),
27
+ url: app.url?.includes(":") ? app.url : tConfig(app.url).toString(),
27
28
  target: app.target === "NEW" ? "_blank" : "_top",
28
29
  iconElement: app.icon && /* @__PURE__ */ jsx(IconUiKit, { name: app.icon.name })
29
- })) : [];
30
- };
31
- const closeAppSwitcherPanel = () => {
32
- setIsPanelOpen(false);
33
- };
34
- const handleAppSwitcherPanelItemClicked = () => {
35
- closeAppSwitcherPanel();
36
- };
37
- const handleAppSwitcherButtonClick = () => {
38
- setIsPanelOpen(!isPanelOpen);
39
- };
40
- if (!apps || apps.length === 0) {
41
- return null;
42
- }
30
+ }));
31
+ }, [apps, tConfig]);
32
+ if (!apps || apps.length === 0) return null;
43
33
  const finalTitle = title ? tConfig(title) : t("title");
44
- return /* @__PURE__ */ jsx(ClickAwayListener, { onClickAway: closeAppSwitcherPanel, children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", margin: 0 }, children: [
34
+ return /* @__PURE__ */ jsx(ClickAwayListener, { onClickAway: () => setIsPanelOpen(false), children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", margin: 0 }, children: [
45
35
  /* @__PURE__ */ jsxs(
46
36
  HvIconButton,
47
37
  {
48
38
  title: finalTitle,
49
- "aria-label": finalTitle,
50
39
  "aria-expanded": isPanelOpen,
51
- onClick: handleAppSwitcherButtonClick,
40
+ onClick: () => setIsPanelOpen(!isPanelOpen),
52
41
  ...isPanelOpen && { "aria-controls": appSwitcherPanelId },
53
42
  children: [
54
43
  /* @__PURE__ */ jsx(IconUiKit, { name: "AppSwitcher" }),
@@ -66,8 +55,8 @@ const AppSwitcherToggle = ({
66
55
  children: /* @__PURE__ */ jsx(
67
56
  HvAppSwitcher,
68
57
  {
69
- applications: createAppsList(),
70
- onActionClickedCallback: handleAppSwitcherPanelItemClicked,
58
+ applications: appsList,
59
+ onActionClickedCallback: () => setIsPanelOpen(false),
71
60
  header: /* @__PURE__ */ jsx(HvTypography, { variant: "label", children: finalTitle })
72
61
  }
73
62
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitachivantara/app-shell-ui",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "author": "Hitachi Vantara UI Kit Team",
@@ -19,10 +19,10 @@
19
19
  "@emotion/react": "^11.10.5",
20
20
  "@emotion/styled": "^11.10.5",
21
21
  "@hitachivantara/app-shell-events": "^2.0.2",
22
- "@hitachivantara/app-shell-navigation": "^2.1.5",
22
+ "@hitachivantara/app-shell-navigation": "^2.1.6",
23
23
  "@hitachivantara/app-shell-services": "^2.0.2",
24
- "@hitachivantara/app-shell-shared": "^2.2.0",
25
- "@hitachivantara/uikit-react-core": "^6.4.2",
24
+ "@hitachivantara/app-shell-shared": "^2.2.1",
25
+ "@hitachivantara/uikit-react-core": "^6.4.3",
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": "3f10053759d187946255aede1c25203f4fea7940",
47
+ "gitHead": "fe1e806628c08552c969d2b99d3d2e977be12b21",
48
48
  "exports": {
49
49
  ".": {
50
50
  "types": "./dist/index.d.ts",