import { ReactElement } from "react"; import type { FormType } from "../../../interfaces"; import { InputTags as DefaultInputTags } from "../../../molecules/forms/input-tags/InputTags"; import { InputText as DefaultInputText } from "../../../molecules/forms/input-text/InputText"; import { Select as DefaultSelect } from "../../../molecules/forms/select/Select"; import { getComponent, registerComponent } from "../../../registries/components"; export const defaultDisplayChoices = [ { label: "Form", value: "form" }, { label: "Wizard", value: "wizard" }, { label: "Pdf", value: "pdf" } ]; export interface FormParametersProps { onChange?: (name: string | undefined, value: any) => void; form: Partial; typeChoices?: { label: string; value: any }[]; displayChoices?: { label: string; value: any }[]; enableTags?: boolean; className?: string; baseUrl?: string; layout?: "html5" | "choicesjs" | "react"; readonly?: Record; } export function FormParameters({ onChange, form, enableTags = true, typeChoices = [], displayChoices = defaultDisplayChoices, className = "", readonly = {}, layout, baseUrl = window.location.origin }: FormParametersProps): ReactElement { const hasTypeChoices = typeChoices && typeChoices.length > 1; const InputText = getComponent("InputText"); const Select = getComponent("Select"); const InputTags = getComponent("InputTags"); return (
{`${baseUrl}/${form.path}`} } required={true} value={form.path} disabled={readonly["path"]} style={{ textTransform: "lowercase", width: "120px" }} onChange={onChange} />
)} {enableTags && (
)}
); } registerComponent("FormParameters", FormParameters);