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.
53 lines
844 B
53 lines
844 B
export enum FormFieldType {
|
|
text,
|
|
password,
|
|
url,
|
|
email,
|
|
phone,
|
|
search,
|
|
number,
|
|
error,
|
|
select,
|
|
checkboxes,
|
|
textarea,
|
|
date,
|
|
color,
|
|
}
|
|
|
|
export interface FormFieldConfig {
|
|
type: FormFieldType,
|
|
name: string,
|
|
title: string,
|
|
required?: boolean,
|
|
}
|
|
|
|
export interface FormConfig {
|
|
endpoint: string,
|
|
method?: 'get'|'post'|'put'|'delete'|'patch',
|
|
fields: (FormFieldConfig)[],
|
|
}
|
|
|
|
export type FormData = {[key: string]: any}
|
|
|
|
export interface FormField {
|
|
getFieldName(): string
|
|
|
|
getValue(): any
|
|
|
|
validate(): boolean
|
|
}
|
|
|
|
export interface FormControl {
|
|
hasField(field: FormField): boolean
|
|
|
|
registerField(field: FormField): void
|
|
|
|
processChanges(): void
|
|
|
|
gather(): FormData | Promise<FormData>
|
|
|
|
submit(): void | Promise<void>
|
|
|
|
isValid(): boolean
|
|
}
|