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-toggle-hidden',
7 templateUrl: './input-toggle-hidden.component.html',
8 styleUrls: [ './input-toggle-hidden.component.scss' ],
11 provide: NG_VALUE_ACCESSOR,
12 useExisting: forwardRef(() => InputToggleHiddenComponent),
17 export class InputToggleHiddenComponent 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
28 constructor (private notifier: Notifier) { }
43 this.show = !this.show
46 activateCopiedMessage () {
47 this.notifier.success($localize`Copied`)
50 propagateChange = (_: any) => { /* empty */ }
52 writeValue (value: string) {
56 registerOnChange (fn: (_: any) => void) {
57 this.propagateChange = fn
60 registerOnTouched () {
65 this.propagateChange(this.value)