import { Checkbox, CheckboxProps, Chip, ChipProps, Fieldset, FieldsetProps, MultiSelect, MultiSelectProps, NumberInput, NumberInputProps, PasswordInput, PasswordInputProps, Select, SelectProps, TextInput, TextInputProps, Textarea, TextareaProps, } from "@mantine/core"; import { ReactNode } from "@tanstack/react-router"; type GeneralInputProps = { hidden?: boolean; key?: string | number; }; type TextInputType = { type: "text"; } & TextInputProps; type MultiSelectInputType = { type: "multi-select"; } & MultiSelectProps; type PasswordInputType = { type: "password"; } & PasswordInputProps; type NumberInputType = { type: "number"; } & Omit; type SelectType = { type: "select"; } & SelectProps; type Group = { type: "group"; inputs: AcceptedInput[]; } & FieldsetProps; type ChipType = { type: "chip"; } & Omit; type CheckboxType = { type: "checkbox"; } & CheckboxProps; type TextareaType = { type: "textarea"; } & TextareaProps; type AcceptedInput = ( | TextInputType | MultiSelectInputType | PasswordInputType | NumberInputType | SelectType | ChipType | Group | CheckboxType | TextareaType ) & GeneralInputProps; interface Options { disableAll?: boolean; readonlyAll?: boolean; inputs: AcceptedInput[]; } function createInputComponents(options: Options) { const components = [] as ReactNode[]; const createComponent = ({ key, ...input }: AcceptedInput) => { switch (input.type) { case "text": return ( ); case "multi-select": return ( ); case "password": return ( ); case "number": return ( ); case "select": return (