nexus-shared 1.1.19 → 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.
Files changed (53) hide show
  1. package/package.json +1 -1
  2. package/src/api-services/authentication-service.tsx +23 -0
  3. package/src/api-services/system-service.tsx +24 -316
  4. package/src/client.ts +1 -2
  5. package/src/components/documents/button.tsx +9 -16
  6. package/src/components/documents/icon-box.tsx +1 -1
  7. package/src/components/documents/tab-button.tsx +2 -2
  8. package/src/components/documents/tag.tsx +30 -0
  9. package/src/components/inputs/input-element.tsx +1 -1
  10. package/src/components/inputs/input-form.tsx +2 -2
  11. package/src/components/layouts/global-dialogbox.tsx +5 -9
  12. package/src/components/layouts/global-layout.tsx +8 -0
  13. package/src/components/layouts/layout-helpers.tsx +1 -4
  14. package/src/components/layouts/panels/user-panel.tsx +112 -0
  15. package/src/components/layouts/utility-menu.tsx +9 -29
  16. package/src/components/panels/theme-panel.tsx +2 -2
  17. package/src/helpers/browser-helpers.tsx +48 -3
  18. package/src/helpers/element-helpers.tsx +66 -0
  19. package/src/interface.ts +1 -0
  20. package/src/interfaces/auth-token-interfaces.tsx +6 -0
  21. package/src/interfaces/browser-interfaces.tsx +13 -0
  22. package/src/interfaces/http-interfaces.tsx +0 -3
  23. package/src/interfaces/icon-interfaces.tsx +3 -0
  24. package/src/interfaces/menu-interfaces.tsx +18 -1
  25. package/src/interfaces/storage-interfaces.tsx +1 -0
  26. package/src/interfaces/theme-interfaces.tsx +43 -129
  27. package/src/interfaces/user-interfaces.tsx +30 -0
  28. package/src/nexus.environments.tsx +39 -27
  29. package/src/services/http-services.tsx +6 -6
  30. package/src/services/loader-service.tsx +33 -17
  31. package/src/services/localstorage-service.tsx +23 -6
  32. package/src/services/message-services.tsx +1 -1
  33. package/src/services/theme-service.tsx +32 -16
  34. package/src/services/user-services.tsx +10 -0
  35. package/src/sso-config/auth-token-validation.ts +4 -8
  36. package/src/sso-config/callback-route.tsx +3 -2
  37. package/src/sso-config/cookie-helpers.tsx +47 -22
  38. package/src/sso-config/oauth-callback-state.ts +5 -2
  39. package/src/sso-config/pkce-helpers.ts +2 -9
  40. package/src/sso-config/provider-complete-route.tsx +7 -4
  41. package/src/sso-config/redirect-context-actions.tsx +2 -3
  42. package/src/sso-config/redirect-context-helpers.tsx +20 -5
  43. package/src/sso-config/refresh-route.tsx +5 -4
  44. package/src/sso-config/sign-in-route.tsx +9 -4
  45. package/src/sso-config/sign-out-route.tsx +7 -3
  46. package/src/sso-config/sign-up-route.tsx +14 -3
  47. package/src/sso-config/sso-backend-flow.ts +10 -17
  48. package/src/sso-config/sso-complete-route.tsx +7 -3
  49. package/src/sso-config/sso-config.ts +7 -5
  50. package/src/sso-config/sso-interfaces.tsx +34 -3
  51. package/src/styles/nexus.grid-view.css +42 -0
  52. package/src/styles/nexus.icon.css +1 -0
  53. package/src/styles/nexus.logic.css +34 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexus-shared",
3
- "version": "1.1.19",
3
+ "version": "1.1.21",
4
4
  "description": "Nexus shared React components for Next.js",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -0,0 +1,23 @@
1
+ import { GetSignOutPageURL } from "../helpers/browser-helpers";
2
+ import { BuildProxyApiUrl, EModules, ICurrentUser, IErrorRespose, ISuccessResponse } from "../interface";
3
+ import { HttpGet, HttpPost } from "../services/http-services";
4
+ import { ShowLoader } from "../services/loader-service";
5
+
6
+ export const GetProfileDetails = async (autoRefresh?: boolean): Promise<ICurrentUser | null> => {
7
+ //Profile/Details
8
+ const response = await HttpGet(BuildProxyApiUrl(EModules.Authentication, "Profile/Details"), null, 0);
9
+ if (response?.isSuccess) return response.result as ICurrentUser;
10
+
11
+ if (response?.code === 401 && autoRefresh) {
12
+ const refreshResponse = await RefreshAuthToken();
13
+ if (refreshResponse?.isSuccess) return GetProfileDetails(false);
14
+ else {
15
+ ShowLoader();
16
+ window.location.href = GetSignOutPageURL();
17
+ }
18
+ }
19
+
20
+ return null;
21
+ };
22
+
23
+ export const RefreshAuthToken = async (): Promise<ISuccessResponse | IErrorRespose> => HttpPost("/api/auth/refresh", null, null, null, 0);
@@ -1,321 +1,29 @@
1
- import { EIcons } from "../interfaces/icon-interfaces";
2
- import { EMenuVisibility, IClientMenu, IPanelMenu, IUtilityMenu } from "../interfaces/menu-interfaces";
1
+ "use server";
3
2
 
