import Component from '../../component.js'
import { elementAttributeContains } from '../../../core/utils.js'

export default class CoUxButton extends Component {
    constructor(parent) {
      let selector = 'ux-button';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-button/ux-button.component.html?at=support/10.x
    }
    get button() {
      let path = '//button[@data-e2e = "ux-button"]';
      return this.currentPath + path;
    }
    get buttonContent() {
      let path = '//span[contains(@class, "ux-button__content")]';
      return this.button + path;
    }
    get buttonIcon() {
      let path = '//span[contains(@class,"ux-button__icon")]';
      return this.button + path;
    }
    async isBlock() {
      return await elementAttributeContains(this.button, 'class', 'ux-button--block');
    }
    async isDisabled() {
      return await elementAttributeContains(this.currentPath, 'class', 'disabled');
    }
    async isLineWrap() {
      return await elementAttributeContains(this.button, 'class', 'ux-button--line-wrap');
    }
    async tabindex() {
      return await (await $(this.button)).getAttribute('tabindex');
    }
    async type() {
      return await (await $(this.button)).getAttribute('type');
    }
    async styleClass() {
      return await (await $(this.currentPath)).getAttribute('styleclass');
    }
    async typeClass() {
      return await (await $(this.currentPath)).getAttribute('typeclass');
    }
    async iconClass() {
      return await (await $(this.currentPath)).getAttribute('iconclass');
    }
    async isOutline() {
      return await elementAttributeContains(this.button, 'class', 'ux-button--outline ');
    }
    async isSecondary() {
      return await elementAttributeContains(this.button, 'class', 'ux-button--secondary ');
    }
    async isSmall() {
      return await elementAttributeContains(this.button, 'class', 'ux-button--small');
    }
    async isLarge() {
      return await elementAttributeContains(this.button, 'class', 'ux-button--large');
    }
    async isBlock() {
      return await elementAttributeContains(this.button, 'class', 'ux-button--block');
    }
    async isFlat() {
      return await elementAttributeContains(this.button, 'class', 'ux-button--flat');
    }
}
