@dbg-riskit/angular-error 9999.9999.9999-rc.445675 → 9999.9999.9999-rc.4579154

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/docs/README.md CHANGED
@@ -1,13 +1,12 @@
1
- ![CI](https://github.deutsche-boerse.de/dev/risk-angular-common/workflows/CI/badge.svg?event=push)
2
- ![lint-bash](https://github.deutsche-boerse.de/dev/risk-angular-common/workflows/lint-bash/badge.svg?event=push)
3
- ![lint-docker](https://github.deutsche-boerse.de/dev/risk-angular-common/workflows/lint-docker/badge.svg?event=push)
1
+ ![CI](https://github.deutsche-boerse.de/RiskIT/risk-angular-common/workflows/CI/badge.svg?event=push)
2
+ ![lint-bash](https://github.deutsche-boerse.de/RiskIT/risk-angular-common/workflows/lint-bash/badge.svg?event=push)
3
+ ![lint-docker](https://github.deutsche-boerse.de/RiskIT/risk-angular-common/workflows/lint-docker/badge.svg?event=push)
4
4
 
5
5
  # risk-angular-common (Angular 13 and @angular/material based library for RiskIT applications)
6
6
 
7
7
  Used by:
8
- - [dev/DAVe-UI](https://github.deutsche-boerse.de/dev/DAVe-UI)
9
- - [dev/DAVe-MarginEstimator-UI](https://github.deutsche-boerse.de/dev/DAVe-MarginEstimator-UI)
10
- - [dev/MDH-UI](https://github.deutsche-boerse.de/dev/MDH-UI)
8
+ - [RiskIT/CPME-UI](https://github.deutsche-boerse.de/RiskIT/CPME-UI)
9
+ - [RiskIT/MDH-UI](https://github.deutsche-boerse.de/RiskIT/MDH-UI)
11
10
  - [RiskIT/openid-k8s-token-generator](https://github.deutsche-boerse.de/RiskIT/openid-k8s-token-generator)
12
11
 
13
12
  ## Packages
@@ -1,17 +1,16 @@
1
1
  import * as i0 from '@angular/core';
2
- import { ErrorHandler, Injectable, Optional, Inject, Component, ChangeDetectionStrategy, Input, EventEmitter, ViewChildren, NgModule } from '@angular/core';
3
- import { AUTH_PROVIDER, DATE_FORMAT } from '@dbg-riskit/angular-common';
2
+ import { ErrorHandler, inject, Injectable, Injector, signal, input, afterNextRender, ChangeDetectionStrategy, Component, viewChildren, computed, effect, untracked } from '@angular/core';
3
+ import { AUTH_PROVIDER, DATE_FORMAT, intervalSignal } from '@dbg-riskit/angular-common';
4
4
  import { toString, ErrorType } from '@dbg-riskit/common';
5
- import { ReplaySubject, EMPTY, Subject, merge, timer } from 'rxjs';
6
- import { trigger, state, style, transition, animate, keyframes } from '@angular/animations';
7
- import { BaseComponent, CommonViewModule } from '@dbg-riskit/angular-view';
8
- import { filter, takeUntil, map, catchError, defaultIfEmpty } from 'rxjs/operators';
9
- import * as i1 from '@angular/common';
10
- import { CommonModule } from '@angular/common';
11
- import * as i2 from '@angular/material/card';
12
- import * as i3 from '@angular/material/icon';
13
- import * as i3$1 from '@angular/material/button';
14
- import * as i5 from '@angular/material/menu';
5
+ import { ReplaySubject, EMPTY } from 'rxjs';
6
+ import { trigger, state, transition, style, animate, keyframes } from '@angular/animations';
7
+ import { toSignal } from '@angular/core/rxjs-interop';
8
+ import { MatIconButton } from '@angular/material/button';
9
+ import { MatIcon } from '@angular/material/icon';
10
+ import { MatMenu, MatMenuTrigger } from '@angular/material/menu';
11
+ import { DatePipe } from '@angular/common';
12
+ import { MatCard, MatCardAvatar, MatCardContent, MatCardHeader, MatCardSubtitle, MatCardTitle } from '@angular/material/card';
13
+ import { catchError, defaultIfEmpty } from 'rxjs/operators';
15
14
 
16
15
  function toErrorMessage(err) {
17
16
  let errorMessage;
@@ -34,9 +33,10 @@ function toErrorMessage(err) {
34
33
  return errorMessage;
35
34
  }
36
35
  class ErrorCollectorService extends ErrorHandler {
37
- constructor(authProvider) {
36
+ constructor() {
38
37
  super();
39
38
  this._errorObservable = new ReplaySubject(10);
39
+ const authProvider = inject(AUTH_PROVIDER, { optional: true });
40
40
  if (authProvider) {
41
41
  authProvider.loggedInStream.subscribe((auth) => {
42
42
  this._errorObservable = new ReplaySubject(10);
@@ -61,41 +61,36 @@ class ErrorCollectorService extends ErrorHandler {
61
61
  this.handleError(err);
62
62
  return EMPTY;
63
63
  }
64
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorCollectorService, deps: [{ token: AUTH_PROVIDER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
65
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorCollectorService }); }
64
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ErrorCollectorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
65
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ErrorCollectorService, providedIn: 'root' }); }
66
66
  }
67
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorCollectorService, decorators: [{
68
- type: Injectable
69
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
70
- type: Optional
71
- }, {
72
- type: Inject,
73
- args: [AUTH_PROVIDER]
74
- }] }]; } });
67
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ErrorCollectorService, decorators: [{
68
+ type: Injectable,
69
+ args: [{ providedIn: 'root' }]
70
+ }], ctorParameters: () => [] });
75
71
 
76
- class ErrorMessageComponent {
77
- constructor(dateFormat, changeDetectorRef) {
78
- this.dateFormat = dateFormat;
79
- this.changeDetectorRef = changeDetectorRef;
80
- this.readState = null;
81
- this.isLast = false;
72
+ class RiskErrorMessageComponent {
73
+ constructor() {
74
+ this.dateFormat = inject(DATE_FORMAT);
75
+ this.injector = inject(Injector);
76
+ this.readState = signal(null, ...(ngDevMode ? [{ debugName: "readState" }] : []));
77
+ this.error = input.required(...(ngDevMode ? [{ debugName: "error" }] : []));
78
+ this.isLast = input(false, ...(ngDevMode ? [{ debugName: "isLast" }] : []));
82
79
  }
83
80
  animate() {
84
- if (this.error != null && !this.error.read && this.readState !== 'read') {
85
- setTimeout(() => {
86
- this.readState = 'read';
87
- this.changeDetectorRef.markForCheck();
88
- });
81
+ const err = this.error();
82
+ if (!err.read() && this.readState() !== 'read') {
83
+ afterNextRender(() => this.readState.set('read'), { injector: this.injector });
89
84
  }
90
85
  }
91
86
  markRead(event) {
92
- if (this.error != null && event.toState === 'read') {
93
- this.error.markRead();
94
- this.changeDetectorRef.markForCheck();
87
+ const err = this.error();
88
+ if (err && event.toState === 'read') {
89
+ err.markRead();
95
90
  }
96
91
  }
97
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorMessageComponent, deps: [{ token: DATE_FORMAT }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
98
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ErrorMessageComponent, selector: "risk-error-message", inputs: { error: "error", isLast: "isLast" }, host: { properties: { "class.risk-error-message": "true" } }, ngImport: i0, template: "<mat-card [class.risk-error-message-last]=\"isLast\" [@readState]=\"readState\" (@readState.done)=\"markRead($event)\">\n <mat-card-header>\n <mat-icon color=\"warn\" mat-card-avatar>error_outline</mat-icon>\n <mat-card-title *ngIf=\"error?.type.isNetworkError()\">Network error</mat-card-title>\n <mat-card-title *ngIf=\"error?.type.isRequestError()\">API error</mat-card-title>\n <mat-card-title *ngIf=\"error?.type.isAuthError()\">Authorization error</mat-card-title>\n <mat-card-title\n *ngIf=\"!error?.type.isNetworkError() && !error?.type.isRequestError() && !error?.type.isAuthError()\">\n General error\n </mat-card-title>\n <mat-card-subtitle>{{error?.date | date:dateFormat}}</mat-card-subtitle>\n </mat-card-header>\n <mat-card-content>\n <p *ngIf=\"error?.statusCode\" class=\"risk-error-message-code\">Error code: {{error?.statusCode}}</p>\n <p>\n {{error?.message}}\n </p>\n </mat-card-content>\n</mat-card>\n", styles: [":host{display:block;padding:0;margin:0}:host>*{vertical-align:bottom}\n", ":host .mat-mdc-card{margin:0 10px 7px}:host .mat-mdc-card.risk-error-message-last{margin-bottom:0}:host .mat-mdc-card .mat-mdc-card-subtitle{margin-bottom:5px}:host .mat-mdc-card p{margin:0}:host .mat-mdc-card p.risk-error-message-code{position:absolute;bottom:10px;right:10px}:host .mat-mdc-card p.risk-error-message-code+p:last-child{margin-bottom:15px}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: i2.MatCardAvatar, selector: "[mat-card-avatar], [matCardAvatar]" }, { kind: "directive", type: i2.MatCardContent, selector: "mat-card-content" }, { kind: "component", type: i2.MatCardHeader, selector: "mat-card-header" }, { kind: "directive", type: i2.MatCardSubtitle, selector: "mat-card-subtitle, [mat-card-subtitle], [matCardSubtitle]" }, { kind: "directive", type: i2.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "pipe", type: i1.DatePipe, name: "date" }], animations: [
92
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: RiskErrorMessageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
93
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: RiskErrorMessageComponent, isStandalone: true, selector: "risk-error-message", inputs: { error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: true, transformFunction: null }, isLast: { classPropertyName: "isLast", publicName: "isLast", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.risk-error-message": "true" } }, ngImport: i0, template: "<mat-card (@readState.done)=\"markRead($event)\" [@readState]=\"readState()\" [class.risk-error-message-last]=\"isLast()\">\n @let err = error();\n <mat-card-header>\n <mat-icon color=\"warn\" mat-card-avatar>error_outline</mat-icon>\n @if (err.type.isNetworkError()) {\n <mat-card-title>Network error</mat-card-title>\n }\n @if (err.type.isRequestError()) {\n <mat-card-title>API error</mat-card-title>\n }\n @if (err.type.isAuthError()) {\n <mat-card-title>Authorization error</mat-card-title>\n }\n @if (!err.type.isNetworkError() && !err.type.isRequestError() && !err.type.isAuthError()) {\n <mat-card-title>General error</mat-card-title>\n }\n <mat-card-subtitle>{{ err.date | date:dateFormat }}</mat-card-subtitle>\n </mat-card-header>\n <mat-card-content>\n @if (err.statusCode) {\n <p class=\"risk-error-message-code\">Error code: {{ err.statusCode }}</p>\n }\n <p> {{ err.message }} </p>\n </mat-card-content>\n</mat-card>\n", styles: [":host{display:block;padding:0;margin:0}:host>*{vertical-align:bottom}\n", ":host .mat-mdc-card{margin:0 10px 7px}:host .mat-mdc-card.risk-error-message-last{margin-bottom:0}:host .mat-mdc-card .mat-mdc-card-subtitle{margin-bottom:5px}:host .mat-mdc-card p{margin:0}:host .mat-mdc-card p.risk-error-message-code{position:absolute;bottom:10px;right:10px}:host .mat-mdc-card p.risk-error-message-code+p:last-child{margin-bottom:15px}\n"], dependencies: [{ kind: "component", type: MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: MatCardAvatar, selector: "[mat-card-avatar], [matCardAvatar]" }, { kind: "directive", type: MatCardContent, selector: "mat-card-content" }, { kind: "component", type: MatCardHeader, selector: "mat-card-header" }, { kind: "directive", type: MatCardSubtitle, selector: "mat-card-subtitle, [mat-card-subtitle], [matCardSubtitle]" }, { kind: "directive", type: MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "pipe", type: DatePipe, name: "date" }], animations: [
99
94
  trigger('readState', [
100
95
  state('read', style({ background: 'transparent' })),
101
96
  transition(':enter', [
@@ -109,9 +104,7 @@ class ErrorMessageComponent {
109
104
  }))
110
105
  ]),
111
106
  transition('* => read', [
112
- style({
113
- background: 'transparent'
114
- }),
107
+ style({ background: 'transparent' }),
115
108
  animate('1500ms', keyframes([
116
109
  style({
117
110
  background: 'rgba(204, 51, 51, .5)',
@@ -134,9 +127,18 @@ class ErrorMessageComponent {
134
127
  ])
135
128
  ], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
136
129
  }
137
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorMessageComponent, decorators: [{
130
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: RiskErrorMessageComponent, decorators: [{
138
131
  type: Component,
139
- args: [{ selector: 'risk-error-message', animations: [
132
+ args: [{ selector: 'risk-error-message', changeDetection: ChangeDetectionStrategy.OnPush, host: { '[class.risk-error-message]': 'true' }, imports: [
133
+ DatePipe,
134
+ MatCard,
135
+ MatCardAvatar,
136
+ MatCardContent,
137
+ MatCardHeader,
138
+ MatCardSubtitle,
139
+ MatCardTitle,
140
+ MatIcon
141
+ ], animations: [
140
142
  trigger('readState', [
141
143
  state('read', style({ background: 'transparent' })),
142
144
  transition(':enter', [
@@ -150,9 +152,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
150
152
  }))
151
153
  ]),
152
154
  transition('* => read', [
153
- style({
154
- background: 'transparent'
155
- }),
155
+ style({ background: 'transparent' }),
156
156
  animate('1500ms', keyframes([
157
157
  style({
158
158
  background: 'rgba(204, 51, 51, .5)',
@@ -173,23 +173,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
173
173
  ]))
174
174
  ])
175
175
  ])
176
- ], host: {
177
- '[class.risk-error-message]': 'true'
178
- }, changeDetection: ChangeDetectionStrategy.OnPush, preserveWhitespaces: false, template: "<mat-card [class.risk-error-message-last]=\"isLast\" [@readState]=\"readState\" (@readState.done)=\"markRead($event)\">\n <mat-card-header>\n <mat-icon color=\"warn\" mat-card-avatar>error_outline</mat-icon>\n <mat-card-title *ngIf=\"error?.type.isNetworkError()\">Network error</mat-card-title>\n <mat-card-title *ngIf=\"error?.type.isRequestError()\">API error</mat-card-title>\n <mat-card-title *ngIf=\"error?.type.isAuthError()\">Authorization error</mat-card-title>\n <mat-card-title\n *ngIf=\"!error?.type.isNetworkError() && !error?.type.isRequestError() && !error?.type.isAuthError()\">\n General error\n </mat-card-title>\n <mat-card-subtitle>{{error?.date | date:dateFormat}}</mat-card-subtitle>\n </mat-card-header>\n <mat-card-content>\n <p *ngIf=\"error?.statusCode\" class=\"risk-error-message-code\">Error code: {{error?.statusCode}}</p>\n <p>\n {{error?.message}}\n </p>\n </mat-card-content>\n</mat-card>\n", styles: [":host{display:block;padding:0;margin:0}:host>*{vertical-align:bottom}\n", ":host .mat-mdc-card{margin:0 10px 7px}:host .mat-mdc-card.risk-error-message-last{margin-bottom:0}:host .mat-mdc-card .mat-mdc-card-subtitle{margin-bottom:5px}:host .mat-mdc-card p{margin:0}:host .mat-mdc-card p.risk-error-message-code{position:absolute;bottom:10px;right:10px}:host .mat-mdc-card p.risk-error-message-code+p:last-child{margin-bottom:15px}\n"] }]
179
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
180
- type: Inject,
181
- args: [DATE_FORMAT]
182
- }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { error: [{
183
- type: Input
184
- }], isLast: [{
185
- type: Input
186
- }] } });
176
+ ], template: "<mat-card (@readState.done)=\"markRead($event)\" [@readState]=\"readState()\" [class.risk-error-message-last]=\"isLast()\">\n @let err = error();\n <mat-card-header>\n <mat-icon color=\"warn\" mat-card-avatar>error_outline</mat-icon>\n @if (err.type.isNetworkError()) {\n <mat-card-title>Network error</mat-card-title>\n }\n @if (err.type.isRequestError()) {\n <mat-card-title>API error</mat-card-title>\n }\n @if (err.type.isAuthError()) {\n <mat-card-title>Authorization error</mat-card-title>\n }\n @if (!err.type.isNetworkError() && !err.type.isRequestError() && !err.type.isAuthError()) {\n <mat-card-title>General error</mat-card-title>\n }\n <mat-card-subtitle>{{ err.date | date:dateFormat }}</mat-card-subtitle>\n </mat-card-header>\n <mat-card-content>\n @if (err.statusCode) {\n <p class=\"risk-error-message-code\">Error code: {{ err.statusCode }}</p>\n }\n <p> {{ err.message }} </p>\n </mat-card-content>\n</mat-card>\n", styles: [":host{display:block;padding:0;margin:0}:host>*{vertical-align:bottom}\n", ":host .mat-mdc-card{margin:0 10px 7px}:host .mat-mdc-card.risk-error-message-last{margin-bottom:0}:host .mat-mdc-card .mat-mdc-card-subtitle{margin-bottom:5px}:host .mat-mdc-card p{margin:0}:host .mat-mdc-card p.risk-error-message-code{position:absolute;bottom:10px;right:10px}:host .mat-mdc-card p.risk-error-message-code+p:last-child{margin-bottom:15px}\n"] }]
177
+ }], propDecorators: { error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: true }] }], isLast: [{ type: i0.Input, args: [{ isSignal: true, alias: "isLast", required: false }] }] } });
187
178
 
188
179
  class ErrorMessageWrapper {
189
180
  constructor(error) {
190
181
  this._date = new Date();
191
- this._read = false;
192
- this.readStateChanged = new EventEmitter();
182
+ this.read = signal(false, ...(ngDevMode ? [{ debugName: "read" }] : []));
193
183
  this._error = error;
194
184
  }
195
185
  get message() {
@@ -204,14 +194,9 @@ class ErrorMessageWrapper {
204
194
  get date() {
205
195
  return this._date;
206
196
  }
207
- get read() {
208
- return this._read;
209
- }
210
197
  markRead() {
211
- if (!this._read) {
212
- this._read = true;
213
- this.readStateChanged.emit(this._read);
214
- this.readStateChanged.complete();
198
+ if (!this.read()) {
199
+ this.read.set(true);
215
200
  }
216
201
  }
217
202
  }
@@ -254,104 +239,79 @@ const JIGGLE_ANIMATION = animate('1s ease-in', keyframes([
254
239
  offset: 0.9
255
240
  })
256
241
  ]));
257
- class ErrorComponent extends BaseComponent {
258
- constructor(errorCollector, authProvider, changeDetectorRef) {
259
- super();
260
- this.errorCollector = errorCollector;
261
- this.authProvider = authProvider;
262
- this.changeDetectorRef = changeDetectorRef;
263
- this.state = null;
242
+ class RiskErrorComponent {
243
+ constructor() {
244
+ this.errorCollector = inject(ErrorCollectorService);
245
+ this.authProvider = inject(AUTH_PROVIDER, { optional: true });
246
+ this.state = signal(null, ...(ngDevMode ? [{ debugName: "state" }] : []));
247
+ this.keepVisibleOnClick = input(...(ngDevMode ? [undefined, { debugName: "keepVisibleOnClick" }] : []));
248
+ this.errorMessages = viewChildren(RiskErrorMessageComponent, ...(ngDevMode ? [{ debugName: "errorMessages" }] : []));
249
+ this.lastErrorFromCollector = toSignal(this.errorCollector.errorStream);
250
+ this.authenticated = this.authProvider == null
251
+ ? signal(true)
252
+ : toSignal(this.authProvider.loggedInStream, { initialValue: false });
264
253
  this._errors = [];
265
- this._menuState = new Subject();
266
- }
267
- ngOnInit() {
268
- // Init Jiggle animation loop
269
- this.initAnimation();
270
- // Subscribe to error stream
271
- this.subscribeToErrors();
272
- // Once opened animate messages and set as read after animation
273
- this._menuState.pipe(filter((opened) => opened), takeUntil(this.destroyed)).subscribe(() => this.animateOnMenuOpened());
274
- // Refresh on "logged-in" state changes
275
- if (this.authProvider) {
276
- this.authProvider.loggedInStream.pipe(takeUntil(this.destroyed)).subscribe((auth) => this.loggedInChanged(auth));
277
- }
278
- }
279
- animateOnMenuOpened() {
280
- const animateMessages = () => this.errorMessages.forEach((message) => message.animate());
281
- animateMessages();
282
- this.errorMessages.changes.pipe(takeUntil(merge(this.destroyed, this._menuState))).subscribe(() => animateMessages());
283
- }
284
- loggedInChanged(auth) {
285
- // Subscribe to errors once logged in again
286
- if (auth) {
287
- this.subscribeToErrors();
288
- }
289
- else {
290
- while (this._errors.length > 0) {
254
+ this.errors = computed(() => {
255
+ if (!this.authenticated()) {
256
+ this._errors = [];
257
+ return this._errors;
258
+ }
259
+ const lastError = this.lastErrorFromCollector();
260
+ if (!lastError) {
261
+ return this._errors;
262
+ }
263
+ const errorMessageWrapper = new ErrorMessageWrapper(lastError);
264
+ this._errors.unshift(errorMessageWrapper);
265
+ while (this._errors.length > 10) {
291
266
  this._errors.pop();
292
267
  }
293
- }
294
- this.changeDetectorRef.markForCheck();
295
- }
296
- subscribeToErrors() {
297
- let until = this.destroyed;
298
- // Stop receiving errors once user was logged out
299
- if (this.authProvider) {
300
- until = merge(until, this.authProvider.loggedInStream.pipe(filter((auth) => !auth), map(() => undefined)));
301
- }
302
- this.errorCollector.errorStream.pipe(takeUntil(until)).subscribe((error) => this.errorReceived(error, until));
303
- }
304
- errorReceived(error, until) {
305
- const errorMessageWrapper = new ErrorMessageWrapper(error);
306
- // Subscribe for state changes
307
- errorMessageWrapper.readStateChanged.pipe(takeUntil(until)).subscribe(() => this.changeDetectorRef.detectChanges());
308
- this._errors.unshift(errorMessageWrapper);
309
- while (this._errors.length > 10) {
310
- this._errors.pop();
311
- }
312
- this.changeDetectorRef.markForCheck();
313
- }
314
- get color() {
315
- if (this.errors.some((error) => !error.read)) {
316
- return 'warn';
317
- }
318
- return null;
319
- }
320
- menuOpened() {
321
- this._menuState.next(true);
322
- }
323
- menuClosed() {
324
- this._menuState.next(false);
325
- }
326
- get errors() {
327
- return this._errors;
268
+ return [...this._errors];
269
+ }, ...(ngDevMode ? [{ debugName: "errors" }] : []));
270
+ this.color = computed(() => {
271
+ for (const error of this.errors()) {
272
+ if (!error.read()) {
273
+ return 'warn';
274
+ }
275
+ }
276
+ return null;
277
+ }, ...(ngDevMode ? [{ debugName: "color" }] : []));
278
+ this.menuOpened = signal(false, ...(ngDevMode ? [{ debugName: "menuOpened" }] : []));
279
+ effect(() => {
280
+ if (this.menuOpened()) {
281
+ for (const message of this.errorMessages()) {
282
+ message.animate();
283
+ }
284
+ }
285
+ });
286
+ const timerSignal = intervalSignal(100, 2000);
287
+ effect(() => {
288
+ timerSignal();
289
+ let animate = false;
290
+ for (const error of untracked(this.errors)) {
291
+ if (!error.read()) {
292
+ animate = true;
293
+ break;
294
+ }
295
+ }
296
+ if (animate) {
297
+ switch (untracked(this.state)) {
298
+ case null:
299
+ this.state.set('active');
300
+ break;
301
+ case 'active':
302
+ this.state.set('newError');
303
+ break;
304
+ }
305
+ }
306
+ });
328
307
  }
329
- // <editor-fold desc="Animation control" defaultstate="collapsed">
330
308
  animationDone(event) {
331
309
  if (event.toState === 'newError') {
332
- // Reset after annimation
333
- this.state = 'active';
334
- // Called from animation controller we need to re-check
335
- this.changeDetectorRef.markForCheck();
310
+ this.state.set('active');
336
311
  }
337
312
  }
338
- initAnimation() {
339
- timer(100, 2000).pipe(
340
- // Run animation everytime we have non-read errors
341
- filter(() => this.errors.some((error) => !error.read)), takeUntil(this.destroyed)).subscribe(() => {
342
- switch (this.state) {
343
- case null:
344
- this.state = 'active';
345
- break;
346
- case 'active':
347
- this.state = 'newError';
348
- break;
349
- }
350
- this.changeDetectorRef.markForCheck();
351
- });
352
- }
353
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorComponent, deps: [{ token: ErrorCollectorService }, { token: AUTH_PROVIDER, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
354
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ErrorComponent, selector: "risk-error-menu", inputs: { keepVisibleOnClick: "keepVisibleOnClick" }, host: { properties: { "class.risk-error-menu": "true" } }, viewQueries: [{ propertyName: "errorMessages", predicate: ErrorMessageComponent, descendants: true }], usesInheritance: true, ngImport: i0, template: "<button *ngIf=\"state != null\"\n mat-icon-button\n [color]=\"color\"\n type=\"button\"\n [@buttonState]=\"state\"\n (@buttonState.done)=\"animationDone($event)\"\n [matMenuTriggerFor]=\"errorMenu\"\n #errorMenuTrigger=\"matMenuTrigger\"\n (menuOpened)=\"menuOpened()\"\n (menuClosed)=\"menuClosed()\"\n [class.risk-menu-open]=\"errorMenuTrigger.menuOpen\">\n <mat-icon>error_outline</mat-icon>\n</button>\n\n<mat-menu #errorMenu=\"matMenu\"\n class=\"risk-error-menu-mat-menu\"\n [overlapTrigger]=\"false\">\n <risk-error-message *ngFor=\"let error of errors; last as isLast\"\n [error]=\"error\"\n (click)=\"keepVisibleOnClick ? $event.stopPropagation() : null\"\n [isLast]=\"isLast\"></risk-error-message>\n</mat-menu>\n", styles: [":host{display:block;padding:0;margin:0}:host>*{vertical-align:bottom}\n", "::ng-deep .risk-error-menu-mat-menu{max-width:600px!important}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3$1.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i5.MatMenu, selector: "mat-menu", exportAs: ["matMenu"] }, { kind: "directive", type: i5.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", exportAs: ["matMenuTrigger"] }, { kind: "component", type: ErrorMessageComponent, selector: "risk-error-message", inputs: ["error", "isLast"] }], animations: [
313
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: RiskErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
314
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: RiskErrorComponent, isStandalone: true, selector: "risk-error-menu", inputs: { keepVisibleOnClick: { classPropertyName: "keepVisibleOnClick", publicName: "keepVisibleOnClick", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.risk-error-menu": "true" } }, viewQueries: [{ propertyName: "errorMessages", predicate: RiskErrorMessageComponent, descendants: true, isSignal: true }], ngImport: i0, template: "@if (state() != null) {\n <button\n #errorMenuTrigger=\"matMenuTrigger\"\n (@buttonState.done)=\"animationDone($event)\"\n [@buttonState]=\"state()\"\n (menuClosed)=\"menuOpened.set(false)\"\n (menuOpened)=\"menuOpened.set(true)\"\n [class.risk-menu-open]=\"errorMenuTrigger.menuOpen\"\n [color]=\"color()\"\n [matMenuTriggerFor]=\"errorMenu\"\n mat-icon-button\n type=\"button\">\n <mat-icon>error_outline</mat-icon>\n </button>\n}\n\n<mat-menu #errorMenu=\"matMenu\"\n [overlapTrigger]=\"false\"\n class=\"risk-error-menu-mat-menu\">\n @for (error of errors(); track error; let isLast = $last) {\n <risk-error-message\n (click)=\"keepVisibleOnClick() ? $event.stopPropagation() : null\"\n [error]=\"error\"\n [isLast]=\"isLast\"/>\n }\n</mat-menu>\n", styles: [":host{display:block;padding:0;margin:0}:host>*{vertical-align:bottom}\n", "::ng-deep .risk-error-menu-mat-menu{max-width:600px!important}\n"], dependencies: [{ kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "directive", type: MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }, { kind: "component", type: RiskErrorMessageComponent, selector: "risk-error-message", inputs: ["error", "isLast"] }], animations: [
355
315
  trigger('buttonState', [
356
316
  state('inactive', style({ transform: 'translateX(0) scale(0)' })),
357
317
  state('active', style({ transform: 'translateX(0) scale(1)' })),
@@ -371,9 +331,17 @@ class ErrorComponent extends BaseComponent {
371
331
  ])
372
332
  ], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
373
333
  }
374
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorComponent, decorators: [{
334
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: RiskErrorComponent, decorators: [{
375
335
  type: Component,
376
- args: [{ selector: 'risk-error-menu', animations: [
336
+ args: [{ selector: 'risk-error-menu', changeDetection: ChangeDetectionStrategy.OnPush, host: {
337
+ '[class.risk-error-menu]': 'true'
338
+ }, imports: [
339
+ MatIcon,
340
+ MatIconButton,
341
+ MatMenu,
342
+ MatMenuTrigger,
343
+ RiskErrorMessageComponent
344
+ ], animations: [
377
345
  trigger('buttonState', [
378
346
  state('inactive', style({ transform: 'translateX(0) scale(0)' })),
379
347
  state('active', style({ transform: 'translateX(0) scale(1)' })),
@@ -391,58 +359,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
391
359
  JIGGLE_ANIMATION
392
360
  ])
393
361
  ])
394
- ], host: {
395
- '[class.risk-error-menu]': 'true'
396
- }, changeDetection: ChangeDetectionStrategy.OnPush, preserveWhitespaces: false, template: "<button *ngIf=\"state != null\"\n mat-icon-button\n [color]=\"color\"\n type=\"button\"\n [@buttonState]=\"state\"\n (@buttonState.done)=\"animationDone($event)\"\n [matMenuTriggerFor]=\"errorMenu\"\n #errorMenuTrigger=\"matMenuTrigger\"\n (menuOpened)=\"menuOpened()\"\n (menuClosed)=\"menuClosed()\"\n [class.risk-menu-open]=\"errorMenuTrigger.menuOpen\">\n <mat-icon>error_outline</mat-icon>\n</button>\n\n<mat-menu #errorMenu=\"matMenu\"\n class=\"risk-error-menu-mat-menu\"\n [overlapTrigger]=\"false\">\n <risk-error-message *ngFor=\"let error of errors; last as isLast\"\n [error]=\"error\"\n (click)=\"keepVisibleOnClick ? $event.stopPropagation() : null\"\n [isLast]=\"isLast\"></risk-error-message>\n</mat-menu>\n", styles: [":host{display:block;padding:0;margin:0}:host>*{vertical-align:bottom}\n", "::ng-deep .risk-error-menu-mat-menu{max-width:600px!important}\n"] }]
397
- }], ctorParameters: function () { return [{ type: ErrorCollectorService }, { type: undefined, decorators: [{
398
- type: Optional
399
- }, {
400
- type: Inject,
401
- args: [AUTH_PROVIDER]
402
- }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { keepVisibleOnClick: [{
403
- type: Input
404
- }], errorMessages: [{
405
- type: ViewChildren,
406
- args: [ErrorMessageComponent]
407
- }] } });
362
+ ], template: "@if (state() != null) {\n <button\n #errorMenuTrigger=\"matMenuTrigger\"\n (@buttonState.done)=\"animationDone($event)\"\n [@buttonState]=\"state()\"\n (menuClosed)=\"menuOpened.set(false)\"\n (menuOpened)=\"menuOpened.set(true)\"\n [class.risk-menu-open]=\"errorMenuTrigger.menuOpen\"\n [color]=\"color()\"\n [matMenuTriggerFor]=\"errorMenu\"\n mat-icon-button\n type=\"button\">\n <mat-icon>error_outline</mat-icon>\n </button>\n}\n\n<mat-menu #errorMenu=\"matMenu\"\n [overlapTrigger]=\"false\"\n class=\"risk-error-menu-mat-menu\">\n @for (error of errors(); track error; let isLast = $last) {\n <risk-error-message\n (click)=\"keepVisibleOnClick() ? $event.stopPropagation() : null\"\n [error]=\"error\"\n [isLast]=\"isLast\"/>\n }\n</mat-menu>\n", styles: [":host{display:block;padding:0;margin:0}:host>*{vertical-align:bottom}\n", "::ng-deep .risk-error-menu-mat-menu{max-width:600px!important}\n"] }]
363
+ }], ctorParameters: () => [], propDecorators: { keepVisibleOnClick: [{ type: i0.Input, args: [{ isSignal: true, alias: "keepVisibleOnClick", required: false }] }], errorMessages: [{ type: i0.ViewChildren, args: [i0.forwardRef(() => RiskErrorMessageComponent), { isSignal: true }] }] } });
408
364
 
409
- class ErrorModule {
410
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
411
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: ErrorModule, declarations: [ErrorComponent,
412
- ErrorMessageComponent], imports: [CommonModule,
413
- CommonViewModule], exports: [ErrorComponent] }); }
414
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorModule, providers: [
415
- ErrorCollectorService,
416
- {
417
- provide: ErrorHandler,
418
- useExisting: ErrorCollectorService
419
- }
420
- ], imports: [CommonModule,
421
- CommonViewModule] }); }
365
+ function provideErrorHandler() {
366
+ return [
367
+ {
368
+ provide: ErrorHandler,
369
+ useExisting: ErrorCollectorService
370
+ }
371
+ ];
422
372
  }
423
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorModule, decorators: [{
424
- type: NgModule,
425
- args: [{
426
- imports: [
427
- CommonModule,
428
- CommonViewModule
429
- ],
430
- exports: [
431
- ErrorComponent
432
- ],
433
- declarations: [
434
- ErrorComponent,
435
- ErrorMessageComponent
436
- ],
437
- providers: [
438
- ErrorCollectorService,
439
- {
440
- provide: ErrorHandler,
441
- useExisting: ErrorCollectorService
442
- }
443
- ]
444
- }]
445
- }] });
446
373
 
447
374
  /**
448
375
  * Collects all error using error collector and returns the "otherwise" error instead.
@@ -457,5 +384,5 @@ function collectErrors(errorCollector, otherwise) {
457
384
  * Generated bundle index. Do not edit.
458
385
  */
459
386
 
460
- export { ErrorCollectorService, ErrorComponent, ErrorModule, JIGGLE_ANIMATION, collectErrors, toErrorMessage };
387
+ export { ErrorCollectorService, JIGGLE_ANIMATION, RiskErrorComponent, collectErrors, provideErrorHandler, toErrorMessage };
461
388
  //# sourceMappingURL=dbg-riskit-angular-error.mjs.map