nexus-shared 1.1.21 → 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.
- package/LICENSE +21 -0
- package/README.md +903 -0
- package/dist/Client.Index.d.ts +44 -0
- package/dist/Client.Index.js +49 -0
- package/dist/Components/Documents/Button.d.ts +29 -0
- package/dist/Components/Documents/Button.js +11 -0
- package/dist/Components/Documents/Menu.d.ts +102 -0
- package/dist/Components/Documents/Menu.js +238 -0
- package/dist/Components/Documents/SplitButton.d.ts +64 -0
- package/dist/Components/Documents/SplitButton.js +127 -0
- package/dist/Components/Documents/TabButtons.d.ts +62 -0
- package/dist/Components/Documents/TabButtons.js +19 -0
- package/dist/Components/Forms/ApiForm.d.ts +21 -0
- package/dist/Components/Forms/ApiForm.js +99 -0
- package/dist/Components/Forms/Crud.d.ts +17 -0
- package/dist/Components/Forms/Crud.js +556 -0
- package/dist/Components/Forms/CrudParts.d.ts +15 -0
- package/dist/Components/Forms/CrudParts.js +36 -0
- package/dist/Components/Forms/Form.d.ts +52 -0
- package/dist/Components/Forms/Form.js +319 -0
- package/dist/Components/Forms/SubmitForm.d.ts +65 -0
- package/dist/Components/Forms/SubmitForm.js +198 -0
- package/dist/Components/Inputs/Calendar.d.ts +69 -0
- package/dist/Components/Inputs/Calendar.js +258 -0
- package/dist/Components/Inputs/CheckBox.d.ts +53 -0
- package/dist/Components/Inputs/CheckBox.js +87 -0
- package/dist/Components/Inputs/CheckBoxGroup.d.ts +20 -0
- package/dist/Components/Inputs/CheckBoxGroup.js +80 -0
- package/dist/Components/Inputs/ChoiceField.d.ts +122 -0
- package/dist/Components/Inputs/ChoiceField.js +169 -0
- package/dist/Components/Inputs/DatePicker.d.ts +54 -0
- package/dist/Components/Inputs/DatePicker.js +246 -0
- package/dist/Components/Inputs/DateRangePicker.d.ts +62 -0
- package/dist/Components/Inputs/DateRangePicker.js +283 -0
- package/dist/Components/Inputs/DateTimePicker.d.ts +75 -0
- package/dist/Components/Inputs/DateTimePicker.js +399 -0
- package/dist/Components/Inputs/Dropdown.d.ts +117 -0
- package/dist/Components/Inputs/Dropdown.js +839 -0
- package/dist/Components/Inputs/DropdownParts.d.ts +84 -0
- package/dist/Components/Inputs/DropdownParts.js +102 -0
- package/dist/Components/Inputs/EditorShell.d.ts +45 -0
- package/dist/Components/Inputs/EditorShell.js +214 -0
- package/dist/Components/Inputs/Field.d.ts +53 -0
- package/dist/Components/Inputs/Field.js +16 -0
- package/dist/Components/Inputs/GroupForm.d.ts +20 -0
- package/dist/Components/Inputs/GroupForm.js +170 -0
- package/dist/Components/Inputs/InputField.d.ts +59 -0
- package/dist/Components/Inputs/InputField.js +169 -0
- package/dist/Components/Inputs/InputRenderer.d.ts +35 -0
- package/dist/Components/Inputs/InputRenderer.js +99 -0
- package/dist/Components/Inputs/MarkdownEditor.d.ts +67 -0
- package/dist/Components/Inputs/MarkdownEditor.js +289 -0
- package/dist/Components/Inputs/NumberBox.d.ts +53 -0
- package/dist/Components/Inputs/NumberBox.js +228 -0
- package/dist/Components/Inputs/RadioGroup.d.ts +20 -0
- package/dist/Components/Inputs/RadioGroup.js +43 -0
- package/dist/Components/Inputs/ReadOnlyNotice.d.ts +36 -0
- package/dist/Components/Inputs/ReadOnlyNotice.js +116 -0
- package/dist/Components/Inputs/RichTextEditor.d.ts +103 -0
- package/dist/Components/Inputs/RichTextEditor.js +1170 -0
- package/dist/Components/Inputs/RichTextParts.d.ts +63 -0
- package/dist/Components/Inputs/RichTextParts.js +157 -0
- package/dist/Components/Inputs/RowsInput.d.ts +104 -0
- package/dist/Components/Inputs/RowsInput.js +259 -0
- package/dist/Components/Inputs/Slider.d.ts +87 -0
- package/dist/Components/Inputs/Slider.js +216 -0
- package/dist/Components/Inputs/TabularForm.d.ts +23 -0
- package/dist/Components/Inputs/TabularForm.js +283 -0
- package/dist/Components/Inputs/TextArea.d.ts +43 -0
- package/dist/Components/Inputs/TextArea.js +31 -0
- package/dist/Components/Inputs/TextBox.d.ts +52 -0
- package/dist/Components/Inputs/TextBox.js +58 -0
- package/dist/Components/Inputs/TextField.d.ts +31 -0
- package/dist/Components/Inputs/TextField.js +35 -0
- package/dist/Components/Inputs/TimePanel.d.ts +34 -0
- package/dist/Components/Inputs/TimePanel.js +288 -0
- package/dist/Components/Inputs/TimePicker.d.ts +54 -0
- package/dist/Components/Inputs/TimePicker.js +239 -0
- package/dist/Components/Inputs/TreeView.d.ts +160 -0
- package/dist/Components/Inputs/TreeView.js +947 -0
- package/dist/Components/Layouts/MessageBox.d.ts +71 -0
- package/dist/Components/Layouts/MessageBox.js +104 -0
- package/dist/Components/Layouts/Popup.d.ts +92 -0
- package/dist/Components/Layouts/Popup.js +376 -0
- package/dist/Components/Layouts/PopupContext.d.ts +2 -0
- package/dist/Components/Layouts/PopupContext.js +4 -0
- package/dist/Components/Layouts/PopupDock.d.ts +22 -0
- package/dist/Components/Layouts/PopupDock.js +121 -0
- package/dist/Components/Layouts/PopupHost.d.ts +56 -0
- package/dist/Components/Layouts/PopupHost.js +163 -0
- package/dist/Components/Layouts/PopupRules.d.ts +30 -0
- package/dist/Components/Layouts/PopupRules.js +63 -0
- package/dist/Components/Layouts/ThemePicker.d.ts +13 -0
- package/dist/Components/Layouts/ThemePicker.js +22 -0
- package/dist/Components/Layouts/ThemeScript.d.ts +14 -0
- package/dist/Components/Layouts/ThemeScript.js +13 -0
- package/dist/Components/Layouts/ThemeSwitcher.d.ts +13 -0
- package/dist/Components/Layouts/ThemeSwitcher.js +29 -0
- package/dist/Components/Layouts/Toaster.d.ts +76 -0
- package/dist/Components/Layouts/Toaster.js +172 -0
- package/dist/Components/Viewers/DataTable.d.ts +25 -0
- package/dist/Components/Viewers/DataTable.js +542 -0
- package/dist/Components/Viewers/DataTableParts.d.ts +134 -0
- package/dist/Components/Viewers/DataTableParts.js +145 -0
- package/dist/Components/Viewers/MarkdownView.d.ts +26 -0
- package/dist/Components/Viewers/MarkdownView.js +79 -0
- package/dist/Components/Viewers/RichTextView.d.ts +18 -0
- package/dist/Components/Viewers/RichTextView.js +17 -0
- package/dist/Helpers/AnimationHelpers.d.ts +6 -0
- package/dist/Helpers/AnimationHelpers.js +35 -0
- package/dist/Helpers/ApiClient.d.ts +74 -0
- package/dist/Helpers/ApiClient.js +197 -0
- package/dist/Helpers/ApiFormHelpers.d.ts +26 -0
- package/dist/Helpers/ApiFormHelpers.js +56 -0
- package/dist/Helpers/ApiModules.d.ts +135 -0
- package/dist/Helpers/ApiModules.js +194 -0
- package/dist/Helpers/ApiResponses.d.ts +41 -0
- package/dist/Helpers/ApiResponses.js +159 -0
- package/dist/Helpers/ApiRoutes.d.ts +150 -0
- package/dist/Helpers/ApiRoutes.js +191 -0
- package/dist/Helpers/ApiToasts.d.ts +21 -0
- package/dist/Helpers/ApiToasts.js +22 -0
- package/dist/Helpers/ClassHelpers.d.ts +3 -0
- package/dist/Helpers/ClassHelpers.js +4 -0
- package/dist/Helpers/CrudBackend.d.ts +56 -0
- package/dist/Helpers/CrudBackend.js +119 -0
- package/dist/Helpers/CrudHelpers.d.ts +76 -0
- package/dist/Helpers/CrudHelpers.js +202 -0
- package/dist/Helpers/DateHelpers.d.ts +88 -0
- package/dist/Helpers/DateHelpers.js +363 -0
- package/dist/Helpers/DatePreferences.d.ts +14 -0
- package/dist/Helpers/DatePreferences.js +94 -0
- package/dist/Helpers/DateTimeHelpers.d.ts +87 -0
- package/dist/Helpers/DateTimeHelpers.js +286 -0
- package/dist/Helpers/DragHelpers.d.ts +129 -0
- package/dist/Helpers/DragHelpers.js +281 -0
- package/dist/Helpers/DropdownHelpers.d.ts +56 -0
- package/dist/Helpers/DropdownHelpers.js +180 -0
- package/dist/Helpers/FormDrafts.d.ts +18 -0
- package/dist/Helpers/FormDrafts.js +76 -0
- package/dist/Helpers/FormStore.d.ts +231 -0
- package/dist/Helpers/FormStore.js +734 -0
- package/dist/Helpers/InputParamsHelpers.d.ts +79 -0
- package/dist/Helpers/InputParamsHelpers.js +388 -0
- package/dist/Helpers/MarkdownEditing.d.ts +27 -0
- package/dist/Helpers/MarkdownEditing.js +250 -0
- package/dist/Helpers/MarkdownHelpers.d.ts +82 -0
- package/dist/Helpers/MarkdownHelpers.js +775 -0
- package/dist/Helpers/MessageBuilder.d.ts +74 -0
- package/dist/Helpers/MessageBuilder.js +254 -0
- package/dist/Helpers/NepaliCalendar.d.ts +25 -0
- package/dist/Helpers/NepaliCalendar.js +107 -0
- package/dist/Helpers/NumberHelpers.d.ts +71 -0
- package/dist/Helpers/NumberHelpers.js +202 -0
- package/dist/Helpers/Permissions.d.ts +62 -0
- package/dist/Helpers/Permissions.js +133 -0
- package/dist/Helpers/PopoverHelpers.d.ts +43 -0
- package/dist/Helpers/PopoverHelpers.js +91 -0
- package/dist/Helpers/RichTextHelpers.d.ts +77 -0
- package/dist/Helpers/RichTextHelpers.js +1072 -0
- package/dist/Helpers/RowsStore.d.ts +160 -0
- package/dist/Helpers/RowsStore.js +584 -0
- package/dist/Helpers/TableColumns.d.ts +40 -0
- package/dist/Helpers/TableColumns.js +254 -0
- package/dist/Helpers/TableExport.d.ts +30 -0
- package/dist/Helpers/TableExport.js +97 -0
- package/dist/Helpers/TableHelpers.d.ts +102 -0
- package/dist/Helpers/TableHelpers.js +281 -0
- package/dist/Helpers/TableStore.d.ts +142 -0
- package/dist/Helpers/TableStore.js +530 -0
- package/dist/Helpers/ThemeHelpers.d.ts +15 -0
- package/dist/Helpers/ThemeHelpers.js +16 -0
- package/dist/Helpers/TimeHelpers.d.ts +73 -0
- package/dist/Helpers/TimeHelpers.js +253 -0
- package/dist/Helpers/TreeStore.d.ts +188 -0
- package/dist/Helpers/TreeStore.js +577 -0
- package/dist/Helpers/ValidationHelpers.d.ts +124 -0
- package/dist/Helpers/ValidationHelpers.js +301 -0
- package/dist/Interfaces/ApiInterfaces.d.ts +149 -0
- package/dist/Interfaces/ApiInterfaces.js +24 -0
- package/dist/Interfaces/CrudInterfaces.d.ts +171 -0
- package/{src/sso-client.tsx → dist/Interfaces/CrudInterfaces.js} +1 -1
- package/dist/Interfaces/DateInterfaces.d.ts +154 -0
- package/dist/Interfaces/DateInterfaces.js +29 -0
- package/dist/Interfaces/FormInterfaces.d.ts +352 -0
- package/dist/Interfaces/FormInterfaces.js +1 -0
- package/dist/Interfaces/InputInterfaces.d.ts +141 -0
- package/dist/Interfaces/InputInterfaces.js +1 -0
- package/dist/Interfaces/MessageInterfaces.d.ts +111 -0
- package/dist/Interfaces/MessageInterfaces.js +5 -0
- package/dist/Interfaces/TableInterfaces.d.ts +291 -0
- package/dist/Interfaces/TableInterfaces.js +1 -0
- package/dist/Interfaces/ThemeInterfaces.d.ts +17 -0
- package/dist/Interfaces/ThemeInterfaces.js +17 -0
- package/dist/Interfaces/TypeInterfaces.d.ts +4 -0
- package/dist/Interfaces/TypeInterfaces.js +1 -0
- package/dist/Server.Index.d.ts +2 -0
- package/dist/Server.Index.js +5 -0
- package/dist/Services/ApiProxy.d.ts +32 -0
- package/dist/Services/ApiProxy.js +111 -0
- package/dist/Services/BrowserApi.d.ts +78 -0
- package/dist/Services/BrowserApi.js +111 -0
- package/dist/Services/ServerApi.d.ts +49 -0
- package/dist/Services/ServerApi.js +75 -0
- package/dist/Services/ThemeService.d.ts +17 -0
- package/dist/Services/ThemeService.js +83 -0
- package/dist/Shared.Index.d.ts +43 -0
- package/dist/Shared.Index.js +47 -0
- package/package.json +82 -33
- package/src/Styles/Nexus.Base.css +70 -0
- package/src/Styles/Nexus.Button.css +151 -0
- package/src/Styles/Nexus.Calendar.css +275 -0
- package/src/Styles/Nexus.Choice.css +345 -0
- package/src/Styles/Nexus.Crud.css +84 -0
- package/src/Styles/Nexus.DateTime.css +81 -0
- package/src/Styles/Nexus.Dropdown.css +774 -0
- package/src/Styles/Nexus.Editor.css +297 -0
- package/src/Styles/Nexus.Form.css +298 -0
- package/src/Styles/Nexus.Index.css +34 -0
- package/src/Styles/Nexus.Input.css +637 -0
- package/src/Styles/Nexus.Markdown.css +265 -0
- package/src/Styles/Nexus.Menu.css +249 -0
- package/src/Styles/Nexus.Popup.css +731 -0
- package/src/Styles/Nexus.RichText.css +463 -0
- package/src/Styles/Nexus.Rows.css +566 -0
- package/src/Styles/Nexus.Slider.css +278 -0
- package/src/Styles/Nexus.Tab.Buttons.css +364 -0
- package/src/Styles/Nexus.Table.css +1014 -0
- package/src/Styles/Nexus.Theme.Picker.css +159 -0
- package/src/Styles/Nexus.Themes.css +194 -0
- package/src/Styles/Nexus.Time.css +147 -0
- package/src/Styles/Nexus.Toast.css +265 -0
- package/src/Styles/Nexus.Tokens.css +72 -0
- package/src/Styles/Nexus.Tree.css +435 -0
- package/src/api-services/authentication-service.tsx +0 -23
- package/src/api-services/preference-service.tsx +0 -5
- package/src/api-services/system-service.tsx +0 -29
- package/src/client.ts +0 -31
- package/src/components/documents/button.tsx +0 -133
- package/src/components/documents/icon-box.tsx +0 -93
- package/src/components/documents/page-title.tsx +0 -7
- package/src/components/documents/tab-button.tsx +0 -172
- package/src/components/documents/tag.tsx +0 -30
- package/src/components/index.js +0 -0
- package/src/components/inputs/checkbox-input.tsx +0 -66
- package/src/components/inputs/input-box.tsx +0 -48
- package/src/components/inputs/input-element.tsx +0 -65
- package/src/components/inputs/input-form.tsx +0 -164
- package/src/components/inputs/input.tsx +0 -181
- package/src/components/inputs/number-input.tsx +0 -108
- package/src/components/inputs/radiobox-input.tsx +0 -53
- package/src/components/inputs/textarea-input.tsx +0 -47
- package/src/components/inputs/textbox-input.tsx +0 -45
- package/src/components/layouts/global-dialogbox.tsx +0 -431
- package/src/components/layouts/global-layout.tsx +0 -64
- package/src/components/layouts/layout-helpers.tsx +0 -20
- package/src/components/layouts/panels/user-panel.tsx +0 -112
- package/src/components/layouts/utility-menu.tsx +0 -49
- package/src/components/panels/theme-panel.tsx +0 -46
- package/src/helpers/bitwise-helpers.tsx +0 -11
- package/src/helpers/browser-helpers.tsx +0 -156
- package/src/helpers/datasource-helpers.tsx +0 -99
- package/src/helpers/element-helpers.tsx +0 -123
- package/src/helpers/input-helpers.tsx +0 -74
- package/src/helpers/string-helpers.tsx +0 -28
- package/src/helpers/utility-helpers.tsx +0 -45
- package/src/helpers/validation-helpers.tsx +0 -302
- package/src/index.ts +0 -26
- package/src/interface.ts +0 -19
- package/src/interfaces/auth-token-interfaces.tsx +0 -6
- package/src/interfaces/browser-interfaces.tsx +0 -36
- package/src/interfaces/button-interfaces.tsx +0 -63
- package/src/interfaces/datasource-interfaces.tsx +0 -22
- package/src/interfaces/datatable-interfaces.tsx +0 -25
- package/src/interfaces/dialogbox-interfaces.tsx +0 -5
- package/src/interfaces/exception-interfaces.tsx +0 -99
- package/src/interfaces/http-interfaces.tsx +0 -129
- package/src/interfaces/icon-interfaces.tsx +0 -129
- package/src/interfaces/input-interfaces.tsx +0 -410
- package/src/interfaces/layout-interfaces.tsx +0 -191
- package/src/interfaces/menu-interfaces.tsx +0 -53
- package/src/interfaces/message-interfaces.tsx +0 -32
- package/src/interfaces/permission-interfaces.tsx +0 -9
- package/src/interfaces/storage-interfaces.tsx +0 -5
- package/src/interfaces/system-interfaces.tsx +0 -22
- package/src/interfaces/theme-interfaces.tsx +0 -123
- package/src/interfaces/type-interfaces.tsx +0 -28
- package/src/interfaces/user-interfaces.tsx +0 -47
- package/src/nexus-client.tsx +0 -21
- package/src/nexus.environments.tsx +0 -66
- package/src/proxy-api/proxy-backend.tsx +0 -60
- package/src/proxy-api/proxy-constants.tsx +0 -28
- package/src/proxy-api/proxy-helpers.tsx +0 -91
- package/src/proxy-api-client.tsx +0 -1
- package/src/proxy-api-server.tsx +0 -2
- package/src/services/http-client-services.tsx +0 -75
- package/src/services/http-services.tsx +0 -158
- package/src/services/loader-service.tsx +0 -185
- package/src/services/localstorage-service.tsx +0 -119
- package/src/services/message-services.tsx +0 -383
- package/src/services/theme-service.tsx +0 -163
- package/src/services/user-services.tsx +0 -10
- package/src/sso-config/auth-token-validation.ts +0 -16
- package/src/sso-config/callback-route.tsx +0 -35
- package/src/sso-config/cookie-encryption.ts +0 -51
- package/src/sso-config/cookie-helpers.tsx +0 -102
- package/src/sso-config/forgot-password-route.tsx +0 -36
- package/src/sso-config/oauth-callback-state.ts +0 -61
- package/src/sso-config/pkce-helpers.ts +0 -9
- package/src/sso-config/provider-complete-route.tsx +0 -18
- package/src/sso-config/redirect-context-actions.tsx +0 -45
- package/src/sso-config/redirect-context-helpers.tsx +0 -159
- package/src/sso-config/redirect-context-persist.tsx +0 -18
- package/src/sso-config/redirect-context-route.tsx +0 -45
- package/src/sso-config/refresh-route.tsx +0 -23
- package/src/sso-config/sign-in-route.tsx +0 -74
- package/src/sso-config/sign-out-route.tsx +0 -57
- package/src/sso-config/sign-up-route.tsx +0 -57
- package/src/sso-config/sso-backend-flow.ts +0 -38
- package/src/sso-config/sso-complete-route.tsx +0 -50
- package/src/sso-config/sso-config.ts +0 -59
- package/src/sso-config/sso-interfaces.tsx +0 -99
- package/src/sso-config/sso-response-helpers.tsx +0 -20
- package/src/sso-server.tsx +0 -21
- package/src/styles/nexus.animation.css +0 -269
- package/src/styles/nexus.core.css +0 -119
- package/src/styles/nexus.dialog.css +0 -144
- package/src/styles/nexus.grid-view.css +0 -42
- package/src/styles/nexus.icon.css +0 -51
- package/src/styles/nexus.input.css +0 -207
- package/src/styles/nexus.loader.css +0 -11
- package/src/styles/nexus.logic.css +0 -47
- package/src/styles/nexus.utility.css +0 -347
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_ANIMATION_DURATION, DEFAULT_ICON_ELEMENT_NAME, EAnimationClasses, EBackgrounds, ECallbackTypes, EIcons, EIconTypes, EMessageBoxButtons, EMessageIcons, EMessageResult, EMessageTypes, EOpacity, ESizes, PopupMessageCallback, UN } from "nexus-shared";
|
|
2
|
-
import { CreateIconBox, IsBrowser, PxToRem, RemoveElement } from "nexus-shared/client";
|
|
3
|
-
|
|
4
|
-
const MESSAGE_IDENTITY = "nexus-message";
|
|
5
|
-
const MESSAGE_GAP_REM = 0.8;
|
|
6
|
-
const MESSAGE_TOP_REM = 1;
|
|
7
|
-
const PROGRESS_BAR_HEIGHT_REM = 0.2;
|
|
8
|
-
|
|
9
|
-
/** Newest first — index 0 is the top message. */
|
|
10
|
-
const activeMessages: HTMLElement[] = [];
|
|
11
|
-
const messageProgressCleanups = new WeakMap<HTMLElement, () => void>();
|
|
12
|
-
let reflowScheduled = false;
|
|
13
|
-
|
|
14
|
-
const stopMessageProgress = (messageElement: HTMLElement) => {
|
|
15
|
-
messageProgressCleanups.get(messageElement)?.();
|
|
16
|
-
messageProgressCleanups.delete(messageElement);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const startMessageProgress = (messageElement: HTMLElement, progressFillElement: HTMLElement, durationMilliseconds: number, onComplete: () => void) => {
|
|
20
|
-
let elapsedMilliseconds = 0;
|
|
21
|
-
let lastFrameTimestamp: number | null = null;
|
|
22
|
-
let animationFrameId = 0;
|
|
23
|
-
|
|
24
|
-
const cancelAnimation = () => {
|
|
25
|
-
if (animationFrameId) cancelAnimationFrame(animationFrameId);
|
|
26
|
-
animationFrameId = 0;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const finishProgress = () => {
|
|
30
|
-
cancelAnimation();
|
|
31
|
-
messageProgressCleanups.delete(messageElement);
|
|
32
|
-
onComplete();
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const updateProgress = (frameTimestamp: number) => {
|
|
36
|
-
animationFrameId = 0;
|
|
37
|
-
if (lastFrameTimestamp !== null) {
|
|
38
|
-
elapsedMilliseconds += frameTimestamp - lastFrameTimestamp;
|
|
39
|
-
progressFillElement.style.width = `${Math.min((elapsedMilliseconds / durationMilliseconds) * 100, 100)}%`;
|
|
40
|
-
if (elapsedMilliseconds >= durationMilliseconds) return finishProgress();
|
|
41
|
-
}
|
|
42
|
-
lastFrameTimestamp = frameTimestamp;
|
|
43
|
-
animationFrameId = requestAnimationFrame(updateProgress);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const onMouseEnter = () => {
|
|
47
|
-
lastFrameTimestamp = null;
|
|
48
|
-
cancelAnimation();
|
|
49
|
-
};
|
|
50
|
-
const onMouseLeave = () => {
|
|
51
|
-
if (!animationFrameId) animationFrameId = requestAnimationFrame(updateProgress);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
messageElement.addEventListener("mouseenter", onMouseEnter);
|
|
55
|
-
messageElement.addEventListener("mouseleave", onMouseLeave);
|
|
56
|
-
messageProgressCleanups.set(messageElement, () => {
|
|
57
|
-
cancelAnimation();
|
|
58
|
-
messageElement.removeEventListener("mouseenter", onMouseEnter);
|
|
59
|
-
messageElement.removeEventListener("mouseleave", onMouseLeave);
|
|
60
|
-
});
|
|
61
|
-
animationFrameId = requestAnimationFrame(updateProgress);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const scheduleReflow = () => {
|
|
65
|
-
if (reflowScheduled) return;
|
|
66
|
-
reflowScheduled = true;
|
|
67
|
-
requestAnimationFrame(() => {
|
|
68
|
-
reflowScheduled = false;
|
|
69
|
-
let offset = MESSAGE_TOP_REM;
|
|
70
|
-
for (const el of activeMessages) {
|
|
71
|
-
el.style.top = `${offset}rem`;
|
|
72
|
-
offset += PxToRem(el.offsetHeight) + MESSAGE_GAP_REM;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const dismissMessage = (el: HTMLElement, callback?: PopupMessageCallback) => {
|
|
78
|
-
const index = activeMessages.indexOf(el);
|
|
79
|
-
if (index === -1) return;
|
|
80
|
-
|
|
81
|
-
stopMessageProgress(el);
|
|
82
|
-
activeMessages.splice(index, 1);
|
|
83
|
-
el.style.right = "-100%";
|
|
84
|
-
el.style.top = "100%";
|
|
85
|
-
RemoveElement(el, DEFAULT_ANIMATION_DURATION, EAnimationClasses.FADE_OUT);
|
|
86
|
-
scheduleReflow();
|
|
87
|
-
callback?.(ECallbackTypes.Destroy);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const _showMessage = (title: string, message: string, messageType: EMessageTypes, delay?: number | UN, duration?: number | UN, icon?: EMessageIcons | UN, callback?: PopupMessageCallback) => {
|
|
91
|
-
if (!IsBrowser()) return;
|
|
92
|
-
|
|
93
|
-
delay = delay ?? 0;
|
|
94
|
-
duration = duration ?? 3000;
|
|
95
|
-
|
|
96
|
-
const createAndShow = () => {
|
|
97
|
-
/** Root message element */
|
|
98
|
-
const messageRootElement = document.createElement("div");
|
|
99
|
-
const messageBodyElement = document.createElement("div");
|
|
100
|
-
const messageHandleElement = document.createElement("div");
|
|
101
|
-
const messageContentElement = document.createElement("div");
|
|
102
|
-
const messageIconElement = document.createElement("div");
|
|
103
|
-
const progressTrackElement = document.createElement("div");
|
|
104
|
-
const progressFillElement = document.createElement("div");
|
|
105
|
-
|
|
106
|
-
document.body.appendChild(messageRootElement);
|
|
107
|
-
messageRootElement.appendChild(messageBodyElement);
|
|
108
|
-
messageBodyElement.appendChild(messageHandleElement);
|
|
109
|
-
messageBodyElement.appendChild(messageIconElement);
|
|
110
|
-
messageBodyElement.appendChild(messageContentElement);
|
|
111
|
-
messageRootElement.appendChild(progressTrackElement);
|
|
112
|
-
progressTrackElement.appendChild(progressFillElement);
|
|
113
|
-
|
|
114
|
-
messageRootElement.className = `${MESSAGE_IDENTITY} pf bs3 r bg1 anim df ddc oh`;
|
|
115
|
-
messageBodyElement.className = "df ac w100";
|
|
116
|
-
messageHandleElement.className = messageType;
|
|
117
|
-
messageIconElement.className = `ib ml4 sm rr ${messageType}`;
|
|
118
|
-
messageContentElement.className = `p4 pr2 fg`;
|
|
119
|
-
progressTrackElement.className = "w100";
|
|
120
|
-
progressFillElement.className = messageType;
|
|
121
|
-
|
|
122
|
-
messageRootElement.style.right = "-100%";
|
|
123
|
-
messageRootElement.style.transitionDuration = `${DEFAULT_ANIMATION_DURATION * 1.5}ms`;
|
|
124
|
-
|
|
125
|
-
messageHandleElement.style.width = "0.3rem";
|
|
126
|
-
messageHandleElement.style.alignSelf = "stretch";
|
|
127
|
-
messageHandleElement.style.flexShrink = "0";
|
|
128
|
-
|
|
129
|
-
progressTrackElement.style.height = `${PROGRESS_BAR_HEIGHT_REM}rem`;
|
|
130
|
-
progressTrackElement.style.flexShrink = "0";
|
|
131
|
-
progressFillElement.style.height = "100%";
|
|
132
|
-
progressFillElement.style.width = "0%";
|
|
133
|
-
|
|
134
|
-
messageIconElement.innerHTML = `<${DEFAULT_ICON_ELEMENT_NAME} class="icon" name="${icon}" />`;
|
|
135
|
-
|
|
136
|
-
const _TM = setTimeout(() => {
|
|
137
|
-
clearTimeout(_TM);
|
|
138
|
-
const WINDOW_WIDTH = window.innerWidth;
|
|
139
|
-
if (WINDOW_WIDTH > 1000) {
|
|
140
|
-
messageRootElement.style.right = "1rem";
|
|
141
|
-
messageRootElement.style.maxWidth = "35rem";
|
|
142
|
-
messageRootElement.style.minWidth = "16rem";
|
|
143
|
-
} else {
|
|
144
|
-
messageRootElement.style.maxWidth = "calc(100vw - 1rem)";
|
|
145
|
-
messageRootElement.style.minWidth = "15rem";
|
|
146
|
-
messageRootElement.style.right = "0.5rem";
|
|
147
|
-
}
|
|
148
|
-
}, 0);
|
|
149
|
-
|
|
150
|
-
const titleElement = document.createElement("p");
|
|
151
|
-
const messageElement = document.createElement("p");
|
|
152
|
-
titleElement.className = "mb1 fw600 w100 df ac";
|
|
153
|
-
messageElement.className = "o08 fs-09 pr3";
|
|
154
|
-
titleElement.innerHTML = `<p class="w100 fg">${title}</p>`;
|
|
155
|
-
messageElement.innerHTML = message;
|
|
156
|
-
messageContentElement.appendChild(titleElement);
|
|
157
|
-
messageContentElement.appendChild(messageElement);
|
|
158
|
-
|
|
159
|
-
const dismiss = () => dismissMessage(messageRootElement, callback);
|
|
160
|
-
CreateIconBox(EIcons.CLOSE, titleElement, null, null, EIconTypes.OUTLINED, EBackgrounds.Background1, ESizes.VeryTiny, ESizes.Tiny, null, null, null, null, EOpacity.O05, "Clear Message", null, null, null, dismiss);
|
|
161
|
-
|
|
162
|
-
activeMessages.unshift(messageRootElement);
|
|
163
|
-
scheduleReflow();
|
|
164
|
-
requestAnimationFrame(scheduleReflow);
|
|
165
|
-
callback?.(ECallbackTypes.Initialize);
|
|
166
|
-
|
|
167
|
-
if (duration > 0) startMessageProgress(messageRootElement, progressFillElement, duration, dismiss);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
if (typeof delay === "number" && delay > 0) {
|
|
171
|
-
const _TM = window.setTimeout(() => {
|
|
172
|
-
clearTimeout(_TM);
|
|
173
|
-
createAndShow();
|
|
174
|
-
}, delay);
|
|
175
|
-
} else createAndShow();
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
export const SuccessMessage = (title: string, message: string, delay?: number | UN, duration?: number | UN, callback?: PopupMessageCallback, icon?: EMessageIcons | UN) => {
|
|
179
|
-
return _showMessage(title, message, EMessageTypes.Success, delay, duration, icon ?? EMessageIcons.Success, callback);
|
|
180
|
-
};
|
|
181
|
-
export const ErrorMessage = (title: string, message: string, delay?: number | UN, duration?: number | UN, callback?: PopupMessageCallback, icon?: EMessageIcons | UN) => {
|
|
182
|
-
return _showMessage(title, message, EMessageTypes.Error, delay, duration, icon ?? EMessageIcons.Error, callback);
|
|
183
|
-
};
|
|
184
|
-
export const WarningMessage = (title: string, message: string, delay?: number | UN, duration?: number | UN, callback?: PopupMessageCallback, icon?: EMessageIcons | UN) => {
|
|
185
|
-
return _showMessage(title, message, EMessageTypes.Warning, delay, duration, icon ?? EMessageIcons.Warning, callback);
|
|
186
|
-
};
|
|
187
|
-
export const InformationMessage = (title: string, message: string, delay?: number | UN, duration?: number | UN, callback?: PopupMessageCallback, icon?: EMessageIcons | UN) => {
|
|
188
|
-
return _showMessage(title, message, EMessageTypes.Information, delay, duration, icon ?? EMessageIcons.Information, callback);
|
|
189
|
-
};
|
|
190
|
-
export const QuestionMessage = (title: string, message: string, delay?: number | UN, duration?: number | UN, callback?: PopupMessageCallback, icon?: EMessageIcons | UN) => {
|
|
191
|
-
return _showMessage(title, message, EMessageTypes.Information, delay, duration, icon ?? EMessageIcons.Question, callback);
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
type MessageBoxButton = {
|
|
195
|
-
result: EMessageResult;
|
|
196
|
-
label: string;
|
|
197
|
-
themeBackgroundClass?: EBackgrounds | string;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const normalizeMessageResult = (value: string): EMessageResult => {
|
|
201
|
-
const v = (value ?? "").trim().toLowerCase();
|
|
202
|
-
if (v === "ok") return EMessageResult.OK;
|
|
203
|
-
if (v === "yes") return EMessageResult.Yes;
|
|
204
|
-
if (v === "no") return EMessageResult.No;
|
|
205
|
-
if (v === "cancel") return EMessageResult.Cancel;
|
|
206
|
-
return EMessageResult.Undefined;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
const getMessageBoxButtons = (messageButtons: EMessageBoxButtons, themeBackgroundClass: EMessageTypes, overrideYesButtonText?: string | null): MessageBoxButton[] => {
|
|
210
|
-
const parts = (messageButtons ?? EMessageBoxButtons.OK).split("_").filter(Boolean);
|
|
211
|
-
const results = parts.map(normalizeMessageResult).filter((r) => r !== EMessageResult.Undefined);
|
|
212
|
-
const resolved = results.length ? results : [EMessageResult.OK];
|
|
213
|
-
|
|
214
|
-
return resolved.map((result) => {
|
|
215
|
-
if (result === EMessageResult.Yes) return { result, label: overrideYesButtonText ?? "Yes", themeBackgroundClass };
|
|
216
|
-
if (result === EMessageResult.OK) return { result, label: "OK", themeBackgroundClass: themeBackgroundClass };
|
|
217
|
-
if (result === EMessageResult.No) return { result, label: "No", themeBackgroundClass: EBackgrounds.AlwaysDarkBackgroundColor };
|
|
218
|
-
if (result === EMessageResult.Cancel) return { result, label: "Cancel", themeBackgroundClass: EBackgrounds.AlwaysDarkBackgroundColor };
|
|
219
|
-
return { result, label: String(result) };
|
|
220
|
-
});
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
const getCloseResult = (buttons: MessageBoxButton[]): EMessageResult => {
|
|
224
|
-
if (buttons.some((b) => b.result === EMessageResult.Cancel)) return EMessageResult.Cancel;
|
|
225
|
-
if (buttons.some((b) => b.result === EMessageResult.No)) return EMessageResult.No;
|
|
226
|
-
if (buttons.some((b) => b.result === EMessageResult.OK)) return EMessageResult.OK;
|
|
227
|
-
return EMessageResult.Undefined;
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Windows-like modal message box (DOM-based).
|
|
232
|
-
* - Keyboard: Tab / Shift+Tab / ArrowLeft / ArrowRight to move focus
|
|
233
|
-
* - Enter: activates focused button
|
|
234
|
-
* - Escape: closes with Cancel/No/OK (in that order if present)
|
|
235
|
-
*/
|
|
236
|
-
export const ShowDialogMessageBox = async (messageButtons: EMessageBoxButtons, title: string, message: string, iconName: EMessageIcons, themeBackgroundClass?: EMessageTypes, overrideYesButtonText?: string | null, confirmMessage?: string | null, allowOverlayClick?: boolean): Promise<EMessageResult | null> => {
|
|
237
|
-
if (!IsBrowser()) return null;
|
|
238
|
-
|
|
239
|
-
return new Promise((resolve) => {
|
|
240
|
-
themeBackgroundClass = themeBackgroundClass ?? EMessageTypes.Information;
|
|
241
|
-
const bodyElement = document.body as HTMLBodyElement;
|
|
242
|
-
const overlayElement = document.createElement("div") as HTMLDivElement;
|
|
243
|
-
const dialogElement = document.createElement("div") as HTMLDivElement;
|
|
244
|
-
|
|
245
|
-
const iconBoxElement = document.createElement("div") as HTMLDivElement;
|
|
246
|
-
const headerElement = document.createElement("div") as HTMLDivElement;
|
|
247
|
-
const headerTextElement = document.createElement("div") as HTMLDivElement;
|
|
248
|
-
const titleElement = document.createElement("h4") as HTMLHeadingElement;
|
|
249
|
-
const messageElement = document.createElement("p") as HTMLParagraphElement;
|
|
250
|
-
const confirmElement = document.createElement("p") as HTMLParagraphElement;
|
|
251
|
-
const buttonRowElement = document.createElement("div") as HTMLDivElement;
|
|
252
|
-
|
|
253
|
-
const buttons = getMessageBoxButtons(messageButtons, themeBackgroundClass, overrideYesButtonText);
|
|
254
|
-
const actionButtons: HTMLButtonElement[] = [];
|
|
255
|
-
let currentFocusIndex = 0;
|
|
256
|
-
let isClosed = false;
|
|
257
|
-
|
|
258
|
-
overlayElement.className = `pf df ac jc ${EBackgrounds.PopupBackgroundColor} ${EAnimationClasses.FADE_IN}`;
|
|
259
|
-
overlayElement.style.zIndex = "100000";
|
|
260
|
-
overlayElement.style.inset = "0";
|
|
261
|
-
|
|
262
|
-
dialogElement.className = `bg1 r bs3 anim df ddc`;
|
|
263
|
-
dialogElement.style.maxWidth = "36rem";
|
|
264
|
-
dialogElement.style.width = "calc(100vw - 2rem)";
|
|
265
|
-
dialogElement.style.boxSizing = "border-box";
|
|
266
|
-
|
|
267
|
-
headerElement.className = "df w100";
|
|
268
|
-
headerElement.style.gap = "1rem";
|
|
269
|
-
headerElement.style.padding = "1.25rem";
|
|
270
|
-
|
|
271
|
-
iconBoxElement.className = `df ac jc rr bb ${themeBackgroundClass}`;
|
|
272
|
-
iconBoxElement.style.minWidth = "4rem";
|
|
273
|
-
iconBoxElement.style.maxWidth = "4rem";
|
|
274
|
-
iconBoxElement.style.minHeight = "4rem";
|
|
275
|
-
iconBoxElement.style.maxHeight = "4rem";
|
|
276
|
-
|
|
277
|
-
const iconElement = document.createElement(DEFAULT_ICON_ELEMENT_NAME) as HTMLElement & { name?: string };
|
|
278
|
-
iconElement.name = `${iconName}${EIconTypes.OUTLINED}`;
|
|
279
|
-
iconElement.className = `icon ${ESizes.Large} o08`;
|
|
280
|
-
iconElement.style.color = "white";
|
|
281
|
-
iconBoxElement.appendChild(iconElement);
|
|
282
|
-
|
|
283
|
-
headerTextElement.className = "fg";
|
|
284
|
-
|
|
285
|
-
titleElement.className = "fw600";
|
|
286
|
-
titleElement.style.margin = "0";
|
|
287
|
-
titleElement.innerText = title ?? "";
|
|
288
|
-
|
|
289
|
-
messageElement.className = "o08";
|
|
290
|
-
messageElement.style.margin = "0.5rem 0 0 0";
|
|
291
|
-
messageElement.innerHTML = message ?? "";
|
|
292
|
-
|
|
293
|
-
confirmElement.className = "o08";
|
|
294
|
-
confirmElement.style.margin = "0.75rem 0 0 0";
|
|
295
|
-
confirmElement.innerHTML = confirmMessage ?? "";
|
|
296
|
-
if (!confirmMessage) confirmElement.style.display = "none";
|
|
297
|
-
|
|
298
|
-
buttonRowElement.className = "df w100";
|
|
299
|
-
buttonRowElement.style.gap = "0.75rem";
|
|
300
|
-
buttonRowElement.style.justifyContent = "flex-end";
|
|
301
|
-
buttonRowElement.style.padding = "0 1.25rem 1.25rem 1.25rem";
|
|
302
|
-
|
|
303
|
-
const setFocus = (index: number) => {
|
|
304
|
-
currentFocusIndex = Math.min(Math.max(index, 0), actionButtons.length - 1);
|
|
305
|
-
actionButtons[currentFocusIndex]?.focus();
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
const closeDialog = (result: EMessageResult) => {
|
|
309
|
-
if (isClosed) return;
|
|
310
|
-
isClosed = true;
|
|
311
|
-
|
|
312
|
-
document.removeEventListener("keydown", onKeyDown);
|
|
313
|
-
overlayElement.removeEventListener("click", onOverlayClick);
|
|
314
|
-
|
|
315
|
-
overlayElement.classList.remove(EAnimationClasses.FADE_IN);
|
|
316
|
-
overlayElement.classList.add(EAnimationClasses.FADE_OUT);
|
|
317
|
-
dialogElement.classList.add(EAnimationClasses.PULSE_OUT);
|
|
318
|
-
|
|
319
|
-
RemoveElement(overlayElement, DEFAULT_ANIMATION_DURATION, EAnimationClasses.FADE_OUT).finally(() => resolve(result));
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
const onOverlayClick = (event: MouseEvent) => {
|
|
323
|
-
if (event.target === overlayElement) closeDialog(getCloseResult(buttons));
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
const onKeyDown = (event: KeyboardEvent) => {
|
|
327
|
-
const key = event.key;
|
|
328
|
-
const isShiftTab = key === "Tab" && event.shiftKey;
|
|
329
|
-
const isTab = key === "Tab" && !event.shiftKey;
|
|
330
|
-
|
|
331
|
-
if (key === "ArrowLeft" || isShiftTab) {
|
|
332
|
-
event.preventDefault();
|
|
333
|
-
setFocus((currentFocusIndex - 1 + actionButtons.length) % actionButtons.length);
|
|
334
|
-
} else if (key === "ArrowRight" || isTab) {
|
|
335
|
-
event.preventDefault();
|
|
336
|
-
setFocus((currentFocusIndex + 1) % actionButtons.length);
|
|
337
|
-
} else if (key === "Enter") {
|
|
338
|
-
event.preventDefault();
|
|
339
|
-
const result = buttons[currentFocusIndex]?.result ?? EMessageResult.Undefined;
|
|
340
|
-
closeDialog(result);
|
|
341
|
-
} else if (key === "Escape") {
|
|
342
|
-
event.preventDefault();
|
|
343
|
-
closeDialog(getCloseResult(buttons));
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
const createButton = (button: MessageBoxButton) => {
|
|
348
|
-
const buttonElement = document.createElement("button") as HTMLButtonElement;
|
|
349
|
-
buttonElement.type = "button";
|
|
350
|
-
buttonElement.className = `sn r h p2 pr4 pl4 ${button.themeBackgroundClass}`;
|
|
351
|
-
buttonElement.style.minWidth = "5.5rem";
|
|
352
|
-
buttonElement.innerText = button.label;
|
|
353
|
-
|
|
354
|
-
const onClick = () => closeDialog(button.result);
|
|
355
|
-
buttonElement.addEventListener("click", onClick, { once: true });
|
|
356
|
-
return buttonElement;
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
for (const button of buttons) {
|
|
360
|
-
const buttonElement = createButton(button);
|
|
361
|
-
buttonRowElement.appendChild(buttonElement);
|
|
362
|
-
actionButtons.push(buttonElement);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
headerTextElement.appendChild(titleElement);
|
|
366
|
-
headerTextElement.appendChild(messageElement);
|
|
367
|
-
headerTextElement.appendChild(confirmElement);
|
|
368
|
-
|
|
369
|
-
headerElement.appendChild(iconBoxElement);
|
|
370
|
-
headerElement.appendChild(headerTextElement);
|
|
371
|
-
|
|
372
|
-
dialogElement.appendChild(headerElement);
|
|
373
|
-
dialogElement.appendChild(buttonRowElement);
|
|
374
|
-
|
|
375
|
-
overlayElement.appendChild(dialogElement);
|
|
376
|
-
bodyElement.insertBefore(overlayElement, bodyElement.firstChild);
|
|
377
|
-
|
|
378
|
-
if (allowOverlayClick === false) overlayElement.addEventListener("click", onOverlayClick);
|
|
379
|
-
document.addEventListener("keydown", onKeyDown);
|
|
380
|
-
|
|
381
|
-
setTimeout(() => setFocus(0), 0);
|
|
382
|
-
});
|
|
383
|
-
};
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_SMALL_ICON_BOX_SIZE } from "../interfaces/icon-interfaces";
|
|
2
|
-
import { DEFAULT_FONT_WEIGHTS } from "../interfaces/layout-interfaces";
|
|
3
|
-
import { O } from "../nexus-client";
|
|
4
|
-
import { EBackgroundColors, EColorTypes, ETextColors, IThemeInformation } from "./../interfaces/theme-interfaces";
|
|
5
|
-
import { GetCurrentTheme, SetCurrentTheme } from "./localstorage-service";
|
|
6
|
-
|
|
7
|
-
const I = "!important;";
|
|
8
|
-
export const ICON_BOX_SCALES = {
|
|
9
|
-
xxs: 1 / 1.7,
|
|
10
|
-
xs: 1 / 1.5,
|
|
11
|
-
sm: DEFAULT_SMALL_ICON_BOX_SIZE,
|
|
12
|
-
ssm: 1 / 1.35,
|
|
13
|
-
lg: 1.25,
|
|
14
|
-
med: 1.1,
|
|
15
|
-
xl: 1.5,
|
|
16
|
-
xxl: 1.8,
|
|
17
|
-
};
|
|
18
|
-
export const THEME_KEYS = ["c1", "c2", "c3", "c10", "c11", "c12", "c13", "c20", "c30", "c41", "c51", "c52", "c100", "c200", "c400", "c600", "c800", "c950"];
|
|
19
|
-
|
|
20
|
-
const _setVariable = (key: string, value: string | null) => {
|
|
21
|
-
if (value) document.documentElement.style.setProperty(key, value);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const _initializeThemes = (themeInformations: IThemeInformation[]): boolean => {
|
|
25
|
-
if (!themeInformations || themeInformations.length === 0) return false;
|
|
26
|
-
|
|
27
|
-
const activeTheme = GetCurrentTheme();
|
|
28
|
-
return _initializeTheme(activeTheme!);
|
|
29
|
-
};
|
|
30
|
-
const _setRule = (sheet: CSSStyleSheet, s: string, r: string) => sheet.insertRule(`${s} { ${r} }`, sheet.cssRules.length);
|
|
31
|
-
const _setResponsiveRule = (sheet: CSSStyleSheet, i: number, max: number, pre: string, w: string, g?: number) => sheet.insertRule(`@media (max-width: ${max}px) { ${g !== undefined ? `.g${g} > ` : ""}.col-${pre}-${i} { width: ${w}${I} } }`, sheet.cssRules.length);
|
|
32
|
-
const _initializeTheme = (theme: IThemeInformation): boolean => {
|
|
33
|
-
if (!theme) return false;
|
|
34
|
-
SetCurrentTheme(theme.systemName);
|
|
35
|
-
|
|
36
|
-
for (const key of THEME_KEYS) {
|
|
37
|
-
const color = theme[key as keyof IThemeInformation] as string;
|
|
38
|
-
const [background, hover, focus, text] = color.split("|");
|
|
39
|
-
|
|
40
|
-
if (!background) continue;
|
|
41
|
-
const keyNumber = key.replace("c", "");
|
|
42
|
-
|
|
43
|
-
if (background !== "NULL") _setVariable(`--B${keyNumber}`, background);
|
|
44
|
-
if (hover !== "NULL") _setVariable(`--H${keyNumber}`, hover);
|
|
45
|
-
if (focus !== "NULL") _setVariable(`--F${keyNumber}`, focus);
|
|
46
|
-
if (text !== "NULL") _setVariable(`--T${keyNumber}`, text);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return true;
|
|
50
|
-
};
|
|
51
|
-
export const InitializeStyles = () => {
|
|
52
|
-
const el = document.getElementById("nexus-styles") as HTMLStyleElement;
|
|
53
|
-
if (!el || !el.classList.contains("nexus-styles")) el.classList.add("nexus-styles");
|
|
54
|
-
const sheet = el.sheet as CSSStyleSheet;
|
|
55
|
-
const themeInformations = O.systemThemes;
|
|
56
|
-
if (!themeInformations || themeInformations.length === 0) return;
|
|
57
|
-
_initializeThemes(themeInformations);
|
|
58
|
-
|
|
59
|
-
const BREAK_POINTS = { xl: 1200, lg: 1050, med: 900, nr: 800, sm: 700, xs: 600 } as any;
|
|
60
|
-
const SUFFIXES = ["", "-top", "-right", "-bottom", "-left"];
|
|
61
|
-
const DIRECTIONS = ["", "t", "r", "b", "l"];
|
|
62
|
-
|
|
63
|
-
Array.from({ length: 12 }, (_, i) => i + 1).forEach((i) => {
|
|
64
|
-
const w = `${(i / 12) * 100}%`;
|
|
65
|
-
_setRule(sheet, `.col-${i}`, `float: left; box-sizing: border-box; width: ${w};`);
|
|
66
|
-
Object.keys(BREAK_POINTS).forEach((b) => _setResponsiveRule(sheet, i, BREAK_POINTS[b], b, w));
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
Array.from({ length: 10 }, (_, i) => i + 1).forEach((i) => {
|
|
70
|
-
const m = 0.2 * i,
|
|
71
|
-
w = `calc((100% / 12) * ${i} - ${m * 2}rem)`;
|
|
72
|
-
_setRule(sheet, `.g${i}`, `padding: 0 ${m}rem;`);
|
|
73
|
-
_setRule(sheet, `.g${i} > [class*='col-']`, `margin: 0 ${m}rem; float: left; box-sizing: border-box;`);
|
|
74
|
-
_setRule(sheet, `.g${i} > .col-12`, `width: ${w}; float: left; box-sizing: border-box;`);
|
|
75
|
-
Array.from({ length: 12 }, (_, j) => j + 1).forEach((j) => {
|
|
76
|
-
const wj = `calc((100% / 12) * ${j} - ${m * 2}rem)`;
|
|
77
|
-
_setRule(sheet, `.g${i} > .col-${j}`, `width: ${wj}; float: left; box-sizing: border-box;`);
|
|
78
|
-
Object.keys(BREAK_POINTS).forEach((b) => _setResponsiveRule(sheet, j, BREAK_POINTS[b], b, wj, i));
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
Array.from({ length: 11 }, (_, i) => {
|
|
82
|
-
const v = 0.2 * (10 - i);
|
|
83
|
-
DIRECTIONS.forEach((d, idx) => {
|
|
84
|
-
const imp = d ? I : ";";
|
|
85
|
-
_setRule(sheet, `.m${d}${10 - i}`, `margin${SUFFIXES[idx]}: ${v}rem${imp}`);
|
|
86
|
-
_setRule(sheet, `.p${d}${10 - i}`, `padding${SUFFIXES[idx]}: ${v}rem${imp}`);
|
|
87
|
-
});
|
|
88
|
-
_setRule(sheet, `.g${10 - i}`, `gap: ${v}rem;`);
|
|
89
|
-
_setRule(sheet, `.cg${10 - i}`, `column-gap: ${v}rem;`);
|
|
90
|
-
_setRule(sheet, `.rg${10 - i}`, `row-gap: ${v}rem;`);
|
|
91
|
-
if (i > 0 && i <= 6) _setRule(sheet, `.h${i}, h${i}`, `font-size: ${(6 - i) * 0.3 + 1}rem;font-weight: 600;`);
|
|
92
|
-
});
|
|
93
|
-
Array.from({ length: 13 }, (_, i) => 0.6 + 0.1 * i).forEach((v) => _setRule(sheet, `.fs-${v.toFixed(1).replace(".", "")}`, `font-size: ${v.toFixed(1)}rem;`));
|
|
94
|
-
Array.from({ length: 4 }, (_, i) => 0.5 + 0.1 * i).forEach((v) => _setRule(sheet, `.o${v.toFixed(1).replace(".", "")}`, `opacity: ${v.toFixed(1)};`));
|
|
95
|
-
Array.from({ length: 9 }, (_, i) => {
|
|
96
|
-
_setRule(sheet, `.tl${i}`, `display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; -webkit-line-clamp: ${i};`);
|
|
97
|
-
if (i <= 8) _setRule(sheet, `.bs${i}`, `box-shadow: var(--BS${i});`);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
DEFAULT_FONT_WEIGHTS.forEach((weight) => _setRule(sheet, `.fw${weight}`, `font-weight: ${weight};`));
|
|
101
|
-
|
|
102
|
-
[90, 180, 270].forEach((r) => _setRule(sheet, `.r${r}`, `transform: rotate(${r}deg);`));
|
|
103
|
-
[1, 2, 3].forEach((s) => {
|
|
104
|
-
const b = `var(--BRD${s}) solid var(--B30)`;
|
|
105
|
-
DIRECTIONS.forEach((d, i) => _setRule(sheet, `.b${d}${s}`, `border${SUFFIXES[i]}: ${b}${d ? ` ${I}` : ""}`));
|
|
106
|
-
_setRule(sheet, `.bat${s}`, `border: var(--BRD${s}) solid transparent`);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
for (const key of THEME_KEYS) {
|
|
110
|
-
const keyNumber = key.replace("c", "");
|
|
111
|
-
_setRule(sheet, `.bg${keyNumber}`, `background-color: var(--B${keyNumber}) ${I}; color: var(--T${keyNumber});`);
|
|
112
|
-
_setRule(sheet, `.h.bg${keyNumber}:hover`, `background-color: var(--H${keyNumber}) ${I}`);
|
|
113
|
-
_setRule(sheet, `.h.bg${keyNumber}:focus`, `background-color: var(--F${keyNumber}) ${I}`);
|
|
114
|
-
_setRule(sheet, `.tx${keyNumber}`, `color: var(--T${keyNumber}) ${I}`);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const ICON_SIZES = {
|
|
118
|
-
xxs: 0.8,
|
|
119
|
-
xs: 1,
|
|
120
|
-
ssm: 1.25,
|
|
121
|
-
sm: 1.4,
|
|
122
|
-
nr: 1.55,
|
|
123
|
-
med: 1.75,
|
|
124
|
-
lg: 1.95,
|
|
125
|
-
xl: 2.2,
|
|
126
|
-
xxl: 2.5,
|
|
127
|
-
fs: 2.85,
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
Object.entries(ICON_SIZES).forEach(([k, v]) => _setRule(sheet, `.icon.${k}`, `font-size: ${v}rem;`));
|
|
131
|
-
|
|
132
|
-
Object.entries(ICON_BOX_SCALES).forEach(([k, s]) => {
|
|
133
|
-
const size = `calc(var(--IH) * ${s})`;
|
|
134
|
-
const css = `min-width: ${size} ${I}; min-height: ${size} ${I}; max-width: ${size} ${I}; max-height: ${size} ${I};`;
|
|
135
|
-
_setRule(sheet, `.ib.${k}`, css);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
_setVariable(`--TOP_HEIGHT`, `calc(var(--IH) * ${ICON_BOX_SCALES.sm})`);
|
|
139
|
-
};
|
|
140
|
-
export const SwitchTheme = (themeCode: string): boolean => {
|
|
141
|
-
const themeInformations = O.systemThemes;
|
|
142
|
-
if (!themeInformations || themeInformations.length === 0) return false;
|
|
143
|
-
|
|
144
|
-
const theme = themeInformations.find((theme) => theme.systemName === themeCode);
|
|
145
|
-
if (!theme) return false;
|
|
146
|
-
SetCurrentTheme(theme.systemName);
|
|
147
|
-
return _initializeTheme(theme);
|
|
148
|
-
};
|
|
149
|
-
export const GetColorCode = (colorCode: string | EBackgroundColors | ETextColors): number | null => {
|
|
150
|
-
if (colorCode) {
|
|
151
|
-
const match = colorCode.match(/\d+/);
|
|
152
|
-
return match ? parseInt(match[0], 10) : 0;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return null;
|
|
156
|
-
};
|
|
157
|
-
export const GetDynamicColor = (colorCode: string | EBackgroundColors | ETextColors, colorType: EColorTypes): string | null => {
|
|
158
|
-
if (colorCode) {
|
|
159
|
-
const code = GetColorCode(colorCode);
|
|
160
|
-
if (code) return `var(${colorType}${code})`;
|
|
161
|
-
}
|
|
162
|
-
return null;
|
|
163
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { EUserRoles, ICurrentUser, UN } from "../interface";
|
|
2
|
-
|
|
3
|
-
let CURRENT_USER: ICurrentUser | null = null;
|
|
4
|
-
export const SetCurrentUser = (user: ICurrentUser | UN) => (CURRENT_USER = user ?? null);
|
|
5
|
-
export const GetCurrentUser = (): ICurrentUser | null => CURRENT_USER;
|
|
6
|
-
export const GetCurrentUserRole = (): EUserRoles | null => {
|
|
7
|
-
const roleName = CURRENT_USER?.roleName;
|
|
8
|
-
if (!roleName) return null;
|
|
9
|
-
return EUserRoles[roleName as keyof typeof EUserRoles];
|
|
10
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { IUserValidationResponse } from "../interfaces/user-interfaces";
|
|
2
|
-
import { HttpGet } from "../services/http-services";
|
|
3
|
-
import { SSO_CONFIG } from "./sso-config";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Verifies the access token by calling the backend Authentication/Verify endpoint.
|
|
7
|
-
* Returns true when the backend responds with HTTP 200 (token accepted), false for any
|
|
8
|
-
* other status or network failure. No JWT secrets or JWKS keys are needed in Next.js.
|
|
9
|
-
*/
|
|
10
|
-
export async function VerifyAccessToken(token: string): Promise<boolean> {
|
|
11
|
-
if (!token?.trim()) return false;
|
|
12
|
-
const response = await HttpGet(SSO_CONFIG.BACKEND_ENDPOINTS.VERIFY, token, 0);
|
|
13
|
-
const validationResponse = response.result as IUserValidationResponse;
|
|
14
|
-
if (!response.isSuccess) return false;
|
|
15
|
-
return validationResponse.isValidUser;
|
|
16
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from "next/server";
|
|
2
|
-
import { URLS } from "../nexus.environments";
|
|
3
|
-
import { SetAuthCookies } from "./cookie-helpers";
|
|
4
|
-
import { DecodeOAuthCallbackState } from "./oauth-callback-state";
|
|
5
|
-
import { ClearRedirectContextCookie, SanitizeReturnPath } from "./redirect-context-helpers";
|
|
6
|
-
import { ExchangeAuthorizationCode } from "./sso-backend-flow";
|
|
7
|
-
import { BuildAuthenticationSignInUrl, SSO_CONFIG } from "./sso-config";
|
|
8
|
-
|
|
9
|
-
export async function CallbackRoute(req: NextRequest) {
|
|
10
|
-
const code = req.nextUrl.searchParams.get("code");
|
|
11
|
-
const state = req.nextUrl.searchParams.get("state");
|
|
12
|
-
const callbackState = DecodeOAuthCallbackState(state);
|
|
13
|
-
const failUrl = new URL(BuildAuthenticationSignInUrl(callbackState?.returnPath));
|
|
14
|
-
|
|
15
|
-
if (!code) return NextResponse.redirect(failUrl);
|
|
16
|
-
|
|
17
|
-
if (!callbackState?.codeVerifier) return NextResponse.redirect(failUrl);
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
const tokenData = await ExchangeAuthorizationCode({
|
|
21
|
-
code,
|
|
22
|
-
redirectUri: SSO_CONFIG.FRONTEND_ENDPOINTS.CALLBACK,
|
|
23
|
-
codeVerifier: callbackState.codeVerifier,
|
|
24
|
-
});
|
|
25
|
-
if (!tokenData) return NextResponse.redirect(failUrl);
|
|
26
|
-
|
|
27
|
-
const redirectTarget = new URL(SanitizeReturnPath(tokenData.returnPath ?? callbackState.returnPath), URLS.CURRENT!);
|
|
28
|
-
const response = NextResponse.redirect(redirectTarget);
|
|
29
|
-
SetAuthCookies(response, tokenData);
|
|
30
|
-
ClearRedirectContextCookie(response);
|
|
31
|
-
return response;
|
|
32
|
-
} catch {
|
|
33
|
-
return NextResponse.redirect(new URL(BuildAuthenticationSignInUrl(callbackState?.returnPath)));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { createCipheriv, createDecipheriv, createHash, randomBytes } from "crypto";
|
|
2
|
-
|
|
3
|
-
const ALGORITHM = "aes-256-gcm";
|
|
4
|
-
const IV_BYTES = 12; // 96-bit IV recommended for GCM
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Derives a 32-byte AES key from SSO_COOKIE_SECRET using SHA-256.
|
|
8
|
-
* The secret itself is never sent to the browser.
|
|
9
|
-
*/
|
|
10
|
-
function deriveKey(): Buffer {
|
|
11
|
-
const raw = process.env.SSO_COOKIE_SECRET?.trim();
|
|
12
|
-
const secret = raw && !raw.startsWith("$") ? raw : process.env.NODE_ENV === "development" ? "NexusDevAuthSecretKey2026MustBe32CharsLong!" : null;
|
|
13
|
-
if (!secret) throw new Error("SSO_COOKIE_SECRET must be configured for cookie encryption.");
|
|
14
|
-
return createHash("sha256").update(secret).digest();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Encrypts a cookie value with AES-256-GCM.
|
|
19
|
-
* Output format: `<iv>.<authTag>.<ciphertext>` (all base64url).
|
|
20
|
-
* The browser stores only this opaque string — the raw token is never exposed.
|
|
21
|
-
*/
|
|
22
|
-
export function EncryptCookieValue(value: string): string {
|
|
23
|
-
const key = deriveKey();
|
|
24
|
-
const iv = randomBytes(IV_BYTES);
|
|
25
|
-
const cipher = createCipheriv(ALGORITHM, key, iv);
|
|
26
|
-
const encrypted = Buffer.concat([cipher.update(value, "utf8"), cipher.final()]);
|
|
27
|
-
const authTag = cipher.getAuthTag();
|
|
28
|
-
return `${iv.toString("base64url")}.${authTag.toString("base64url")}.${encrypted.toString("base64url")}`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Decrypts a cookie value produced by EncryptCookieValue.
|
|
33
|
-
* Returns null if the value is missing, malformed, or the auth tag fails (tampered).
|
|
34
|
-
*/
|
|
35
|
-
export function DecryptCookieValue(value: string): string | null {
|
|
36
|
-
if (!value) return null;
|
|
37
|
-
try {
|
|
38
|
-
const parts = value.split(".");
|
|
39
|
-
if (parts.length !== 3) return null;
|
|
40
|
-
const key = deriveKey();
|
|
41
|
-
const iv = Buffer.from(parts[0], "base64url");
|
|
42
|
-
const authTag = Buffer.from(parts[1], "base64url");
|
|
43
|
-
const encrypted = Buffer.from(parts[2], "base64url");
|
|
44
|
-
const decipher = createDecipheriv(ALGORITHM, key, iv);
|
|
45
|
-
decipher.setAuthTag(authTag);
|
|
46
|
-
const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
|
|
47
|
-
return decrypted.toString("utf8");
|
|
48
|
-
} catch {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
}
|