nexus-shared 1.1.21 → 3.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/CHANGELOG.md +262 -0
- package/LICENSE +21 -0
- package/README.md +1000 -0
- package/dist/Client.Index.d.ts +55 -0
- package/dist/Client.Index.js +60 -0
- package/dist/Components/Chats/Chat.d.ts +28 -0
- package/dist/Components/Chats/Chat.js +19 -0
- package/dist/Components/Chats/ChatButton.d.ts +26 -0
- package/dist/Components/Chats/ChatButton.js +41 -0
- package/dist/Components/Chats/ChatComposer.d.ts +41 -0
- package/dist/Components/Chats/ChatComposer.js +177 -0
- package/dist/Components/Chats/ChatConversations.d.ts +35 -0
- package/dist/Components/Chats/ChatConversations.js +38 -0
- package/dist/Components/Chats/ChatPanel.d.ts +66 -0
- package/dist/Components/Chats/ChatPanel.js +94 -0
- package/dist/Components/Chats/ChatParts.d.ts +87 -0
- package/dist/Components/Chats/ChatParts.js +100 -0
- package/dist/Components/Chats/ChatThread.d.ts +22 -0
- package/dist/Components/Chats/ChatThread.js +96 -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 +242 -0
- package/dist/Components/Documents/SplitButton.d.ts +64 -0
- package/dist/Components/Documents/SplitButton.js +129 -0
- package/dist/Components/Documents/TabButtons.d.ts +80 -0
- package/dist/Components/Documents/TabButtons.js +38 -0
- package/dist/Components/Forms/ApiForm.d.ts +23 -0
- package/dist/Components/Forms/ApiForm.js +100 -0
- package/dist/Components/Forms/Crud.d.ts +17 -0
- package/dist/Components/Forms/Crud.js +708 -0
- package/dist/Components/Forms/CrudParts.d.ts +15 -0
- package/dist/Components/Forms/CrudParts.js +36 -0
- package/dist/Components/Forms/ExcelImport.d.ts +42 -0
- package/dist/Components/Forms/ExcelImport.js +190 -0
- package/dist/Components/Forms/Form.d.ts +52 -0
- package/dist/Components/Forms/Form.js +323 -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 +400 -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 +172 -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 +37 -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 +117 -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 +115 -0
- package/dist/Components/Inputs/RowsInput.js +308 -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 +27 -0
- package/dist/Components/Inputs/TabularForm.js +348 -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 +240 -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 +49 -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 +596 -0
- package/dist/Components/Viewers/DataTableColumns.d.ts +28 -0
- package/dist/Components/Viewers/DataTableColumns.js +243 -0
- package/dist/Components/Viewers/DataTableParts.d.ts +138 -0
- package/dist/Components/Viewers/DataTableParts.js +157 -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 +96 -0
- package/dist/Helpers/ApiClient.js +200 -0
- package/dist/Helpers/ApiFormHelpers.d.ts +49 -0
- package/dist/Helpers/ApiFormHelpers.js +120 -0
- package/dist/Helpers/ApiModules.d.ts +131 -0
- package/dist/Helpers/ApiModules.js +195 -0
- package/dist/Helpers/ApiResponses.d.ts +51 -0
- package/dist/Helpers/ApiResponses.js +250 -0
- package/dist/Helpers/ApiRoutes.d.ts +140 -0
- package/dist/Helpers/ApiRoutes.js +183 -0
- package/dist/Helpers/ApiToasts.d.ts +21 -0
- package/dist/Helpers/ApiToasts.js +22 -0
- package/dist/Helpers/ChatBackend.d.ts +134 -0
- package/dist/Helpers/ChatBackend.js +332 -0
- package/dist/Helpers/ChatHelpers.d.ts +189 -0
- package/dist/Helpers/ChatHelpers.js +486 -0
- package/dist/Helpers/ChatHooks.d.ts +81 -0
- package/dist/Helpers/ChatHooks.js +175 -0
- package/dist/Helpers/ChatStore.d.ts +132 -0
- package/dist/Helpers/ChatStore.js +394 -0
- package/dist/Helpers/ChatSummaries.d.ts +39 -0
- package/dist/Helpers/ChatSummaries.js +118 -0
- package/dist/Helpers/ClassHelpers.d.ts +3 -0
- package/dist/Helpers/ClassHelpers.js +4 -0
- package/dist/Helpers/CrudBackend.d.ts +98 -0
- package/dist/Helpers/CrudBackend.js +214 -0
- package/dist/Helpers/CrudHelpers.d.ts +111 -0
- package/dist/Helpers/CrudHelpers.js +267 -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/ExcelBackend.d.ts +106 -0
- package/dist/Helpers/ExcelBackend.js +290 -0
- package/dist/Helpers/ExcelHelpers.d.ts +98 -0
- package/dist/Helpers/ExcelHelpers.js +302 -0
- package/dist/Helpers/FormDrafts.d.ts +18 -0
- package/dist/Helpers/FormDrafts.js +76 -0
- package/dist/Helpers/FormStore.d.ts +233 -0
- package/dist/Helpers/FormStore.js +752 -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 +252 -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 +68 -0
- package/dist/Helpers/PopoverHelpers.js +195 -0
- package/dist/Helpers/RichTextHelpers.d.ts +77 -0
- package/dist/Helpers/RichTextHelpers.js +1072 -0
- package/dist/Helpers/RowsStore.d.ts +166 -0
- package/dist/Helpers/RowsStore.js +606 -0
- package/dist/Helpers/TableColumns.d.ts +47 -0
- package/dist/Helpers/TableColumns.js +282 -0
- package/dist/Helpers/TableExport.d.ts +30 -0
- package/dist/Helpers/TableExport.js +97 -0
- package/dist/Helpers/TableHelpers.d.ts +110 -0
- package/dist/Helpers/TableHelpers.js +301 -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 +174 -0
- package/dist/Interfaces/ApiInterfaces.js +30 -0
- package/dist/Interfaces/ChatInterfaces.d.ts +240 -0
- package/{src/sso-client.tsx → dist/Interfaces/ChatInterfaces.js} +1 -1
- package/dist/Interfaces/CrudInterfaces.d.ts +232 -0
- package/dist/Interfaces/CrudInterfaces.js +1 -0
- package/dist/Interfaces/DateInterfaces.d.ts +154 -0
- package/dist/Interfaces/DateInterfaces.js +29 -0
- package/dist/Interfaces/ExcelInterfaces.d.ts +215 -0
- package/dist/Interfaces/ExcelInterfaces.js +45 -0
- package/dist/Interfaces/FormInterfaces.d.ts +402 -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 +351 -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 +95 -0
- package/dist/Services/BrowserApi.js +129 -0
- package/dist/Services/ChatApi.d.ts +37 -0
- package/dist/Services/ChatApi.js +98 -0
- package/dist/Services/ExcelApi.d.ts +46 -0
- package/dist/Services/ExcelApi.js +196 -0
- package/dist/Services/ServerApi.d.ts +54 -0
- package/dist/Services/ServerApi.js +78 -0
- package/dist/Services/ThemeService.d.ts +17 -0
- package/dist/Services/ThemeService.js +83 -0
- package/dist/Shared.Index.d.ts +51 -0
- package/dist/Shared.Index.js +55 -0
- package/package.json +85 -33
- package/src/Styles/Nexus.Base.css +70 -0
- package/src/Styles/Nexus.Button.css +153 -0
- package/src/Styles/Nexus.Calendar.css +275 -0
- package/src/Styles/Nexus.Chat.css +1489 -0
- package/src/Styles/Nexus.Choice.css +345 -0
- package/src/Styles/Nexus.Crud.css +161 -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.Excel.css +370 -0
- package/src/Styles/Nexus.Form.css +321 -0
- package/src/Styles/Nexus.Index.css +36 -0
- package/src/Styles/Nexus.Input.css +637 -0
- package/src/Styles/Nexus.Markdown.css +265 -0
- package/src/Styles/Nexus.Menu.css +259 -0
- package/src/Styles/Nexus.Popup.css +731 -0
- package/src/Styles/Nexus.RichText.css +463 -0
- package/src/Styles/Nexus.Rows.css +596 -0
- package/src/Styles/Nexus.Slider.css +278 -0
- package/src/Styles/Nexus.Tab.Buttons.css +419 -0
- package/src/Styles/Nexus.Table.css +1296 -0
- package/src/Styles/Nexus.Theme.Picker.css +232 -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
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type ToastTone = "neutral" | "info" | "success" | "warning" | "danger";
|
|
3
|
+
export type ToastPosition = "top-right" | "top-center" | "top-left" | "bottom-right" | "bottom-center" | "bottom-left";
|
|
4
|
+
export interface ToastAction {
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
}
|
|
8
|
+
export interface ToastOptions {
|
|
9
|
+
/** Pass the id of a toast that is showing to update it in place. */
|
|
10
|
+
id?: string;
|
|
11
|
+
/** Text under the title. */
|
|
12
|
+
message?: ReactNode;
|
|
13
|
+
/** Default `neutral`. */
|
|
14
|
+
tone?: ToastTone;
|
|
15
|
+
/** Replaces the tone's icon; `null` shows none. */
|
|
16
|
+
icon?: ReactNode | null;
|
|
17
|
+
/** Milliseconds until the toast closes itself. Default 5000; 0 keeps it until it is closed. Pauses while hovered. */
|
|
18
|
+
duration?: number;
|
|
19
|
+
/** A button at the end, such as Undo. Clicking it closes the toast. */
|
|
20
|
+
action?: ToastAction;
|
|
21
|
+
/** Shows the close button. Default true. */
|
|
22
|
+
closable?: boolean;
|
|
23
|
+
/** Where this toast stacks. Default: the Toaster's position. */
|
|
24
|
+
position?: ToastPosition;
|
|
25
|
+
/** After the toast has left. */
|
|
26
|
+
onClose?: () => void;
|
|
27
|
+
}
|
|
28
|
+
export interface ToastData extends ToastOptions {
|
|
29
|
+
id: string;
|
|
30
|
+
title: ReactNode;
|
|
31
|
+
tone: ToastTone;
|
|
32
|
+
duration: number;
|
|
33
|
+
/** The toast is playing its exit animation. */
|
|
34
|
+
closing: boolean;
|
|
35
|
+
/** Grows on every update, so the timer starts again. */
|
|
36
|
+
version: number;
|
|
37
|
+
}
|
|
38
|
+
/** Shows a toast, or updates the one with the same `id`. Returns the id. */
|
|
39
|
+
declare function show(title: ReactNode, options?: ToastOptions | string): string;
|
|
40
|
+
/** Closes one toast, or every toast without an id. */
|
|
41
|
+
export declare function dismissToast(id?: string): void;
|
|
42
|
+
type ToastText<T> = ReactNode | ((value: T) => ReactNode);
|
|
43
|
+
declare function loading(title: ReactNode, options?: ToastOptions | string): string;
|
|
44
|
+
export interface ToastPromiseTexts<T> {
|
|
45
|
+
loading: ReactNode;
|
|
46
|
+
success: ToastText<T>;
|
|
47
|
+
error: ToastText<unknown>;
|
|
48
|
+
}
|
|
49
|
+
/** A loading toast that turns into a success or an error toast when the promise settles. Returns the promise. */
|
|
50
|
+
declare function promise<T>(work: Promise<T>, texts: ToastPromiseTexts<T>, options?: ToastOptions): Promise<T>;
|
|
51
|
+
/**
|
|
52
|
+
* Shows a toast: `toast("Saved")`, `toast.success("Booking confirmed", "Room 204, 3 nights")`,
|
|
53
|
+
* `toast.error("Could not save", { action: { label: "Retry", onClick: save } })`, `toast.promise(save(), { ... })`.
|
|
54
|
+
* Needs one `<Toaster />` on the page.
|
|
55
|
+
*/
|
|
56
|
+
export declare const toast: typeof show & {
|
|
57
|
+
info: (title: ReactNode, options?: ToastOptions | string) => string;
|
|
58
|
+
success: (title: ReactNode, options?: ToastOptions | string) => string;
|
|
59
|
+
warning: (title: ReactNode, options?: ToastOptions | string) => string;
|
|
60
|
+
error: (title: ReactNode, options?: ToastOptions | string) => string;
|
|
61
|
+
loading: typeof loading;
|
|
62
|
+
promise: typeof promise;
|
|
63
|
+
dismiss: typeof dismissToast;
|
|
64
|
+
};
|
|
65
|
+
export interface ToasterProps {
|
|
66
|
+
/** Corner or edge where toasts stack. Default `top-right`. */
|
|
67
|
+
position?: ToastPosition;
|
|
68
|
+
/** Most toasts shown at once per position; the oldest close to make room. Default 5. */
|
|
69
|
+
max?: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Shows the toasts. Put one in the root layout. Toasts stack from the chosen edge, newest nearest to it,
|
|
73
|
+
* and the rest of the page stays clickable around them.
|
|
74
|
+
*/
|
|
75
|
+
export declare function Toaster({ position, max }: ToasterProps): import("react").JSX.Element;
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { iconAlertCircle, iconAlertTriangle, iconCircleCheck, iconInfoCircle, iconLoader2, iconX, InlineIcon } from "nexus-icons";
|
|
4
|
+
import { useEffect, useLayoutEffect, useRef, useSyncExternalStore } from "react";
|
|
5
|
+
import { afterAnimation } from "../../Helpers/AnimationHelpers.js";
|
|
6
|
+
import { cx } from "../../Helpers/ClassHelpers.js";
|
|
7
|
+
const DEFAULT_DURATION = 5000;
|
|
8
|
+
const GAP = 8;
|
|
9
|
+
const EMPTY = [];
|
|
10
|
+
let toasts = [];
|
|
11
|
+
let counter = 0;
|
|
12
|
+
let hosts = 0;
|
|
13
|
+
let warned = false;
|
|
14
|
+
const listeners = new Set();
|
|
15
|
+
function emit() {
|
|
16
|
+
for (const listener of listeners)
|
|
17
|
+
listener();
|
|
18
|
+
}
|
|
19
|
+
function subscribe(listener) {
|
|
20
|
+
listeners.add(listener);
|
|
21
|
+
return () => {
|
|
22
|
+
listeners.delete(listener);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const getSnapshot = () => toasts;
|
|
26
|
+
const getServerSnapshot = () => EMPTY;
|
|
27
|
+
function normalize(options) {
|
|
28
|
+
return typeof options === "string" ? { message: options } : (options ?? {});
|
|
29
|
+
}
|
|
30
|
+
/** Shows a toast, or updates the one with the same `id`. Returns the id. */
|
|
31
|
+
function show(title, options) {
|
|
32
|
+
const next = normalize(options);
|
|
33
|
+
const id = next.id ?? `nx-toast-${++counter}`;
|
|
34
|
+
const existing = toasts.find(item => item.id === id);
|
|
35
|
+
const data = {
|
|
36
|
+
...existing,
|
|
37
|
+
...next,
|
|
38
|
+
id,
|
|
39
|
+
title,
|
|
40
|
+
tone: next.tone ?? existing?.tone ?? "neutral",
|
|
41
|
+
duration: next.duration ?? existing?.duration ?? DEFAULT_DURATION,
|
|
42
|
+
closing: false,
|
|
43
|
+
version: (existing?.version ?? 0) + 1,
|
|
44
|
+
};
|
|
45
|
+
toasts = existing ? toasts.map(item => (item.id === id ? data : item)) : [data, ...toasts];
|
|
46
|
+
if (hosts === 0 && !warned && typeof window !== "undefined") {
|
|
47
|
+
warned = true;
|
|
48
|
+
console.warn("toast(): no <Toaster /> is mounted, so toasts cannot show. Add one to the root layout.");
|
|
49
|
+
}
|
|
50
|
+
emit();
|
|
51
|
+
return id;
|
|
52
|
+
}
|
|
53
|
+
/** Closes one toast, or every toast without an id. */
|
|
54
|
+
export function dismissToast(id) {
|
|
55
|
+
let changed = false;
|
|
56
|
+
toasts = toasts.map(item => {
|
|
57
|
+
if ((id === undefined || item.id === id) && !item.closing) {
|
|
58
|
+
changed = true;
|
|
59
|
+
return { ...item, closing: true };
|
|
60
|
+
}
|
|
61
|
+
return item;
|
|
62
|
+
});
|
|
63
|
+
if (changed)
|
|
64
|
+
emit();
|
|
65
|
+
}
|
|
66
|
+
function removeToast(id) {
|
|
67
|
+
const item = toasts.find(candidate => candidate.id === id);
|
|
68
|
+
if (!item)
|
|
69
|
+
return;
|
|
70
|
+
toasts = toasts.filter(candidate => candidate.id !== id);
|
|
71
|
+
emit();
|
|
72
|
+
item.onClose?.();
|
|
73
|
+
}
|
|
74
|
+
const withTone = (options, tone) => ({ ...normalize(options), tone });
|
|
75
|
+
const resolveText = (text, value) => (typeof text === "function" ? text(value) : text);
|
|
76
|
+
function loading(title, options) {
|
|
77
|
+
return show(title, { ...normalize(options), tone: "neutral", icon: _jsx(InlineIcon, { icon: iconLoader2, className: "nx-spin" }), duration: 0, closable: false });
|
|
78
|
+
}
|
|
79
|
+
/** A loading toast that turns into a success or an error toast when the promise settles. Returns the promise. */
|
|
80
|
+
function promise(work, texts, options) {
|
|
81
|
+
const id = loading(texts.loading, options);
|
|
82
|
+
const settle = (tone, title) => show(title, { ...options, id, tone, icon: undefined, duration: options?.duration ?? DEFAULT_DURATION, closable: options?.closable ?? true });
|
|
83
|
+
work.then(value => settle("success", resolveText(texts.success, value)), error => settle("danger", resolveText(texts.error, error)));
|
|
84
|
+
return work;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Shows a toast: `toast("Saved")`, `toast.success("Booking confirmed", "Room 204, 3 nights")`,
|
|
88
|
+
* `toast.error("Could not save", { action: { label: "Retry", onClick: save } })`, `toast.promise(save(), { ... })`.
|
|
89
|
+
* Needs one `<Toaster />` on the page.
|
|
90
|
+
*/
|
|
91
|
+
export const toast = Object.assign(show, {
|
|
92
|
+
info: (title, options) => show(title, withTone(options, "info")),
|
|
93
|
+
success: (title, options) => show(title, withTone(options, "success")),
|
|
94
|
+
warning: (title, options) => show(title, withTone(options, "warning")),
|
|
95
|
+
error: (title, options) => show(title, withTone(options, "danger")),
|
|
96
|
+
loading,
|
|
97
|
+
promise,
|
|
98
|
+
dismiss: dismissToast,
|
|
99
|
+
});
|
|
100
|
+
const TONE_ICONS = {
|
|
101
|
+
neutral: null,
|
|
102
|
+
info: iconInfoCircle,
|
|
103
|
+
success: iconCircleCheck,
|
|
104
|
+
warning: iconAlertTriangle,
|
|
105
|
+
danger: iconAlertCircle,
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Shows the toasts. Put one in the root layout. Toasts stack from the chosen edge, newest nearest to it,
|
|
109
|
+
* and the rest of the page stays clickable around them.
|
|
110
|
+
*/
|
|
111
|
+
export function Toaster({ position = "top-right", max = 5 }) {
|
|
112
|
+
const items = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
113
|
+
const rootRef = useRef(null);
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
hosts++;
|
|
116
|
+
return () => {
|
|
117
|
+
hosts--;
|
|
118
|
+
};
|
|
119
|
+
}, []);
|
|
120
|
+
// Over the limit, the oldest toasts of that position close.
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
const perPosition = new Map();
|
|
123
|
+
for (const item of items) {
|
|
124
|
+
if (item.closing)
|
|
125
|
+
continue;
|
|
126
|
+
const key = item.position ?? position;
|
|
127
|
+
const count = (perPosition.get(key) ?? 0) + 1;
|
|
128
|
+
perPosition.set(key, count);
|
|
129
|
+
if (count > max)
|
|
130
|
+
dismissToast(item.id);
|
|
131
|
+
}
|
|
132
|
+
}, [items, max, position]);
|
|
133
|
+
// Every toast is shown as a popover and stacked from its edge; a closing toast keeps no room, so the others slide up.
|
|
134
|
+
useLayoutEffect(() => {
|
|
135
|
+
const root = rootRef.current;
|
|
136
|
+
if (!root)
|
|
137
|
+
return;
|
|
138
|
+
const offsets = new Map();
|
|
139
|
+
for (const node of Array.from(root.querySelectorAll(".nx-toast"))) {
|
|
140
|
+
if (typeof node.showPopover === "function" && !node.matches(":popover-open"))
|
|
141
|
+
node.showPopover();
|
|
142
|
+
const key = node.dataset.position ?? position;
|
|
143
|
+
const offset = offsets.get(key) ?? 0;
|
|
144
|
+
node.style.setProperty("--nx-toast-offset", `${offset}px`);
|
|
145
|
+
if (!node.classList.contains("nx-toast--closing"))
|
|
146
|
+
offsets.set(key, offset + node.offsetHeight + GAP);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return (_jsx("div", { ref: rootRef, className: "nx-toaster", children: items.map(item => (_jsx(ToastView, { item: item, position: item.position ?? position }, item.id))) }));
|
|
150
|
+
}
|
|
151
|
+
function ToastView({ item, position }) {
|
|
152
|
+
const { id, title, message, tone, icon, duration, action, closable = true, closing, version } = item;
|
|
153
|
+
const nodeRef = useRef(null);
|
|
154
|
+
// The toast leaves once its exit animation has played, or in the same frame with reduced motion.
|
|
155
|
+
useLayoutEffect(() => {
|
|
156
|
+
const node = nodeRef.current;
|
|
157
|
+
if (!closing || !node)
|
|
158
|
+
return;
|
|
159
|
+
return afterAnimation(node, "nx-toast-out", () => removeToast(id));
|
|
160
|
+
}, [closing, id]);
|
|
161
|
+
const toneIcon = TONE_ICONS[tone];
|
|
162
|
+
const shownIcon = icon === undefined ? (toneIcon && _jsx(InlineIcon, { icon: toneIcon })) : icon;
|
|
163
|
+
function onProgressEnd(event) {
|
|
164
|
+
event.stopPropagation();
|
|
165
|
+
if (event.animationName === "nx-toast-progress")
|
|
166
|
+
dismissToast(id);
|
|
167
|
+
}
|
|
168
|
+
return (_jsxs("div", { ref: nodeRef, popover: "manual", role: tone === "danger" || tone === "warning" ? "alert" : "status", "data-position": position, className: cx("nx-toast", `nx-toast--${tone}`, `nx-toast--${position}`, closing && "nx-toast--closing"), children: [shownIcon && _jsx("span", { className: "nx-toast__icon", children: shownIcon }), _jsxs("div", { className: "nx-toast__body", children: [_jsx("div", { className: "nx-toast__title", children: title }), message && _jsx("div", { className: "nx-toast__message", children: message })] }), action && (_jsx("button", { type: "button", className: "nx-toast__action", onClick: () => {
|
|
169
|
+
action.onClick();
|
|
170
|
+
dismissToast(id);
|
|
171
|
+
}, children: action.label })), closable && (_jsx("button", { type: "button", className: "nx-toast__close", "aria-label": "Close", title: "Close", onClick: () => dismissToast(id), children: _jsx(InlineIcon, { icon: iconX }) })), duration > 0 && !closing && _jsx("span", { className: "nx-toast__progress", style: { animationDuration: `${duration}ms` }, onAnimationEnd: onProgressEnd }, version)] }));
|
|
172
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TableStore } from "../../Helpers/TableStore.ts";
|
|
2
|
+
import type { DataTableProps, TableRow } from "../../Interfaces/TableInterfaces.ts";
|
|
3
|
+
/**
|
|
4
|
+
* The store of a table, for the page: pass it as `table`, then call `table.reload()`, `table.upsert(row)`, or
|
|
5
|
+
* `table.getSelected()` from anywhere.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useTable<TRow extends TableRow = TableRow>(): TableStore<TRow>;
|
|
8
|
+
/**
|
|
9
|
+
* A data table. Columns are params (`{ key, label, format, ... }`); rows are given (`rows`), loaded once (`load`), or
|
|
10
|
+
* loaded a page at a time (`load` with `paging="server"`, which sends the search, the sort, and the page). The user
|
|
11
|
+
* arranges the columns: the Columns menu shows and hides them, a heading drags into another place, its edge changes its
|
|
12
|
+
* width, and its menu pins it left or right; with a `stateKey` the table remembers all of it on the device.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* <DataTable
|
|
16
|
+
* aria-label="Guests"
|
|
17
|
+
* columns={[{ key: "name", label: "Name" }, { key: "visits", label: "Visits", format: "number" }]}
|
|
18
|
+
* load={(query, signal) => fetchGuests(query, signal)}
|
|
19
|
+
* paging="server"
|
|
20
|
+
* selectable
|
|
21
|
+
* massActions={[{ id: "email", label: "Email", onSelect: rows => email(rows) }]}
|
|
22
|
+
* rowActions={row => [{ id: "edit", label: "Edit", icon: <InlineIcon icon={iconPencil} />, inline: true, onSelect: edit }]}
|
|
23
|
+
* />
|
|
24
|
+
*/
|
|
25
|
+
export declare function DataTable<TRow extends TableRow = TableRow>(props: DataTableProps<TRow>): import("react").JSX.Element;
|