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() id = Math.random().toString(11).slice(2, 8) // id cannot be left empty or undefined
20 @Input() autocomplete = 'off'
21 @Input() placeholder = ''
22 @Input() withToggle = true
23 @Input() withCopy = false
24 @Input() readonly = false
27 constructor (private notifier: Notifier) { }
42 this.show = !this.show
45 activateCopiedMessage () {
46 this.notifier.success($localize`Copied`)
49 propagateChange = (_: any) => { /* empty */ }
51 writeValue (value: string) {
55 registerOnChange (fn: (_: any) => void) {
56 this.propagateChange = fn
59 registerOnTouched () {
64 this.propagateChange(this.value)