@yuuvis/client-core 2.2.0 → 2.3.1
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/fesm2022/yuuvis-client-core.mjs +184 -4
- package/fesm2022/yuuvis-client-core.mjs.map +1 -1
- package/index.d.ts +1 -2
- package/lib/service/pending-changes/index.d.ts +4 -0
- package/lib/service/pending-changes/pending-changes-dialog.guard.service.d.ts +128 -0
- package/lib/service/pending-changes/pending-changes-tab.guard.directive.d.ts +9 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -39,8 +39,7 @@ export * from './lib/service/logger/logger.interface';
|
|
|
39
39
|
export * from './lib/service/notification/notification.service';
|
|
40
40
|
export * from './lib/service/object-config/object-config.interface';
|
|
41
41
|
export * from './lib/service/object-config/object-config.service';
|
|
42
|
-
export * from './lib/service/pending-changes
|
|
43
|
-
export * from './lib/service/pending-changes/pending-changes.service';
|
|
42
|
+
export * from './lib/service/pending-changes';
|
|
44
43
|
export * from './lib/service/prediction/prediction.interface';
|
|
45
44
|
export * from './lib/service/prediction/prediction.service';
|
|
46
45
|
export * from './lib/service/retention/retention.service';
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { MatDialogRef } from '@angular/material/dialog';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Service that provides guards for Material Dialog close operations.
|
|
6
|
+
*
|
|
7
|
+
* This service allows you to intercept and control dialog close events,
|
|
8
|
+
* enabling confirmation dialogs or preventing accidental closure when
|
|
9
|
+
* there are unsaved changes or pending operations.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* readonly #dialogCloseGuard = inject(DialogCloseGuard);
|
|
14
|
+
*
|
|
15
|
+
* openDialog() {
|
|
16
|
+
* const dialogRef = this.dialog.open(MyComponent);
|
|
17
|
+
*
|
|
18
|
+
* // Prevent dialog from closing if there are unsaved changes
|
|
19
|
+
* this.#dialogCloseGuard.dialogCanClose(dialogRef, () => {
|
|
20
|
+
* return this.hasUnsavedChanges() ? this.confirmClose() : true;
|
|
21
|
+
* }).subscribe();
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class DialogCloseGuard {
|
|
26
|
+
#private;
|
|
27
|
+
/**
|
|
28
|
+
* Guards against dialog closure when the backdrop is clicked.
|
|
29
|
+
*
|
|
30
|
+
* This method disables the default close behavior and only allows the dialog
|
|
31
|
+
* to close when the provided check function returns true. The check is triggered
|
|
32
|
+
* specifically when the user clicks on the dialog backdrop.
|
|
33
|
+
*
|
|
34
|
+
* @param dialogRef - Reference to the Material Dialog instance
|
|
35
|
+
* @param checkFunction - Function that determines if the dialog can be closed.
|
|
36
|
+
* Can return a boolean directly or an Observable<boolean>
|
|
37
|
+
* @returns Observable<boolean> - Emits true when the dialog can be closed via backdrop click
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* this.dialogCloseGuard.checkBackdropCanClose(dialogRef, () => {
|
|
42
|
+
* return this.formIsDirty ? this.showConfirmDialog() : true;
|
|
43
|
+
* }).subscribe(canClose => {
|
|
44
|
+
* if (canClose) {
|
|
45
|
+
* dialogRef.close();
|
|
46
|
+
* }
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
checkBackdropCanClose(dialogRef: MatDialogRef<any>, checkFunction: () => boolean | Observable<boolean>): Observable<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* Guards against dialog closure when the Escape key is pressed.
|
|
53
|
+
*
|
|
54
|
+
* This method disables the default close behavior and only allows the dialog
|
|
55
|
+
* to close when the provided check function returns true. The check is triggered
|
|
56
|
+
* specifically when the user presses the Escape key.
|
|
57
|
+
*
|
|
58
|
+
* @param dialogRef - Reference to the Material Dialog instance
|
|
59
|
+
* @param checkFunction - Function that determines if the dialog can be closed.
|
|
60
|
+
* Can return a boolean directly or an Observable<boolean>
|
|
61
|
+
* @returns Observable<boolean> - Emits true when the dialog can be closed via Escape key
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* this.dialogCloseGuard.checkKeydownEventsCanClose(dialogRef, () => {
|
|
66
|
+
* return this.hasUnsavedChanges ? this.confirmDiscardChanges() : true;
|
|
67
|
+
* }).subscribe(canClose => {
|
|
68
|
+
* if (canClose) {
|
|
69
|
+
* dialogRef.close();
|
|
70
|
+
* }
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
checkKeydownEventsCanClose(dialogRef: MatDialogRef<any>, checkFunction: () => boolean | Observable<boolean>): Observable<boolean>;
|
|
75
|
+
/**
|
|
76
|
+
* Comprehensive dialog close guard that handles both backdrop clicks and Escape key presses.
|
|
77
|
+
*
|
|
78
|
+
* This method provides a unified approach to guard dialog closure by monitoring both
|
|
79
|
+
* backdrop clicks and Escape key events. When either event occurs, it runs the provided
|
|
80
|
+
* check function and automatically closes the dialog if the check passes.
|
|
81
|
+
*
|
|
82
|
+
* This is the most convenient method when you want to guard against all common
|
|
83
|
+
* dialog close scenarios with a single setup.
|
|
84
|
+
*
|
|
85
|
+
* @template T - The type of data that the dialog returns
|
|
86
|
+
* @param dialogRef - Reference to the Material Dialog instance
|
|
87
|
+
* @param checkFunction - Function that determines if the dialog can be closed.
|
|
88
|
+
* Can return a boolean directly or an Observable<boolean>
|
|
89
|
+
* @returns Observable<false | void> - Emits false if the dialog cannot be closed,
|
|
90
|
+
* or void when the dialog is successfully closed
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Simple boolean check
|
|
95
|
+
* this.dialogCloseGuard.dialogCanClose(dialogRef, () => !this.hasUnsavedChanges).subscribe();
|
|
96
|
+
*
|
|
97
|
+
* // Async check with confirmation dialog
|
|
98
|
+
* this.dialogCloseGuard.dialogCanClose(dialogRef, () => {
|
|
99
|
+
* return this.hasUnsavedChanges
|
|
100
|
+
* ? this.confirmationService.confirm('Discard changes?')
|
|
101
|
+
* : of(true);
|
|
102
|
+
* }).subscribe();
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
preventCloseUntil<T>(dialogRef: MatDialogRef<T>, checkFunction: () => boolean | Observable<boolean>): Observable<false | void>;
|
|
106
|
+
/**
|
|
107
|
+
* Specialized dialog close guard that automatically checks for pending changes.
|
|
108
|
+
*
|
|
109
|
+
* This convenience method provides automatic pending changes detection without
|
|
110
|
+
* requiring a custom check function. It integrates with the PendingChangesService
|
|
111
|
+
* to determine if there are any unsaved changes, and handles both backdrop clicks
|
|
112
|
+
* and Escape key presses automatically.
|
|
113
|
+
*
|
|
114
|
+
* This method is ideal when you want to prevent dialog closure if there are
|
|
115
|
+
* pending changes anywhere in the application, without having to implement
|
|
116
|
+
* custom change detection logic.
|
|
117
|
+
*
|
|
118
|
+
* @template T - The type of data that the dialog returns
|
|
119
|
+
* @param dialogRef - Reference to the Material Dialog instance
|
|
120
|
+
* @returns Observable<false | void> - Emits false if there are pending changes
|
|
121
|
+
* preventing closure, or void when the dialog
|
|
122
|
+
* is successfully closed
|
|
123
|
+
*
|
|
124
|
+
*/
|
|
125
|
+
pendingChangesDialogCanClose<T>(dialogRef: MatDialogRef<T>): Observable<false | void>;
|
|
126
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DialogCloseGuard, never>;
|
|
127
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DialogCloseGuard>;
|
|
128
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DoCheck } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class TabGuardDirective implements DoCheck {
|
|
4
|
+
#private;
|
|
5
|
+
constructor();
|
|
6
|
+
ngDoCheck(): void;
|
|
7
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TabGuardDirective, never>;
|
|
8
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<TabGuardDirective, "mat-tab-group[yuvTabGuardDisable]", never, {}, {}, never, never, true, never>;
|
|
9
|
+
}
|