import  Component from '../component.js';
import  TheadComponent from '../thead.js';
import  TbodyComponent from '../tbody.js';
import  TfootComponent from '../tfoot.js';
import TableComponent from '../table.js';
import CoEuiSkeleton from './eui-skeleton.js';

export default class CoEuiTableV2 extends Component {
    constructor(parent) {
      let selector = '*[self::eui-table-v2 or self::table[@euiTableV2]]';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-table-v2/eui-table-v2.component.html
    }
    get cdkVirtual() {
      return this.currentPath + '//cdk-virtual-scroll-viewport';
    }
    async isVirtualScroll() {
      return await (await $(this.cdkVirtual)).isExisting();
    }
    get tableCO() {
      return new TableComponent(this.cdkVirtual);
    }
    get theadCO() {
      return new TheadComponent(this.tableCO);
    }
    async hasCdkVirtualHeader() {
      return await (await this.theadCO.element()).isExisting();
    }
    get tbodyCO() {
      return new TbodyComponent(this.tableCO);
    }
    async hasCdkVirtualBody() {
      return await (await this.tbodyCO.element()).isExisting();
    }
    get tfootCO() {
      return new TfootComponent(this.tableCO);
    }
    async hascdkVirtualFooter() {
      return await (await this.tfootCO.element()).isExisting();
    }
    get theadCO() {
      return new TheadComponent(this.currentPath);
    }
    async hasHeader() {
      return await (await this.theadCO.element()).isExisting();
    }
    get tbodyCO() {
      return new TbodyComponent(this.currentPath);
    }
    async hasBody() {
      return await (await this.tbodyCO.element()).isExisting();
    }
    get tfootCO() {
      return new TfootComponent(this.currentPath);
    }
    get skeletonLoadingCO(){
      return new CoEuiSkeleton(this.currentPath);
    }
    async isResponsive() {
      return await (await $(this.currentPath + '/self::*[contains(@class,"eui-table-default--responsive")]')).isExisting();
    }
    async hasStickyHeader() {
      return await (await $(this.currentPath + '/self::*[contains(@class,"eui-table-v2--sticky-header")]')).isExisting();
    }
    async hasStickyFooter() {
      return await (await $(this.currentPath + '/self::*[contains(@class,"eui-table-v2--sticky-footer")]')).isExisting();
    }
    async hasStickyColumns() {
      return await (await $(this.currentPath + '/self::*[contains(@class,"eui-table-v2--sticky-cols")]')).isExisting();
    }
    async isOrderable() {
      return await (await $(this.currentPath + '/self::*[contains(@class,"eui-table-v2--cols-orderable")]')).isExisting();
    }
    async isLoading() {
      return await (await $(this.currentPath + '/self::*[contains(@class,"eui-table-v2--loading")]')).isExisting();
    }
}
