import{r as t,c as e,h as s,H as i,g as a}from"./p-a6030c6e.js";const o=':host{display:block;width:100%}:host .table{display:grid;font-family:"Nunito Sans", "Carbona", "Tahoma", "Helvetica", "Arial", sans-serif;color:var(--color-content-default, #454545);width:100%;border:1px solid var(--color-border-3, #E1E1E1);border-radius:8px;overflow-x:auto;background-color:var(--color-surface-1, #F6F6F6)}:host .table .thead{border-bottom:1px solid var(--color-border-1, #B1B1B1);padding:0 16px}:host .table .thead .header{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between;text-align:left;-ms-flex-align:center;align-items:center;height:64px;gap:16px}:host .table .thead .header .header-title{height:64px;width:100%;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center;-ms-flex-pack:start;justify-content:flex-start;gap:8px}:host .table .thead .header .header-title .title-click{cursor:pointer}:host .table .body-row{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;height:64px;padding:0 16px;gap:16px;border-bottom:1px solid var(--color-border-2, #CFCFCF)}:host .table .body-row .body-item{height:48px;width:100%;gap:8px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:start;justify-content:flex-start}:host .table .body-row:last-child{border-bottom:none}';const l=o;const r=class{constructor(s){t(this,s);this.bdsTableClick=e(this,"bdsTableClick",7);this.bdsTableDelete=e(this,"bdsTableDelete",7);this.bdsTableChange=e(this,"bdsTableChange",7);this.newTable=[];this.headerData=[];this.tableData=[];this.sortAscending=undefined;this.headerActive=undefined;this.options=undefined;this.column=undefined;this.avatar=false;this.chips=false;this.actionArea=undefined;this.sorting=false}componentWillLoad(){this.getDataFromProprety()}getDataFromProprety(){this.headerData=JSON.parse(this.column);this.tableData=JSON.parse(this.options)}renderArrow(t){if(t){return s("bds-icon",{name:"arrow-up",size:"small"})}else{return null}}async deleteItem(t){const e=this.tableData.filter(((e,s)=>s===t&&e));this.bdsTableDelete.emit(e[0]);this.tableData.splice(t,1);this.tableData=[...this.tableData];this.bdsTableChange.emit(this.tableData)}clickButton(t,e,s){this.bdsTableClick.emit({item:t,index:e,nameButton:s})}orderColumn(t){this.headerActive=t;this.sortAscending=this.sortAscending?false:true;if(this.sortAscending===false){this.tableData.sort((function(e,s){return e[t]>s[t]?1:-1}))}else{this.tableData.sort((function(e,s){return e[t]>s[t]?-1:1}))}}render(){return s(i,{key:"7ad2e86b3c2e5caa19b8127260a97ed55a9ba52a"},s("table",{key:"af16d599ac4753b4e019ffdad475ea4cd9c6c007",class:"table"},s("thead",{key:"0603aa5ad3e20f2c0d64e825b92a365d3ad1859b",class:"thead"},s("tr",{key:"a3a830e7ca9e8c6d33b4773ca625831f5f072f94",class:"header"},this.headerData.map(((t,e)=>s("th",{class:"header-title",key:e},this.sorting?s("bds-typo",{class:"title-click",onClick:()=>this.orderColumn(t.value),variant:"fs-14",bold:this.headerActive===`${t.value}`?"bold":"semi-bold"},t.heading):s("bds-typo",{variant:"fs-14",bold:"semi-bold"},t.heading),this.sortAscending===true&&this.sorting===true&&this.headerActive===`${t.value}`?s("bds-icon",{class:"header-icon",name:"arrow-up",size:"small"}):this.sortAscending===false&&this.sorting===true&&this.headerActive===`${t.value}`?s("bds-icon",{name:"arrow-down",size:"small"}):""))))),s("tbody",{key:"1fcf3f64e0ba6fa6d87eee44f349b53f81311814"},this.tableData.map(((t,e)=>s("tr",{class:"body-row",key:e},this.headerData.map(((i,a)=>s("td",{class:"body-item",key:a},this.actionArea&&i.editAction?s("bds-button-icon",{onClick:()=>this.clickButton(t,e,i.editAction),variant:"secondary",icon:t[`${i.editAction}`],size:"short"}):"",this.actionArea&&i.deleteAction?s("bds-button-icon",{onClick:()=>this.clickButton(t,e,i.deleteAction),variant:"secondary",icon:t[`${i.deleteAction}`],size:"short"}):"",this.actionArea&&i.customAction?s("bds-button-icon",{onClick:()=>this.clickButton(t,e,i.customAction),variant:"secondary",icon:t[`${i.customAction}`],size:"short"}):"",this.chips&&i.chips?s("bds-chip-tag",{color:t[`${i.chips}`]?t[`${i.chips}`]:"default"},t[`${i.value}`]):"",this.avatar&&i.img?s("bds-avatar",{size:"extra-small",thumbnail:t[`${i.img}`],name:t[`${i.value}`]}):"",i.chips?"":s("bds-typo",{variant:"fs-14",bold:this.headerActive===`${i.value}`?"bold":"regular"},t[`${i.value}`]))))))))))}get el(){return a(this)}};r.style=l;export{r as bds_data_table};
//# sourceMappingURL=p-957473f5.entry.js.map