import InputComponent from '../../input.js';

export default class CoUxFormControlRadio extends InputComponent {
    constructor(parent) {
        let selector = 'input[@data-e2e = "ux-form-control-ra-rw"]';
        super(parent, selector);
        //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/legacy/ux-form-control/ux-form-control.component.html
    }
    get radioLabel() {
        let path = '/ancestor-or-self::ux-form-control[1]//label[contains(@class, "radio-label")]';
        return this.currentPath + path;
    }
    getRadioButtonLabelByText(text) {
        let path = '//descendant-or-self::*[text()[normalize-space()="' + text + '"]]';
        return this.radioLabel + path;
    }
    async isDisabled() {
        let at = await (await $(this.currentPath)).getAttribute('Disabled');
        if ( at === 'true' ) {
            return true;
        } else if (at === null) {
            return false;
        } else { throw new Error(
            '<CoUxFormControlRadio> <isDisabled> method needs to be revised!');
        }
    }
}


