nexus-shared 1.1.20 → 1.1.21

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-shared",
3
- "version": "1.1.20",
3
+ "version": "1.1.21",
4
4
  "description": "Nexus shared React components for Next.js",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -1,20 +1,15 @@
1
1
  "use server";
2
2
 
3
3
  import { IThemeInformation } from "../interface";
4
- import { EMenuTargets, IClientMenu, IPanelMenu, IUtilityMenu } from "../interfaces/menu-interfaces";
4
+ import { EMenuTargets, IPanelMenu, IUtilityMenu } from "../interfaces/menu-interfaces";
5
5
  import { APIS, NEXUS_CONFIG, NEXUS_INFO } from "../nexus.environments";
6
6
  import { HttpGet } from "../services/http-services";
7
7
 
8
- const TOKEN_GLOBAL_CLIENT_MENU = "DJ3FKL4_IOR4U5_I4O5J4KDLJ_U_IO";
9
- const TOKEN_GLOBAL_UTILITY_MENU = "DJ3FKL4_IOR4U5_I4O5J4KDLJ_dfj45k_d";
10
- const TOKEN_GLOBAL_PANEL_MENU = "dj_dfjk3453IOR4U5_I4O5J4KDLJ_dfj45k_d";
11
- const TOKEN_GLOBAL_THEMES = "DJWJR_GJDK_65GKD54ZJD_00";
12
-
13
- export const GetClientMenusAsync = async (): Promise<IClientMenu[]> => {
14
- 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);
15
- if (!response.isSuccess) return [];
16
- return response.result as IClientMenu[];
17
- };
8
+ // @ts-ignore
9
+ const processEnv = process.env;
10
+ const TOKEN_GLOBAL_UTILITY_MENU = processEnv.TOKEN_GLOBAL_UTILITY_MENU as string;
11
+ const TOKEN_GLOBAL_PANEL_MENU = processEnv.TOKEN_GLOBAL_PANEL_MENU as string;
12
+ const TOKEN_GLOBAL_THEMES = processEnv.TOKEN_GLOBAL_THEMES as string;
18
13
 
