@abpjs/theme-shared 1.1.0 → 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.
@@ -11,6 +11,8 @@ export interface ConfirmationDialogProps {
11
11
  *
12
12
  * In Chakra v3, we use Dialog with role="alertdialog" instead of AlertDialog.
13
13
  *
14
+ * @since 2.0.0 - Updated to use Confirmation.DialogData structure
15
+ *
14
16
  * @example
15
17
  * ```tsx
16
18
  * function App() {
@@ -2,19 +2,27 @@ import React from 'react';
2
2
  import { Toaster } from '../../models';
3
3
  /**
4
4
  * Get Chakra color palette for severity.
5
+ * @since 2.0.0 - Added 'neutral' and 'warning' support
5
6
  */
6
7
  declare function getSeverityColorPalette(severity: Toaster.Severity): string;
7
8
  /**
8
9
  * Get background color for severity.
10
+ * @since 2.0.0 - Added 'neutral' and 'warning' support
9
11
  */
10
12
  declare function getSeverityBg(severity: Toaster.Severity): string;
11
13
  /**
12
14
  * Get border color for severity.
15
+ * @since 2.0.0 - Added 'neutral' and 'warning' support
13
16
  */
14
17
  declare function getSeverityBorderColor(severity: Toaster.Severity): string;
15
18
  export interface ToastContainerProps {
16
19
  /** Position of toasts */
17
20
  position?: 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left';
21
+ /**
22
+ * Container key for filtering toasts to this container
23
+ * @since 2.0.0
24
+ */
25
+ containerKey?: string;
18
26
  }
19
27
  /**
20
28
  * ToastContainer - Syncs toaster state with Chakra v3's toast system.
@@ -26,6 +34,8 @@ export interface ToastContainerProps {
26
34
  * handle RTL languages - toasts will appear on the correct side based on
27
35
  * the current text direction.
28
36
  *
37
+ * @since 2.0.0 - Added containerKey prop for filtering toasts
38
+ *
29
39
  * @example
30
40
  * ```tsx
31
41
  * function App() {
@@ -38,6 +48,6 @@ export interface ToastContainerProps {
38
48
  * }
39
49
  * ```
40
50
  */
41
- export declare function ToastContainer({ position }: ToastContainerProps): React.ReactElement;
51
+ export declare function ToastContainer({ position, containerKey }: ToastContainerProps): React.ReactElement;
42
52
  export { getSeverityColorPalette as getSeverityColorScheme, getSeverityBg, getSeverityBorderColor };
43
53
  export default ToastContainer;
@@ -2,6 +2,11 @@
2
2
  * Default global styles for ABP theme shared components.
3
3
  * These styles can be injected into your app's global CSS or used with a style tag.
4
4
  *
5
+ * @since 2.0.0 - Updated styles:
6
+ * - Removed modal-specific styles (now handled by components)
7
+ * - Added sorting icon styles
8
+ * - Added table scrollbar width styling
9
+ *
5
10
  * @example
6
11
  * ```tsx
7
12
  * // Option 1: Use with a style tag in your app
@@ -20,5 +25,5 @@
20
25
  * // Copy the content of DEFAULT_STYLES to your styles.css
21
26
  * ```
22
27
  */
23
- export declare const DEFAULT_STYLES = "\n.is-invalid .form-control {\n border-color: #dc3545;\n border-style: solid !important;\n}\n\n.is-invalid .invalid-feedback,\n.is-invalid + * .invalid-feedback {\n display: block;\n}\n\n.data-tables-filter {\n text-align: right;\n}\n\n.pointer {\n cursor: pointer;\n}\n\n.navbar .dropdown-submenu a::after {\n transform: rotate(-90deg);\n position: absolute;\n right: 16px;\n top: 18px;\n}\n\n.modal {\n background-color: rgba(0, 0, 0, .6);\n}\n\n.abp-ellipsis {\n display: inline-block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* <animations */\n\n.fade-in-top {\n animation: fadeInTop 0.4s ease-in-out;\n}\n\n.fade-out-top {\n animation: fadeOutTop 0.4s ease-in-out;\n}\n\n@keyframes fadeInTop {\n from {\n transform: translateY(-5px);\n opacity: 0;\n }\n\n to {\n transform: translateY(5px);\n opacity: 1;\n }\n}\n\n@keyframes fadeOutTop {\n to {\n transform: translateY(-5px);\n opacity: 0;\n }\n}\n\n/* </animations */\n\n/* Loader bar styles */\n.abp-loader-bar {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n height: 3px;\n z-index: 9999;\n background-color: rgba(0, 0, 0, 0.1);\n overflow: hidden;\n}\n\n.abp-progress {\n height: 100%;\n background-color: #3182ce;\n transition: width 0.3s ease-out;\n}\n";
28
+ export declare const DEFAULT_STYLES = "\n.is-invalid .form-control {\n border-color: #dc3545;\n border-style: solid !important;\n}\n\n.is-invalid .invalid-feedback,\n.is-invalid + * .invalid-feedback {\n display: block;\n}\n\n.data-tables-filter {\n text-align: right;\n}\n\n.pointer {\n cursor: pointer;\n}\n\n.navbar .dropdown-submenu a::after {\n transform: rotate(-90deg);\n position: absolute;\n right: 16px;\n top: 18px;\n}\n\n.navbar .dropdown-menu {\n min-width: 215px;\n}\n\n.ui-table-scrollable-body::-webkit-scrollbar {\n height: 5px !important;\n width: 5px !important;\n}\n\n.ui-table-scrollable-body::-webkit-scrollbar-track {\n background: #ddd;\n}\n\n.ui-table-scrollable-body::-webkit-scrollbar-thumb {\n background: #8a8686;\n}\n\n.abp-ellipsis-inline {\n display: inline-block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.abp-ellipsis {\n overflow: hidden !important;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.ui-widget-overlay {\n z-index: 1000;\n}\n\n.color-white {\n color: #FFF !important;\n}\n\n.custom-checkbox > label {\n cursor: pointer;\n}\n\n/* <animations */\n\n.fade-in-top {\n animation: fadeInTop 0.2s ease-in-out;\n}\n\n.fade-out-top {\n animation: fadeOutTop 0.2s ease-in-out;\n}\n\n.abp-collapsed-height {\n -moz-transition: max-height linear 0.35s;\n -ms-transition: max-height linear 0.35s;\n -o-transition: max-height linear 0.35s;\n -webkit-transition: max-height linear 0.35s;\n overflow:hidden;\n transition:max-height 0.35s linear;\n height:auto;\n max-height: 0;\n}\n\n.abp-mh-25 {\n max-height: 25vh;\n}\n\n.abp-mh-50 {\n transition:max-height 0.65s linear;\n max-height: 50vh;\n}\n\n.abp-mh-75 {\n transition:max-height 0.85s linear;\n max-height: 75vh;\n}\n\n.abp-mh-100 {\n transition:max-height 1s linear;\n max-height: 100vh;\n}\n\n/* Sorting icon styles - @since 2.0.0 */\n[class^=\"sorting\"] {\n opacity: .3;\n cursor: pointer;\n}\n[class^=\"sorting\"]:before {\n right: 0.5rem;\n content: \"\u2191\";\n}\n[class^=\"sorting\"]:after {\n right: 0.5rem;\n content: \"\u2193\";\n}\n\n.sorting_desc {\n opacity: 1;\n}\n.sorting_desc:before {\n opacity: .3;\n}\n\n.sorting_asc {\n opacity: 1;\n}\n.sorting_asc:after {\n opacity: .3;\n}\n\n@keyframes fadeInTop {\n from {\n transform: translateY(-5px);\n opacity: 0;\n }\n\n to {\n transform: translateY(0px);\n opacity: 1;\n }\n}\n\n@keyframes fadeOutTop {\n to {\n transform: translateY(-5px);\n opacity: 0;\n }\n}\n\n/* </animations */\n\n/* Loader bar styles */\n.abp-loader-bar {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n height: 3px;\n z-index: 9999;\n background-color: rgba(0, 0, 0, 0.1);\n overflow: hidden;\n}\n\n.abp-progress {\n height: 100%;\n background-color: #3182ce;\n transition: width 0.3s ease-out;\n}\n";
24
29
  export default DEFAULT_STYLES;
@@ -1,41 +1,86 @@
1
1
  import React, { type ReactNode } from 'react';
2
+ import type { Config } from '@abpjs/core';
2
3
  import { Confirmation, Toaster } from '../models';
3
4
  /**
4
- * Internal confirmation message structure.
5
+ * Subscriber callback type for confirmation$ observable pattern
6
+ * @since 2.0.0
5
7
  */
6
- export interface ConfirmationMessage {
7
- /** Unique ID for this confirmation */
8
- id: string;
9
- /** Message content (can be localization key) */
10
- message: string;
11
- /** Title (can be localization key) */
12
- title?: string;
13
- /** Severity level affects the styling */
14
- severity: Toaster.Severity;
15
- /** Options for the confirmation */
16
- options: Confirmation.Options;
17
- }
8
+ type ConfirmationSubscriber = (data: Confirmation.DialogData | null) => void;
18
9
  /**
19
10
  * ConfirmationService interface - matches the Angular service API.
11
+ * @since 2.0.0 - Major changes:
12
+ * - No longer extends AbstractToaster
13
+ * - Added confirmation$ ReplaySubject pattern via subscribe method
14
+ * - Now accepts Config.LocalizationParam for message and title
20
15
  */
21
16
  export interface ConfirmationService {
22
- /** Show an info confirmation */
23
- info(message: string, title?: string, options?: Confirmation.Options): Promise<Toaster.Status>;
24
- /** Show a success confirmation */
25
- success(message: string, title?: string, options?: Confirmation.Options): Promise<Toaster.Status>;
26
- /** Show a warning confirmation */
27
- warn(message: string, title?: string, options?: Confirmation.Options): Promise<Toaster.Status>;
28
- /** Show an error confirmation */
29
- error(message: string, title?: string, options?: Confirmation.Options): Promise<Toaster.Status>;
30
- /** Clear the current confirmation */
17
+ /**
18
+ * Show an info confirmation
19
+ * @param message Message content (supports localization)
20
+ * @param title Title (supports localization)
21
+ * @param options Confirmation options
22
+ * @returns Promise resolving to user's response status
23
+ */
24
+ info(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Confirmation.Options>): Promise<Toaster.Status>;
25
+ /**
26
+ * Show a success confirmation
27
+ * @param message Message content (supports localization)
28
+ * @param title Title (supports localization)
29
+ * @param options Confirmation options
30
+ * @returns Promise resolving to user's response status
31
+ */
32
+ success(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Confirmation.Options>): Promise<Toaster.Status>;
33
+ /**
34
+ * Show a warning confirmation
35
+ * @param message Message content (supports localization)
36
+ * @param title Title (supports localization)
37
+ * @param options Confirmation options
38
+ * @returns Promise resolving to user's response status
39
+ */
40
+ warn(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Confirmation.Options>): Promise<Toaster.Status>;
41
+ /**
42
+ * Show an error confirmation
43
+ * @param message Message content (supports localization)
44
+ * @param title Title (supports localization)
45
+ * @param options Confirmation options
46
+ * @returns Promise resolving to user's response status
47
+ */
48
+ error(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Confirmation.Options>): Promise<Toaster.Status>;
49
+ /**
50
+ * Show a confirmation with specified severity
51
+ * @param message Message content (supports localization)
52
+ * @param title Title (supports localization)
53
+ * @param severity Severity level for styling
54
+ * @param options Confirmation options
55
+ * @returns Promise resolving to user's response status
56
+ * @since 2.0.0
57
+ */
58
+ show(message: Config.LocalizationParam, title?: Config.LocalizationParam, severity?: Confirmation.Severity, options?: Partial<Confirmation.Options>): Promise<Toaster.Status>;
59
+ /**
60
+ * Clear the current confirmation
61
+ * @param status Optional status to resolve with (default: dismiss)
62
+ */
31
63
  clear(status?: Toaster.Status): void;
64
+ /**
65
+ * Listen for escape key to dismiss confirmation
66
+ * @since 2.0.0
67
+ */
68
+ listenToEscape(): void;
69
+ /**
70
+ * Subscribe to confirmation updates (mimics RxJS ReplaySubject pattern).
71
+ * @param subscriber Callback function called with current confirmation data
72
+ * @returns Unsubscribe function
73
+ * @since 2.0.0
74
+ */
75
+ subscribe(subscriber: ConfirmationSubscriber): () => void;
32
76
  }
33
77
  /**
34
78
  * Context value containing the service and current confirmation.
35
79
  */
36
80
  export interface ConfirmationContextValue {
37
81
  service: ConfirmationService;
38
- confirmation: ConfirmationMessage | null;
82
+ /** Current confirmation dialog data */
83
+ confirmation: Confirmation.DialogData | null;
39
84
  /** Respond to the current confirmation */
40
85
  respond: (status: Toaster.Status) => void;
41
86
  }
@@ -48,6 +93,12 @@ export interface ConfirmationProviderProps {
48
93
  * This is the React equivalent of Angular's ConfirmationService.
49
94
  * Wrap your app with this provider to enable confirmation dialogs.
50
95
  *
96
+ * @since 2.0.0 - Major changes:
97
+ * - Now accepts Config.LocalizationParam for message and title
98
+ * - Added subscribe method for observable pattern
99
+ * - Added listenToEscape method
100
+ * - Uses Confirmation.DialogData structure
101
+ *
51
102
  * @example
52
103
  * ```tsx
53
104
  * <ConfirmationProvider>
@@ -63,6 +114,8 @@ export declare function ConfirmationProvider({ children }: ConfirmationProviderP
63
114
  * @returns ConfirmationService with methods to show confirmation dialogs
64
115
  * @throws Error if used outside of ConfirmationProvider
65
116
  *
117
+ * @since 2.0.0 - Service now accepts Config.LocalizationParam
118
+ *
66
119
  * @example
67
120
  * ```tsx
68
121
  * function MyComponent() {
@@ -72,7 +125,7 @@ export declare function ConfirmationProvider({ children }: ConfirmationProviderP
72
125
  * const status = await confirmation.warn(
73
126
  * 'Are you sure you want to delete this item?',
74
127
  * 'Confirm Delete',
75
- * { yesCopy: 'Delete', cancelCopy: 'Cancel' }
128
+ * { yesText: 'Delete', cancelText: 'Cancel' }
76
129
  * );
77
130
  *
78
131
  * if (status === Toaster.Status.confirm) {
@@ -89,7 +142,7 @@ export declare function useConfirmation(): ConfirmationService;
89
142
  * Hook to access the current confirmation state.
90
143
  * This is typically used by the ConfirmationDialog component.
91
144
  *
92
- * @returns Current confirmation message and respond function
145
+ * @returns Current confirmation data and respond function
93
146
  */
94
147
  export declare function useConfirmationState(): Pick<ConfirmationContextValue, 'confirmation' | 'respond'>;
95
148
  /**
@@ -98,3 +151,4 @@ export declare function useConfirmationState(): Pick<ConfirmationContextValue, '
98
151
  * @returns ConfirmationContextValue with service, confirmation, and respond
99
152
  */
100
153
  export declare function useConfirmationContext(): ConfirmationContextValue;
154
+ export {};
@@ -2,30 +2,91 @@ import React, { type ReactNode } from 'react';
2
2
  import type { Config } from '@abpjs/core';
3
3
  import { Toaster } from '../models';
4
4
  /**
5
- * Internal toast message with unique ID for tracking.
5
+ * Internal toast with numeric ID for tracking.
6
+ * @since 2.0.0 - Uses Toaster.Toast structure with numeric ID
6
7
  */
7
- interface InternalToast extends Toaster.Message {
8
- id: string;
8
+ interface InternalToast extends Toaster.Toast {
9
+ /** Numeric ID assigned by the service */
10
+ id: number;
9
11
  }
12
+ /**
13
+ * Subscriber callback type for toasts$ observable pattern
14
+ * @since 2.0.0
15
+ */
16
+ type ToastsSubscriber = (toasts: Toaster.Toast[]) => void;
10
17
  /**
11
18
  * ToasterService interface - matches the Angular service API.
12
- * Updated in v1.1.0 to accept Config.LocalizationParam for message and title.
19
+ * @since 2.0.0 - Major changes:
20
+ * - Methods now return number (toast ID) instead of Observable<Status>
21
+ * - Added toasts$ ReplaySubject pattern via subscribe method
22
+ * - Removed addAll method (use show directly)
13
23
  */
14
24
  export interface ToasterService {
15
- /** Show an info toast */
16
- info(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Toaster.Options): Promise<Toaster.Status>;
17
- /** Show a success toast */
18
- success(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Toaster.Options): Promise<Toaster.Status>;
19
- /** Show a warning toast */
20
- warn(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Toaster.Options): Promise<Toaster.Status>;
21
- /** Show an error toast */
22
- error(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Toaster.Options): Promise<Toaster.Status>;
23
- /** Add multiple messages at once */
24
- addAll(messages: Toaster.Message[]): void;
25
- /** Clear all toasts or a specific one by status */
26
- clear(status?: Toaster.Status): void;
27
- /** Remove a specific toast by ID */
28
- remove(id: string): void;
25
+ /**
26
+ * Creates an info toast with given parameters.
27
+ * @param message Content of the toast
28
+ * @param title Title of the toast
29
+ * @param options Specific style or structural options for individual toast
30
+ * @returns Toast ID
31
+ * @since 2.0.0 - Now returns number instead of Promise<Status>
32
+ */
33
+ info(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Toaster.ToastOptions>): number;
34
+ /**
35
+ * Creates a success toast with given parameters.
36
+ * @param message Content of the toast
37
+ * @param title Title of the toast
38
+ * @param options Specific style or structural options for individual toast
39
+ * @returns Toast ID
40
+ * @since 2.0.0 - Now returns number instead of Promise<Status>
41
+ */
42
+ success(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Toaster.ToastOptions>): number;
43
+ /**
44
+ * Creates a warning toast with given parameters.
45
+ * @param message Content of the toast
46
+ * @param title Title of the toast
47
+ * @param options Specific style or structural options for individual toast
48
+ * @returns Toast ID
49
+ * @since 2.0.0 - Now returns number instead of Promise<Status>
50
+ */
51
+ warn(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Toaster.ToastOptions>): number;
52
+ /**
53
+ * Creates an error toast with given parameters.
54
+ * @param message Content of the toast
55
+ * @param title Title of the toast
56
+ * @param options Specific style or structural options for individual toast
57
+ * @returns Toast ID
58
+ * @since 2.0.0 - Now returns number instead of Promise<Status>
59
+ */
60
+ error(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Toaster.ToastOptions>): number;
61
+ /**
62
+ * Creates a toast with given parameters.
63
+ * @param message Content of the toast
64
+ * @param title Title of the toast
65
+ * @param severity Sets color of the toast. "success", "warning" etc.
66
+ * @param options Specific style or structural options for individual toast
67
+ * @returns Toast ID
68
+ * @since 2.0.0
69
+ */
70
+ show(message: Config.LocalizationParam, title?: Config.LocalizationParam, severity?: Toaster.Severity, options?: Partial<Toaster.ToastOptions>): number;
71
+ /**
72
+ * Removes the toast with given id.
73
+ * @param id ID of the toast to be removed.
74
+ * @since 2.0.0
75
+ */
76
+ remove(id: number): void;
77
+ /**
78
+ * Removes all open toasts at once.
79
+ * @param key Optional container key to clear toasts from specific container
80
+ * @since 2.0.0
81
+ */
82
+ clear(key?: string): void;
83
+ /**
84
+ * Subscribe to toast updates (mimics RxJS ReplaySubject pattern).
85
+ * @param subscriber Callback function called with current toasts
86
+ * @returns Unsubscribe function
87
+ * @since 2.0.0
88
+ */
89
+ subscribe(subscriber: ToastsSubscriber): () => void;
29
90
  }
30
91
  /**
31
92
  * Context value containing the service and current toasts.
@@ -43,6 +104,11 @@ export interface ToasterProviderProps {
43
104
  * This is the React equivalent of Angular's ToasterService.
44
105
  * Wrap your app with this provider to enable toast notifications.
45
106
  *
107
+ * @since 2.0.0 - Major changes:
108
+ * - Methods now return number (toast ID) instead of Promise<Status>
109
+ * - Added subscribe method for observable pattern
110
+ * - Severity 'warn' changed to 'warning'
111
+ *
46
112
  * @example
47
113
  * ```tsx
48
114
  * <ToasterProvider>
@@ -58,6 +124,8 @@ export declare function ToasterProvider({ children }: ToasterProviderProps): Rea
58
124
  * @returns ToasterService with methods to show toast notifications
59
125
  * @throws Error if used outside of ToasterProvider
60
126
  *
127
+ * @since 2.0.0 - Service methods now return number (toast ID)
128
+ *
61
129
  * @example
62
130
  * ```tsx
63
131
  * function MyComponent() {
@@ -66,7 +134,8 @@ export declare function ToasterProvider({ children }: ToasterProviderProps): Rea
66
134
  * const handleSave = async () => {
67
135
  * try {
68
136
  * await saveData();
69
- * toaster.success('Data saved successfully!', 'Success');
137
+ * const toastId = toaster.success('Data saved successfully!', 'Success');
138
+ * // Can later remove: toaster.remove(toastId);
70
139
  * } catch (error) {
71
140
  * toaster.error('Failed to save data', 'Error');
72
141
  * }
package/dist/index.d.ts CHANGED
@@ -2,11 +2,24 @@
2
2
  * @abpjs/theme-shared
3
3
  *
4
4
  * ABP Framework Theme Shared components for React.
5
- * Translated from @abp/ng.theme.shared v1.1.0
5
+ * Translated from @abp/ng.theme.shared v2.0.0
6
6
  *
7
7
  * This package provides shared UI components, services, and utilities
8
8
  * for theme/modal management in ABP Framework React applications.
9
9
  *
10
+ * New in v2.0.0:
11
+ * - ToasterService: Methods now return number (toast ID) instead of Promise<Status>
12
+ * - ToasterService: Added subscribe() method for observable pattern
13
+ * - ToasterService: Removed addAll method (use show directly)
14
+ * - Toaster.Options renamed to Toaster.ToastOptions
15
+ * - New Toaster.Toast interface
16
+ * - Toaster.Severity: Changed 'warn' to 'warning', added 'neutral'
17
+ * - Confirmation.Options: No longer extends Toaster.Options
18
+ * - Confirmation: Added DialogData interface and Severity type
19
+ * - Confirmation.Options: Removed deprecated cancelCopy/yesCopy
20
+ * - ConfirmationService: Added show(), listenToEscape(), subscribe() methods
21
+ * - Updated styles with sorting icon classes
22
+ *
10
23
  * New in v1.1.0:
11
24
  * - ToasterService now accepts Config.LocalizationParam for message and title
12
25
  * - Confirmation.Options: Added cancelText/yesText (deprecated cancelCopy/yesCopy)