feat(ui): Added textarea component to ui-libs. (TV-849)

Squashed commit of the following:

commit 61ecaf467c63cdd10f4d66131b105d3b12d60e49
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Wed Nov 3 11:14:19 2021 +0100

    Removed unused input

commit 2254c1dd547cbf3639e5232fe6d8e657491a369c
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Wed Nov 3 11:12:38 2021 +0100

    Implemented textarea component inside ui-libs
This commit is contained in:
Erik Tiekstra
2021-11-03 12:04:15 +01:00
parent 37cdf9285a
commit e51e13dfa8
17 changed files with 256 additions and 63 deletions
@@ -1,5 +1,5 @@
/* tslint:disable:no-unused-variable */
import { FormCheckboxComponent } from './form-checkbox.component';
import { CheckboxComponent } from './checkbox.component';
export class MockInjector {
get = jest.fn();
@@ -14,10 +14,10 @@ export class MockChangeDetectorRef {
checkNoChanges = jest.fn();
}
describe('FormCheckboxComponent', () => {
let component: FormCheckboxComponent;
describe('CheckboxComponent', () => {
let component: CheckboxComponent;
it('should create', () => {
component = new FormCheckboxComponent(new MockInjector(), new MockChangeDetectorRef());
component = new CheckboxComponent(new MockInjector(), new MockChangeDetectorRef());
expect(component).toBeTruthy();
});
});
+3 -4
View File
@@ -8,7 +8,6 @@ import {
Input,
OnChanges,
Output,
SimpleChanges,
} from '@angular/core';
import { ControlValueAccessor, NgControl, NG_VALUE_ACCESSOR } from '@angular/forms';
import { uuid } from '@utils/uuid.util';
@@ -42,7 +41,7 @@ export class CheckboxComponent implements AfterViewInit, ControlValueAccessor, O
@Input() uiId: string = uuid();
@Input() uiName: string;
@Input() uiAnnounceIfOptional: boolean = false;
@Output() uiOnChange: EventEmitter<any> = new EventEmitter();
@Output() uiOnChange: EventEmitter<boolean> = new EventEmitter();
name: string | number;
@@ -79,7 +78,7 @@ export class CheckboxComponent implements AfterViewInit, ControlValueAccessor, O
}
}
ngOnChanges(changes: SimpleChanges): void {
ngOnChanges(): void {
const ngControl: NgControl = this.injector.get(NgControl, null);
if (ngControl) {
this.name = ngControl.name;
@@ -96,7 +95,7 @@ export class CheckboxComponent implements AfterViewInit, ControlValueAccessor, O
}
}
writeValue(value: any): void {
writeValue(value: boolean): void {
this._value = value;
this.changeDetectorRef.detectChanges();
}