4
- export const GetClientMenus = async (): Promise<IClientMenu[]> => {
5
- return [
6
- {
7
- id: 1,
8
- menuCode: "home",
9
- menuIcon: EIcons.HOME,
10
- menuName: "Home",
11
- menuUrl: "/home",
12
- documentTitle: "Home Page",
13
- menuVisibilities: EMenuVisibility.GuestOnly | EMenuVisibility.AuthenticatedOnly,
14
- displayOrder: 1,
15
- pageTitle: "Home Page",
16
- breadcrumbTitle: "Home",
17
- },
18
- {
19
- id: 2,
20
- menuCode: "about-me",
21
- menuIcon: EIcons.PERSON,
22
- menuName: "About Me",
23
- menuUrl: "/about-me",
24
- documentTitle: "About Me",
25
- menuVisibilities: EMenuVisibility.GuestOnly | EMenuVisibility.AuthenticatedOnly,
26
- displayOrder: 2,
27
- pageTitle: "About Me",
28
- breadcrumbTitle: "About Me",
29
- },
30
- {
31
- id: 3,
32
- menuCode: "about-us",
33
- menuIcon: EIcons.PERSON,
34
- menuName: "About Us",
35
- menuUrl: "/about-us",
36
- documentTitle: "About Us",
37
- menuVisibilities: EMenuVisibility.GuestOnly | EMenuVisibility.AuthenticatedOnly,
38
- displayOrder: 2,
39
- pageTitle: "About Us",
40
- breadcrumbTitle: "About Us",
41
- },
42
- {
43
- id: 4,
44
- menuCode: "my-projects",
45
- menuIcon: EIcons.BRIEFCASE,
46
- menuName: "My Projects",
47
- menuUrl: "/my-projects",
48
- documentTitle: "My Projects",
49
- menuVisibilities: EMenuVisibility.GuestOnly | EMenuVisibility.AuthenticatedOnly,
50
- displayOrder: 3,
51
- pageTitle: "My Projects",
52
- breadcrumbTitle: "My Projects",
53
- },
54
- {
55
- id: 5,
56
- menuCode: "products",
57
- menuIcon: EIcons.CUBE,
58
- menuName: "My Products",
59
- menuUrl: "/products",
60
- documentTitle: "My Products",
61
- menuVisibilities: EMenuVisibility.GuestOnly | EMenuVisibility.AuthenticatedOnly,
62
- displayOrder: 4,
63
- pageTitle: "My Products",
64
- breadcrumbTitle: "My Products",
65
- },
66
- {
67
- id: 6,
68
- menuCode: "products",
69
- menuIcon: EIcons.CUBE,
70
- menuName: "Our Products",
71
- menuUrl: "/our-products",
72
- documentTitle: "Our Products",
73
- menuVisibilities: EMenuVisibility.GuestOnly | EMenuVisibility.AuthenticatedOnly,
74
- displayOrder: 4,
75
- pageTitle: "Our Products",
76
- breadcrumbTitle: "Our Products",
77
- },
78
- {
79
- id: 7,
80
- menuCode: "blog",
81
- menuIcon: EIcons.NEWSPAPER,
82
- menuName: "Blog",
83
- menuUrl: "/blog",
84
- menuVisibilities: EMenuVisibility.GuestOnly | EMenuVisibility.AuthenticatedOnly,
85
- displayOrder: 5,
86
- pageTitle: "Blog",
87
- breadcrumbTitle: "Blog",
88
- documentTitle: "Blog",
89
- },
90
- {
91
- id: 8,
92
- menuCode: "portfolio-gallery",
93
- menuIcon: EIcons.IMAGES,
94
- menuName: "Portfolio Gallery",
95
- menuUrl: "/portfolio-gallery",
96
- documentTitle: "Portfolio Gallery",
97
- menuVisibilities: EMenuVisibility.GuestOnly | EMenuVisibility.AuthenticatedOnly,
98
- displayOrder: 6,
99
- pageTitle: "Portfolio Gallery",
100
- breadcrumbTitle: "Portfolio Gallery",
101
- },
102
- {
103
- id: 9,
104
- menuCode: "our-gallery",
105
- menuIcon: EIcons.IMAGES,
106
- menuName: "Our Gallery",
107
- menuUrl: "/our-gallery",
108
- documentTitle: "Our Gallery",
109
- menuVisibilities: EMenuVisibility.GuestOnly | EMenuVisibility.AuthenticatedOnly,
110
- displayOrder: 6,
111
- pageTitle: "Our Gallery",
112
- breadcrumbTitle: "Our Gallery",
113
- },
114
- {
115
- id: 10,
116
- menuCode: "services",
117
- menuIcon: EIcons.CONSTRUCT,
118
- menuName: "Services",
119
- menuUrl: "/services",
120
- documentTitle: "Services",
121
- menuVisibilities: EMenuVisibility.GuestOnly | EMenuVisibility.AuthenticatedOnly,
122
- displayOrder: 7,
123
- pageTitle: "Services",
124
- breadcrumbTitle: "Services",
125
- },
126
- {
127
- id: 11,
128
- menuCode: "faq",
129
- menuIcon: EIcons.HELP_CIRCLE,
130
- menuName: "FAQ",
131
- menuUrl: "/faq",
132
- documentTitle: "FAQ",
133
- menuVisibilities: EMenuVisibility.GuestOnly | EMenuVisibility.AuthenticatedOnly,
134
- displayOrder: 8,
135
- pageTitle: "FAQ",
136
- breadcrumbTitle: "FAQ",
137
- },
138
- {
139
- id: 12,
140
- menuCode: "contact-me",
141
- menuIcon: EIcons.CALL,
142
- menuName: "Contact Me",
143
- menuUrl: "/contact-me",
144
- documentTitle: "Contact Me",
145
- menuVisibilities: EMenuVisibility.GuestOnly | EMenuVisibility.AuthenticatedOnly,
146
- displayOrder: 9,
147
- pageTitle: "Contact Me",
148
- breadcrumbTitle: "Contact Me",
149
- },
150
- {
151
- id: 13,
152
- menuCode: "contact-us",
153
- menuIcon: EIcons.CALL,
154
- menuName: "Contact Us",
155
- menuUrl: "/contact-us",
156
- documentTitle: "Contact Us",
157
- menuVisibilities: EMenuVisibility.GuestOnly | EMenuVisibility.AuthenticatedOnly,
158
- displayOrder: 9,
159
- pageTitle: "Contact Us",
160
- breadcrumbTitle: "Contact Us",
161
- },
162
- ];
163
- };
3
+ import { IThemeInformation } from "../interface";
4
+ import { EMenuTargets, IPanelMenu, IUtilityMenu } from "../interfaces/menu-interfaces";
5
+ import { APIS, NEXUS_CONFIG, NEXUS_INFO } from "../nexus.environments";
6
+ import { HttpGet } from "../services/http-services";
7
+
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;
164
13
 
