@yuuvis/client-core 2.3.0 → 2.3.2

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/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/pending-changes-guard.service';
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';
@@ -11,3 +11,16 @@ export interface YuvEvent {
11
11
  */
12
12
  data?: any;
13
13
  }
14
+ /**
15
+ * Mandatory Custom event prefix for all custom YUV events
16
+ */
17
+ export declare const CUSTOM_EVENT_PREFIX = "yuv.";
18
+ /**
19
+ * Message event interface for postMessage events
20
+ */
21
+ export interface YuvMessage {
22
+ type: string;
23
+ data: any;
24
+ timestamp: number;
25
+ source: string;
26
+ }
@@ -7,6 +7,13 @@ import * as i0 from "@angular/core";
7
7
  export declare class EventService {
8
8
  #private;
9
9
  event$: Observable<YuvEvent>;
10
+ constructor();
11
+ /**
12
+ * Triggers a postMessage event that will be sent to the yuuvis global event Trigger
13
+ * @param type Type/key of the event
14
+ * @param data Data to be sent along with the event
15
+ */
16
+ triggerPostMessageEvent(type: string, data?: any): void;
10
17
  /**
11
18
  * Trigger an global event
12
19
  * @param type Type/key of the event
@@ -0,0 +1,4 @@
1
+ export * from './pending-changes-guard.service';
2
+ export * from './pending-changes-dialog.guard.service';
3
+ export * from './pending-changes.service';
4
+ export * from './pending-changes-tab.guard.directive';
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuuvis/client-core",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "author": "OPTIMAL SYSTEMS GmbH <npm@optimal-systems.de>",
5
5
  "license": "MIT",
6
6
  "peerDependencies": {