@abpjs/theme-shared 2.0.0 → 2.1.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.
|
@@ -12,6 +12,7 @@ export interface ConfirmationDialogProps {
|
|
|
12
12
|
* In Chakra v3, we use Dialog with role="alertdialog" instead of AlertDialog.
|
|
13
13
|
*
|
|
14
14
|
* @since 2.0.0 - Updated to use Confirmation.DialogData structure
|
|
15
|
+
* @since 2.1.0 - Uses Confirmation.Status instead of Toaster.Status
|
|
15
16
|
*
|
|
16
17
|
* @example
|
|
17
18
|
* ```tsx
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
2
|
import type { Config } from '@abpjs/core';
|
|
3
|
-
import { Confirmation
|
|
3
|
+
import { Confirmation } from '../models';
|
|
4
4
|
/**
|
|
5
5
|
* Subscriber callback type for confirmation$ observable pattern
|
|
6
6
|
* @since 2.0.0
|
|
@@ -12,6 +12,8 @@ type ConfirmationSubscriber = (data: Confirmation.DialogData | null) => void;
|
|
|
12
12
|
* - No longer extends AbstractToaster
|
|
13
13
|
* - Added confirmation$ ReplaySubject pattern via subscribe method
|
|
14
14
|
* - Now accepts Config.LocalizationParam for message and title
|
|
15
|
+
*
|
|
16
|
+
* @since 2.1.0 - Changed from Toaster.Status to Confirmation.Status
|
|
15
17
|
*/
|
|
16
18
|
export interface ConfirmationService {
|
|
17
19
|
/**
|
|
@@ -21,7 +23,7 @@ export interface ConfirmationService {
|
|
|
21
23
|
* @param options Confirmation options
|
|
22
24
|
* @returns Promise resolving to user's response status
|
|
23
25
|
*/
|
|
24
|
-
info(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Confirmation.Options>): Promise<
|
|
26
|
+
info(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Confirmation.Options>): Promise<Confirmation.Status>;
|
|
25
27
|
/**
|
|
26
28
|
* Show a success confirmation
|
|
27
29
|
* @param message Message content (supports localization)
|
|
@@ -29,7 +31,7 @@ export interface ConfirmationService {
|
|
|
29
31
|
* @param options Confirmation options
|
|
30
32
|
* @returns Promise resolving to user's response status
|
|
31
33
|
*/
|
|
32
|
-
success(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Confirmation.Options>): Promise<
|
|
34
|
+
success(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Confirmation.Options>): Promise<Confirmation.Status>;
|
|
33
35
|
/**
|
|
34
36
|
* Show a warning confirmation
|
|
35
37
|
* @param message Message content (supports localization)
|
|
@@ -37,7 +39,7 @@ export interface ConfirmationService {
|
|
|
37
39
|
* @param options Confirmation options
|
|
38
40
|
* @returns Promise resolving to user's response status
|
|
39
41
|
*/
|
|
40
|
-
warn(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Confirmation.Options>): Promise<
|
|
42
|
+
warn(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Confirmation.Options>): Promise<Confirmation.Status>;
|
|
41
43
|
/**
|
|
42
44
|
* Show an error confirmation
|
|
43
45
|
* @param message Message content (supports localization)
|
|
@@ -45,7 +47,7 @@ export interface ConfirmationService {
|
|
|
45
47
|
* @param options Confirmation options
|
|
46
48
|
* @returns Promise resolving to user's response status
|
|
47
49
|
*/
|
|
48
|
-
error(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Confirmation.Options>): Promise<
|
|
50
|
+
error(message: Config.LocalizationParam, title?: Config.LocalizationParam, options?: Partial<Confirmation.Options>): Promise<Confirmation.Status>;
|
|
49
51
|
/**
|
|
50
52
|
* Show a confirmation with specified severity
|
|
51
53
|
* @param message Message content (supports localization)
|
|
@@ -54,13 +56,15 @@ export interface ConfirmationService {
|
|
|
54
56
|
* @param options Confirmation options
|
|
55
57
|
* @returns Promise resolving to user's response status
|
|
56
58
|
* @since 2.0.0
|
|
59
|
+
* @since 2.1.0 - Uses Confirmation.Severity instead of Toaster.Severity
|
|
57
60
|
*/
|
|
58
|
-
show(message: Config.LocalizationParam, title?: Config.LocalizationParam, severity?: Confirmation.Severity, options?: Partial<Confirmation.Options>): Promise<
|
|
61
|
+
show(message: Config.LocalizationParam, title?: Config.LocalizationParam, severity?: Confirmation.Severity, options?: Partial<Confirmation.Options>): Promise<Confirmation.Status>;
|
|
59
62
|
/**
|
|
60
63
|
* Clear the current confirmation
|
|
61
64
|
* @param status Optional status to resolve with (default: dismiss)
|
|
65
|
+
* @since 2.1.0 - Uses Confirmation.Status instead of Toaster.Status
|
|
62
66
|
*/
|
|
63
|
-
clear(status?:
|
|
67
|
+
clear(status?: Confirmation.Status): void;
|
|
64
68
|
/**
|
|
65
69
|
* Listen for escape key to dismiss confirmation
|
|
66
70
|
* @since 2.0.0
|
|
@@ -76,13 +80,14 @@ export interface ConfirmationService {
|
|
|
76
80
|
}
|
|
77
81
|
/**
|
|
78
82
|
* Context value containing the service and current confirmation.
|
|
83
|
+
* @since 2.1.0 - respond uses Confirmation.Status instead of Toaster.Status
|
|
79
84
|
*/
|
|
80
85
|
export interface ConfirmationContextValue {
|
|
81
86
|
service: ConfirmationService;
|
|
82
87
|
/** Current confirmation dialog data */
|
|
83
88
|
confirmation: Confirmation.DialogData | null;
|
|
84
89
|
/** Respond to the current confirmation */
|
|
85
|
-
respond: (status:
|
|
90
|
+
respond: (status: Confirmation.Status) => void;
|
|
86
91
|
}
|
|
87
92
|
export interface ConfirmationProviderProps {
|
|
88
93
|
children: ReactNode;
|
|
@@ -99,6 +104,8 @@ export interface ConfirmationProviderProps {
|
|
|
99
104
|
* - Added listenToEscape method
|
|
100
105
|
* - Uses Confirmation.DialogData structure
|
|
101
106
|
*
|
|
107
|
+
* @since 2.1.0 - Uses Confirmation.Status instead of Toaster.Status
|
|
108
|
+
*
|
|
102
109
|
* @example
|
|
103
110
|
* ```tsx
|
|
104
111
|
* <ConfirmationProvider>
|
|
@@ -115,6 +122,7 @@ export declare function ConfirmationProvider({ children }: ConfirmationProviderP
|
|
|
115
122
|
* @throws Error if used outside of ConfirmationProvider
|
|
116
123
|
*
|
|
117
124
|
* @since 2.0.0 - Service now accepts Config.LocalizationParam
|
|
125
|
+
* @since 2.1.0 - Uses Confirmation.Status instead of Toaster.Status
|
|
118
126
|
*
|
|
119
127
|
* @example
|
|
120
128
|
* ```tsx
|
|
@@ -128,7 +136,7 @@ export declare function ConfirmationProvider({ children }: ConfirmationProviderP
|
|
|
128
136
|
* { yesText: 'Delete', cancelText: 'Cancel' }
|
|
129
137
|
* );
|
|
130
138
|
*
|
|
131
|
-
* if (status ===
|
|
139
|
+
* if (status === Confirmation.Status.confirm) {
|
|
132
140
|
* await deleteItem();
|
|
133
141
|
* }
|
|
134
142
|
* };
|
|
@@ -143,6 +151,7 @@ export declare function useConfirmation(): ConfirmationService;
|
|
|
143
151
|
* This is typically used by the ConfirmationDialog component.
|
|
144
152
|
*
|
|
145
153
|
* @returns Current confirmation data and respond function
|
|
154
|
+
* @since 2.1.0 - respond uses Confirmation.Status
|
|
146
155
|
*/
|
|
147
156
|
export declare function useConfirmationState(): Pick<ConfirmationContextValue, 'confirmation' | 'respond'>;
|
|
148
157
|
/**
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(index_exports, {
|
|
|
38
38
|
ChakraDialog: () => import_react11.Dialog,
|
|
39
39
|
ChangePassword: () => ChangePassword,
|
|
40
40
|
Checkbox: () => Checkbox,
|
|
41
|
+
Confirmation: () => Confirmation,
|
|
41
42
|
ConfirmationDialog: () => ConfirmationDialog,
|
|
42
43
|
ConfirmationProvider: () => ConfirmationProvider,
|
|
43
44
|
DEFAULT_STYLES: () => DEFAULT_STYLES,
|
|
@@ -84,6 +85,17 @@ var Toaster;
|
|
|
84
85
|
})(Status = Toaster2.Status || (Toaster2.Status = {}));
|
|
85
86
|
})(Toaster || (Toaster = {}));
|
|
86
87
|
|
|
88
|
+
// src/models/confirmation.ts
|
|
89
|
+
var Confirmation;
|
|
90
|
+
((Confirmation2) => {
|
|
91
|
+
let Status;
|
|
92
|
+
((Status2) => {
|
|
93
|
+
Status2["confirm"] = "confirm";
|
|
94
|
+
Status2["reject"] = "reject";
|
|
95
|
+
Status2["dismiss"] = "dismiss";
|
|
96
|
+
})(Status = Confirmation2.Status || (Confirmation2.Status = {}));
|
|
97
|
+
})(Confirmation || (Confirmation = {}));
|
|
98
|
+
|
|
87
99
|
// src/constants/styles.ts
|
|
88
100
|
var DEFAULT_STYLES = `
|
|
89
101
|
.is-invalid .form-control {
|
|
@@ -406,7 +418,7 @@ function ConfirmationProvider({ children }) {
|
|
|
406
418
|
if (!escapeListenerRef.current) return;
|
|
407
419
|
const handleEscape = (event) => {
|
|
408
420
|
if (event.key === "Escape" && confirmation && confirmation.options?.closable !== false) {
|
|
409
|
-
respond(
|
|
421
|
+
respond(Confirmation.Status.dismiss);
|
|
410
422
|
}
|
|
411
423
|
};
|
|
412
424
|
document.addEventListener("keydown", handleEscape);
|
|
@@ -417,7 +429,7 @@ function ConfirmationProvider({ children }) {
|
|
|
417
429
|
const show = (0, import_react2.useCallback)(
|
|
418
430
|
(message, title, severity = "neutral", options = {}) => {
|
|
419
431
|
if (resolverRef.current) {
|
|
420
|
-
resolverRef.current(
|
|
432
|
+
resolverRef.current(Confirmation.Status.dismiss);
|
|
421
433
|
}
|
|
422
434
|
const id = options.id?.toString() || generateId2();
|
|
423
435
|
const dialogData = {
|
|
@@ -454,7 +466,7 @@ function ConfirmationProvider({ children }) {
|
|
|
454
466
|
);
|
|
455
467
|
const clear = (0, import_react2.useCallback)(
|
|
456
468
|
(status) => {
|
|
457
|
-
respond(status ??
|
|
469
|
+
respond(status ?? Confirmation.Status.dismiss);
|
|
458
470
|
},
|
|
459
471
|
[respond]
|
|
460
472
|
);
|
|
@@ -842,13 +854,13 @@ function ConfirmationDialog({ className }) {
|
|
|
842
854
|
const yesCopy = yesKey ? t(yesKey) : t("AbpUi::Yes");
|
|
843
855
|
const cancelCopy = cancelKey ? t(cancelKey) : t("AbpUi::Cancel");
|
|
844
856
|
const handleConfirm = () => {
|
|
845
|
-
respond(
|
|
857
|
+
respond(Confirmation.Status.confirm);
|
|
846
858
|
};
|
|
847
859
|
const handleCancel = () => {
|
|
848
|
-
respond(
|
|
860
|
+
respond(Confirmation.Status.reject);
|
|
849
861
|
};
|
|
850
862
|
const handleDismiss = () => {
|
|
851
|
-
respond(
|
|
863
|
+
respond(Confirmation.Status.dismiss);
|
|
852
864
|
};
|
|
853
865
|
const handleOpenChange = (details) => {
|
|
854
866
|
if (!details.open && options?.closable !== false) {
|
|
@@ -2040,6 +2052,7 @@ function injectThemeSharedStyles() {
|
|
|
2040
2052
|
ChakraDialog,
|
|
2041
2053
|
ChangePassword,
|
|
2042
2054
|
Checkbox,
|
|
2055
|
+
Confirmation,
|
|
2043
2056
|
ConfirmationDialog,
|
|
2044
2057
|
ConfirmationProvider,
|
|
2045
2058
|
DEFAULT_STYLES,
|
package/dist/index.mjs
CHANGED
|
@@ -9,6 +9,17 @@ var Toaster;
|
|
|
9
9
|
})(Status = Toaster2.Status || (Toaster2.Status = {}));
|
|
10
10
|
})(Toaster || (Toaster = {}));
|
|
11
11
|
|
|
12
|
+
// src/models/confirmation.ts
|
|
13
|
+
var Confirmation;
|
|
14
|
+
((Confirmation2) => {
|
|
15
|
+
let Status;
|
|
16
|
+
((Status2) => {
|
|
17
|
+
Status2["confirm"] = "confirm";
|
|
18
|
+
Status2["reject"] = "reject";
|
|
19
|
+
Status2["dismiss"] = "dismiss";
|
|
20
|
+
})(Status = Confirmation2.Status || (Confirmation2.Status = {}));
|
|
21
|
+
})(Confirmation || (Confirmation = {}));
|
|
22
|
+
|
|
12
23
|
// src/constants/styles.ts
|
|
13
24
|
var DEFAULT_STYLES = `
|
|
14
25
|
.is-invalid .form-control {
|
|
@@ -347,7 +358,7 @@ function ConfirmationProvider({ children }) {
|
|
|
347
358
|
if (!escapeListenerRef.current) return;
|
|
348
359
|
const handleEscape = (event) => {
|
|
349
360
|
if (event.key === "Escape" && confirmation && confirmation.options?.closable !== false) {
|
|
350
|
-
respond(
|
|
361
|
+
respond(Confirmation.Status.dismiss);
|
|
351
362
|
}
|
|
352
363
|
};
|
|
353
364
|
document.addEventListener("keydown", handleEscape);
|
|
@@ -358,7 +369,7 @@ function ConfirmationProvider({ children }) {
|
|
|
358
369
|
const show = useCallback2(
|
|
359
370
|
(message, title, severity = "neutral", options = {}) => {
|
|
360
371
|
if (resolverRef.current) {
|
|
361
|
-
resolverRef.current(
|
|
372
|
+
resolverRef.current(Confirmation.Status.dismiss);
|
|
362
373
|
}
|
|
363
374
|
const id = options.id?.toString() || generateId2();
|
|
364
375
|
const dialogData = {
|
|
@@ -395,7 +406,7 @@ function ConfirmationProvider({ children }) {
|
|
|
395
406
|
);
|
|
396
407
|
const clear = useCallback2(
|
|
397
408
|
(status) => {
|
|
398
|
-
respond(status ??
|
|
409
|
+
respond(status ?? Confirmation.Status.dismiss);
|
|
399
410
|
},
|
|
400
411
|
[respond]
|
|
401
412
|
);
|
|
@@ -810,13 +821,13 @@ function ConfirmationDialog({ className }) {
|
|
|
810
821
|
const yesCopy = yesKey ? t(yesKey) : t("AbpUi::Yes");
|
|
811
822
|
const cancelCopy = cancelKey ? t(cancelKey) : t("AbpUi::Cancel");
|
|
812
823
|
const handleConfirm = () => {
|
|
813
|
-
respond(
|
|
824
|
+
respond(Confirmation.Status.confirm);
|
|
814
825
|
};
|
|
815
826
|
const handleCancel = () => {
|
|
816
|
-
respond(
|
|
827
|
+
respond(Confirmation.Status.reject);
|
|
817
828
|
};
|
|
818
829
|
const handleDismiss = () => {
|
|
819
|
-
respond(
|
|
830
|
+
respond(Confirmation.Status.dismiss);
|
|
820
831
|
};
|
|
821
832
|
const handleOpenChange = (details) => {
|
|
822
833
|
if (!details.open && options?.closable !== false) {
|
|
@@ -2026,6 +2037,7 @@ export {
|
|
|
2026
2037
|
Dialog2 as ChakraDialog,
|
|
2027
2038
|
ChangePassword,
|
|
2028
2039
|
Checkbox,
|
|
2040
|
+
Confirmation,
|
|
2029
2041
|
ConfirmationDialog,
|
|
2030
2042
|
ConfirmationProvider,
|
|
2031
2043
|
DEFAULT_STYLES,
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* - Added DialogData interface
|
|
8
8
|
* - Added Severity type
|
|
9
9
|
* - Removed deprecated cancelCopy/yesCopy
|
|
10
|
+
*
|
|
11
|
+
* @since 2.1.0 - Added Status enum (confirmation-specific, replaces Toaster.Status usage)
|
|
10
12
|
*/
|
|
11
13
|
import type { Config } from '@abpjs/core';
|
|
12
14
|
export declare namespace Confirmation {
|
|
@@ -51,4 +53,13 @@ export declare namespace Confirmation {
|
|
|
51
53
|
* @since 2.0.0
|
|
52
54
|
*/
|
|
53
55
|
type Severity = 'neutral' | 'success' | 'info' | 'warning' | 'error';
|
|
56
|
+
/**
|
|
57
|
+
* Status values for confirmation dialog responses.
|
|
58
|
+
* @since 2.1.0 - Moved from Toaster.Status to be confirmation-specific
|
|
59
|
+
*/
|
|
60
|
+
enum Status {
|
|
61
|
+
confirm = "confirm",
|
|
62
|
+
reject = "reject",
|
|
63
|
+
dismiss = "dismiss"
|
|
64
|
+
}
|
|
54
65
|
}
|
package/dist/models/toaster.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ import type { Config } from '@abpjs/core';
|
|
|
8
8
|
* - New `Toast` interface
|
|
9
9
|
* - `Severity` type changed: 'warn' → 'warning', added 'neutral'
|
|
10
10
|
* - ToasterService methods now return number (toast ID) instead of Observable
|
|
11
|
+
*
|
|
12
|
+
* @since 2.1.0 - Status enum deprecated, use Confirmation.Status instead
|
|
11
13
|
*/
|
|
12
14
|
export declare namespace Toaster {
|
|
13
15
|
/**
|
|
@@ -53,6 +55,8 @@ export declare namespace Toaster {
|
|
|
53
55
|
type Severity = 'neutral' | 'success' | 'info' | 'warning' | 'error';
|
|
54
56
|
/**
|
|
55
57
|
* Status values for toast/confirmation interactions.
|
|
58
|
+
* @deprecated Status will be removed from toaster model in v2.2. Use Confirmation.Status instead.
|
|
59
|
+
* @since 2.1.0 - Deprecated in favor of Confirmation.Status
|
|
56
60
|
*/
|
|
57
61
|
enum Status {
|
|
58
62
|
confirm = "confirm",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abpjs/theme-shared",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "ABP Framework Theme Shared components for React - translated from @abp/ng.theme.shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"next-themes": "^0.4.6",
|
|
28
28
|
"react-hook-form": "^7.48.0",
|
|
29
29
|
"react-icons": "^5.5.0",
|
|
30
|
-
"@abpjs/core": "2.
|
|
30
|
+
"@abpjs/core": "2.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@abp/ng.theme.shared": "2.
|
|
33
|
+
"@abp/ng.theme.shared": "2.1.0",
|
|
34
34
|
"@vitest/coverage-v8": "^3.2.0"
|
|
35
35
|
},
|
|
36
36
|
"author": "tekthar.com",
|