chore: copia de libs/shared con prefijo Pi y APIs de terceros actualizadas
This commit is contained in:
52
libs/ui/src/lib/util/form-control/form-control.ts
Normal file
52
libs/ui/src/lib/util/form-control/form-control.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { ControlContainer, ControlValueAccessor } from '@angular/forms';
|
||||
|
||||
@Injectable()
|
||||
export class PiFormControl implements ControlValueAccessor {
|
||||
value: number | string | Array<string> | boolean;
|
||||
|
||||
onChange = (value: number | string | Array<string> | boolean) => {};
|
||||
|
||||
onTouched = () => {};
|
||||
|
||||
disabled = false;
|
||||
focused = false;
|
||||
touched = false;
|
||||
|
||||
constructor(protected injector: Injector) {}
|
||||
|
||||
get controlContainer(): any {
|
||||
return this.injector.get(ControlContainer);
|
||||
}
|
||||
|
||||
writeValue(value: number | string | Array<string> | boolean) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
registerOnChange(onChange: any) {
|
||||
this.onChange = onChange;
|
||||
}
|
||||
|
||||
registerOnTouched(onTouched: any) {
|
||||
this.onTouched = onTouched;
|
||||
}
|
||||
|
||||
markAsTouched() {
|
||||
if (!this.touched) {
|
||||
this.onTouched();
|
||||
this.touched = true;
|
||||
}
|
||||
}
|
||||
|
||||
setDisabledState(disabled: boolean) {
|
||||
this.disabled = disabled;
|
||||
}
|
||||
|
||||
onFocus(): void {
|
||||
this.focused = true;
|
||||
}
|
||||
|
||||
onBlur(): void {
|
||||
this.focused = false;
|
||||
}
|
||||
}
|
||||
1
libs/ui/src/lib/util/form-control/index.ts
Normal file
1
libs/ui/src/lib/util/form-control/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './form-control';
|
||||
Reference in New Issue
Block a user