import{r as t,h as e}from"./p-0d5a2e05.js";var s=undefined&&undefined.__rest||function(t,e){var s={};for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0)s[i]=t[i];if(t!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,i=Object.getOwnPropertySymbols(t);o<i.length;o++){if(e.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(t,i[o]))s[i[o]]=t[i[o]]}return s};const i=class{constructor(e){t(this,e);this.data=[{selected:true},{selected:true}];this.rowDivider=true;this.showSelectCheckBox=true;this.alternate=true;this.cells=[{propertyName:"test",isFilter:false,isSort:false,title:"Test",type:"propertyName",colSpan:1},{propertyName:"test",isFilter:false,isSort:false,title:"Test",type:"propertyName",colSpan:1}];this.contained=true;this.sortedData=[];this.direction=false;this.sortData=(t="up",e,s)=>{if(t==="up"){const t=[...this.data.sort(((t,s)=>s[e]>t[e]?1:t[e]>s[e]?-1:0))];this.sortedData=t}else if(t==="down"){const t=[...this.data.sort(((t,s)=>t[e]>s[e]?1:s[e]>t[e]?-1:0))];this.sortedData=t}this.cells[s].sort=t=="down"?"up":"down"};this.handleSelectedRowChanges=(t,e)=>{const s=[...this.data];s[e].selected=t;this.sortedData=s;if(this.getSelectedRows){this.getSelectedRows({selectedRows:s.filter((t=>t.selected)),currentSelectedRow:s[e],currentSelectedRowIndex:e})}};this.selectAll=t=>{const e=[...this.data];e.forEach((e=>e.selected=t));this.sortedData=e;if(this.getSelectedRows){this.getSelectedRows({selectedRows:e})}}}componentDidLoad(){if(document.dir){if(document.dir==="rtl")this.direction=true;else this.direction=false}else if(document.documentElement.lang){if(document.documentElement.lang==="ar")this.direction=true;else this.direction=false}else this.direction=false}componentDidUpdate(){const t=[...this.data.map((t=>{t.selected=false;return t}))];this.sortedData=t}render(){return e("div",{key:"486261d777a76a8f743b78ee9b914a33c3517771",class:`table-wrapper ${this.contained?"table-contained":""}`},e("table",{key:"4947f0d9ae3c57567f791f493800d24887ceb710",class:` azm-table ${this.contained?"table-contained":""}`,style:{direction:this.direction?"rtl":"ltr"}},e("thead",{key:"0f23ad0e92c6fc7447f25ac88e3f8dc8d4d34f7f"},e("tr",{key:"907d886131b971f82ba38d6b7c618036305c4c35",class:`${this.rowDivider?"row-divider":""}`},this.showSelectCheckBox&&e("th",{key:"c1bd0bb7f57a1b1fffb495ff7856f642562f4a51",style:{width:"20px"}},e("dga-checkbox",{key:"a7eafc197701ac7e69c9c6497dfad9e05d6d66c1",showBorderOnFocusAndFocusOute:false,value:"true",onChange:t=>this.selectAll(t.target.checked)})),this.cells.map(((t,i)=>{var{sort:o,isSort:c,propertyName:n,type:a}=t,r=s(t,["sort","isSort","propertyName","type"]);return e("th",{key:i},e("span",null,e("span",{class:"text"},r.title),e("span",{class:"icon-wrapper"},c&&o=="up"&&a=="propertyName"&&e("button",{class:"btn btn--sort btn--icon btn--md",onClick:()=>this.sortData("up",n,i)},e("dga-icon",{icon:"SortByUp02Icon"})),c&&(!o||o=="down")&&a=="propertyName"&&e("button",{class:"btn btn--sort btn--icon btn--md",onClick:()=>this.sortData("down",n,i)},e("dga-icon",{icon:"SortByDown02Icon"})),r.isFilter&&e("button",{class:"btn btn--sort btn--icon btn--md ",onClick:()=>this.pressOnFilter&&this.pressOnFilter(n)},e("dga-icon",{icon:"FilterIcon"})))))})))),e("tbody",{key:"0157efcc873b02e690231494601df9a2466af704"},this.sortedData.map(((t,s)=>e("tr",{class:`${this.rowDivider?"row-divider":""} ${this.alternate?"alternate":""} ${t.selected?"row-selected":""} `,key:s},this.showSelectCheckBox&&e("td",null,e("dga-checkbox",{name:s+"checkboxSelection",value:t.selected,id:s+"checkboxSelection",showBorderOnFocusAndFocusOute:false,onChange:t=>this.handleSelectedRowChanges(t.target.checked,s),checked:t.selected}))))))))}};export{i as dga_data_table};
//# sourceMappingURL=p-e9782ec1.entry.js.map