32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { CommonModule } from '@angular/common';
|
|
import { Component, forwardRef, Input } from '@angular/core';
|
|
import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
import { BaseInputComponent } from '../base-input/base-input.component';
|
|
import { TooltipComponent } from '../tooltip/tooltip.component';
|
|
import { ValidationMessagesService } from '../validation-messages.service';
|
|
|
|
@Component({
|
|
selector: 'app-validated-input',
|
|
templateUrl: './validated-input.component.html',
|
|
standalone: true,
|
|
imports: [CommonModule, FormsModule, TooltipComponent],
|
|
providers: [
|
|
{
|
|
provide: NG_VALUE_ACCESSOR,
|
|
useExisting: forwardRef(() => ValidatedInputComponent),
|
|
multi: true,
|
|
},
|
|
],
|
|
})
|
|
export class ValidatedInputComponent extends BaseInputComponent {
|
|
@Input() kind: 'text' | 'number' | 'email' | 'tel' = 'text';
|
|
constructor(validationMessagesService: ValidationMessagesService) {
|
|
super(validationMessagesService);
|
|
}
|
|
|
|
onInputChange(event: Event): void {
|
|
this.value = event;
|
|
this.onChange(event);
|
|
}
|
|
}
|