1 import { Component, forwardRef, Input } from '@angular/core'
2 import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
3 import { Notifier } from '@app/core'
6 selector: 'my-input-text',
7 templateUrl: './input-text.component.html',
8 styleUrls: [ './input-text.component.scss' ],
11 provide: NG_VALUE_ACCESSOR,
12 useExisting: forwardRef(() => InputTextComponent),
17 export class InputTextComponent implements ControlValueAccessor {
18 @Input() inputId = Math.random().toString(11).slice(2, 8) // id cannot be left empty or undefined
20 @Input() autocomplete = 'off'
21 @Input() placeholder = ''
23 @Input() withToggle = true
24 @Input() withCopy = false
25 @Input() readonly = false
27 @Input() formError: string
29 constructor (private notifier: Notifier) { }
44 this.show = !this.show
47 activateCopiedMessage () {
48 this.notifier.success($localize`Copied`)
51 propagateChange = (_: any) => { /* empty */ }
53 writeValue (value: string) {
57 registerOnChange (fn: (_: any) => void) {
58 this.propagateChange = fn
61 registerOnTouched () {
66 this.propagateChange(this.value)