-import { Component, forwardRef, Input } from '@angular/core'
+import { Component, ElementRef, forwardRef, Input, ViewChild } from '@angular/core'
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
import { Notifier } from '@app/core'
-import { GlobalIconName } from '../shared-icons'
@Component({
selector: 'my-input-text',
]
})
export class InputTextComponent implements ControlValueAccessor {
+ @ViewChild('input') inputElement: ElementRef
+
@Input() inputId = Math.random().toString(11).slice(2, 8) // id cannot be left empty or undefined
@Input() value = ''
@Input() autocomplete = 'off'
@Input() withCopy = false
@Input() readonly = false
@Input() show = false
+ @Input() formError: string
constructor (private notifier: Notifier) { }
this.notifier.success($localize`Copied`)
}
- getEyeIcon (): GlobalIconName {
- if (this.show) return 'sensitive'
-
- return 'unsensitive'
- }
-
propagateChange = (_: any) => { /* empty */ }
writeValue (value: string) {
update () {
this.propagateChange(this.value)
}
+
+ focus () {
+ const el: HTMLElement = this.inputElement.nativeElement
+
+ el.focus({ preventScroll: true })
+ }
}