
import { CubeFieldData, FieldTypes, SetFieldsArrType } from "./types.js";
import { ReactNode } from "react";

//#region src/components/form/Form/use-form.d.ts
type PartialString<T> = { [P in keyof T & string]?: T[P] };
type CubeFormData<T extends FieldTypes> = { [K in keyof T & string]?: CubeFieldData<K, T[K]> };
declare class CubeFormInstance<T extends FieldTypes, TFormData extends CubeFormData<T> = CubeFormData<T>> {
  forceReRender: () => void;
  private defaultValues;
  private fields;
  ref: {};
  isSubmitting: boolean;
  submitError: unknown;
  onValuesChange: (data: T) => void | Promise<void>;
  onSubmit: (data: T) => void | Promise<void>;
  constructor(forceReRender?: () => void);
  submit(): Promise<void>;
  setFieldsValue: (newData: PartialString<T>, touched?: boolean, skipRender?: boolean) => void;
  getFieldValue<Name extends keyof T & string>(name: Name): T[Name] | undefined;
  getFieldsValue(): PartialString<T>;
  /**
   * Similar to getFieldsValue() but respects '.' notation and creates nested objects.
   */
  getFormData(): T;
  setFieldValue<Name extends keyof T & string>(name: Name, value: T[Name], isTouched?: boolean, skipRender?: boolean): void;
  getFieldInstance<Name extends keyof T & string>(name: Name): TFormData[Name];
  setInitialFieldsValue(values: PartialString<T>): void;
  updateInitialFieldsValue(values: FieldTypes): void;
  resetFields(names?: (keyof T & string)[], skipRender?: boolean): void;
  validateField<Name extends keyof T & string>(name: Name): Promise<any>;
  validateFields<Names extends (keyof T)[]>(names?: Names): Promise<any>;
  isFieldValid<Name extends keyof T & string>(name: Name): boolean;
  isFieldInvalid<Name extends keyof T & string>(name: Name): boolean;
  isFieldTouched<Name extends keyof T & string>(name: Name): boolean;
  get isTouched(): boolean;
  get isDirty(): boolean;
  /**
   * True if all fields are verified and valid
   * IMPORTANT: This is not the same as `!isInvalid`, because it also checks if all fields are verified.
   */
  get isValid(): boolean;
  /**
   * True if at least one field is verified and invalid.
   * IMPORTANT: This is not the same as `!isValid`, because it only checks that at least
   * one field is verified and invalid.
   */
  get isInvalid(): boolean;
  getFieldError<Name extends keyof T & string>(name: Name): ReactNode[];
  /**
   * @deprecated This field is not supposed to be used directly.
   */
  createField<Name extends keyof T & string>(name: Name, skipRender?: boolean): TFormData[Name];
  /**
   * @deprecated This field is not supposed to be used directly.
   */
  removeField<Name extends keyof T & string>(name: Name, skipRender?: boolean): void;
  /**
   * @deprecated This method is not recommended. Use other ways to alter fields.
   * Use `setFieldValue` to change the value of a field.
   * Use `verifyField` to validate a field.
   * Use `setFieldError` to set an error for a field.
   * Use `clearFieldsValidation` to clear all errors for a field.
   */
  setFields<Names extends keyof T & string>(newFields: SetFieldsArrType<T, Names>[]): void;
  resetFieldsValidation(names?: (keyof T & string)[], skipRender?: boolean): void;
  setFieldError(name: keyof T & string, error: ReactNode, skipRender?: boolean): void;
  setSubmitting(isSubmitting: boolean): void;
  _createField<Name extends keyof T & string, Data extends TFormData[Name]>(name: Name, data?: Data): Data;
}
declare function useForm<TSourceType extends FieldTypes>(form?: CubeFormInstance<TSourceType, CubeFormData<TSourceType>>, ref?: any, options?: {
  onSubmit?: CubeFormInstance<TSourceType>['onSubmit'];
  onValuesChange?: CubeFormInstance<TSourceType>['onValuesChange'];
}): [CubeFormInstance<TSourceType>];
//#endregion
export { CubeFormData, CubeFormInstance, useForm };
//# sourceMappingURL=use-form.d.ts.map