import Component from '../../component.js'
import CoUxChip from './ux-chip.js'

export default class CoUxChipsList extends Component {
    constructor(parent) {
      let selector = 'div[@data-e2e = "ux-chips-list"]';
      super(parent, selector);
    }
    get flexContainer() {
      let path = '//div[contains(@class, "flex-container")]';
      return this.currentPath + path;
    }
    get chipList() {
      let path = '//mat-chip-list[contains(@class, "mat-chip-list")]';
      return this.flexContainer + path;
    }
    get chipCO() {
      return new CoUxChip(this.chipList);
    }
    async chipCount() {
      let list = await this.chipCO.elementList();
      return await list.length;
    }
    get expandButton() {
      return new CoUxButton(this.chipList).componentByClass('ux-chips-list__expand-button');
    }
    async isExpanded() {
      let cl = await (await $(this.expandButton).buttonIcon).getAttribute('class');
      if (cl.includes('ux-icon-chevron-down')) {
         return false;
      } else if (cl.includes('ux-icon-chevron-up')) {
         return true;
      }
    }
}


