nexus-shared 1.1.20 → 2.0.0

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 (332) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +903 -0
  3. package/dist/Client.Index.d.ts +44 -0
  4. package/dist/Client.Index.js +49 -0
  5. package/dist/Components/Documents/Button.d.ts +29 -0
  6. package/dist/Components/Documents/Button.js +11 -0
  7. package/dist/Components/Documents/Menu.d.ts +102 -0
  8. package/dist/Components/Documents/Menu.js +238 -0
  9. package/dist/Components/Documents/SplitButton.d.ts +64 -0
  10. package/dist/Components/Documents/SplitButton.js +127 -0
  11. package/dist/Components/Documents/TabButtons.d.ts +62 -0
  12. package/dist/Components/Documents/TabButtons.js +19 -0
  13. package/dist/Components/Forms/ApiForm.d.ts +21 -0
  14. package/dist/Components/Forms/ApiForm.js +99 -0
  15. package/dist/Components/Forms/Crud.d.ts +17 -0
  16. package/dist/Components/Forms/Crud.js +556 -0
  17. package/dist/Components/Forms/CrudParts.d.ts +15 -0
  18. package/dist/Components/Forms/CrudParts.js +36 -0
  19. package/dist/Components/Forms/Form.d.ts +52 -0
  20. package/dist/Components/Forms/Form.js +319 -0
  21. package/dist/Components/Forms/SubmitForm.d.ts +65 -0
  22. package/dist/Components/Forms/SubmitForm.js +198 -0
  23. package/dist/Components/Inputs/Calendar.d.ts +69 -0
  24. package/dist/Components/Inputs/Calendar.js +258 -0
  25. package/dist/Components/Inputs/CheckBox.d.ts +53 -0
  26. package/dist/Components/Inputs/CheckBox.js +87 -0
  27. package/dist/Components/Inputs/CheckBoxGroup.d.ts +20 -0
  28. package/dist/Components/Inputs/CheckBoxGroup.js +80 -0
  29. package/dist/Components/Inputs/ChoiceField.d.ts +122 -0
  30. package/dist/Components/Inputs/ChoiceField.js +169 -0
  31. package/dist/Components/Inputs/DatePicker.d.ts +54 -0
  32. package/dist/Components/Inputs/DatePicker.js +246 -0
  33. package/dist/Components/Inputs/DateRangePicker.d.ts +62 -0
  34. package/dist/Components/Inputs/DateRangePicker.js +283 -0
  35. package/dist/Components/Inputs/DateTimePicker.d.ts +75 -0
  36. package/dist/Components/Inputs/DateTimePicker.js +399 -0
  37. package/dist/Components/Inputs/Dropdown.d.ts +117 -0
  38. package/dist/Components/Inputs/Dropdown.js +839 -0
  39. package/dist/Components/Inputs/DropdownParts.d.ts +84 -0
  40. package/dist/Components/Inputs/DropdownParts.js +102 -0
  41. package/dist/Components/Inputs/EditorShell.d.ts +45 -0
  42. package/dist/Components/Inputs/EditorShell.js +214 -0
  43. package/dist/Components/Inputs/Field.d.ts +53 -0
  44. package/dist/Components/Inputs/Field.js +16 -0
  45. package/dist/Components/Inputs/GroupForm.d.ts +20 -0
  46. package/dist/Components/Inputs/GroupForm.js +170 -0
  47. package/dist/Components/Inputs/InputField.d.ts +59 -0
  48. package/dist/Components/Inputs/InputField.js +169 -0
  49. package/dist/Components/Inputs/InputRenderer.d.ts +35 -0
  50. package/dist/Components/Inputs/InputRenderer.js +99 -0
  51. package/dist/Components/Inputs/MarkdownEditor.d.ts +67 -0
  52. package/dist/Components/Inputs/MarkdownEditor.js +289 -0
  53. package/dist/Components/Inputs/NumberBox.d.ts +53 -0
  54. package/dist/Components/Inputs/NumberBox.js +228 -0
  55. package/dist/Components/Inputs/RadioGroup.d.ts +20 -0
  56. package/dist/Components/Inputs/RadioGroup.js +43 -0
  57. package/dist/Components/Inputs/ReadOnlyNotice.d.ts +36 -0
  58. package/dist/Components/Inputs/ReadOnlyNotice.js +116 -0
  59. package/dist/Components/Inputs/RichTextEditor.d.ts +103 -0
  60. package/dist/Components/Inputs/RichTextEditor.js +1170 -0
  61. package/dist/Components/Inputs/RichTextParts.d.ts +63 -0
  62. package/dist/Components/Inputs/RichTextParts.js +157 -0
  63. package/dist/Components/Inputs/RowsInput.d.ts +104 -0
  64. package/dist/Components/Inputs/RowsInput.js +259 -0
  65. package/dist/Components/Inputs/Slider.d.ts +87 -0
  66. package/dist/Components/Inputs/Slider.js +216 -0
  67. package/dist/Components/Inputs/TabularForm.d.ts +23 -0
  68. package/dist/Components/Inputs/TabularForm.js +283 -0
  69. package/dist/Components/Inputs/TextArea.d.ts +43 -0
  70. package/dist/Components/Inputs/TextArea.js +31 -0
  71. package/dist/Components/Inputs/TextBox.d.ts +52 -0
  72. package/dist/Components/Inputs/TextBox.js +58 -0
  73. package/dist/Components/Inputs/TextField.d.ts +31 -0
  74. package/dist/Components/Inputs/TextField.js +35 -0
  75. package/dist/Components/Inputs/TimePanel.d.ts +34 -0
  76. package/dist/Components/Inputs/TimePanel.js +288 -0
  77. package/dist/Components/Inputs/TimePicker.d.ts +54 -0
  78. package/dist/Components/Inputs/TimePicker.js +239 -0
  79. package/dist/Components/Inputs/TreeView.d.ts +160 -0
  80. package/dist/Components/Inputs/TreeView.js +947 -0
  81. package/dist/Components/Layouts/MessageBox.d.ts +71 -0
  82. package/dist/Components/Layouts/MessageBox.js +104 -0
  83. package/dist/Components/Layouts/Popup.d.ts +92 -0
  84. package/dist/Components/Layouts/Popup.js +376 -0
  85. package/dist/Components/Layouts/PopupContext.d.ts +2 -0
  86. package/dist/Components/Layouts/PopupContext.js +4 -0
  87. package/dist/Components/Layouts/PopupDock.d.ts +22 -0
  88. package/dist/Components/Layouts/PopupDock.js +121 -0
  89. package/dist/Components/Layouts/PopupHost.d.ts +56 -0
  90. package/dist/Components/Layouts/PopupHost.js +163 -0
  91. package/dist/Components/Layouts/PopupRules.d.ts +30 -0
  92. package/dist/Components/Layouts/PopupRules.js +63 -0
  93. package/dist/Components/Layouts/ThemePicker.d.ts +13 -0
  94. package/dist/Components/Layouts/ThemePicker.js +22 -0
  95. package/dist/Components/Layouts/ThemeScript.d.ts +14 -0
  96. package/dist/Components/Layouts/ThemeScript.js +13 -0
  97. package/dist/Components/Layouts/ThemeSwitcher.d.ts +13 -0
  98. package/dist/Components/Layouts/ThemeSwitcher.js +29 -0
  99. package/dist/Components/Layouts/Toaster.d.ts +76 -0
  100. package/dist/Components/Layouts/Toaster.js +172 -0
  101. package/dist/Components/Viewers/DataTable.d.ts +25 -0
  102. package/dist/Components/Viewers/DataTable.js +542 -0
  103. package/dist/Components/Viewers/DataTableParts.d.ts +134 -0
  104. package/dist/Components/Viewers/DataTableParts.js +145 -0
  105. package/dist/Components/Viewers/MarkdownView.d.ts +26 -0
  106. package/dist/Components/Viewers/MarkdownView.js +79 -0
  107. package/dist/Components/Viewers/RichTextView.d.ts +18 -0
  108. package/dist/Components/Viewers/RichTextView.js +17 -0
  109. package/dist/Helpers/AnimationHelpers.d.ts +6 -0
  110. package/dist/Helpers/AnimationHelpers.js +35 -0
  111. package/dist/Helpers/ApiClient.d.ts +74 -0
  112. package/dist/Helpers/ApiClient.js +197 -0
  113. package/dist/Helpers/ApiFormHelpers.d.ts +26 -0
  114. package/dist/Helpers/ApiFormHelpers.js +56 -0
  115. package/dist/Helpers/ApiModules.d.ts +135 -0
  116. package/dist/Helpers/ApiModules.js +194 -0
  117. package/dist/Helpers/ApiResponses.d.ts +41 -0
  118. package/dist/Helpers/ApiResponses.js +159 -0
  119. package/dist/Helpers/ApiRoutes.d.ts +150 -0
  120. package/dist/Helpers/ApiRoutes.js +191 -0
  121. package/dist/Helpers/ApiToasts.d.ts +21 -0
  122. package/dist/Helpers/ApiToasts.js +22 -0
  123. package/dist/Helpers/ClassHelpers.d.ts +3 -0
  124. package/dist/Helpers/ClassHelpers.js +4 -0
  125. package/dist/Helpers/CrudBackend.d.ts +56 -0
  126. package/dist/Helpers/CrudBackend.js +119 -0
  127. package/dist/Helpers/CrudHelpers.d.ts +76 -0
  128. package/dist/Helpers/CrudHelpers.js +202 -0
  129. package/dist/Helpers/DateHelpers.d.ts +88 -0
  130. package/dist/Helpers/DateHelpers.js +363 -0
  131. package/dist/Helpers/DatePreferences.d.ts +14 -0
  132. package/dist/Helpers/DatePreferences.js +94 -0
  133. package/dist/Helpers/DateTimeHelpers.d.ts +87 -0
  134. package/dist/Helpers/DateTimeHelpers.js +286 -0
  135. package/dist/Helpers/DragHelpers.d.ts +129 -0
  136. package/dist/Helpers/DragHelpers.js +281 -0
  137. package/dist/Helpers/DropdownHelpers.d.ts +56 -0
  138. package/dist/Helpers/DropdownHelpers.js +180 -0
  139. package/dist/Helpers/FormDrafts.d.ts +18 -0
  140. package/dist/Helpers/FormDrafts.js +76 -0
  141. package/dist/Helpers/FormStore.d.ts +231 -0
  142. package/dist/Helpers/FormStore.js +734 -0
  143. package/dist/Helpers/InputParamsHelpers.d.ts +79 -0
  144. package/dist/Helpers/InputParamsHelpers.js +388 -0
  145. package/dist/Helpers/MarkdownEditing.d.ts +27 -0
  146. package/dist/Helpers/MarkdownEditing.js +250 -0
  147. package/dist/Helpers/MarkdownHelpers.d.ts +82 -0
  148. package/dist/Helpers/MarkdownHelpers.js +775 -0
  149. package/dist/Helpers/MessageBuilder.d.ts +74 -0
  150. package/dist/Helpers/MessageBuilder.js +254 -0
  151. package/dist/Helpers/NepaliCalendar.d.ts +25 -0
  152. package/dist/Helpers/NepaliCalendar.js +107 -0
  153. package/dist/Helpers/NumberHelpers.d.ts +71 -0
  154. package/dist/Helpers/NumberHelpers.js +202 -0
  155. package/dist/Helpers/Permissions.d.ts +62 -0
  156. package/dist/Helpers/Permissions.js +133 -0
  157. package/dist/Helpers/PopoverHelpers.d.ts +43 -0
  158. package/dist/Helpers/PopoverHelpers.js +91 -0
  159. package/dist/Helpers/RichTextHelpers.d.ts +77 -0
  160. package/dist/Helpers/RichTextHelpers.js +1072 -0
  161. package/dist/Helpers/RowsStore.d.ts +160 -0
  162. package/dist/Helpers/RowsStore.js +584 -0
  163. package/dist/Helpers/TableColumns.d.ts +40 -0
  164. package/dist/Helpers/TableColumns.js +254 -0
  165. package/dist/Helpers/TableExport.d.ts +30 -0
  166. package/dist/Helpers/TableExport.js +97 -0
  167. package/dist/Helpers/TableHelpers.d.ts +102 -0
  168. package/dist/Helpers/TableHelpers.js +281 -0
  169. package/dist/Helpers/TableStore.d.ts +142 -0
  170. package/dist/Helpers/TableStore.js +530 -0
  171. package/dist/Helpers/ThemeHelpers.d.ts +15 -0
  172. package/dist/Helpers/ThemeHelpers.js +16 -0
  173. package/dist/Helpers/TimeHelpers.d.ts +73 -0
  174. package/dist/Helpers/TimeHelpers.js +253 -0
  175. package/dist/Helpers/TreeStore.d.ts +188 -0
  176. package/dist/Helpers/TreeStore.js +577 -0
  177. package/dist/Helpers/ValidationHelpers.d.ts +124 -0
  178. package/dist/Helpers/ValidationHelpers.js +301 -0
  179. package/dist/Interfaces/ApiInterfaces.d.ts +149 -0
  180. package/dist/Interfaces/ApiInterfaces.js +24 -0
  181. package/dist/Interfaces/CrudInterfaces.d.ts +171 -0
  182. package/{src/sso-client.tsx → dist/Interfaces/CrudInterfaces.js} +1 -1
  183. package/dist/Interfaces/DateInterfaces.d.ts +154 -0
  184. package/dist/Interfaces/DateInterfaces.js +29 -0
  185. package/dist/Interfaces/FormInterfaces.d.ts +352 -0
  186. package/dist/Interfaces/FormInterfaces.js +1 -0
  187. package/dist/Interfaces/InputInterfaces.d.ts +141 -0
  188. package/dist/Interfaces/InputInterfaces.js +1 -0
  189. package/dist/Interfaces/MessageInterfaces.d.ts +111 -0
  190. package/dist/Interfaces/MessageInterfaces.js +5 -0
  191. package/dist/Interfaces/TableInterfaces.d.ts +291 -0
  192. package/dist/Interfaces/TableInterfaces.js +1 -0
  193. package/dist/Interfaces/ThemeInterfaces.d.ts +17 -0
  194. package/dist/Interfaces/ThemeInterfaces.js +17 -0
  195. package/dist/Interfaces/TypeInterfaces.d.ts +4 -0
  196. package/dist/Interfaces/TypeInterfaces.js +1 -0
  197. package/dist/Server.Index.d.ts +2 -0
  198. package/dist/Server.Index.js +5 -0
  199. package/dist/Services/ApiProxy.d.ts +32 -0
  200. package/dist/Services/ApiProxy.js +111 -0
  201. package/dist/Services/BrowserApi.d.ts +78 -0
  202. package/dist/Services/BrowserApi.js +111 -0
  203. package/dist/Services/ServerApi.d.ts +49 -0
  204. package/dist/Services/ServerApi.js +75 -0
  205. package/dist/Services/ThemeService.d.ts +17 -0
  206. package/dist/Services/ThemeService.js +83 -0
  207. package/dist/Shared.Index.d.ts +43 -0
  208. package/dist/Shared.Index.js +47 -0
  209. package/package.json +82 -33
  210. package/src/Styles/Nexus.Base.css +70 -0
  211. package/src/Styles/Nexus.Button.css +151 -0
  212. package/src/Styles/Nexus.Calendar.css +275 -0
  213. package/src/Styles/Nexus.Choice.css +345 -0
  214. package/src/Styles/Nexus.Crud.css +84 -0
  215. package/src/Styles/Nexus.DateTime.css +81 -0
  216. package/src/Styles/Nexus.Dropdown.css +774 -0
  217. package/src/Styles/Nexus.Editor.css +297 -0
  218. package/src/Styles/Nexus.Form.css +298 -0
  219. package/src/Styles/Nexus.Index.css +34 -0
  220. package/src/Styles/Nexus.Input.css +637 -0
  221. package/src/Styles/Nexus.Markdown.css +265 -0
  222. package/src/Styles/Nexus.Menu.css +249 -0
  223. package/src/Styles/Nexus.Popup.css +731 -0
  224. package/src/Styles/Nexus.RichText.css +463 -0
  225. package/src/Styles/Nexus.Rows.css +566 -0
  226. package/src/Styles/Nexus.Slider.css +278 -0
  227. package/src/Styles/Nexus.Tab.Buttons.css +364 -0
  228. package/src/Styles/Nexus.Table.css +1014 -0
  229. package/src/Styles/Nexus.Theme.Picker.css +159 -0
  230. package/src/Styles/Nexus.Themes.css +194 -0
  231. package/src/Styles/Nexus.Time.css +147 -0
  232. package/src/Styles/Nexus.Toast.css +265 -0
  233. package/src/Styles/Nexus.Tokens.css +72 -0
  234. package/src/Styles/Nexus.Tree.css +435 -0
  235. package/src/api-services/authentication-service.tsx +0 -23
  236. package/src/api-services/preference-service.tsx +0 -5
  237. package/src/api-services/system-service.tsx +0 -34
  238. package/src/client.ts +0 -31
  239. package/src/components/documents/button.tsx +0 -142
  240. package/src/components/documents/icon-box.tsx +0 -93
  241. package/src/components/documents/page-title.tsx +0 -7
  242. package/src/components/documents/tab-button.tsx +0 -172
  243. package/src/components/documents/tag.tsx +0 -30
  244. package/src/components/index.js +0 -0
  245. package/src/components/inputs/checkbox-input.tsx +0 -66
  246. package/src/components/inputs/input-box.tsx +0 -48
  247. package/src/components/inputs/input-element.tsx +0 -65
  248. package/src/components/inputs/input-form.tsx +0 -164
  249. package/src/components/inputs/input.tsx +0 -181
  250. package/src/components/inputs/number-input.tsx +0 -108
  251. package/src/components/inputs/radiobox-input.tsx +0 -53
  252. package/src/components/inputs/textarea-input.tsx +0 -47
  253. package/src/components/inputs/textbox-input.tsx +0 -45
  254. package/src/components/layouts/global-dialogbox.tsx +0 -431
  255. package/src/components/layouts/global-layout.tsx +0 -59
  256. package/src/components/layouts/layout-helpers.tsx +0 -20
  257. package/src/components/layouts/panels/user-panel.tsx +0 -112
  258. package/src/components/layouts/utility-menu.tsx +0 -49
  259. package/src/components/panels/theme-panel.tsx +0 -46
  260. package/src/helpers/bitwise-helpers.tsx +0 -11
  261. package/src/helpers/browser-helpers.tsx +0 -156
  262. package/src/helpers/datasource-helpers.tsx +0 -99
  263. package/src/helpers/element-helpers.tsx +0 -57
  264. package/src/helpers/input-helpers.tsx +0 -74
  265. package/src/helpers/string-helpers.tsx +0 -28
  266. package/src/helpers/utility-helpers.tsx +0 -45
  267. package/src/helpers/validation-helpers.tsx +0 -302
  268. package/src/index.ts +0 -26
  269. package/src/interface.ts +0 -19
  270. package/src/interfaces/auth-token-interfaces.tsx +0 -6
  271. package/src/interfaces/browser-interfaces.tsx +0 -36
  272. package/src/interfaces/button-interfaces.tsx +0 -63
  273. package/src/interfaces/datasource-interfaces.tsx +0 -22
  274. package/src/interfaces/datatable-interfaces.tsx +0 -25
  275. package/src/interfaces/dialogbox-interfaces.tsx +0 -5
  276. package/src/interfaces/exception-interfaces.tsx +0 -99
  277. package/src/interfaces/http-interfaces.tsx +0 -129
  278. package/src/interfaces/icon-interfaces.tsx +0 -129
  279. package/src/interfaces/input-interfaces.tsx +0 -410
  280. package/src/interfaces/layout-interfaces.tsx +0 -191
  281. package/src/interfaces/menu-interfaces.tsx +0 -49
  282. package/src/interfaces/message-interfaces.tsx +0 -32
  283. package/src/interfaces/permission-interfaces.tsx +0 -9
  284. package/src/interfaces/storage-interfaces.tsx +0 -5
  285. package/src/interfaces/system-interfaces.tsx +0 -22
  286. package/src/interfaces/theme-interfaces.tsx +0 -123
  287. package/src/interfaces/type-interfaces.tsx +0 -28
  288. package/src/interfaces/user-interfaces.tsx +0 -47
  289. package/src/nexus-client.tsx +0 -21
  290. package/src/nexus.environments.tsx +0 -66
  291. package/src/proxy-api/proxy-backend.tsx +0 -60
  292. package/src/proxy-api/proxy-constants.tsx +0 -28
  293. package/src/proxy-api/proxy-helpers.tsx +0 -91
  294. package/src/proxy-api-client.tsx +0 -1
  295. package/src/proxy-api-server.tsx +0 -2
  296. package/src/services/http-client-services.tsx +0 -75
  297. package/src/services/http-services.tsx +0 -158
  298. package/src/services/loader-service.tsx +0 -185
  299. package/src/services/localstorage-service.tsx +0 -119
  300. package/src/services/message-services.tsx +0 -383
  301. package/src/services/theme-service.tsx +0 -161
  302. package/src/services/user-services.tsx +0 -10
  303. package/src/sso-config/auth-token-validation.ts +0 -16
  304. package/src/sso-config/callback-route.tsx +0 -35
  305. package/src/sso-config/cookie-encryption.ts +0 -51
  306. package/src/sso-config/cookie-helpers.tsx +0 -102
  307. package/src/sso-config/forgot-password-route.tsx +0 -36
  308. package/src/sso-config/oauth-callback-state.ts +0 -61
  309. package/src/sso-config/pkce-helpers.ts +0 -9
  310. package/src/sso-config/provider-complete-route.tsx +0 -18
  311. package/src/sso-config/redirect-context-actions.tsx +0 -45
  312. package/src/sso-config/redirect-context-helpers.tsx +0 -159
  313. package/src/sso-config/redirect-context-persist.tsx +0 -18
  314. package/src/sso-config/redirect-context-route.tsx +0 -45
  315. package/src/sso-config/refresh-route.tsx +0 -23
  316. package/src/sso-config/sign-in-route.tsx +0 -74
  317. package/src/sso-config/sign-out-route.tsx +0 -57
  318. package/src/sso-config/sign-up-route.tsx +0 -57
  319. package/src/sso-config/sso-backend-flow.ts +0 -38
  320. package/src/sso-config/sso-complete-route.tsx +0 -50
  321. package/src/sso-config/sso-config.ts +0 -59
  322. package/src/sso-config/sso-interfaces.tsx +0 -99
  323. package/src/sso-config/sso-response-helpers.tsx +0 -20
  324. package/src/sso-server.tsx +0 -21
  325. package/src/styles/nexus.animation.css +0 -269
  326. package/src/styles/nexus.core.css +0 -119
  327. package/src/styles/nexus.dialog.css +0 -144
  328. package/src/styles/nexus.icon.css +0 -51
  329. package/src/styles/nexus.input.css +0 -207
  330. package/src/styles/nexus.loader.css +0 -11
  331. package/src/styles/nexus.logic.css +0 -47
  332. package/src/styles/nexus.utility.css +0 -347
