import Component from '../../component.js'
import TdComponent from '../../td.js'
import TrComponent from '../../tr.js'
import { elementAttributeContains } from '../../../core/utils.js'

export default class CoEuiTable extends Component {
    constructor(parent) {
      let selector = '*[self::eui-table or self::table[@euiTable]]';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components-next/src/lib/components/eui-table/eui-table.component.html
    }
    get thead() {
      return this.currentPath + '//thead'
    }
    async hasHeader() {
      return await (await $(this.thead)).isExisting();
    }
    get tbody() {
      return this.currentPath + '//tbody'
    }
    async hasBody() {
      return await (await $(this.tbody)).isExisting();
    }
    async tbodyIsLoading() {
      return await elementAttributeContains(this.tbody, 'class', 'eui-table__loading');
    }
    get bodyRowCO() {
      return new TrComponent(this.tbody);
    }
    get bodyCellCO() {
      return new TdComponent(this.tbody);
    }
    get tfoot() {
      return this.currentPath + '//tfoot'
    }
    async hasFooter() {
      return await (await $(this.tfoot)).isExisting();
    }
    get footerRowCO() {
      return new TrComponent(this.tfoot);
    }
    get footerCellCO() {
      return new TdComponent(this.tfoot);
    }
    get stickyHeaderContainer() {
      return this.currentPath + '//div[contains(@class, "eui-table__sticky-header-container")]';
    }
    get stickyHeaderTable() {
      return this.stickyHeader + '//table[contains(@class, "eui-table")]';
    }
    get stickyHeaderTableThead() {
      return this.stickyHeaderTable + '//thead';
    }
    async hasStickyHeader() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-table--sticky-header');
    }
    async euiTableDraggable() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-table--draggable');
    }
    async euiTableCompact() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-table--compact');
    }
    async euiTableBordered() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-table--bordered');
    }
    async euiTableFixedLayout() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-table--fixed-layout');
    }
    async euiTableResponsive() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-table--responsive');
    }


}


