|
|
|
@ -16,7 +16,8 @@ |
|
|
|
|
|
|
|
import { |
|
|
|
AfterContentChecked, |
|
|
|
AfterContentInit, AfterViewChecked, |
|
|
|
AfterContentInit, |
|
|
|
AfterViewChecked, |
|
|
|
AfterViewInit, |
|
|
|
ChangeDetectorRef, |
|
|
|
Component, |
|
|
|
@ -25,17 +26,20 @@ import { |
|
|
|
ElementRef, |
|
|
|
EventEmitter, |
|
|
|
HostBinding, |
|
|
|
Input, NgZone, |
|
|
|
Input, |
|
|
|
NgZone, |
|
|
|
OnChanges, |
|
|
|
OnDestroy, |
|
|
|
OnInit, |
|
|
|
Output, |
|
|
|
QueryList, |
|
|
|
SimpleChanges, |
|
|
|
ViewChild |
|
|
|
} from '@angular/core'; |
|
|
|
import { PageComponent } from '@shared/components/page.component'; |
|
|
|
import { Store } from '@ngrx/store'; |
|
|
|
import { AppState } from '@core/core.state'; |
|
|
|
import { BehaviorSubject, Subject, Subscription } from 'rxjs'; |
|
|
|
import { BehaviorSubject, Observable, ReplaySubject, Subject, Subscription } from 'rxjs'; |
|
|
|
import { BreakpointObserver, BreakpointState } from '@angular/cdk/layout'; |
|
|
|
import { MediaBreakpoints } from '@shared/models/constants'; |
|
|
|
import { coerceBoolean } from '@shared/decorators/coercion'; |
|
|
|
@ -46,6 +50,7 @@ import { MatButtonToggle, MatButtonToggleGroup } from '@angular/material/button- |
|
|
|
export interface ToggleHeaderOption { |
|
|
|
name: string; |
|
|
|
value: any; |
|
|
|
error$?: Observable<string>; |
|
|
|
} |
|
|
|
|
|
|
|
export type ToggleHeaderAppearance = 'fill' | 'fill-invert' | 'stroked'; |
|
|
|
@ -59,10 +64,14 @@ export type ScrollDirection = 'after' | 'before'; |
|
|
|
} |
|
|
|
) |
|
|
|
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
|
|
|
export class ToggleOption { |
|
|
|
export class ToggleOption implements OnChanges, OnDestroy { |
|
|
|
|
|
|
|
@Input() value: any; |
|
|
|
|
|
|
|
@Input() error: string; |
|
|
|
|
|
|
|
currentError = new ReplaySubject<string>(1); |
|
|
|
|
|
|
|
get viewValue(): string { |
|
|
|
return (this._element?.nativeElement.textContent || '').trim(); |
|
|
|
} |
|
|
|
@ -70,6 +79,18 @@ export class ToggleOption { |
|
|
|
constructor( |
|
|
|
private _element: ElementRef<HTMLElement> |
|
|
|
) {} |
|
|
|
|
|
|
|
ngOnChanges(changes: SimpleChanges) { |
|
|
|
if (changes?.error) { |
|
|
|
if (changes.error.currentValue !== changes.error.previousValue) { |
|
|
|
this.currentError.next(this.error); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ngOnDestroy() { |
|
|
|
this.currentError.complete(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Directive() |
|
|
|
@ -102,8 +123,10 @@ export abstract class _ToggleBase extends PageComponent implements AfterContentI |
|
|
|
this.options.length = 0; |
|
|
|
this.toggleOptions.forEach(option => { |
|
|
|
this.options.push( |
|
|
|
{ name: option.viewValue, |
|
|
|
value: option.value |
|
|
|
{ |
|
|
|
name: option.viewValue, |
|
|
|
value: option.value, |
|
|
|
error$: option.currentError.asObservable() |
|
|
|
} |
|
|
|
); |
|
|
|
}); |
|
|
|
|