1 import { Component, forwardRef, Input } from '@angular/core'
2 import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
3 import { Notifier } from '@app/core'
7 selector: 'my-input-text',
8 templateUrl: './input-text.component.html',
9 styleUrls: [ './input-text.component.scss' ],
12 provide: NG_VALUE_ACCESSOR,
13 useExisting: forwardRef(() => InputTextComponent),
18 export class InputTextComponent implements ControlValueAccessor {
19 @Input() inputId = Math.random().toString(11).slice(2, 8) // id cannot be left empty or undefined
21 @Input() autocomplete = 'off'
22 @Input() placeholder = ''
24 @Input() withToggle = true
25 @Input() withCopy = false
26 @Input() readonly = false
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)