import joi from 'joi';
import { FormComponent } from "./FormComponent.js";
import { TextField } from "./TextField.js";
import { messageTemplate } from "../pageControllers/validationOptions.js";
export class HiddenField extends FormComponent {
  constructor(def, props) {
    super(def, props);
    const {
      options
    } = def;
    let formSchema = joi.string().trim().label(this.label).required();
    if (options.required === false) {
      formSchema = formSchema.allow('');
    }
    this.formSchema = formSchema.default('');
    this.stateSchema = formSchema.default(null).allow(null);
    this.schema = {};
    this.options = {};
  }
  getFormValueFromState(state) {
    const {
      name
    } = this;
    return this.getFormValue(state[name]);
  }
  isValue(value) {
    return TextField.isText(value);
  }

  /**
   * For error preview page that shows all possible errors on a component
   */
  getAllPossibleErrors() {
    return HiddenField.getAllPossibleErrors();
  }

  /**
   * Static version of getAllPossibleErrors that doesn't require a component instance.
   */
  static getAllPossibleErrors() {
    return {
      baseErrors: [{
        type: 'required',
        template: messageTemplate.required
      }],
      advancedSettingsErrors: []
    };
  }
}
//# sourceMappingURL=HiddenField.js.map