165
- export const GetUtilityMenus = async (): Promise<IUtilityMenu[]> => {
166
- return [
167
- {
168
- id: 1,
169
- menuCode: "root-search",
170
- menuIcon: EIcons.SEARCH,
171
- menuName: "Search",
172
- menuVisibilities: EMenuVisibility.AuthenticatedOnly | EMenuVisibility.GuestOnly,
173
- displayOrder: 1,
174
- },
175
- {
176
- id: 2,
177
- menuCode: "favorite-menu",
178
- menuIcon: EIcons.HEART,
179
- menuName: "Favorite",
180
- menuVisibilities: EMenuVisibility.AuthenticatedOnly | EMenuVisibility.GuestOnly,
181
- displayOrder: 2,
182
- },
183
- {
184
- id: 3,
185
- menuCode: "cart-menu",
186
- menuIcon: EIcons.CART,
187
- menuName: "Cart",
188
- menuVisibilities: EMenuVisibility.AuthenticatedOnly | EMenuVisibility.GuestOnly,
189
- displayOrder: 3,
190
- },
191
- {
192
- id: 4,
193
- menuCode: "switch-theme",
194
- menuIcon: EIcons.COLOR_PALETTE,
195
- menuName: "Theme",
196
- menuVisibilities: EMenuVisibility.AuthenticatedOnly | EMenuVisibility.GuestOnly,
197
- displayOrder: 4,
198
- },
199
- {
200
- id: 5,
201
- menuCode: "mega-menu",
202
- menuIcon: EIcons.GRID,
203
- menuName: "Mega Menu",
204
- menuVisibilities: EMenuVisibility.AuthenticatedOnly | EMenuVisibility.GuestOnly,
205
- displayOrder: 5,
206
- },
207
- ];
14
+ export const GetUtilityMenusAsync = async (): Promise<IUtilityMenu[]> => {
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);
16
+ if (!response.isSuccess) return [];
17
+ return response.result as IUtilityMenu[];
208
18
  };
209
19
 
