proto-form
Version:
A typescript base library for managing native javascript forms. Handles onChange events, and normalizing data flow. Leverages native javascript events.
27 lines (25 loc) • 671 B
text/typescript
export type Values = {
[key: string]: FormDataEntryValue | FormDataEntryValue[] | null
}
export interface ProtoFormProps<T> {
e_form: HTMLFormElement | null
onChange?: (form: ReturnValues<T>) => void
onBlur?: (
obj: ReturnValues<T> & {
name: string
}
) => void
onIsValid?: (form: ReturnValues<T>) => void
onIsInvalid?: (form: ReturnValues<T>) => void
onSubmit?: (form: ReturnValues<T>) => void
children?: HTMLElement | HTMLElement[]
noValidate?: boolean
allUniqueCheckboxKeys?: string[]
}
export interface ReturnValues<T> {
values: T
blurredKeys: Set<string>
keys: Set<string>
e_form: HTMLFormElement
lastTouched?: string
}