///
import { Validator } from '@querycap/validators';
import { Dictionary as Dictionary$1 } from '@querycap/lodash';
import * as _______reactorx_core from '@reactorx/core';
import * as lodash from 'lodash';
import * as react from 'react';
import { FormHTMLAttributes, ReactNode, FunctionComponent, InputHTMLAttributes } from 'react';
interface FieldState {
name?: string;
active?: boolean;
changed?: boolean;
touched?: boolean;
visited?: boolean;
error?: string;
validate?: Validator;
}
interface FormState {
id: string;
fields: Dictionary$1;
initials: TFormValues;
values: TFormValues;
submitting?: boolean;
}
declare type FormErrors = Dictionary$1;
declare const FieldPrefixProvider: react.Provider<{
prefix: string;
}>;
declare const useFieldNameMayWithPrefix: (name: string) => string;
declare const pickValidValues: (values: any) => any;
declare const useNewFormContext: (formName: string, initialValues: Partial) => {
formName: string;
addField: (fieldName: string, validate: FieldState["validate"]) => void;
removeField: (fieldName: string) => void;
updateField: (fieldName: string, nextValue: any, error?: string | undefined, initial?: boolean | undefined) => void;
focusField: (fieldName: string) => void;
blurField: (fieldName: string) => void;
getValues: () => any;
getErrors: () => lodash.Dictionary;
validateAndErrors: () => Dictionary;
setErrors: (errors: Dictionary) => void;
createSubmit: (cb: (values: TFormValues) => void) => (e: React.FormEvent) => void;
startSubmit: () => void;
endSubmit: () => void;
destroy: () => void;
reset: () => void;
state$: _______reactorx_core.Volume>;
};
declare const useForm: () => {
formName: string;
addField: (fieldName: string, validate: FieldState["validate"]) => void;
removeField: (fieldName: string) => void;
updateField: (fieldName: string, nextValue: any, error?: string | undefined, initial?: boolean | undefined) => void;
focusField: (fieldName: string) => void;
blurField: (fieldName: string) => void;
getValues: () => any;
getErrors: () => lodash.Dictionary;
validateAndErrors: () => Dictionary;
setErrors: (errors: Dictionary) => void;
createSubmit: (cb: (values: object) => void) => (e: React.FormEvent) => void;
startSubmit: () => void;
endSubmit: () => void;
destroy: () => void;
reset: () => void;
state$: _______reactorx_core.Volume>;
};
declare const useNewForm: (formName: string, initialValues?: Partial) => readonly [{
formName: string;
addField: (fieldName: string, validate: FieldState["validate"]) => void;
removeField: (fieldName: string) => void;
updateField: (fieldName: string, nextValue: any, error?: string | undefined, initial?: boolean | undefined) => void;
focusField: (fieldName: string) => void;
blurField: (fieldName: string) => void;
getValues: () => any;
getErrors: () => lodash.Dictionary;
validateAndErrors: () => Dictionary;
setErrors: (errors: Dictionary) => void;
createSubmit: (cb: (values: TFormValues) => void) => (e: React.FormEvent) => void;
startSubmit: () => void;
endSubmit: () => void;
destroy: () => void;
reset: () => void;
state$: _______reactorx_core.Volume>;
}, ({ onSubmit, children, ...otherProps }: Omit, "onSubmit"> & {
onSubmit?: ((values: TFormValues, end: () => void) => void) | undefined;
}) => JSX.Element];
interface FieldMeta {
name?: string;
readOnly?: boolean;
disabled?: boolean;
}
interface FieldProps extends Partial {
validate?: Validator;
children: ReactNode;
}
interface CurrentFieldContext extends FieldMeta {
value: any;
state: FieldState;
controls: {
handleValueChange: (v: T, initial?: boolean) => void;
handleBlur: (e?: FocusEvent) => void;
handleFocus: (e?: FocusEvent) => void;
};
}
declare const useField: () => CurrentFieldContext;
declare const useFieldState: (name: string) => {
formID: string;
name: string;
value: any;
state: FieldState;
};
declare const Field: ({ name: n, validate: v, disabled, readOnly, children }: FieldProps) => JSX.Element | null;
declare const asField: (Comp: FunctionComponent) => ({ name, validate, readOnly, disabled, ...props }: TProps & Omit) => JSX.Element;
interface FieldInputCommonProps extends FieldMeta {
value: T;
onValueChange: (v: T, initial?: boolean) => void;
onFocus?: () => void;
onBlur?: () => void;
}
declare const FieldInput: ({ children }: {
children: (props: FieldInputCommonProps) => JSX.Element | number;
}) => JSX.Element;
interface SimpleInputTextProps extends FieldInputCommonProps, Omit, keyof FieldInputCommonProps> {
}
declare const SimpleInputText: ({ onValueChange, ...props }: SimpleInputTextProps) => JSX.Element;
interface IFormSection {
name: string;
children: ReactNode;
}
declare const FormSection: ({ name, children }: IFormSection) => JSX.Element;
interface FieldArrayHelpers {
add: (defaultValue?: any) => void;
remove: (idx: number) => void;
update: (cb: (values: any[]) => any[]) => void;
each: (render: (idx: number) => ReactNode) => ReactNode;
}
interface FieldArrayProps {
name: string;
defaultValues?: any[];
children: (helpers: FieldArrayHelpers) => ReactNode;
}
declare const FieldArray: ({ defaultValues, name, children }: FieldArrayProps) => JSX.Element;
export { CurrentFieldContext, Field, FieldArray, FieldArrayHelpers, FieldArrayProps, FieldInput, FieldInputCommonProps, FieldMeta, FieldPrefixProvider, FieldProps, FieldState, FormErrors, FormSection, FormState, IFormSection, SimpleInputText, asField, pickValidValues, useField, useFieldNameMayWithPrefix, useFieldState, useForm, useNewForm, useNewFormContext };