210
- export const GetUserPanels = async (): Promise<IPanelMenu[]> => {
211
- return [
212
- {
213
- id: 1,
214
- menuCode: "message-menu",
215
- menuIcon: EIcons.MAIL,
216
- menuName: "Messages",
217
- menuVisibilities: EMenuVisibility.AuthenticatedOnly,
218
- displayOrder: 1,
219
- groupOrder: 1,
220
- },
221
- {
222
- id: 2,
223
- menuCode: "notification-menu",
224
- menuIcon: EIcons.NOTIFICATIONS,
225
- menuName: "Notifications",
226
- menuVisibilities: EMenuVisibility.AuthenticatedOnly,
227
- displayOrder: 2,
228
- groupOrder: 1,
229
- },
230
- {
231
- id: 3,
232
- menuCode: "switch-theme",
233
- menuIcon: EIcons.COLOR_PALETTE,
234
- menuName: "Theme Mode",
235
- menuVisibilities: EMenuVisibility.AuthenticatedOnly | EMenuVisibility.GuestOnly,
236
- displayOrder: 2,
237
- groupOrder: 2,
238
- },
239
- {
240
- id: 4,
241
- menuCode: "language",
242
- menuIcon: EIcons.LANGUAGE,
243
- menuName: "Language",
244
- menuVisibilities: EMenuVisibility.AuthenticatedOnly | EMenuVisibility.GuestOnly,
245
- displayOrder: 2,
246
- groupOrder: 2,
247
- },
248
- {
249
- id: 5,
250
- menuCode: "currency",
251
- menuIcon: EIcons.CASH,
252
- menuName: "Currency Format",
253
- menuVisibilities: EMenuVisibility.AuthenticatedOnly | EMenuVisibility.GuestOnly,
254
- displayOrder: 2,
255
- groupOrder: 2,
256
- },
257
- {
258
- id: 6,
259
- menuCode: "calendar-date",
260
- menuIcon: EIcons.CALENDAR,
261
- menuName: "Calendar Date",
262
- menuVisibilities: EMenuVisibility.AuthenticatedOnly | EMenuVisibility.GuestOnly,
263
- displayOrder: 2,
264
- groupOrder: 2,
265
- },
266
- {
267
- id: 7,
268
- menuCode: "help-support",
269
- menuIcon: EIcons.HELP_CIRCLE,
270
- menuName: "Help & Support",
271
- menuVisibilities: EMenuVisibility.AuthenticatedOnly | EMenuVisibility.GuestOnly,
272
- displayOrder: 2,
273
- groupOrder: 2,
274
- },
275
- {
276
- id: 8,
277
- menuCode: "settings",
278
- menuIcon: EIcons.SETTINGS,
279
- menuName: "Account Settings",
280
- menuVisibilities: EMenuVisibility.AuthenticatedOnly,
281
- displayOrder: 3,
282
- groupOrder: 3,
283
- },
284
- {
285
- id: 9,
286
- menuCode: "switch-branch",
287
- menuIcon: EIcons.REPEAT,
288
- menuName: "Switch Branch",
289
- menuVisibilities: EMenuVisibility.AuthenticatedOnly,
290
- displayOrder: 3,
291
- groupOrder: 3,
292
- },
293
- {
294
- id: 10,
295
- menuCode: "switch-fiscal-year",
296
- menuIcon: EIcons.CALENDAR,
297
- menuName: "Switch Fiscal Year",
298
- menuVisibilities: EMenuVisibility.AuthenticatedOnly,
299
- displayOrder: 3,
300
- groupOrder: 3,
301
- },
302
- {
303
- id: 11,
304
- menuCode: "sign-out",
305
- menuIcon: EIcons.EXIT,
306
- menuName: "Sign Out",
307
- menuVisibilities: EMenuVisibility.AuthenticatedOnly,
308
- displayOrder: 3,
309
- groupOrder: 3,
310
- },
311
- {
312
- id: 12,
313
- menuCode: "sign-in",
314
- menuIcon: EIcons.LOGIN,
315
- menuName: "Sign In",
316
- menuVisibilities: EMenuVisibility.GuestOnly,
317
- displayOrder: 3,
318
- groupOrder: 3,
319
- },
320
- ];
20
+ export const GetUserPanelsAsync = async (): Promise<IPanelMenu[]> => {
21
+ const response = await HttpGet(`${APIS.CONFIGURATION}/Resources/PanelMenus/${NEXUS_INFO.CURRENT_MODULE}/${NEXUS_INFO.IS_ADMIN_MODULE ? EMenuTargets.AdminModule : EMenuTargets.ClientModule}/${TOKEN_GLOBAL_PANEL_MENU}`, null, NEXUS_CONFIG.DEFAULT_REVALIDATE_TIME_ONE_DAY);
22
+ if (!response.isSuccess) return [];
23
+ return response.result as IPanelMenu[];
24
+ };
25
+ export const GetSystemThemesAsync = async (): Promise<IThemeInformation[]> => {
26
+ const response = await HttpGet(`${APIS.CONFIGURATION}/Resources/Themes/${TOKEN_GLOBAL_THEMES}`, null, NEXUS_CONFIG.DEFAULT_REVALIDATE_TIME_ONE_DAY);
27
+ if (!response.isSuccess) return [];
28
+ return response.result as IThemeInformation[];
321
29
  };
package/src/client.ts CHANGED
@@ -24,9 +24,8 @@ export * from "./helpers/browser-helpers";
24
24
  export * from "./services/http-client-services";
25
25
  export * from "./services/loader-service";
26
26
  export * from "./services/localstorage-service";
27
+ export * from "./services/user-services";
27
28
  export * from "./services/message-services";
28
29
  export * from "./services/theme-service";
29
30
  // Core
30
31
  export * from "./nexus-client";
31
- export * from "./proxy-api-client";
32
- export * from "./sso-client";
@@ -1,33 +1,26 @@
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
- import { EIconTypes } from "../../interfaces/icon-interfaces";
7
- import { COLUMN_SIZE_ATTRIBUTE_KEY, EFlexPositions, EOpacity, ESizes } from "../../interfaces/layout-interfaces";
8
+ import { DEFAULT_ICON_SIZE, EIconTypes } from "../../interfaces/icon-interfaces";
9
+ import { COLUMN_SIZE_ATTRIBUTE_KEY, EFlexPositions, EOpacity } from "../../interfaces/layout-interfaces";
8
10
  import { EBackgroundColors, EBackgrounds } from "../../interfaces/theme-interfaces";
9
11
  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, overrideColor?: EBackgroundColors | null, overrideActive?: string) => {
14
- if (!element) return;
15
-
16
- if (overrideColor) element.style.setProperty("--ACTIVE_BORDER_COLOR", overrideColor);
17
-
18
- if (isActive) element.classList.add(overrideActive ?? "active");
19
- else element.classList.remove(overrideActive ?? "active");
20
- };
21
-
22
15
  export const Button = ({ button, buttonType, styles, needColumnSize }: { button: IButton; buttonType?: EButtonTypes; styles?: React.CSSProperties | UN; needColumnSize?: boolean | UN }) => {
23
16
  return IsValidURL(button.url) ? (
24
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)}>
25
- {button.icon && <Icon icon={button.icon} type={button.iconType ?? EIconTypes.FILLED} opacity={EOpacity.O08} size={ESizes.Small} defaultClass="mr4" />}
18
+ {button.icon && <Icon icon={button.icon} type={button.iconType ?? EIconTypes.OUTLINED} opacity={EOpacity.O08} size={button.iconSize ?? DEFAULT_ICON_SIZE} defaultClass="mr4" />}
26
19
  <span>{button.label instanceof Function ? button.label(button.data) : button.label}</span>
