generated from garrettmills/template-npm-typescript
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
697 B
29 lines
697 B
import {ExComponent} from '../../ExComponent.js'
|
|
import {FormControl, FormField} from '../types.js'
|
|
import {FormComponent} from '../Form.component.js'
|
|
|
|
export abstract class InputComponent extends ExComponent implements FormField {
|
|
mount() {
|
|
super.mount()
|
|
this.control()?.registerField(this)
|
|
}
|
|
|
|
protected control(): undefined | FormControl {
|
|
let parent = this.parentElement
|
|
|
|
while ( parent ) {
|
|
if ( parent instanceof FormComponent ) {
|
|
return parent
|
|
}
|
|
|
|
parent = parent.parentElement
|
|
}
|
|
}
|
|
|
|
abstract getFieldName(): string
|
|
|
|
abstract getValue(): any
|
|
|
|
abstract validate(): boolean
|
|
}
|