import { StatusField } from "../../enums.mjs";
import { FieldType, GenericFieldsBuilder, GetErrors, OnChangeField, OnSetValue, PropsField, TypeField } from "../../types.mjs";

//#region src/utils/builders/BaseField.d.ts
declare class BaseField<Type extends FieldType<any, any, any, any>> {
  fieldsBuilder?: GenericFieldsBuilder;
  type?: TypeField;
  name: Type['name'];
  value: Type['value'];
  defaultInputValue?: Type['value'];
  label: Type['label'];
  status?: StatusField;
  disabled: boolean;
  errors?: GetErrors<Type['validations']> | [];
  inputRef?: HTMLInputElement | null;
  onChange?: OnChangeField<Type>;
  onSetValue?: OnSetValue<Type>;
  pristine: boolean;
  /**
   * A control is `dirty` if the user has changed the value
   * in the UI.
   *
   * @returns True if the user has changed the value of this control in the UI; compare `pristine`.
   * Programmatic changes to a control's value do not mark it dirty.
   */
  get dirty(): boolean;
  /**
   * A control is `valid` when its `status` is `VALID`.
   *
   * @see {@link StatusField}
   *
   * @returns True if the control has passed all of its validation tests,
   * false otherwise.
   */
  get valid(): boolean;
  /**
   * A control is `invalid` when its `status` is `INVALID`.
   *
   *
   * @returns True if this control has failed one or more of its validation checks,
   * false otherwise.
   */
  get invalid(): boolean;
  /**
   * A control is `pending` when its `status` is `PENDING`.
   *
   *
   * @returns True if this control is in the process of conducting a validation check,
   * false otherwise.
   */
  get pending(): boolean;
  /**
   * A control is `enabled` as long as its `status` is not `DISABLED`.
   *
   * @returns True if the control has any status other than 'DISABLED',
   * false if the status is 'DISABLED'.
   *
   *
   */
  get enabled(): boolean;
  /**
   * Disables the control. This means the control is exempt from validation checks and
   * excluded from the aggregate value of any parent. Its status is `DISABLED`.
   *
   * If the control has children, all children are also disabled.
   *
   */
  disable(): void;
  /**
   * Enables the control. This means the control is included in validation checks and
   * the aggregate value of its parent. Its status recalculates based on its value and
   * its validators.
   *
   * By default, if the control has children, all children are enabled.
   *
   */
  enable(): void;
  /**
   * Marks the control as `dirty`. A control becomes dirty when
   * the control's value is changed through the UI; compare `markAsTouched`.
   *
   * @see `markAsTouched()`
   * @see `markAsUntouched()`
   * @see `markAsPristine()`
   *
   */
  markAsDirty: () => void;
  /**
   * Marks the control as `pristine`.
   *
   * If the control has any children, marks all children as `pristine`,
   * and recalculates the `pristine` status of all parent
   * controls.
   *
   * @see `markAsTouched()`
   * @see `markAsUntouched()`
   * @see `markAsDirty()`
   *
   */
  markAsPristine: () => void;
  _setInitialStatus(): void;
  constructor({
    type,
    name,
    value,
    disabled,
    defaultInputValue,
    label,
    onChange,
    onSetValue
  }: PropsField<Type>);
}
//#endregion
export { BaseField, BaseField as default };