27
20
  </Link>
28
21
  ) : (
29
- <button style={styles ?? undefined} className={DEFAULT_BUTTON_CLASS(button.columnSize, undefined, button.borderSize, button.background, button.defaultClass, needColumnSize)} key={button.displayOrder} type={buttonType ?? EButtonTypes.BUTTON} onClick={(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => button.onClick?.(event, event.currentTarget as HTMLElement, button.data, button.displayOrder)}>
30
- {button.icon && <Icon icon={button.icon} type={button.iconType ?? EIconTypes.FILLED} opacity={EOpacity.O08} size={ESizes.Small} defaultClass="mr4" />}
22
+ <button style={styles ?? { minHeight: "var(--IH)" }} className={DEFAULT_BUTTON_CLASS(button.columnSize, undefined, button.borderSize, button.background, button.defaultClass, needColumnSize)} key={button.displayOrder} type={buttonType ?? EButtonTypes.BUTTON} onClick={(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => button.onClick?.(event, event.currentTarget as HTMLElement, button.data, button.displayOrder)}>
23
+ {button.icon && <Icon icon={button.icon} type={button.iconType ?? EIconTypes.OUTLINED} opacity={EOpacity.O08} size={button.iconSize ?? DEFAULT_ICON_SIZE} defaultClass="mr4" />}
31
24
  <span>{button.label instanceof Function ? button.label(button.data) : button.label}</span>
32
25
  </button>
33
26
  );
@@ -36,7 +29,7 @@ export const CreateButton = (param: IButton, parent?: HTMLElement | UN, styles?:
36
29
  const button = document.createElement(param.url ? "a" : "button");
37
30
  button.setAttribute(COLUMN_SIZE_ATTRIBUTE_KEY, (param.columnSize ?? 12).toString());
38
31
  if (param.icon) {
39
- const icon = CreateIcon(param.icon, button, param.iconType, param.iconSize ?? ESizes.Small, null, null);
32
+ const icon = CreateIcon(param.icon, button, param.iconType ?? EIconTypes.OUTLINED, param.iconSize ?? DEFAULT_ICON_SIZE, null, null);
40
33
  icon.classList.add("mr4");
41
34
  }
42
35
 
@@ -90,4 +90,4 @@ export const CreateIconBox = (icon: EIcons, parent?: HTMLElement | UN, children?
90
90
  return iconBox;
91
91
  };
92
92
 
93
- export const CreateToggleButton = (parentElement?: HTMLElement | null, children?: HTMLElement | UN, id?: string, boxSize?: ESizes | null, iconSize?: ESizes | null, opacity?: EOpacity | UN, iconType?: EIconTypes | null, boxBackground?: EBackgrounds) => CreateIconBox(EIcons.ELLIPSIS_HORIZONTAL, parentElement, children, id, iconType, boxBackground, boxSize, iconSize, `h ${boxBackground ?? NEXUS_CONFIG.DEFAULT_BACKGROUND} ml5`, "r90");
93
+ export const CreateToggleButton = (parentElement?: HTMLElement | null, children?: HTMLElement | UN, id?: string | UN, boxSize?: ESizes | null, iconSize?: ESizes | null, opacity?: EOpacity | UN, iconType?: EIconTypes | null, boxBackground?: EBackgrounds) => CreateIconBox(EIcons.ELLIPSIS_HORIZONTAL, parentElement, children, id, iconType, boxBackground, boxSize, iconSize, `h ${boxBackground ?? NEXUS_CONFIG.DEFAULT_BACKGROUND} ml5`, "r90");
@@ -123,7 +123,7 @@ export const TabButtons = ({ buttons, activeButton, onClicked }: { buttons: IBut
123
123
 
124
124
  for (const btn of visibleItems) {
125
125
  if (active && active.id && btn.id === active.id) {
126
- btn.iconType = EIconTypes.FILLED;
126
+ btn.iconType = EIconTypes.OUTLINED;
127
127
  btn.defaultClass = "btn active jc r";
128
128
  } else btn.defaultClass = `jc r ${NEXUS_CONFIG.DEFAULT_BACKGROUND}`;
129
129
  }
@@ -157,7 +157,7 @@ export const TabButtons = ({ buttons, activeButton, onClicked }: { buttons: IBut
157
157
  ))}
158
158
 
159
159
  {tabButtons.hiddenButtons && (
160
- <Iconbox defaultClass="ml5" icon={EIcons.ELLIPSIS_HORIZONTAL} iconType={EIconTypes.FILLED} iconDefaultClass="r90" id={THEME_MENU_ELIPSE_BTN_ID}>
160
+ <Iconbox defaultClass="ml5" icon={EIcons.ELLIPSIS_HORIZONTAL} iconType={EIconTypes.OUTLINED} iconDefaultClass="r90" id={THEME_MENU_ELIPSE_BTN_ID}>
161
161
  <GlobalDialogbox defaultPadding={0} iggnoreChildClick={false} buttonIdentity={THEME_MENU_ELIPSE_BTN_ID} position={EPositions.Right}>
162
162
  <Buttons buttons={tabButtons.hiddenButtons} />
163
163
  </GlobalDialogbox>
@@ -0,0 +1,30 @@
1
+ import { CSSProperties } from "react";
2
+ import { EBackgrounds, EOpacity, EUserRoles, UN } from "../../interface";
3
+
4
+ export const GlobalTag = ({ value, background, isSmall, defaultClass, fontOpacity }: { value: string; background?: EBackgrounds; isSmall?: boolean; defaultClass?: string; fontOpacity?: EOpacity }) => {
5
+ isSmall = isSmall ?? true;
6
+ const style = { width: "fit-content" } as CSSProperties;
7
+ if (isSmall) style.minHeight = "1.2rem";
8
+ return (
9
+ <small style={style} className={`pr3 pl3 r pr item nw ${fontOpacity ?? EOpacity.O08} ${isSmall ? "fs-07" : "p1"} ${defaultClass ?? ""} df ac jc ${background ?? EBackgrounds.ThemeColor600}`}>
10
+ {value}
11
+ </small>
12
+ );
13
+ };
14
+ export function GetUserRoleTag(role: string | EUserRoles | UN, isShort?: boolean, defaultClass?: string): React.JSX.Element {
15
+ const status = role?.toString();
16
+
17
+ switch (status) {
18
+ case "3":
19
+ case "SuperAdmin":
20
+ return <GlobalTag isSmall={true} value={isShort ? "SA" : "Super"} defaultClass={defaultClass} />;
21
+ case "2":
22
+ case "Admin":
23
+ return <GlobalTag isSmall={true} value={isShort ? "A" : "Admin"} defaultClass={defaultClass} />;
24
+ case "1":
25
+ case "User":
26
+ return <GlobalTag isSmall={true} value={isShort ? "U" : "User"} defaultClass={defaultClass} />;
27
+ default:
28
+ return <GlobalTag isSmall={true} value={isShort ? "G" : "Guest"} defaultClass={defaultClass} />;
29
+ }
30
+ }
@@ -56,7 +56,7 @@ export const CreateInputButton = (param: ISubmitbutton, parentElement: HTMLEleme
56
56
  const span = document.createElement("span");
57
57
  span.textContent = value;
58
58
  span.classList.add("nw", "toh", "fs-10", "fw-600");
59
- const icon = CreateIconBox(iconParam.icon, button, null, null, iconParam.type ?? EIconTypes.FILLED, iconParam.background ?? param.background ?? EBackgrounds.None, iconParam.boxSize, iconParam.iconSize, null, null, null, null, iconParam.opacity, null, null, null, null, iconParam.onClicked, iconParam.onMouseEnter);
59
+ const icon = CreateIconBox(iconParam.icon, button, null, null, iconParam.type ?? EIconTypes.OUTLINED, iconParam.background ?? param.background ?? EBackgrounds.None, iconParam.boxSize, iconParam.iconSize, null, null, null, null, iconParam.opacity, null, null, null, null, iconParam.onClicked, iconParam.onMouseEnter);
60
60
  icon.classList.add("mr3");
61
61
  button.appendChild(span);
62
62
  } else button.innerText = value;
@@ -94,7 +94,7 @@ export const CreateSubmitForm = (param: ISubmitForm, parentIdentifier: HTMLEleme
94
94
  rowGap = rowGap ?? DEFAULT_ROW_GAP;
95
95
  const PADDING = rowGap * 2;
96
96
 
97
- const buttonParam = GetButton("Submit", null, null, EIcons.SAVE, null, null, EBackgrounds.PrimaryColor, DEFAULT_BUTTON_CLASS, null, EIconTypes.FILLED, null, 0, null, EButtonTypes.SUBMIT);
97
+ const buttonParam = GetButton("Submit", null, null, EIcons.SAVE, null, null, EBackgrounds.PrimaryColor, DEFAULT_BUTTON_CLASS, null, EIconTypes.OUTLINED, null, 0, null, EButtonTypes.SUBMIT);
98
98
  const buttonContainer = document.createElement("div");
99
99
  buttonContainer.className = `df ac pt1 pb5 ${buttonPosition} bb pr${PADDING} pl${PADDING}`;
100
100
  buttonContainer.style.minHeight = "calc(var(--IH) * 1.5)";
@@ -103,7 +103,7 @@ export const CreateSubmitForm = (param: ISubmitForm, parentIdentifier: HTMLEleme
103
103
  CreateButton(buttonParam, buttonContainer, buttonStyle, false);
104
104
 
105
105
  if (param.onCancelClick) {
106
- const buttonParam = GetButton("Cancel", null, null, EIcons.CLOSE, param.onCancelClick, null, EBackgrounds.ErrorColor, DEFAULT_BUTTON_CLASS + ` ml${PADDING}`, null, EIconTypes.FILLED, null, 0, null, EButtonTypes.BUTTON);
106
+ const buttonParam = GetButton("Cancel", null, null, EIcons.CLOSE, param.onCancelClick, null, EBackgrounds.ErrorColor, DEFAULT_BUTTON_CLASS + ` ml${PADDING}`, null, EIconTypes.OUTLINED, null, 0, null, EButtonTypes.BUTTON);
107
107
  CreateButton(buttonParam, buttonContainer, buttonStyle, false);
108
108
  }
109
109
  }
@@ -1,4 +1,4 @@
1
- 'use client';
1
+ "use client";
2
2
 
3
3
  import React, { useEffect } from "react";
4
4
  import { ConvertRemToPixels, IsKeyPressed } from "../../helpers/browser-helpers";
@@ -17,7 +17,7 @@ export const DEFAULT_DIALOGBOX_HOVER_EFFECT_DELAY = 500;
17
17
  interface IDialogRegistryEntry {
18
18
  triggerElement: HTMLElement;
19
19
  affectedElement: HTMLElement;
20
- iggnoreChildClick?: boolean;
20
+ iggnoreChildClick?: boolean | UN;
21
21
  close: (isInitial: boolean) => void;
22
22
  }
23
23
 
@@ -32,12 +32,7 @@ let globalDocumentClickTimeout: ReturnType<typeof setTimeout>;
32
32
  const shouldKeepDialogOpen = (entry: IDialogRegistryEntry, path: EventTarget[], target: HTMLElement) => {
33
33
  if (entry.iggnoreChildClick === false) return target === entry.triggerElement;
34
34
 
35
- return (
36
- path.includes(entry.triggerElement) ||
37
- path.includes(entry.affectedElement) ||
38
- isClickInsideOpenNestedDialog(entry.triggerElement, path) ||
39
- entry.triggerElement.contains(target)
40
- );
35
+ return path.includes(entry.triggerElement) || path.includes(entry.affectedElement) || isClickInsideOpenNestedDialog(entry.triggerElement, path) || entry.triggerElement.contains(target);
41
36
  };
42
37
 
43
38
  const isClickInsideOpenNestedDialog = (parentTrigger: HTMLElement, path: EventTarget[]) => {
@@ -169,7 +164,7 @@ export const GlobalDialogbox = ({ children, hoverEffectDelay, position, buttonId
169
164
  return <ul id={GetDialogId(buttonIdentity)}>{isVisible && children}</ul>;
170
165
  };
171
166
 
172
- export const InitializeDialogbox = (triggerElement: HTMLElement, affectedElement: HTMLElement, hoverEffectDelay?: number | boolean, defaultHeight?: string, defaultPadding?: number, defaultWidth?: number, background?: EBackgrounds, onVisibilityChanged?: (isVisible: boolean) => void, onDisposed?: () => void, iggnoreChildClick?: boolean, position?: EPositions, defaultClass?: string, preferTopWhenEnoughSpace?: boolean, targetInput?: HTMLTextAreaElement | HTMLInputElement | UN, isAutoHideInInitialization?: boolean): IDialogboxResults | null => {
167
+ export const InitializeDialogbox = (triggerElement: HTMLElement, affectedElement: HTMLElement, hoverEffectDelay?: number | boolean | UN, defaultHeight?: string | UN, defaultPadding?: number | UN, defaultWidth?: number | UN, background?: EBackgrounds | UN, onVisibilityChanged?: (isVisible: boolean) => void | UN, onDisposed?: () => void | UN, iggnoreChildClick?: boolean | UN, position?: EPositions | UN, defaultClass?: string | UN, preferTopWhenEnoughSpace?: boolean | UN, targetInput?: HTMLTextAreaElement | HTMLInputElement | UN, isAutoHideInInitialization?: boolean | UN): IDialogboxResults | null => {
173
168
  if (!triggerElement || !affectedElement) return null;
174
169
  defaultHeight = defaultHeight ?? "auto";
175
170
  defaultPadding = defaultPadding ?? 5;
@@ -331,6 +326,7 @@ export const InitializeDialogbox = (triggerElement: HTMLElement, affectedElement
331
326
  unregisterDialog(triggerElement);
332
327
  onDisposed?.();
333
328
  };
329
+ // @ts-ignore
334
330
  let visibilityTimeout: NodeJS.Timeout;
335
331
  const visibility = (visible: boolean, isInitial: boolean) => {
336
332
  const isVisible = visible;
@@ -6,6 +6,7 @@ import { IGlobalLayout, ROOT_LOADER_IDENTITY } from "../../interfaces/layout-int
6
6
  import { FILES } from "../../nexus.environments";
7
7
  import { LayoutHelpers } from "./layout-helpers";
8
8
 
9
+ import { GetSystemThemesAsync } from "../../api-services/system-service";
9
10
  import "./../../styles/nexus.animation.css";
10
11
  import "./../../styles/nexus.core.css";
11
12
  import "./../../styles/nexus.dialog.css";
@@ -15,9 +16,13 @@ import "./../../styles/nexus.loader.css";
15
16
  import "./../../styles/nexus.logic.css";
16
17
  import "./../../styles/nexus.utility.css";
17
18
 
19
+ // import "./../../styles/nexus.grid-view.css";
20
+
18
21
  const inter = Inter({ weight: ["300", "400", "500", "600", "700", "800"], subsets: ["latin"] });
19
22
 
20
23
  export const GlobalLayout = async ({ children, globalLayout }: Readonly<{ children: React.ReactNode; globalLayout: IGlobalLayout }>) => {
24
+ const systemThemes = await GetSystemThemesAsync();
25
+ globalLayout.systemThemes = systemThemes;
21
26
  return (
22
27
  <html lang="en">
23
28
  <head>
@@ -50,6 +55,9 @@ export const GlobalLayout = async ({ children, globalLayout }: Readonly<{ childr
50
55
  {children}
51
56
  <Script type="module" src="https://cdn.jsdelivr.net/npm/ionicons@5.5.2/dist/ionicons/ionicons.esm.js" strategy="lazyOnload"></Script>
52
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
+ }
53
61
  </body>
54
62
  </html>
55
63
  );
@@ -3,15 +3,12 @@
3
3
  import { useEffect } from "react";
4
4
  import { RemoveElement } from "../../helpers/browser-helpers";
5
5
  import { IGlobalLayout, ROOT_LOADER_IDENTITY } from "../../interfaces/layout-interfaces";
6
- import { DEFAULT_THEME_INFORMATIONS } from "../../interfaces/theme-interfaces";
7
6
  import { O } from "../../nexus-client";
8
7
  import { InitializeStyles } from "../../services/theme-service";
9
8
 
10
9
  export const LayoutHelpers = ({ globalLayout }: Readonly<{ globalLayout: IGlobalLayout }>) => {
11
10
  useEffect(() => {
12
- globalLayout.systemThemes = DEFAULT_THEME_INFORMATIONS;
13
- O.systemThemes = DEFAULT_THEME_INFORMATIONS;
14
-
11
+ O.systemThemes = globalLayout.systemThemes;
15
12
  const timeout = setTimeout(() => {
16
13
  clearTimeout(timeout);
17
14
  RemoveElement(ROOT_LOADER_IDENTITY, 500);