import type Element from "../../form/elements/Element.js";
import type InputBase from "./InputBase.js";
import type { EditType } from "../support/forms/types.js";

export interface EditableInputProperties<ElementType extends Element | null | undefined = Element | null | undefined> extends Partial<Pick<EditableInput<ElementType>, "editType">> {}

/**
 * The mixin for [FieldInput](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureForm/FieldInput/)
 *
 * @since 4.27
 */
export default abstract class EditableInput<ElementType extends Element | null | undefined = Element | null | undefined> extends InputBase<ElementType> {
  /** Indicates if the input is editable. */
  get editable(): boolean;
  /**
   * The value that will be set for the Arcade variable `$editcontext.editType`
   * in the Arcade context used to evaluate form expressions.
   *
   * Accepted values are "INSERT", "UPDATE", "DELETE", and "NA".
   *
   * For `FieldInput`s with value expressions, this property is also used in
   * determining whether or not the value expressions should be applied. Per the
   * [Web Map Specification](https://developers.arcgis.com/web-map-specification/objects/formFieldElement/),
   * value expressions are ignored if the associated layer field is not
   * editable. Determining whether the layer field is editable must consider
   * whether the specific type of edit being attempted is allowed. For example,
   * if a layer has the `supportsAdd` capability but does not have the
   * `supportsUpdate` capability, then the value expression will be applied if
   * `editType` is `INSERT` but ignored if `editType` is `UPDATE`.
   *
   * For the purposes of determining whether or not the layer allows the current
   * edit type, a value of `"NA"` is always considered allowed.
   *
   * @default "NA"
   */
  accessor editType: EditType;
}