62 lines
1.3 KiB
TypeScript
62 lines
1.3 KiB
TypeScript
export type AbstractSchemaField = {
|
|
id: string
|
|
label: string
|
|
description: string | null
|
|
required: boolean
|
|
placeholder: string | null
|
|
meta?: {
|
|
required?: boolean
|
|
}
|
|
}
|
|
|
|
export type TextField = {
|
|
type: "text"
|
|
multiline: boolean
|
|
validator: {
|
|
minLength: number | null
|
|
maxLength: number | null
|
|
regex: string
|
|
}
|
|
} & AbstractSchemaField
|
|
|
|
export type EmailField = {
|
|
type: "email",
|
|
validator: {
|
|
allowedDomains: string[],
|
|
}
|
|
} & AbstractSchemaField
|
|
|
|
export type NumberField = {
|
|
type: "number",
|
|
validator: {
|
|
min: number | null
|
|
max: number | null
|
|
}
|
|
} & AbstractSchemaField
|
|
|
|
export type DateField = {
|
|
type: "date"
|
|
validator: {
|
|
minDate: Date | null
|
|
maxDate: Date | null
|
|
}
|
|
} & AbstractSchemaField
|
|
|
|
export type SelectField = {
|
|
type: "select",
|
|
multiple: boolean
|
|
options: string[]
|
|
} & AbstractSchemaField
|
|
|
|
export type CheckboxField = {
|
|
type: "checkbox"
|
|
} & AbstractSchemaField
|
|
|
|
export type FormSchemaField = TextField | EmailField | NumberField | DateField | SelectField | CheckboxField
|
|
|
|
export type FieldType = "text" | "number" | "date" | "select" | "checkbox" | "email"
|
|
export const FieldTypes: FieldType[] = ["text", "email", "number", "date", "select", "checkbox"]
|
|
|
|
export type FormSchema = {
|
|
fields: FormSchemaField[],
|
|
} |