import { MultiSelect, MultiSelectProps, NumberInput, NumberInputProps, PasswordInput, PasswordInputProps, Select, SelectProps, TextInput, TextInputProps, } from "@mantine/core"; import { ReactNode } from "@tanstack/react-router"; type GeneralInputProps = { hidden?: boolean; }; 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; interface Options { disableAll?: boolean; readonlyAll?: boolean; inputs: (( | TextInputType | MultiSelectInputType | PasswordInputType | NumberInputType | SelectType ) & GeneralInputProps)[]; } function createInputComponents(options: Options) { const components = [] as ReactNode[]; for (const input of options.inputs) { if (input.hidden) continue; switch (input.type) { case "text": components.push( ); break; case "multi-select": components.push( ); break; case "password": components.push( ); break; case "number": components.push( ); break; case "select": components.push(