UNPKG

@react-formless/core

Version:
79 lines 5.57 kB
/// <reference types="react" /> import { Option, F1, Result, ArrayItem, Err } from "@react-formless/utils"; import { FormSchema, FormState, FormResult, CollectionInputSchema, SimpleInputSchema, ListInputSchema, SimpleInputProps, ExtInputProps, InputOptionSchema, InputPropsBase, InputState, MultiselectInputSchema, RenderParams, InputMultiselectRenderFn, InputOptionRenderFn, InputBoxRenderFn } from "."; export declare const validateForm: <T>(schema: FormSchema<T>, state: FormState<T>) => FormState<T>; export declare const formStateToFormResult: <T>(schema: FormSchema<T>, state: FormState<T>) => FormResult<T>; export declare const toResult: <T>(schema: FormSchema<T>, state: FormState<T>) => Result<T, T>; export declare const formResultToResult: <T>(schema: FormSchema<T>, res: FormResult<T>) => Result<T, T>; export declare const toFormState: <T>(schema: FormSchema<T>, value: T) => FormState<T>; export declare const mkInputState: <T>(defValue: T, value: T, active?: boolean, visited?: boolean) => InputState<T>; export declare const mkHiddenInputState: <T>(value: T) => InputState<T>; export declare function toInputState<T>(s: CollectionInputSchema<T>, value: T): Array<FormState<ArrayItem<T>>>; export declare function toInputState<T>(s: ListInputSchema<T>, value: T[]): Array<InputState<T>>; export declare function toInputState<T>(s: MultiselectInputSchema<T>, value: T[]): InputState<T[]>; export declare function toInputState<T>(s: SimpleInputSchema<T>, value: T): InputState<T>; export declare const validate: <T>({ state, schema: { toValue, type, validators }, setDelta }: SimpleInputProps, v: any) => Err<string, any> | import("@react-formless/utils").State<"Ok", { value: any; }>; export declare const getInputProps: <T2 = HTMLInputElement>(p: SimpleInputProps) => ExtInputProps<T2>; export declare const getExtInputProps: <T>(p: InputPropsBase<import("@react-formless/utils").State<"number" | "textarea" | "hidden" | "text" | "email" | "password", { validators?: import("@react-formless/utils").Validator<T, string>[] | null | undefined; toValue?: F1<string, T | null> | undefined; fromValue?: F1<T | null, string> | undefined; sectionTitle?: string | undefined; } & Pick<import("react").InputHTMLAttributes<T>, "value" | "disabled" | "name" | "placeholder" | "id" | "onChange" | "readOnly">> | import("@react-formless/utils").State<"customBox", { validators?: import("@react-formless/utils").Validator<T, string>[] | null | undefined; toValue?: F1<string, T | null> | undefined; fromValue?: F1<T | null, string> | undefined; sectionTitle?: string | undefined; } & Pick<import("react").InputHTMLAttributes<T>, "value" | "disabled" | "name" | "placeholder" | "id" | "onChange" | "readOnly"> & { subtype?: string | undefined; }>, InputState<T>, F1<InputState<T>, void>> | InputPropsBase<import("@react-formless/utils").State<"radio" | "select", { validators?: import("@react-formless/utils").Validator<T, string>[] | null | undefined; toValue?: F1<string, T | null> | undefined; fromValue?: F1<T | null, string> | undefined; sectionTitle?: string | undefined; } & Pick<import("react").InputHTMLAttributes<T>, "value" | "disabled" | "name" | "placeholder" | "id" | "onChange" | "readOnly"> & { values: import(".").Tuples<T>; }> | import("@react-formless/utils").State<"customOption", { validators?: import("@react-formless/utils").Validator<T, string>[] | null | undefined; toValue?: F1<string, T | null> | undefined; fromValue?: F1<T | null, string> | undefined; sectionTitle?: string | undefined; } & Pick<import("react").InputHTMLAttributes<T>, "value" | "disabled" | "name" | "placeholder" | "id" | "onChange" | "readOnly"> & { values: import(".").Tuples<T>; subtype?: string | undefined; }>, InputState<T>, F1<InputState<T>, void>> | InputPropsBase<import("@react-formless/utils").State<"multiselect", { validators?: import("@react-formless/utils").Validator<T, string>[] | null | undefined; toValue?: F1<string, T | null> | undefined; fromValue?: F1<T | null, string> | undefined; sectionTitle?: string | undefined; } & Pick<import("react").InputHTMLAttributes<T>, "value" | "disabled" | "name" | "placeholder" | "id" | "onChange" | "readOnly"> & { values: import(".").Tuples<ArrayItem<T>>; creatable?: true | undefined; }>, InputState<T[]>, F1<InputState<T[]>, void>>) => { value: T | T[] | undefined; disabled: boolean; onChange: (v: T | T[] | undefined) => Err<string, any> | import("@react-formless/utils").State<"Ok", { value: any; }>; onFocus: () => void; onBlur: () => void; name?: string | undefined; placeholder?: string | undefined; id?: string | undefined; }; export declare const getDropdownInputProps: <T>({ state, schema, setDelta }: InputPropsBase<import("@react-formless/utils").State<"radio" | "select", { validators?: import("@react-formless/utils").Validator<T, string>[] | null | undefined; toValue?: F1<string, T | null> | undefined; fromValue?: F1<T | null, string> | undefined; sectionTitle?: string | undefined; } & Pick<import("react").InputHTMLAttributes<T>, "value" | "disabled" | "name" | "placeholder" | "id" | "onChange" | "readOnly"> & { values: import(".").Tuples<T>; }>, InputState<T>, F1<InputState<T>, void>>) => { selected: Option<T>[]; options: Option<T>[]; onSelect: (o: Option<T>) => void; }; export declare const isFormActive: <T>(schema: FormSchema<T>, state: FormState<T>) => boolean; //# sourceMappingURL=forms.d.ts.map