tibi-starter/types/formComponent.d.ts
2024-01-27 18:58:35 +00:00

145 lines
2.8 KiB
TypeScript

interface FormValues {
[key: string]: CustomHTMLElement
blockGroups?: Set<number>
}
interface FormObj {
formRows?: string[]
index?: number
formTitle?: string
formValues?: Writable<FormValues>
honey?: boolean
agreement?: boolean
}
// Before transformation
interface TempFormBefore {
[rowName: string]: TempFormRowBefore
}
interface TempFormRowBefore {
[newKey: string]: [any, boolean, boolean]
}
// After transformation
interface TempFormAfter {
[rowName: string]: Array<[string, [any, boolean, boolean]]>
}
interface TempFormIndices {
[rowName: string]: {
[newKey: string]: number
}
}
type ValueEntry =
| [string, [boolean | string | any, boolean]]
| [string, [any, CustomHTMLElement, string | null, boolean]]
type ObjectEntry = [string, CustomHTMLElement]
interface DBFormObj {
emailSubject: string
emailReciever: string
emailCC: string[]
emailIntroduction: string
rows: DBFormRow[]
}
interface DBFormRow {
title: string
emailTitle: string
columns: FormColumn[]
}
interface Block {
label: string
emailName: string
}
interface LabelNumberInput {
group: number
title: string
emailName: string
block: Block[]
}
type inputWidgets =
| "labelNumber"
| "times"
| "select"
| "defaultCalendar"
| "customCalendar"
| "number"
| "checkboxGroup"
| "test"
| "multiSelect"
type StandardInputProperties = {
emailTitle: string
placeholder: string
notRequired: boolean
fieldOrder: number
textTitle: string
}
interface CheckboxGroupInput {
groupTitle: string
checkboxes: {
standardInputProperties: StandardInputProperties[]
}[]
}
interface DateInput {
standardInputProperties: StandardInputProperties
}
interface DatePickerInput {
standardInputProperties: StandardInputProperties
props: {
allowedDateRanges: {
from: Date
to: Date
}
excludeDates: string[]
}
}
interface MultiSelectInput {
standardInputProperties: StandardInputProperties
props: {
additionalAddableValues: boolean
}
options: {
name: string
}
}
interface NumberInput {
standardInputProperties: StandardInputProperties
}
interface TextInput {
standardInputProperties: StandardInputProperties
textArea: boolean
emailValidation: boolean
telValidation: boolean
}
interface TimesInput {
standardInputProperties: StandardInputProperties
times: {
from: string
to: string
}[]
}
interface FormColumn {
inputWidgets: inputWidgets
labelNumberInput?: LabelNumber
checkboxGroupInput?: CheckboxGroupInput
dateInput?: DateInputInput
datePickerInput?: DatePickerInput
multiSelectInput?: MultiSelectInput
numberInput?: NumberInput
timesInput?: TimesInput
textInput?: TextInput
}