19
14
  export const GetUtilityMenusAsync = async (): Promise<IUtilityMenu[]> => {
20
15
  const response = await HttpGet(`${APIS.CONFIGURATION}/Resources/UtilityMenus/${NEXUS_INFO.CURRENT_MODULE}/${NEXUS_INFO.IS_ADMIN_MODULE ? EMenuTargets.AdminModule : EMenuTargets.ClientModule}/${TOKEN_GLOBAL_UTILITY_MENU}`, null, NEXUS_CONFIG.DEFAULT_REVALIDATE_TIME_ONE_DAY);
@@ -1,7 +1,9 @@
1
1
  import Link from "next/link";
2
2
  import React from "react";
3
3
  import { IsValidURL } from "../../helpers/browser-helpers";
4
- import { SetElementStyles } from "../../helpers/element-helpers";
4
+ import { SET_BUTTON_ACTIVE_CLASS, SetElementStyles } from "../../helpers/element-helpers";
5
+
6
+ export { SET_BUTTON_ACTIVE_CLASS };
5
7
  import { DEFAULT_BUTTON_CLASS, DEFAULT_LINK_BUTTON_STYLE, EButtonTypes, ETargets, IButton } from "../../interfaces/button-interfaces";
6
8
  import { DEFAULT_ICON_SIZE, EIconTypes } from "../../interfaces/icon-interfaces";
7
9
  import { COLUMN_SIZE_ATTRIBUTE_KEY, EFlexPositions, EOpacity } from "../../interfaces/layout-interfaces";
@@ -10,17 +12,6 @@ import { ClickHandler, UN } from "../../interfaces/type-interfaces";
10
12
  import { NEXUS_CONFIG } from "../../nexus.environments";
11
13
  import { CreateIcon, Icon } from "./icon-box";
12
14
 
13
- export const SET_BUTTON_ACTIVE_CLASS = (isActive: boolean, element: HTMLElement, overrideBackgroundColor?: EBackgroundColors | UN, overrideBorderColor?: EBackgroundColors | UN, overrideTextColor?: EBackgroundColors | UN, overrideActiveClass?: string | UN) => {
14
- if (!element) return;
15
-
16
- if (isActive && overrideBackgroundColor) element.style.setProperty("--ACTIVE_BACKGROUND_COLOR", overrideBackgroundColor);
17
- if (isActive && overrideBorderColor) element.style.setProperty("--ACTIVE_BORDER_COLOR", overrideBorderColor);
18
- if (isActive && overrideTextColor) element.style.setProperty("--ACTIVE_TEXT_COLOR", overrideTextColor);
19
-
20
- if (isActive) element.classList.add(overrideActiveClass ?? "active");
21
- else element.classList.remove(overrideActiveClass ?? "active");
22
- };
23
-
24
15
  export const Button = ({ button, buttonType, styles, needColumnSize }: { button: IButton; buttonType?: EButtonTypes; styles?: React.CSSProperties | UN; needColumnSize?: boolean | UN }) => {
25
16
  return IsValidURL(button.url) ? (
26
17
  <Link href={button.url ?? "#"} style={styles ?? undefined} className={DEFAULT_BUTTON_CLASS(button.columnSize, undefined, button.borderSize, button.background, button.defaultClass, needColumnSize)} key={button.displayOrder ?? 0} type={buttonType ?? EButtonTypes.BUTTON} onClick={(event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => button.onClick?.(event, event.currentTarget as HTMLElement, button.data, button.displayOrder)}>
@@ -16,6 +16,8 @@ import "./../../styles/nexus.loader.css";
16
16
  import "./../../styles/nexus.logic.css";
17
17
  import "./../../styles/nexus.utility.css";
18
18
 
19
+ // import "./../../styles/nexus.grid-view.css";
20
+
19
21
  const inter = Inter({ weight: ["300", "400", "500", "600", "700", "800"], subsets: ["latin"] });
20
22
 
21
23
  export const GlobalLayout = async ({ children, globalLayout }: Readonly<{ children: React.ReactNode; globalLayout: IGlobalLayout }>) => {
@@ -53,6 +55,9 @@ export const GlobalLayout = async ({ children, globalLayout }: Readonly<{ childr
53
55
  {children}
54
56
  <Script type="module" src="https://cdn.jsdelivr.net/npm/ionicons@5.5.2/dist/ionicons/ionicons.esm.js" strategy="lazyOnload"></Script>
55
57
  <Script noModule src="https://cdn.jsdelivr.net/npm/ionicons@5.5.2/dist/ionicons/ionicons.js" strategy="lazyOnload"></Script>
58
+ {
59
+ // <div id="half-mm-grid"></div>
60
+ }
56
61
  </body>
57
62
  </html>
58
63
  );
@@ -11,7 +11,7 @@ import { ProfilePanel } from "./panels/user-panel";
11
11
 
12
12
  export const UtilityMenu = ({ utilityMenus, userPanels, column, paddingRight, globalLayout, iconBoxBackground, hasAccessToken }: Readonly<{ utilityMenus: IUtilityMenu[]; userPanels: IPanelMenu[]; column?: number; paddingRight?: number; globalLayout: IGlobalLayout; iconBoxBackground: EBackgrounds; hasAccessToken?: boolean | UN }>) => {
13
13
  return (
14
- <div style={{ paddingRight: paddingRight ?? 0 }} className={`utilities df fr ac jr h100p col-${column ?? 12}`}>
14
+ <div className={`utilities df fr ac jr h100p pr${paddingRight ?? 0} col-${column ?? 12}`}>
15
15
  {utilityMenus.map((utilityMenu, index) => (
16
16
  <UtilityIcon key={index} utilityMenu={utilityMenu} boxBackground={iconBoxBackground} globalLayout={globalLayout} />
17
17
  ))}
@@ -1,4 +1,70 @@
1
+ import { EBackgroundColors, EBackgrounds, EColorTypes } from "../interfaces/theme-interfaces";
1
2
  import { UN } from "../interfaces/type-interfaces";
3
+ import { GetDynamicColor } from "../services/theme-service";
4
+ import { GetCurrentBaseURL, GetCurrentFullURL, SetDocumentTitleDebounce } from "./browser-helpers";
5
+
6
+ const HOME_PATHS = ["/", "", "/home", "home", "/index", "index"];
7
+
8
+ export interface IMenuDocumentTitle {
9
+ menuUrl?: string;
10
+ menuName: string;
11
+ documentTitle?: string;
12
+ }
13
+
14
+ export interface IFindActiveMenuOptions {
15
+ rootPath?: string;
16
+ defaultMenuUrl?: string;
17
+ }
18
+
19
+ export const SET_BUTTON_ACTIVE_CLASS = (isActive: boolean, element: HTMLElement, overrideBackgroundColor?: EBackgroundColors | UN, overrideBorderColor?: EBackgroundColors | UN, overrideTextColor?: EBackgroundColors | UN, overrideActiveClass?: string | UN) => {
20
+ if (!element) return;
21
+
22
+ if (isActive && overrideBackgroundColor) element.style.setProperty("--ACTIVE_BACKGROUND_COLOR", overrideBackgroundColor);
23
+ if (isActive && overrideBorderColor) element.style.setProperty("--ACTIVE_BORDER_COLOR", overrideBorderColor);
24
+ if (isActive && overrideTextColor) element.style.setProperty("--ACTIVE_TEXT_COLOR", overrideTextColor);
25
+
26
+ if (isActive) element.classList.add(overrideActiveClass ?? "active");
27
+ else element.classList.remove(overrideActiveClass ?? "active");
28
+ };
29
+
30
+ export function FindActiveMenu<T extends IMenuDocumentTitle>(menus: T[], options?: IFindActiveMenuOptions): T | undefined {
31
+ const rootPath = options?.rootPath ?? "";
32
+ const defaultMenuUrl = options?.defaultMenuUrl ?? "/home";
33
+
34
+ const fullUrl = GetCurrentFullURL()?.split("?")[0] ?? "";
35
+ const baseURL = GetCurrentBaseURL() ?? "";
36
+ const url = fullUrl.replace(baseURL, "");
37
+
38
+ const relativePath = rootPath ? (url === rootPath || url === `${rootPath}/` ? "/" : url.startsWith(`${rootPath}/`) ? url.slice(rootPath.length) : url) : url;
39
+ const normalizedRelativePath = relativePath.replace(/^\//, "");
40
+ const isHome = HOME_PATHS.includes(relativePath) || HOME_PATHS.includes(normalizedRelativePath);
41
+
42
+ let activeMenu: T | undefined;
43
+
44
+ if (isHome) {
45
+ activeMenu = rootPath ? menus.find((x) => x.menuUrl === defaultMenuUrl.replace(/^\//, "")) : menus.find((x) => x.menuUrl === defaultMenuUrl);
46
+ } else {
47
+ activeMenu = menus.find((x) => {
48
+ const menuPath = rootPath ? `${rootPath}/${x.menuUrl}` : (x.menuUrl ?? "");
49
+ return url.includes(menuPath) || url.includes(x.menuUrl ?? "");
50
+ });
51
+ }
52
+
53
+ SetDocumentTitleDebounce(activeMenu?.documentTitle ?? activeMenu?.menuName);
54
+ return activeMenu;
55
+ }
56
+
57
+ export const SetSiblingMenuLinkActive = (activeLink: HTMLElement, container: HTMLElement | UN, linkSelector: string, boxBackground: EBackgrounds, activeClass: string = "left-active") => {
58
+ if (!activeLink) return;
59
+
60
+ SET_BUTTON_ACTIVE_CLASS(true, activeLink, GetDynamicColor(boxBackground, EColorTypes.Hover) as EBackgroundColors, null, GetDynamicColor(boxBackground, EColorTypes.Text) as EBackgroundColors, activeClass);
61
+
62
+ const menuContainer = container ?? activeLink.closest("ul");
63
+ const allMenuLinks = menuContainer?.querySelectorAll(linkSelector) ?? [];
64
+ for (const menuLink of allMenuLinks) {
65
+ if (menuLink !== activeLink) SET_BUTTON_ACTIVE_CLASS(false, menuLink as HTMLElement, null, null, null, activeClass);
66
+ }
67
+ };
2
68
 
3
69
  export function RenderChildren<T>(parentContainer: HTMLElement, elementList: HTMLElement[], toggleButton: HTMLElement, activeItem: T | UN, visibleItems: T[], hiddenItems: T[], createItem: (item: T) => HTMLElement, refreshElementClass: (element: HTMLElement, activeItem: T | UN) => void, isInit: boolean, isHiddenItemClicked: boolean, dataUniqueKey: string, dataAttributeKey: string) {
4
70
  if (!isInit) {
@@ -1,4 +1,5 @@
1
1
  import { EIcons } from "./icon-interfaces";
2
+ import { UN } from "./type-interfaces";
2
3
 
3
4
  export const UTILITIES_BUTTON_PREFIX = "btn-utility-";
4
5
  export const GetUtilityMenuCode = (utilityCode: string) => `${UTILITIES_BUTTON_PREFIX}${utilityCode}`;
@@ -14,7 +15,7 @@ export enum EMenuVisibility {
14
15
  }
15
16
  export interface IMenuBase {
16
17
  id?: string | number;
17
- menuVisibilities: EMenuVisibility;
18
+ menuVisibilities: EMenuVisibility | UN;
18
19
  menuName: string;
19
20
  menuCode: string;
20
21
  menuIcon: EIcons;
@@ -34,6 +35,9 @@ export interface IClientMenu extends IMenuBase {
34
35
  pageTitle: string;
35
36
  breadcrumbTitle?: string;
36
37
  }
38
+ export interface IAdminMenu extends IClientMenu {
39
+ parentId?: string | number;
40
+ }
37
41
  export const BUTTON_IDENTITY = (isneedPrefix: boolean) => {
38
42
  const _ = isneedPrefix ? UTILITIES_BUTTON_PREFIX : "";
39
43
  return {
@@ -134,6 +134,8 @@ export const InitializeStyles = () => {
134
134
  const css = `min-width: ${size} ${I}; min-height: ${size} ${I}; max-width: ${size} ${I}; max-height: ${size} ${I};`;
135
135
  _setRule(sheet, `.ib.${k}`, css);
136
136
  });
137
+
138
+ _setVariable(`--TOP_HEIGHT`, `calc(var(--IH) * ${ICON_BOX_SCALES.sm})`);
137
139
  };
138
140
  export const SwitchTheme = (themeCode: string): boolean => {
139
141
  const themeInformations = O.systemThemes;
@@ -3,8 +3,8 @@ import { NextRequest, NextResponse } from "next/server";
3
3
  import { VerifyAccessToken } from "./auth-token-validation";
4
4
  import { DecryptCookieValue, EncryptCookieValue } from "./cookie-encryption";
5
5
  import { GetAuthCookieOptions } from "./redirect-context-helpers";
6
- import { CookieInfo, SSOAuthResponse } from "./sso-interfaces";
7
6
  import { SSO_CONFIG } from "./sso-config";
7
+ import { CookieInfo, SSOAuthResponse } from "./sso-interfaces";
8
8
 
9
9
  export const AUTH_COOKIES = {
10
10
  ssoSession: "sso_session",
@@ -0,0 +1,42 @@
1
+ :root {
2
+ --Border-Size: 0.03rem;
3
+ }
4
+
5
+ #inch-grid,
6
+ #cm-grid,
7
+ #mm-grid,
8
+ #half-mm-grid,
9
+ #quarter-mm-grid {
10
+ position: fixed;
11
+ top: 0;
12
+ left: 0;
13
+ z-index: 1000000;
14
+ width: 100%;
15
+ height: 100vh;
16
+ pointer-events: none;
17
+ }
18
+
19
+ #inch-grid {
20
+ background-image: repeating-linear-gradient(0deg, rgb(200, 200, 200), rgb(200, 200, 200) var(--Border-Size), transparent var(--Border-Size), transparent 1in), repeating-linear-gradient(90deg, rgb(200, 200, 200), rgb(200, 200, 200) var(--Border-Size), transparent var(--Border-Size), transparent 1in);
21
+ background-size: 100% 1in, 1in 1in;
22
+ display: none;
23
+ }
24
+
25
+ #cm-grid {
26
+ background-image: repeating-linear-gradient(0deg, rgb(70, 70, 70), rgb(70, 70, 700) var(--Border-Size), transparent var(--Border-Size), transparent 1cm), repeating-linear-gradient(90deg, rgb(70, 70, 700), rgb(700, 700, 700) var(--Border-Size), transparent var(--Border-Size), transparent 1cm);
27
+ background-size: 100% 1cm, 1cm 1cm;
28
+ }
29
+
30
+ #mm-grid {
31
+ background-image: repeating-linear-gradient(0deg, rgb(200, 200, 200), rgb(200, 200, 200) var(--Border-Size), transparent var(--Border-Size), transparent 1cm), repeating-linear-gradient(90deg, rgb(200, 200, 200), rgb(200, 200, 200) var(--Border-Size), transparent var(--Border-Size), transparent 5mm);
32
+ background-size: 100% 5mm, 5mm 5mm;
33
+ }
34
+ #half-mm-grid {
35
+ background-image: repeating-linear-gradient(0deg, rgb(200, 200, 200), rgb(200, 200, 200) var(--Border-Size), transparent var(--Border-Size), transparent 1cm), repeating-linear-gradient(90deg, rgb(200, 200, 200), rgb(200, 200, 200) var(--Border-Size), transparent var(--Border-Size), transparent 2.5mm);
36
+ background-size: 100% 2.5mm, 2.5mm 2.5mm;
37
+ }
38
+
39
+ #quarter-mm-grid {
40
+ background-image: repeating-linear-gradient(0deg, rgb(200, 200, 200), rgb(200, 200, 200) var(--Border-Size), transparent var(--Border-Size), transparent 1cm), repeating-linear-gradient(90deg, rgb(200, 200, 200), rgb(200, 200, 200) var(--Border-Size), transparent var(--Border-Size), transparent 1.25mm);
41
+ background-size: 100% 1.25mm, 1.25mm 1.25mm;
42
+ }