@@ -1,46 +0,0 @@
1
- "use client";
2
-
3
- import React, { useEffect } from "react";
4
- import { GetButton, IButton } from "../../interfaces/button-interfaces";
5
- import { EIconTypes } from "../../interfaces/icon-interfaces";
6
- import { ClickHandler } from "../../interfaces/type-interfaces";
7
- import { O } from "../../nexus-client";
8
- import { GetCurrentThemeName, SetCurrentTheme } from "../../services/localstorage-service";
9
- import { SwitchTheme } from "../../services/theme-service";
10
- import { CreateTabButtons } from "../documents/tab-button";
11
-
12
- const onClicked: ClickHandler = (event, element, button: IButton) => {
13
- if (button.id === GetCurrentThemeName()) return;
14
- const themeCode = button.id;
15
- if (!themeCode) return;
16
- SwitchTheme(themeCode);
17
- SetCurrentTheme(themeCode);
18
- };
19
- const RenderSwitchTheme = (baseElement: HTMLElement) => {
20
- if (!baseElement || baseElement.classList.contains("ddcc")) return;
21
- baseElement.classList.add("ddcc");
22
-
23
- const currentTheme = GetCurrentThemeName();
24
- const themes = O.systemThemes;
25
-
26
- if (!themes || themes.length === 0) {
27
- const p = document.createElement("p");
28
- p.textContent = "No theme available!";
29
- p.className = "o08 p5 bg3 tc";
30
- baseElement.appendChild(p);
31
- return;
32
- }
33
- const themeButtons: IButton[] = themes.map((theme, index) => GetButton(theme.displayName, theme.systemName, null, theme.iconName, onClicked, theme, null, null, theme.displayOrder, EIconTypes.OUTLINED, null));
34
- const activeButton = themeButtons.find((button) => button.id === currentTheme);
35
- CreateTabButtons(themeButtons, baseElement, activeButton, onClicked);
36
-
37
- return "Theme Settings";
38
- };
39
-
40
- export const ThemePanel = () => {
41
- const containerRef = React.useRef<HTMLDivElement>(null);
42
- useEffect(() => {
43
- if (containerRef.current) RenderSwitchTheme(containerRef.current);
44
- }, [containerRef.current]);
45
- return <div ref={containerRef}></div>;
46
- };
@@ -1,11 +0,0 @@
1
- export function HasFlag(state: number, flag: number): boolean {
2
- return (state & flag) === flag;
3
- }
4
- export function BitwiseToList<T>(enumType: any, bitwiseValue: number): T[] {
5
- return Object.values(enumType)
6
- .filter((v) => typeof v === "number")
7
- .filter((v: number) => (bitwiseValue & v) === v && v !== 0) as T[];
8
- }
9
- export function ListToBitwise(values: number[]): number {
10
- return values.reduce((acc, curr) => acc | curr, 0);
11
- }
@@ -1,156 +0,0 @@
1
- import { BuildProxyApiUrl, EModules, ESigninRequestMode, UN } from "../interface";
2
- import { EAnimationClasses } from "../interfaces/layout-interfaces";
3
- import { FILES, NEXUS_INFO, URLS } from "../nexus.environments";
4
- import { EFileSizes, EKeyModifier, EKeys } from "./../interfaces/browser-interfaces";
5
- import { HasFlag } from "./bitwise-helpers";
6
- import { Debounce } from "./utility-helpers";
7
-
8
- export const IsBrowser = (): boolean => typeof window !== "undefined" && typeof document !== "undefined";
9
-
10
- export const RemoveElement = async (elementIdentity: string | HTMLElement, timeout?: number | UN, animation?: EAnimationClasses | UN): Promise<boolean> => {
11
- return new Promise(async (resolve) => {
12
- if (!IsBrowser() || !elementIdentity) return resolve(false);
13
- else if (typeof elementIdentity === "string") {
14
- const element = document.getElementById(elementIdentity);
15
- if (element) return await RemoveElement(element, timeout);
16
- } else if (elementIdentity instanceof HTMLElement || (elementIdentity as HTMLElement)) {
17
- const timeoutIdentifier = setTimeout(() => {
18
- (elementIdentity as HTMLElement).remove();
19
- clearTimeout(timeoutIdentifier);
20
- elementIdentity.remove();
21
- return resolve(true);
22
- }, timeout ?? 0);
23
- elementIdentity.classList.add(animation ?? EAnimationClasses.FADE_OUT);
24
- return resolve(true);
25
- } else return resolve(false);
26
- });
27
- };
28
-
29
- const setDocumentTitle = (title?: string) => IsBrowser() && (document.title = `Nexus - ${title ?? NEXUS_INFO.CURRENT_MODULE_SHORT_NAME ?? "Solutions"}`);
30
- export const SetDocumentTitleDebounce = Debounce(setDocumentTitle, 100);
31
-
32
- export const ConvertRemToPixels = (rem: number): number => {
33
- const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
34
- return Math.round(rem * fontSize * 1000) / 1000;
35
- };
36
-
37
- export const ConvertPixelsToRem = (px: number): number => {
38
- const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
39
- return Math.round((px / fontSize) * 1000) / 1000;
40
- };
41
- export const IsKeyPressed = (event: any, key: EKeys | string, modifier?: EKeyModifier): boolean => {
42
- const isPressed = (event?.key ?? event?.nativeEvent?.data) === key;
43
- if (!isPressed) return isPressed;
44
-
45
- if (!modifier) return isPressed;
46
-
47
- if (HasFlag(modifier, EKeyModifier.Shift) && !event.shiftKey) return false;
48
- if (HasFlag(modifier, EKeyModifier.Ctrl) && !event.ctrlKey) return false;
49
- if (HasFlag(modifier, EKeyModifier.Alt) && !event.altKey) return false;
50
-
51
- return isPressed;
52
- };
53
- export const IsValidURL = (url?: string | null) => url !== undefined && url !== null && url !== "#" && url.length > 0;
54
-
55
- export const FindChildElement = (parent: HTMLElement, childSelector: string, shouldScanAllChildren: boolean = false) => {
56
- if (!parent || !childSelector) return null;
57
- if (shouldScanAllChildren) {
58
- const children = parent.querySelectorAll(childSelector);
59
- return children.length > 0 ? children[0] : null;
60
- } else return parent.querySelector(childSelector);
61
- };
62
-
63
- export const FindChildElements = (parent: HTMLElement, childSelector: string, shouldScanAllChildren: boolean = false) => {
64
- if (!parent || !childSelector) return [];
65
- if (shouldScanAllChildren) {
66
- const children = parent.querySelectorAll(childSelector);
67
- return children.length > 0 ? children : [];
68
- } else {
69
- const children = parent.querySelectorAll(childSelector);
70
- return children.length > 0 ? [children[0]] : [];
71
- }
72
- };
73
- export const PxToRem = (px: number): number => {
74
- const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
75
- return Math.round((px / fontSize) * 1000) / 1000;
76
- };
77
-
78
- export const ConvertColorToRGBA = (color: string, alpha: number = 0.1): string => {
79
- if (!color) return "rgba(0, 0, 0, 0.1)";
80
-
81
- let finalColor = color.trim();
82
- if (finalColor.startsWith("var(")) finalColor = finalColor.replace(/^var\(\s*/, "").replace(/\s*\)$/, "");
83
- // CSS Variable Support
84
- if (finalColor.startsWith("--")) finalColor = getComputedStyle(document.documentElement).getPropertyValue(finalColor).trim();
85
-
86
- // Create temporary element for browser auto parsing
87
- const temp = document.createElement("div");
88
- temp.style.color = finalColor;
89
-
90
- document.body.appendChild(temp);
91
-
92
- const computed = getComputedStyle(temp).color;
93
-
94
- document.body.removeChild(temp);
95
-
96
- // computed => rgb(...) or rgba(...)
97
- const match = computed.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)(?:[,\s\/]+([\d.]+))?\s*\)/i);
98
-
99
- if (!match) return "rgba(0, 0, 0, 1)";
100
-
101
- const r = parseInt(match[1], 10);
102
- const g = parseInt(match[2], 10);
103
- const b = parseInt(match[3], 10);
104
-
105
- let a = match[4] !== undefined ? parseFloat(match[4]) : 1;
106
-
107
- // Override alpha if provided
108
- if (alpha) a = alpha;
109
-
110
- return `rgba(${r}, ${g}, ${b}, ${a})`;
111
- };
112
- export function FindParentElement<ELEMENT extends Element>(element: Element | null | undefined, selector: string): ELEMENT | null {
113
- if (!element || !selector || !element.matches) return null;
114
-
115
- if (element.matches(selector)) return element as ELEMENT;
116
-
117
- return FindParentElement<ELEMENT>(element.parentElement, selector);
118
- }
119
- export const GetCurrentFullURL = () => window?.location?.href;
120
- export const GetCurrentBaseURL = () => window?.location?.origin;
121
- export const BuildImageUrl = (viewToken?: string | UN, size?: EFileSizes | UN, fallback?: string | UN, isPublic: boolean = false) => {
122
- if (!viewToken) return fallback ?? FILES.ICONS.NO_IMAGE;
123
- if (!size) size = EFileSizes.SIZE_256;
124
- if (isPublic) return BuildProxyApiUrl(EModules.Drive, `Public/Image/${size}/${viewToken}`);
125
- else return BuildProxyApiUrl(EModules.Drive, `Private/Image/${size}/${viewToken}`);
126
- };
127
-
128
- const resolveReturnPath = (redirectURL?: string | UN): string => {
129
- if (redirectURL) {
130
- try {
131
- const url = new URL(redirectURL, GetCurrentBaseURL());
132
- return url.pathname + url.search || "/";
133
- } catch {
134
- /* fall through to current location */
135
- }
136
- }
137
- if (!IsBrowser()) return "/";
138
- return window.location.pathname + window.location.search || "/";
139
- };
140
-
141
- export const GetAuthPageURL = (redirectURL?: string | UN, signinMode?: ESigninRequestMode | UN) => {
142
- const setupUrl = new URL(URLS.GLOBAL_SIGNIN);
143
- setupUrl.searchParams.set("redirect_uri", `${GetCurrentBaseURL()}/api/auth/callback`);
144
- setupUrl.searchParams.set("state", resolveReturnPath(redirectURL));
145
- setupUrl.searchParams.set("signin_mode", signinMode ?? ESigninRequestMode.DEFAULT);
146
- return setupUrl.toString();
147
- };
148
-
149
- /** Clears the session via /api/auth/sign-out; non-admin apps return to the current page (with query params). */
150
- export const GetSignOutPageURL = (returnPath?: string | UN) => {
151
- const signOutUrl = new URL(`${GetCurrentBaseURL()}/api/auth/sign-out`);
152
- if (!NEXUS_INFO.IS_ADMIN_MODULE) {
153
- signOutUrl.searchParams.set("returnUrl", resolveReturnPath(returnPath));
154
- }
155
- return signOutUrl.toString();
156
- };
@@ -1,99 +0,0 @@
1
- import { IColumn } from "../interfaces/datatable-interfaces";
2
- import { IsNullOrEmpty } from "./string-helpers";
3
-
4
- export function GetVisibleAndHiddenItems<T>(allItems: T[], visibleRef: T[], hiddenRef: T[], activeItem: T | undefined, maxVisibleCount: number): { visibleItems: T[]; hiddenItems: T[] } {
5
- let visibleItems: T[] = [];
6
- let hiddenItems: T[] = [];
7
- visibleRef.length = 0;
8
- hiddenRef.length = 0;
9
-
10
- if (allItems.length <= maxVisibleCount) {
11
- const _ = {
12
- visibleItems: allItems,
13
- hiddenItems: [],
14
- };
15
- visibleRef.push(..._.visibleItems);
16
- hiddenRef.push(..._.hiddenItems);
17
- return _;
18
- }
19
-
20
- if (!activeItem || !allItems.includes(activeItem)) {
21
- visibleItems = allItems.slice(0, maxVisibleCount);
22
- hiddenItems = allItems.slice(maxVisibleCount);
23
- } else {
24
- const index = allItems.indexOf(activeItem);
25
- // It means the active item is within the visible range
26
- const selectedItem = allItems[index];
27
- // 0 to maxVisibleCount - 1
28
- visibleItems = allItems.slice(0, maxVisibleCount - 1);
29
- visibleItems.push(selectedItem);
30
- hiddenItems = allItems.slice(maxVisibleCount - 1);
31
- // remove the hidden but active item from the hidden items
32
- hiddenItems = hiddenItems.filter((item) => item !== selectedItem);
33
- if (index > maxVisibleCount - 1) {
34
- } else {
35
- visibleItems = allItems.slice(0, maxVisibleCount);
36
- hiddenItems = allItems.slice(maxVisibleCount);
37
- }
38
- }
39
- visibleRef.push(...visibleItems);
40
- hiddenRef.push(...hiddenItems);
41
- return { visibleItems, hiddenItems };
42
- }
43
- export function DynamicSorting<T>(data: T[], key: keyof T, isAsc: boolean) {
44
- return [...data].sort((a, b) => {
45
- const aValue = a[key];
46
- const bValue = b[key];
47
- let result = 0;
48
-
49
- // **Handle null & undefined values**
50
- if (aValue == null && bValue == null) return 0;
51
- if (aValue == null) return isAsc ? -1 : 1;
52
- if (bValue == null) return isAsc ? 1 : -1;
53
-
54
- // **Handle numbers**
55
- if (typeof aValue === "number" && typeof bValue === "number") result = aValue - bValue;
56
- // **Handle strings**
57
- else if (typeof aValue === "string" && typeof bValue === "string") result = aValue.localeCompare(bValue);
58
- // **Handle dates**
59
- else if (aValue instanceof Date && bValue instanceof Date) result = aValue.getTime() - bValue.getTime();
60
- // **Handle objects (fallback)**
61
- else if (typeof aValue === "object" && typeof bValue === "object") result = JSON.stringify(aValue).localeCompare(JSON.stringify(bValue));
62
- // **Handle mixed types (fallback)**
63
- else result = String(aValue).localeCompare(String(bValue));
64
-
65
- return isAsc ? result : -result;
66
- });
67
- }
68
- export function CreateClone<T>(data: T | T[], index?: number, object?: T): T | T[] {
69
- // Check if the input is an array
70
- if (Array.isArray(data)) {
71
- // Clone each element in the array
72
- let clonedArray = data.map((item) => ({ ...item }));
73
-
74
- // If both index and object are provided, add the object at the specified index
75
- if (index !== undefined && object !== undefined) {
76
- // Insert object at the specified index
77
- clonedArray.splice(index, 0, { ...object });
78
- }
79
- return clonedArray;
80
- } else if (typeof data === "object" && data !== null)
81
- // Clone a single object
82
- return { ...data };
83
- else throw new Error("Input must be an object or an array of objects");
84
- }
85
- export const SearchDatasourceUsingColumns = (dataSource: any[], searchText: string | null, columns: IColumn[]) => {
86
- if (!dataSource || !Array.isArray(dataSource) || dataSource.length === 0 || !columns || columns.length === 0 || IsNullOrEmpty(searchText)) return dataSource;
87
- const searchableColumns = columns.filter((column) => column.isSearchable);
88
- if (searchableColumns.length === 0) return dataSource;
89
- const searchLower = searchText?.toLowerCase().trim();
90
- return dataSource.filter((data) => {
91
- return searchableColumns.some((column) => {
92
- if (column.systemName) {
93
- const value = data[column.systemName];
94
- return value && value.toString().toLowerCase().includes(searchLower);
95
- }
96
- return false;
97
- });
98
- });
99
- };
@@ -1,57 +0,0 @@
1
- import { UN } from "../interfaces/type-interfaces";
2
-
3
- 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
- if (!isInit) {
5
- // Update classes for all item links based on activeItem
6
- for (const element of elementList) refreshElementClass(element, activeItem);
7
- if (isHiddenItemClicked && activeItem) {
8
- // A hidden item was clicked: replace last visible item in DOM with the active one
9
- const newActiveItem = createItem(activeItem);
10
- const lastItemElement = elementList[elementList.length - 1];
11
-
12
- if (lastItemElement) {
13
- lastItemElement.replaceWith(newActiveItem);
14
- elementList[elementList.length - 1].remove();
15
- elementList[elementList.length - 1] = newActiveItem;
16
- }
17
- } else {
18
- // Ensure last visible DOM element matches last item in visibleItems
19
- const lastVisible = visibleItems[visibleItems.length - 1];
20
- const lastDomItem = elementList[elementList.length - 1];
21
-
22
- const currentItemCode = lastDomItem?.getAttribute(dataAttributeKey);
23
- if (lastVisible && lastDomItem && currentItemCode !== (lastVisible as any)[dataUniqueKey]) {
24
- const correctedItem = createItem(lastVisible);
25
- lastDomItem.replaceWith(correctedItem);
26
- lastDomItem.remove();
27
- elementList[elementList.length - 1] = correctedItem;
28
- }
29
- }
30
- return;
31
- }
32
-
33
- // Initial render: clear and create full visible item
34
- elementList.length = 0;
35
- parentContainer.innerHTML = "";
36
-
37
- for (const item of visibleItems) {
38
- const itemItem = createItem(item);
39
- parentContainer.appendChild(itemItem);
40
- elementList.push(itemItem);
41
- }
42
-
43
- // Append toggle icon if hidden items exist
44
- if (hiddenItems.length > 0) {
45
- parentContainer.appendChild(toggleButton);
46
- }
47
- }
48
- export const SetElementStyles = (element: HTMLElement, styles: React.CSSProperties | UN) => {
49
- if (!element || !styles) return;
50
- if (typeof styles === "object") {
51
- Object.keys(styles).forEach((key) => {
52
- const value = styles[key as keyof typeof styles];
53
- if (value === undefined) return;
54
- element.style.setProperty(key, value === null ? null : String(value));
55
- });
56
- } else element.style.setProperty(styles as string, styles as string);
57
- };
@@ -1,74 +0,0 @@
1
- import { DEFAULT_ICON_ELEMENT_NAME, IErrorRespose } from "../interface";
2
- import { EValueChangeTypes, IInputCreateResults, IInputRootParameters } from "../interfaces/input-interfaces";
3
- import { ESizes } from "../interfaces/layout-interfaces";
4
- import { UN } from "../interfaces/type-interfaces";
5
- import { AddRemoveErrorFromInput } from "./validation-helpers";
6
-
7
- export const INPUT_ICON_BOX_CLASS = "input-icon-box";
8
- export const GetParentKey = (parentKey?: string | null) => {
9
- if (parentKey) return parentKey.split("|")[0];
10
- return undefined;
11
- };
12
- export const GetInputId = (param: IInputRootParameters<any>) => param.id.split("-")[0];
13
- export const GetInputClasses = (size?: ESizes | UN, cls?: string | UN) => `ipt pr sn ${size ?? ""} ${cls ?? ""}`;
14
- export const SetHaveValueClass = (input: HTMLElement, isHaveValue: boolean) => {
15
- if (!input) return;
16
- input.classList.toggle("txhv", isHaveValue);
17
- };
18
- export const ForceSetValues = (inputs: IInputCreateResults[] | UN, keys: string[] | UN, value: any | null, timeout?: number | UN, invokeOnChanged?: boolean | UN) => {
19
- if (!inputs || inputs.length === 0) return;
20
- for (const input of inputs) if (!keys || keys.length === 0 || keys.includes(GetInputId(input.input))) ForceSetValue(input, value, timeout, invokeOnChanged);
21
- };
22
- export const ForceSetValue = (input?: IInputCreateResults | null, value?: any | null, timeout?: number | UN, invokeOnChanged?: boolean | UN) => {
23
- const timeoutValue = setTimeout(() => {
24
- input?.forceChangeDefaultValue && input.forceChangeDefaultValue(value, EValueChangeTypes.ForceChanged, invokeOnChanged);
25
- clearTimeout(timeoutValue);
26
- }, timeout ?? 0);
27
- };
28
-
29
- export const ApplyPasswordInputs = (inputResults: IInputCreateResults[] | UN, selectors: string[] | UN) => {
30
- if (!inputResults || inputResults.length === 0 || !selectors || selectors.length === 0) return;
31
- for (const selector of selectors) {
32
- const input = inputResults.find((x) => x.input.id === selector);
33
- if (input) ApplyPasswordInput(input.rootElement.querySelector(`div.ib.${INPUT_ICON_BOX_CLASS}`), input.inputElement);
34
- }
35
- };
36
-
37
- export const ApplyPasswordInput = (iconbox: HTMLElement | null, inputElement: HTMLElement | null) => {
38
- const input = inputElement as HTMLInputElement | undefined;
39
- if (!input || !iconbox) return;
40
-
41
- if (!iconbox.classList.contains("h")) iconbox.classList.add("h");
42
-
43
- const icon = iconbox.querySelector(DEFAULT_ICON_ELEMENT_NAME) as HTMLElement | null;
44
- if (!icon) return;
45
- const onMouseLeave = () => {
46
- iconbox.removeEventListener("mouseleave", onMouseLeave);
47
- iconbox.removeEventListener("click", onClicked);
48
- input.type = "password";
49
- if (icon) icon.setAttribute("name", "key");
50
- };
51
- const onMouseEnter = () => {
52
- icon.setAttribute("name", "eye");
53
- iconbox.addEventListener("mouseleave", onMouseLeave);
54
- iconbox.addEventListener("click", onClicked);
55
- };
56
- const onClicked = () => {
57
- const isPassword = input.type === "password";
58
- input.type = isPassword ? "text" : "password";
59
- if (icon) icon.setAttribute("name", isPassword ? "eye-off" : "eye");
60
- };
61
- iconbox.addEventListener("mouseenter", onMouseEnter);
62
- };
63
-
64
- export const SetResponseErrorMessage = (apiResponse: IErrorRespose, inputResults: IInputCreateResults[] | UN) => {
65
- if (!apiResponse || !inputResults || inputResults.length === 0 || !apiResponse.inputName) return;
66
-
67
- const inputKeys = apiResponse.inputName.toLowerCase().split("|");
68
- let isFirstElement = true;
69
- for (const inputKey of inputKeys) {
70
- const input = inputResults.find((x) => GetInputId(x.input).toLowerCase() === inputKey);
71
- if (input) AddRemoveErrorFromInput(input.input, input.inputElement, true, apiResponse.message, isFirstElement);
72
- isFirstElement = false;
73
- }
74
- };
@@ -1,28 +0,0 @@
1
- import { UN } from "../interfaces/type-interfaces";
2
-
3
- export const ConvertToCode = (text: string | UN) => text?.toString().toLowerCase().replace(/\s+/g, "-") ?? null;
4
-
5
- export const IsNullOrEmpty = (value?: string | null) => !(value !== null && value !== undefined && value.toString().trim().length > 0);
6
- export function MakeFirstLetterUpperCase(str?: string) {
7
- if (!str) return str;
8
- return str.charAt(0).toUpperCase() + str.slice(1);
9
- }
10
- export const GetRandomNumber = (min = 0, max = 100) => Math.floor(Math.random() * (max - min + 1)) + min;
11
- export const GetRandomString = (length: number = 10, includeNumbers: boolean = true, includeSpecialChars: boolean = false): string => {
12
- const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + (includeNumbers ? "0123456789" : "") + (includeSpecialChars ? "!@#$%^&*()_+-=[]{}|;:,.<>?/" : "");
13
- let result = "";
14
-
15
- for (let i = 0; i < length; i++) {
16
- const randomIndex = Math.floor(Math.random() * characters.length);
17
- result += characters[randomIndex];
18
- }
19
-
20
- return result;
21
- };
22
- export function PadStart(value: string | number | null | undefined, targetLength: number, padString: string = "0"): string {
23
- if (value == null || value === undefined) return "";
24
-
25
- const str = value?.toString();
26
- if (str.length >= targetLength) return str;
27
- return padString.repeat(targetLength - str.length) + str;
28
- }
@@ -1,45 +0,0 @@
1
- const DEFAULT_DELAY = 500;
2
-
3
- export type DebouncedFunction<T extends (...args: any[]) => void> = ((...args: Parameters<T>) => void) & {
4
- cancel: () => void;
5
- executeImmediately: (...args: Parameters<T>) => void;
6
- };
7
-
8
- export function Debounce<T extends (...args: any[]) => void>(func: T, delay?: number): DebouncedFunction<T> {
9
- let timer: ReturnType<typeof setTimeout> | undefined;
10
- let lastArgs: Parameters<T> | undefined;
11
- let isPending = false;
12
-
13
- const debounced = (...args: Parameters<T>) => {
14
- lastArgs = args;
15
- isPending = true;
16
- clearTimeout(timer);
17
- timer = setTimeout(() => {
18
- timer = undefined;
19
- isPending = false;
20
- lastArgs = undefined;
21
- func(...args);
22
- }, delay ?? DEFAULT_DELAY);
23
- };
24
-
25
- /** Cancel the debounced function */
26
- debounced.cancel = () => {
27
- clearTimeout(timer);
28
- timer = undefined;
29
- isPending = false;
30
- lastArgs = undefined;
31
- };
32
-
33
- /** Execute the debounced function immediately */
34
- debounced.executeImmediately = (...args: Parameters<T>) => {
35
- clearTimeout(timer);
36
- timer = undefined;
37
- const invokeArgs = args.length > 0 ? args : isPending ? lastArgs : undefined;
38
- isPending = false;
39
- lastArgs = undefined;
40
- if (invokeArgs !== undefined) func(...invokeArgs);
41
- };
42
-
43
- return debounced;
44
- }
45
- export const Delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));