import Component from '../../component.js'
import CoUxFormControlText from './ux-form-control-text.js'
import CoUxFormControlTextArea from './ux-form-control-textArea.js'
import CoUxFormControlSelect from './ux-form-control-select.js'
import CoUxFormControlCheckbox from './ux-form-control-checkBox.js'
import CoUxFormControlNumber from './ux-form-control-number.js'
import CoUxFormControlRadio from './ux-form-control-radio.js'
import CoUxControlFeedback from './ux-control-feedback.js'

export default class CoUxFormControl extends Component {
    constructor(parent) {
      let selector = 'ux-form-control';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-form-control/ux-form-control.component.html
   }
   get dataE2E() {
      return this.currentPath + '//*[contains(@data-e2e, "ux-form-control")]';
   }
   // Text
   get inputTextCO() {
      return new CoUxFormControlText(this.currentPath);
   }
   // Text Area
   get textareaCO() {
      return new CoUxFormControlTextArea(this.currentPath);
   }
   // Select
   get selectCO() {
      return new CoUxFormControlSelect(this.currentPath);
   }
   // Check Box
   get checkboxCO() {
      return new CoUxFormControlCheckbox(this.currentPath);
   }
   // Number
   get inputNumberCO() {
      return new CoUxFormControlNumber(this.currentPath);
   }
   // Radio
   get radioCO() {
      return new CoUxFormControlRadio(this.currentPath);
   }
   // Control Feedback
   get controlFeedbackCO() {
      return new CoUxControlFeedback(this.currentPath);
   }
   /**
   * @param input i
   * nputText: formcontrolname/placeholderlabel/maxlengthvalidationerrormessage/maxlength
   * @param input select: formcontrolname/placeholderlabel/selectkeyname/selectvaluename
   * @param input textarea: formcontrolname/placeholderlabel/maxlength/maxlengthvalidationerrormessage
   * @param input number: formcontrolname/maxlength/maxlengthvalidationerrormessage/decimalseparator/thousandseparator
   * @param input checkbox: formcontrolname
   * @param input radio: formcontrolname/formcontrolvalue/radiolabel/groupid
   * @type string
   */
   async getInputAtribute(input) {
      let value = await (await $(this.currentPath)).getAttribute(input);
      return value;
   }
   get readOnlyValue() {
      let path = '//*[@data-e2e ="ux-form-control-ro" or @data-e2e ="ux-form-control-cb-ro" '+ 
      'or @data-e2e ="ux-form-control-sel-ro"]';
      return this.currentPath + path;
   }
   async isReadOnly() {
      return await (await $(this.readOnlyValue)).isExisting();
   } 
}


