nexus-public 1.0.11 → 1.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexus-public",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Nexus public React components for Next.js",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -20,7 +20,7 @@
20
20
  "next": "16.2.6"
21
21
  },
22
22
  "dependencies": {
23
- "nexus-shared": "^1.1.20"
23
+ "nexus-shared": "^1.1.21"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/react": "^19.2.15",
@@ -0,0 +1,13 @@
1
+ "use server";
2
+
3
+ import { APIS, EMenuTargets, HttpGet, IClientMenu, NEXUS_CONFIG, NEXUS_INFO } from "nexus-shared";
4
+
5
+ // @ts-ignore
6
+ const processEnv = process.env;
7
+ const TOKEN_GLOBAL_CLIENT_MENU = processEnv.TOKEN_GLOBAL_CLIENT_MENU as string;
8
+
9
+ export const GetClientMenusAsync = async (): Promise<IClientMenu[]> => {
10
+ const response = await HttpGet(`${APIS.CONFIGURATION}/Resources/GlobalMenus/${NEXUS_INFO.CURRENT_MODULE}/${NEXUS_INFO.IS_ADMIN_MODULE ? EMenuTargets.AdminModule : EMenuTargets.ClientModule}/${TOKEN_GLOBAL_CLIENT_MENU}`, null, NEXUS_CONFIG.DEFAULT_REVALIDATE_TIME_ONE_DAY);
11
+ if (!response.isSuccess) return [];
12
+ return response.result as IClientMenu[];
13
+ };
@@ -1,8 +1,9 @@
1
1
  "use server";
2
2
 
3
- import { EBackgrounds, GetClientMenusAsync, GetUserPanelsAsync, GetUtilityMenusAsync, GlobalLayout, HasAccessToken, IGlobalLayout, NEXUS_CONFIG } from "nexus-shared";
3
+ import { EBackgrounds, GetUserPanelsAsync, GetUtilityMenusAsync, GlobalLayout, HasAccessToken, IGlobalLayout, NEXUS_CONFIG } from "nexus-shared";
4
4
  import { UtilityMenu } from "nexus-shared/client";
5
5
  import React from "react";
6
+ import { GetClientMenusAsync } from "../../api-services/system-service";
6
7
  import { ClientMenu } from "./client-menu";
7
8
 
8
9
  import "./../../styles/nexus.layout.css";
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import Image from "next/image";
3
3
  import Link from "next/link";
4
- import { DEFAULT_ANIMATION_DURATION, DEFAULT_BUTTON_CLASS, DEFAULT_ICON_ELEMENT_NAME, DEFAULT_MOBILE_VIEW_WIDTH, EBackgroundColors, EBackgrounds, EColorTypes, EIcons, EIconTypes, EOpacity, EPositions, ESizes, FILES, GetButton, GetVisibleAndHiddenItems, IClientMenu, IDialogboxResults, RenderChildren, UN } from "nexus-shared";
5
- import { CreateButtons, CreateToggleButton, FindParentElement, GetCurrentBaseURL, GetCurrentFullURL, GetDynamicColor, HideLoader, Icon, ICON_BOX_SCALES, Iconbox, InitializeDialogbox, SET_BUTTON_ACTIVE_CLASS, SetDocumentTitleDebounce, ShowLoader } from "nexus-shared/client";
4
+ import { DEFAULT_ANIMATION_DURATION, DEFAULT_BUTTON_CLASS, DEFAULT_ICON_ELEMENT_NAME, DEFAULT_MOBILE_VIEW_WIDTH, EBackgroundColors, EBackgrounds, EColorTypes, EIcons, EIconTypes, EOpacity, EPositions, ESizes, FILES, FindActiveMenu, GetButton, GetVisibleAndHiddenItems, IClientMenu, IDialogboxResults, RenderChildren, SetSiblingMenuLinkActive, UN } from "nexus-shared";
5
+ import { CreateButtons, CreateToggleButton, FindParentElement, GetDynamicColor, HideLoader, Icon, Iconbox, InitializeDialogbox, SET_BUTTON_ACTIVE_CLASS, SetDocumentTitleDebounce, ShowLoader } from "nexus-shared/client";
6
6
  import React, { useEffect, useRef } from "react";
7
7
 
8
8
  const TOGGLE_BUTTON_ID = "client-menu-toggle-button";
@@ -77,19 +77,6 @@ export const ClientMenu = ({ clientMenus, column, boxBackground }: Readonly<{ cl
77
77
  </div>
78
78
  );
79
79
  };
80
- const FindActiveMenu = (clientMenus: IClientMenu[]) => {
81
- let fullUrl = GetCurrentFullURL().split("?")[0];
82
- const baseURL = GetCurrentBaseURL();
83
- const url = fullUrl.replace(baseURL, "");
84
- if (url === "/" || url === "" || url === "/home" || url === "home" || url === "/index" || url === "index") {
85
- const activeMenu = clientMenus.find((x) => x.menuUrl === "/home");
86
- SetDocumentTitleDebounce(activeMenu?.documentTitle ?? activeMenu?.menuName);
87
- return activeMenu;
88
- }
89
- const activeMenu = clientMenus.find((x) => url.includes(x.menuUrl ?? ""));
90
- SetDocumentTitleDebounce(activeMenu?.documentTitle ?? activeMenu?.menuName);
91
- return activeMenu;
92
- };
93
80
  const onMainLinkClicked = (e: React.MouseEvent | HTMLElement, menu: IClientMenu | null, toggleClientMenu: (isShow: boolean) => void, boxBackground: EBackgrounds, showLoader: boolean = true) => {
94
81
  if (showLoader) {
95
82
  ShowLoader();
@@ -97,11 +84,7 @@ const onMainLinkClicked = (e: React.MouseEvent | HTMLElement, menu: IClientMenu
97
84
  }
98
85
  toggleClientMenu(false);
99
86
  const link = e instanceof HTMLElement ? e : (e.currentTarget as HTMLElement);
100
- SET_BUTTON_ACTIVE_CLASS(true, link, GetDynamicColor(boxBackground, EColorTypes.Hover) as EBackgroundColors, null, GetDynamicColor(boxBackground, EColorTypes.Text) as EBackgroundColors, "left-active");
101
- const allMenuLinks = link.parentElement?.parentElement?.querySelectorAll("a.client-menu-link") ?? [];
102
- for (const menuLink of allMenuLinks) {
103
- if (menuLink !== link) SET_BUTTON_ACTIVE_CLASS(false, menuLink as HTMLElement, null, null, null, "left-active");
104
- }
87
+ SetSiblingMenuLinkActive(link, link.closest("ul"), "a.client-menu-link", boxBackground);
105
88
  document.body.click();
106
89
  };
107
90
 
@@ -153,7 +136,7 @@ const renderClientMenu = (closeMenuHandler: (isShow: boolean) => void, clientMen
153
136
  link.innerHTML = `</${DEFAULT_ICON_ELEMENT_NAME}><span class="fw400 en nw">${menu.menuName ?? "Unknown"}</span>`;
154
137
  link.onclick = (event: Event) => onMenuLinkClick(event, menu);
155
138
  link.className = _getLinkClass(isActive, boxBackground);
156
- link.style.minHeight = `calc(var(--IH) * ${ICON_BOX_SCALES.sm})`;
139
+ link.style.minHeight = `var(--TOP_HEIGHT)`;
157
140
  SET_BUTTON_ACTIVE_CLASS(isActive, link, GetDynamicColor(boxBackground, EColorTypes.Hover) as EBackgroundColors, null, GetDynamicColor(boxBackground, EColorTypes.Text) as EBackgroundColors, "active");
158
141
  menuItem.appendChild(link);
159
142
  return menuItem;