import React from "react"; import { Button } from "../../design"; import { Type, TypeProps, Value } from "./InputElement"; /** * Form schema */ export declare type FormTemplate = Record; /** * Generate value object from form schema */ export declare type MapFormToValues = { [Property in keyof T]: Value; }; /** * Generate data object from form schema */ declare type MapFormToData = { [Property in keyof T]: TypeProps; }; /** * Form props */ export interface Props { /** * Form schema */ schema: T; /** * Props required for rendering form elements */ data: MapFormToData; /** * Handle changes to the data */ onChange?: (data: MapFormToValues, key: keyof T) => void; /** * Handle form submission */ onSubmit?: (data: MapFormToValues) => void; /** * Provide an observable object of values */ observed?: MapFormToValues; /** * Provide default values for keys */ defaults?: Partial>; /** * Submit button properties */ submitBtn?: Omit, "type">; /** * Whether all elements are disabled */ disabled?: boolean; } /** * Get initial values to use for the form data * @param schema Schema to use * @param defaults Defaults to apply * @returns Initial values */ export declare function getInitialValues(schema: T, defaults?: Partial>): MapFormToValues; /** * Dynamic Form component */ export declare function Form({ schema, data, disabled, onChange, onSubmit, observed, defaults, submitBtn, }: Props): JSX.Element; export {}; /** * Example on using
: function test() { return ( { if (key === "test") { console.log("test changed!"); } }} onSubmit={(v) => { v.test; }} /> ); } */