UNPKG

@bhplugin/vue3-datatable

Version:

Vue3 Datatable - fully customizable & easy to use datatable library

2 lines (1 loc) 30.7 kB
"use strict";const e=require("vue"),Fe={class:"bh-filter-menu bh-absolute bh-z-[1] bh-bg-white bh-shadow-md bh-rounded-md bh-top-full bh-right-0 bh-w-32 bh-mt-1"},Ne=e.defineComponent({__name:"column-filter",props:["column","columnFilterLang"],emits:["close","filterChange"],setup(y,{emit:k}){const a=y;e.onBeforeUnmount(()=>{document.removeEventListener("click",l)}),e.onMounted(()=>{document.addEventListener("click",l)});const v=k,l=()=>{v("close")},d=u=>{a.column.condition=u,u===""&&(a.column.value=""),v("filterChange",a.column)};return(u,r)=>{var c,B,p,_,T,E,w,q,S,V,H,L,A,$,O,F,P,b,N;return e.openBlock(),e.createElementBlock("div",Fe,[e.createElementVNode("div",{class:"bh-text-[13px] bh-font-normal bh-rounded bh-overflow-hidden",onClick:e.withModifiers(l,["stop"])},[e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition===""}),onClick:r[0]||(r[0]=g=>d(""))},e.toDisplayString((c=a.columnFilterLang&&a.columnFilterLang.no_filter)!=null?c:"No filter"),3),a.column.type==="string"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="contain"}),onClick:r[1]||(r[1]=g=>d("contain"))},e.toDisplayString((B=a.columnFilterLang&&a.columnFilterLang.contain)!=null?B:"Contain"),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="not_contain"}),onClick:r[2]||(r[2]=g=>d("not_contain"))},e.toDisplayString((p=a.columnFilterLang&&a.columnFilterLang.not_contain)!=null?p:"Not contain"),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="equal"}),onClick:r[3]||(r[3]=g=>d("equal"))},e.toDisplayString((_=a.columnFilterLang&&a.columnFilterLang.equal)!=null?_:"Equal"),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="not_equal"}),onClick:r[4]||(r[4]=g=>d("not_equal"))},e.toDisplayString((T=a.columnFilterLang&&a.columnFilterLang.not_equal)!=null?T:"Not equal"),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="start_with"}),onClick:r[5]||(r[5]=g=>d("start_with"))},e.toDisplayString((E=a.columnFilterLang&&a.columnFilterLang.start_with)!=null?E:"Starts with"),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="end_with"}),onClick:r[6]||(r[6]=g=>d("end_with"))},e.toDisplayString((w=a.columnFilterLang&&a.columnFilterLang.end_with)!=null?w:"Ends with"),3)],64)):a.column.type==="number"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="equal"}),onClick:r[7]||(r[7]=g=>d("equal"))},e.toDisplayString((q=a.columnFilterLang&&a.columnFilterLang.equal)!=null?q:"Equal"),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="not_equal"}),onClick:r[8]||(r[8]=g=>d("not_equal"))},e.toDisplayString((S=a.columnFilterLang&&a.columnFilterLang.not_equal)!=null?S:"Not equal"),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="greater_than"}),onClick:r[9]||(r[9]=g=>d("greater_than"))},e.toDisplayString((V=a.columnFilterLang&&a.columnFilterLang.greater_than)!=null?V:"Greater than"),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="greater_than_equal"}),onClick:r[10]||(r[10]=g=>d("greater_than_equal"))},e.toDisplayString((H=a.columnFilterLang&&a.columnFilterLang.greater_than_equal)!=null?H:"Greater than or equal"),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="less_than"}),onClick:r[11]||(r[11]=g=>d("less_than"))},e.toDisplayString((L=a.columnFilterLang&&a.columnFilterLang.less_than)!=null?L:"Less than"),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="less_than_equal"}),onClick:r[12]||(r[12]=g=>d("less_than_equal"))},e.toDisplayString((A=a.columnFilterLang&&a.columnFilterLang.less_than_equal)!=null?A:"Less than or equal"),3)],64)):a.column.type==="date"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="equal"}),onClick:r[13]||(r[13]=g=>d("equal"))},e.toDisplayString(($=a.columnFilterLang&&a.columnFilterLang.equal)!=null?$:"Equal"),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="not_equal"}),onClick:r[14]||(r[14]=g=>d("not_equal"))},e.toDisplayString((O=a.columnFilterLang&&a.columnFilterLang.not_equal)!=null?O:"Not equal"),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="greater_than"}),onClick:r[15]||(r[15]=g=>d("greater_than"))},e.toDisplayString((F=a.columnFilterLang&&a.columnFilterLang.greater_than)!=null?F:"Greater than"),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="less_than"}),onClick:r[16]||(r[16]=g=>d("less_than"))},e.toDisplayString((P=a.columnFilterLang&&a.columnFilterLang.less_than)!=null?P:"Less than"),3)],64)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="is_null"}),onClick:r[17]||(r[17]=g=>d("is_null"))},e.toDisplayString((b=a.columnFilterLang&&a.columnFilterLang.is_null)!=null?b:"Is null"),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({active:a.column.condition==="is_not_null"}),onClick:r[18]||(r[18]=g=>d("is_not_null"))},e.toDisplayString((N=a.columnFilterLang&&a.columnFilterLang.is_not_null)!=null?N:"Not null"),3)])])}}}),G=(y,k)=>{const a=y.__vccOpts||y;for(const[v,l]of k)a[v]=l;return a},_e={},Se={version:"1.1",viewBox:"0 0 17 12",xmlns:"http://www.w3.org/2000/svg"};function Ve(y,k){return e.openBlock(),e.createElementBlock("svg",Se,k[0]||(k[0]=[e.createElementVNode("g",{fill:"none","fill-rule":"evenodd"},[e.createElementVNode("g",{transform:"translate(-9 -11)",fill:"currentColor","fill-rule":"nonzero"},[e.createElementVNode("path",{d:"m25.576 11.414c0.56558 0.55188 0.56558 1.4439 0 1.9961l-9.404 9.176c-0.28213 0.27529-0.65247 0.41385-1.0228 0.41385-0.37034 0-0.74068-0.13855-1.0228-0.41385l-4.7019-4.588c-0.56584-0.55188-0.56584-1.4442 0-1.9961 0.56558-0.55214 1.4798-0.55214 2.0456 0l3.679 3.5899 8.3812-8.1779c0.56558-0.55214 1.4798-0.55214 2.0456 0z"})])],-1)]))}const ie=G(_e,[["render",Ve]]),Le={},ze={viewBox:"0 0 24 24",width:"24",height:"24",stroke:"currentColor","stroke-width":"3",fill:"none","stroke-linecap":"round","stroke-linejoin":"round",class:"css-i6dzq1"};function xe(y,k){return e.openBlock(),e.createElementBlock("svg",ze,k[0]||(k[0]=[e.createElementVNode("line",{x1:"5",y1:"12",x2:"19",y2:"12"},null,-1)]))}const $e=G(Le,[["render",xe]]),Me={},qe={viewBox:"0 0 24 24",width:"24",height:"24",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round",class:"css-i6dzq1"};function De(y,k){return e.openBlock(),e.createElementBlock("svg",qe,k[0]||(k[0]=[e.createElementVNode("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"},null,-1)]))}const Ae=G(Me,[["render",De]]),Re={key:"hdrrow"},Te={class:"bh-checkbox"},He=["onClick"],Oe={width:"16",height:"16",viewBox:"0 0 14 14",fill:"none"},Pe={key:0,class:"bh-filter bh-relative"},Ue=["onUpdate:modelValue"],Ie=["onUpdate:modelValue"],Ge=["onUpdate:modelValue"],Ke=["onUpdate:modelValue"],Je=["onClick"],re=e.defineComponent({__name:"column-header",props:["all","currentSortColumn","currentSortDirection","isOpenFilter","isFooter","checkAll","columnFilterLang"],emits:["selectAll","sortChange","filterChange","toggleFilterMenu"],setup(y,{emit:k}){const a=e.ref(null),v=y,l=k,d=()=>{a.value&&(a.value.indeterminate=v.checkAll!==0?!v.checkAll:!1,a.value.checked=v.checkAll)};return e.watch(()=>v.checkAll,d),(u,r)=>(e.openBlock(),e.createElementBlock("tr",Re,[v.all.hasCheckbox?(e.openBlock(),e.createElementBlock("th",{key:"chkall",class:e.normalizeClass(["bh-w-px",{"bh-sticky bh-bg-blue-light bh-z-[1]":v.all.stickyHeader||v.all.stickyFirstColumn,"bh-top-0":v.all.stickyHeader,"bh-left-0":v.all.stickyFirstColumn}])},[e.createElementVNode("div",Te,[e.createElementVNode("input",{ref_key:"selectedAll",ref:a,type:"checkbox",onClick:r[0]||(r[0]=e.withModifiers(c=>l("selectAll",c.target.checked),["stop"]))},null,512),e.createElementVNode("div",null,[e.createVNode(ie,{class:"check"}),e.createVNode($e,{class:"intermediate"})])])],2)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.all.columns,(c,B)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[c.hide?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("th",{key:c.field,class:e.normalizeClass(["bh-select-none bh-z-[1]",[v.all.sortable&&c.sort?"bh-cursor-pointer":"",B===0&&v.all.stickyFirstColumn?"bh-sticky bh-left-0 bh-bg-blue-light":"",v.all.hasCheckbox&&B===0&&v.all.stickyFirstColumn?"bh-left-[52px]":""]]),style:e.normalizeStyle({width:c.width,"min-width":c.minWidth,"max-width":c.maxWidth})},[e.createElementVNode("div",{class:e.normalizeClass(["bh-flex bh-items-center",[c.headerClass?c.headerClass:""]]),onClick:p=>v.all.sortable&&c.sort&&l("sortChange",c.field)},[e.createTextVNode(e.toDisplayString(c.title)+" ",1),v.all.sortable&&c.sort?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["bh-ml-3 bh-sort bh-flex bh-items-center",[v.currentSortColumn,v.currentSortDirection]])},[(e.openBlock(),e.createElementBlock("svg",Oe,[e.createElementVNode("polygon",{points:"3.11,6.25 10.89,6.25 7,1.75 ",fill:"currentColor",class:e.normalizeClass(["bh-text-black/20",[y.currentSortColumn===c.field&&y.currentSortDirection==="asc"?"!bh-text-primary":""]])},null,2),e.createElementVNode("polygon",{points:"7,12.25 10.89,7.75 3.11,7.75 ",fill:"currentColor",class:e.normalizeClass(["bh-text-black/20",[y.currentSortColumn===c.field&&y.currentSortDirection==="desc"?"!bh-text-primary":""]])},null,2)]))],2)):e.createCommentVNode("",!0)],10,He),v.all.columnFilter&&!v.isFooter?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[c.filter?(e.openBlock(),e.createElementBlock("div",Pe,[c.type==="string"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,"onUpdate:modelValue":p=>c.value=p,type:"text",class:"bh-form-control",onKeyup:r[1]||(r[1]=p=>l("filterChange"))},null,40,Ue)),[[e.vModelText,c.value,void 0,{trim:!0}]]):e.createCommentVNode("",!0),c.type==="number"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:1,"onUpdate:modelValue":p=>c.value=p,type:"number",class:"bh-form-control",onKeyup:r[2]||(r[2]=p=>l("filterChange"))},null,40,Ie)),[[e.vModelText,c.value,void 0,{number:!0,trim:!0}]]):c.type==="date"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,"onUpdate:modelValue":p=>c.value=p,type:"date",class:"bh-form-control",onChange:r[3]||(r[3]=p=>l("filterChange"))},null,40,Ge)),[[e.vModelText,c.value]]):c.type==="bool"?e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:3,"onUpdate:modelValue":p=>c.value=p,class:"bh-form-control",onChange:r[4]||(r[4]=p=>l("filterChange")),onClick:r[5]||(r[5]=p=>v.isOpenFilter=null)},r[8]||(r[8]=[e.createElementVNode("option",{value:void 0},"All",-1),e.createElementVNode("option",{value:!0},"True",-1),e.createElementVNode("option",{value:!1},"False",-1)]),40,Ke)),[[e.vModelSelect,c.value]]):e.createCommentVNode("",!0),c.type!=="bool"?(e.openBlock(),e.createElementBlock("button",{key:4,type:"button",onClick:e.withModifiers(p=>l("toggleFilterMenu",c),["stop"])},[e.createVNode(Ae,{class:"bh-w-4"})],8,Je)):e.createCommentVNode("",!0),e.withDirectives(e.createVNode(Ne,{column:c,type:c.type,columnFilterLang:v.columnFilterLang,onClose:r[6]||(r[6]=p=>l("toggleFilterMenu",null)),onFilterChange:r[7]||(r[7]=p=>l("filterChange"))},null,8,["column","type","columnFilterLang"]),[[e.vShow,v.isOpenFilter===c.field]])])):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0)],6))],64))),256))]))}}),We={},Ye={width:"84",height:"84",viewBox:"0 0 24 24",class:"bh-loader bh-text-primary"};function Qe(y,k){return e.openBlock(),e.createElementBlock("svg",Ye,k[0]||(k[0]=[e.createStaticVNode('<circle cx="18" cy="12" r="0" fill="currentColor"><animate attributeName="r" begin=".67" calcMode="spline" dur="1.5s" keySplines="0.2 0.2 0.4 0.8;0.2 0.2 0.4 0.8;0.2 0.2 0.4 0.8" repeatCount="indefinite" values="0;2;0;0"></animate></circle><circle cx="12" cy="12" r="0" fill="currentColor"><animate attributeName="r" begin=".33" calcMode="spline" dur="1.5s" keySplines="0.2 0.2 0.4 0.8;0.2 0.2 0.4 0.8;0.2 0.2 0.4 0.8" repeatCount="indefinite" values="0;2;0;0"></animate></circle><circle cx="6" cy="12" r="0" fill="currentColor"><animate attributeName="r" begin="0" calcMode="spline" dur="1.5s" keySplines="0.2 0.2 0.4 0.8;0.2 0.2 0.4 0.8;0.2 0.2 0.4 0.8" repeatCount="indefinite" values="0;2;0;0"></animate></circle>',3)]))}const Xe=G(We,[["render",Qe]]),Ze={class:"bh-datatable bh-antialiased bh-relative bh-text-black bh-text-sm bh-font-normal"},je=["onClick"],et={class:"bh-checkbox"},tt=["value"],lt=["innerHTML"],nt={key:1},ot=["colspan"],at=["colspan"],rt={key:0,class:"bh-absolute bh-inset-0 bh-bg-blue-light/50 bh-grid bh-place-content-center"},it={class:"bh-flex bh-items-center bh-flex-wrap bh-flex-col sm:bh-flex-row bh-gap-4"},st={class:"bh-pagination-info bh-flex bh-items-center"},ut={class:"bh-mr-2"},ct=["value"],dt={class:"bh-pagination-number sm:bh-ml-auto bh-inline-flex bh-items-center bh-space-x-1"},mt=["innerHTML"],vt={key:1,"aria-hidden":"true",width:"14",height:"14",viewBox:"0 0 16 16"},ft=["innerHTML"],ht={key:1,"aria-hidden":"true",width:"14",height:"14",viewBox:"0 0 16 16"},pt=["onClick"],gt=["innerHTML"],kt={key:1,"aria-hidden":"true",width:"14",height:"14",viewBox:"0 0 16 16"},bt=["innerHTML"],Ct={key:1,"aria-hidden":"true",width:"14",height:"14",viewBox:"0 0 16 16"},yt=e.defineComponent({__name:"custom-table",props:{loading:{type:Boolean,default:!1},isServerMode:{type:Boolean,default:!1},skin:{default:"bh-table-striped bh-table-hover"},totalRows:{default:0},rows:{default:()=>[]},columns:{default:()=>[]},hasCheckbox:{type:Boolean,default:!1},search:{default:""},columnChooser:{type:Boolean,default:!1},page:{default:1},pageSize:{default:10},pageSizeOptions:{default:()=>[10,20,30,50,100]},showPageSize:{type:Boolean,default:!0},rowClass:{default:[]},cellClass:{default:[]},sortable:{type:Boolean,default:!1},sortColumn:{default:"id"},sortDirection:{default:"asc"},columnFilter:{type:Boolean,default:!1},columnFilterLang:{default:null},pagination:{type:Boolean,default:!0},showNumbers:{type:Boolean,default:!0},showNumbersCount:{default:5},showFirstPage:{type:Boolean,default:!0},showLastPage:{type:Boolean,default:!0},firstArrow:{default:""},lastArrow:{default:""},nextArrow:{default:""},previousArrow:{default:""},paginationInfo:{default:"Showing {0} to {1} of {2} entries"},noDataContent:{default:"No data available"},stickyHeader:{type:Boolean,default:!1},height:{default:"500px"},stickyFirstColumn:{type:Boolean,default:!1},cloneHeaderInFooter:{type:Boolean,default:!1},selectRowOnClick:{type:Boolean,default:!1}},emits:["change","sortChange","searchChange","pageChange","pageSizeChange","rowSelect","filterChange","rowClick","rowDBClick"],setup(y,{expose:k,emit:a}){var te,le;const v=e.useSlots(),l=y;for(const t of l.columns||[]){const n=((te=t.type)==null?void 0:te.toLowerCase())||"string";t.type=n,t.isUnique=t.isUnique!==void 0?t.isUnique:!1,t.hide=t.hide!==void 0?t.hide:!1,t.filter=t.filter!==void 0?t.filter:!0,t.search=t.search!==void 0?t.search:!0,t.sort=t.sort!==void 0?t.sort:!0,t.html=t.html!==void 0?t.html:!1,t.condition=!n||n==="string"?"contain":"equal"}const d=e.ref([]),u=e.ref(l.page),r=e.ref(l.pagination?l.pageSize:(le=l.rows)==null?void 0:le.length),c=l.pageSize,B=e.ref(l.sortColumn),p=l.sortColumn,_=e.ref(l.sortDirection),T=l.sortDirection,E=e.ref(l.totalRows),w=e.ref([]),q=e.ref(null),S=e.ref(l.loading),V=e.ref(l.search),H=JSON.parse(JSON.stringify(l.columns)),L=e.ref(null),A=e.ref(null);let $=e.ref(0);const O=e.ref(230);e.onMounted(()=>{z()});const F=a;k({reset(){ke()},getSelectedRows(){return be()},getColumnFilters(){return Ce()},clearSelectedRows(){return ye()},selectRow(t){j(t)},unselectRow(t){ee(t)},isRowSelected(t){return I(t)},getFilteredRows(){return W()},getVisibleRows(){return we()}});const P=(t,...n)=>t.replace(/{(\d+)}/g,(i,f)=>typeof n[f]<"u"?n[f]:i),b=e.computed(()=>{const t=l.columns.find(n=>n.isUnique);return(t==null?void 0:t.field)||null}),N=e.computed(()=>{const t=r.value<1?1:Math.ceil(E.value/r.value);return Math.max(t||0,1)}),g=e.computed(()=>(u.value-1)*r.value+1),J=e.computed(()=>{const t=u.value*r.value;return E.value>=t?t:E.value}),se=e.computed(()=>{let t,n;return typeof l.showNumbersCount<"u"&&l.showNumbersCount<N.value?(t=Math.max(u.value-Math.floor(l.showNumbersCount/2),1),n=t+l.showNumbersCount-1,n>N.value&&(n=N.value,t=n-l.showNumbersCount+1)):(t=1,n=N.value),Array.from(Array(n+1-t).keys()).map(C=>t+C)}),W=()=>{var C,R,ne;let t=l.rows||[];if(!l.isServerMode){if(l.columnFilter&&((C=l.columns)==null||C.forEach(o=>{o.filter&&(o.value!==void 0&&o.value!==null&&o.value!==""||o.condition==="is_null"||o.condition=="is_not_null")&&(o.type==="string"?(o.value&&!o.condition&&(o.condition="contain"),o.condition==="contain"?t=t.filter(s=>{var h;return(h=m(s,o.field))==null?void 0:h.toString().toLowerCase().includes(o.value.toLowerCase())}):o.condition==="not_contain"?t=t.filter(s=>{var h;return!((h=m(s,o.field))!=null&&h.toString().toLowerCase().includes(o.value.toLowerCase()))}):o.condition==="equal"?t=t.filter(s=>{var h;return((h=m(s,o.field))==null?void 0:h.toString().toLowerCase())===o.value.toLowerCase()}):o.condition==="not_equal"?t=t.filter(s=>{var h;return((h=m(s,o.field))==null?void 0:h.toString().toLowerCase())!==o.value.toLowerCase()}):o.condition=="start_with"?t=t.filter(s=>{var h;return((h=m(s,o.field))==null?void 0:h.toString().toLowerCase().indexOf(o.value.toLowerCase()))===0}):o.condition=="end_with"&&(t=t.filter(s=>{var h;return((h=m(s,o.field))==null?void 0:h.toString().toLowerCase().substr(o.value.length*-1))===o.value.toLowerCase()}))):o.type==="number"?(o.value&&!o.condition&&(o.condition="equal"),o.condition==="equal"?t=t.filter(s=>m(s,o.field)&&parseFloat(m(s,o.field))===parseFloat(o.value)):o.condition==="not_equal"?t=t.filter(s=>m(s,o.field)&&parseFloat(m(s,o.field))!==parseFloat(o.value)):o.condition==="greater_than"?t=t.filter(s=>m(s,o.field)&&parseFloat(m(s,o.field))>parseFloat(o.value)):o.condition==="greater_than_equal"?t=t.filter(s=>m(s,o.field)&&parseFloat(m(s,o.field))>=parseFloat(o.value)):o.condition==="less_than"?t=t.filter(s=>m(s,o.field)&&parseFloat(m(s,o.field))<parseFloat(o.value)):o.condition==="less_than_equal"&&(t=t.filter(s=>m(s,o.field)&&parseFloat(m(s,o.field))<=parseFloat(o.value)))):o.type==="date"?(o.value&&!o.condition&&(o.condition="equal"),o.condition==="equal"?t=t.filter(s=>m(s,o.field)&&U(m(s,o.field))===o.value):o.condition==="not_equal"?t=t.filter(s=>m(s,o.field)&&U(m(s,o.field))!==o.value):o.condition==="greater_than"?t=t.filter(s=>m(s,o.field)&&U(m(s,o.field))>o.value):o.condition==="less_than"&&(t=t.filter(s=>m(s,o.field)&&U(m(s,o.field))<o.value))):o.type==="bool"&&(t=t.filter(s=>m(s,o.field)===o.value)),o.condition==="is_null"?(t=t.filter(s=>m(s,o.field)==null||m(s,o.field)==""),o.value=""):o.condition==="is_not_null"&&(o.value="",t=t.filter(s=>m(s,o.field))))})),V.value&&(t==null?void 0:t.length)){let o=[];const s=(l.columns||[]).filter(h=>h.search&&!h.hide).map(h=>h.field);for(var n=0;n<(t==null?void 0:t.length);n++)for(var i=0;i<s.length;i++)if((R=m(t[n],s[i]))!=null&&R.toString().toLowerCase().includes(V.value.toLowerCase())){o.push(t[n]);break}t=o}if(l.sortable){var f=new Intl.Collator(void 0,{numeric:((ne=l.columns.find(s=>s.field==B.value))==null?void 0:ne.type)==="number",sensitivity:"base"});const o=_.value==="desc"?-1:1;t.sort((s,h)=>{var oe,ae;const Be=(oe=B.value)==null?void 0:oe.split(".").reduce((M,K)=>M==null?void 0:M[K],s),Ee=(ae=B.value)==null?void 0:ae.split(".").reduce((M,K)=>M==null?void 0:M[K],h);return f.compare(Be,Ee)*o})}}return t},z=()=>{let t=[],n=W();return l.isServerMode?(E.value=l.totalRows||0,t=n):(E.value=(n==null?void 0:n.length)||0,t=n.slice(g.value-1,J.value)),d.value=t||[],t};e.watch(()=>l.loading,()=>{S.value=l.loading});const Y=t=>{t?L.value===t.field?L.value=null:L.value=t.field:L.value=null},ue=()=>{if(u.value==1)return!1;u.value--},ce=t=>{u.value=t},de=()=>{if(u.value>=N.value)return!1;u.value++},me=()=>{x(!1),l.isServerMode?D("page"):(z(),F("pageChange",u.value))};e.watch(()=>u.value,me),e.watch(()=>l.page,t=>{u.value=t});const ve=()=>{x(!1),z()};e.watch(()=>l.rows,ve);const fe=()=>{x(!1),l.isServerMode?u.value===1?D("pagesize",!0):u.value=1:(u.value=1,z(),F("pageSizeChange",r.value))};e.watch(()=>r.value,fe);const Q=t=>{let n="asc";t==B.value&&_.value==="asc"&&(n="desc");let i=(u.value-1)*r.value,f=r.value;B.value=t,_.value=n,x(!1),z(),l.isServerMode?D("sort"):F("sortChange",{offset:i,limit:f,field:t,direction:n})},X=t=>{q.value=t.length&&d.value.length&&t.length===d.value.length;const n=d.value.filter((i,f)=>w.value.includes(b.value?i[b.value]:f));F("rowSelect",n)};e.watch(()=>w.value,X);const x=t=>{t?w.value=d.value.map((n,i)=>b.value?n[b.value]:i):w.value=[]},Z=()=>{x(!1),l.isServerMode?u.value===1?D("filter",!0):u.value=1:(u.value=1,z(),F("filterChange",l.columns))},he=()=>{x(!1),l.isServerMode?u.value===1?D("search",!0):u.value=1:(u.value=1,z(),F("searchChange",V.value))};e.watch(()=>l.search,()=>{V.value=l.search,he()});const m=(t,n)=>n==null?void 0:n.split(".").reduce((i,f)=>i==null?void 0:i[f],t),U=t=>{try{if(!t)return"";const n=new Date(t),i=n.getDate(),f=n.getMonth()+1;return n.getFullYear()+"-"+(f>9?f:"0"+f)+"-"+(i>9?i:"0"+i)}catch{}return""},pe=(t,n)=>{$.value++,$.value===1?A.value=setTimeout(()=>{$.value=0,l.selectRowOnClick&&(I(n)?ee(n):j(n),X(w.value)),F("rowClick",t)},O.value):$.value===2&&(clearTimeout(A.value),$.value=0,F("rowDBClick",t))},D=(t,n=!1)=>{if(l.isServerMode){ge();const i={current_page:n?1:u.value,pagesize:r.value,offset:(u.value-1)*r.value,sort_column:B.value,sort_direction:_.value,search:V.value,column_filters:l.columns,change_type:t};F("change",i)}},ge=()=>{for(let t=0;t<l.columns.length;t++){let n=l.columns[t];n.filter&&(n.value!==void 0&&n.value!==null&&n.value!==""||n.condition==="is_null"||n.condition==="is_not_null")&&(n.type==="string"&&n.value&&!n.condition&&(n.condition="contain"),n.type==="number"&&n.value&&!n.condition&&(n.condition="equal"),n.type==="date"&&n.value&&!n.condition&&(n.condition="equal"))}},ke=()=>{x(!1);for(let t=0;t<l.columns.length;t++)l.columns[t]=H[t];V.value="",r.value=c,B.value=p,_.value=T,l.isServerMode?u.value===1?D("reset",!0):u.value=1:(u.value=1,z())},be=()=>d.value.filter((n,i)=>w.value.includes(b.value?n[b.value]:i)),Ce=()=>l.columns,ye=()=>{w.value=[]},j=t=>{if(!I(t)){const n=d.value.find((i,f)=>f===t);w.value.push(b.value?n[b.value]:t)}},ee=t=>{if(I(t)){const n=d.value.find((i,f)=>f===t);w.value=w.value.filter(i=>i!==(b.value?n[b.value]:t))}},I=t=>{const n=d.value.find((i,f)=>f===t);return n?w.value.includes(b.value?n[b.value]:t):!1},we=()=>z();return(t,n)=>(e.openBlock(),e.createElementBlock("div",Ze,[e.createElementVNode("div",{class:e.normalizeClass(["bh-table-responsive",{"bh-min-h-[300px]":S.value}]),style:e.normalizeStyle({height:l.stickyHeader&&l.height})},[e.createElementVNode("table",{class:e.normalizeClass([l.skin])},[e.createElementVNode("thead",{class:e.normalizeClass({"bh-sticky bh-top-0 bh-z-10":l.stickyHeader})},[e.createVNode(re,{all:l,currentSortColumn:B.value,currentSortDirection:_.value,isOpenFilter:L.value,checkAll:q.value,columnFilterLang:l.columnFilterLang,onSelectAll:x,onSortChange:Q,onFilterChange:Z,onToggleFilterMenu:Y},null,8,["currentSortColumn","currentSortDirection","isOpenFilter","checkAll","columnFilterLang"])],2),e.createElementVNode("tbody",null,[E.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(d.value,(i,f)=>(e.openBlock(),e.createElementBlock("tr",{key:i[b.value]?i[b.value]:f,class:e.normalizeClass([typeof l.rowClass=="function"?t.rowClass(i):l.rowClass,l.selectRowOnClick?"bh-cursor-pointer":""]),onClick:e.withModifiers(C=>pe(i,f),["prevent"])},[l.hasCheckbox?(e.openBlock(),e.createElementBlock("td",{key:0,class:e.normalizeClass({"bh-sticky bh-left-0 bh-bg-blue-light":l.stickyFirstColumn})},[e.createElementVNode("div",et,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":n[0]||(n[0]=C=>w.value=C),type:"checkbox",value:i[b.value]?i[b.value]:f,onClick:n[1]||(n[1]=e.withModifiers(()=>{},["stop"]))},null,8,tt),[[e.vModelCheckbox,w.value]]),e.createElementVNode("div",null,[e.createVNode(ie,{class:"check"})])])],2)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.columns,(C,R)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[C.hide?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("td",{key:C.field,class:e.normalizeClass([typeof l.cellClass=="function"?t.cellClass(i):l.cellClass,R===0&&l.stickyFirstColumn?"bh-sticky bh-left-0 bh-bg-blue-light":"",l.hasCheckbox&&R===0&&l.stickyFirstColumn?"bh-left-[52px]":"",C.cellClass?C.cellClass:""])},[e.unref(v)[C.field]?e.renderSlot(t.$slots,C.field,{key:0,value:i}):C.cellRenderer?(e.openBlock(),e.createElementBlock("div",{key:1,innerHTML:C.cellRenderer(i)},null,8,lt)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(m(i,C.field)),1)],64))],2))],64))),256))],10,je))),128)):e.createCommentVNode("",!0),!E.value&&!S.value?(e.openBlock(),e.createElementBlock("tr",nt,[e.createElementVNode("td",{colspan:l.columns.length+1},e.toDisplayString(l.noDataContent),9,ot)])):e.createCommentVNode("",!0),!E.value&&S.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:2},e.renderList(l.pageSize,i=>(e.openBlock(),e.createElementBlock("tr",{key:i,class:"!bh-bg-white bh-h-11 !bh-border-transparent"},[e.createElementVNode("td",{colspan:l.columns.length+1,class:"!bh-p-0 !bh-border-transparent"},n[5]||(n[5]=[e.createElementVNode("div",{class:"bh-skeleton-box bh-h-8"},null,-1)]),8,at)]))),128)):e.createCommentVNode("",!0)]),l.cloneHeaderInFooter?(e.openBlock(),e.createElementBlock("tfoot",{key:0,class:e.normalizeClass({"bh-sticky bh-bottom-0":l.stickyHeader})},[e.createVNode(re,{all:l,currentSortColumn:B.value,currentSortDirection:_.value,isOpenFilter:L.value,isFooter:!0,checkAll:q.value,onSelectAll:x,onSortChange:Q,onFilterChange:Z,onToggleFilterMenu:Y},null,8,["currentSortColumn","currentSortDirection","isOpenFilter","checkAll"])],2)):e.createCommentVNode("",!0)],2),E.value&&S.value?(e.openBlock(),e.createElementBlock("div",rt,[e.createVNode(Xe)])):e.createCommentVNode("",!0)],6),l.pagination&&E.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["bh-pagination bh-py-5",{"bh-pointer-events-none":S.value}])},[e.createElementVNode("div",it,[e.createElementVNode("div",st,[e.createElementVNode("span",ut,e.toDisplayString(P(l.paginationInfo,E.value?g.value:0,J.value,E.value)),1),l.showPageSize?e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:0,"onUpdate:modelValue":n[2]||(n[2]=i=>r.value=i),class:"bh-pagesize"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.pageSizeOptions,i=>(e.openBlock(),e.createElementBlock("option",{value:i,key:i},e.toDisplayString(i),9,ct))),128))],512)),[[e.vModelSelect,r.value]]):e.createCommentVNode("",!0)]),e.createElementVNode("div",dt,[l.showFirstPage?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["bh-page-item first-page",{disabled:u.value<=1}]),onClick:n[3]||(n[3]=i=>u.value=1)},[l.firstArrow?(e.openBlock(),e.createElementBlock("span",{key:0,innerHTML:l.firstArrow},null,8,mt)):(e.openBlock(),e.createElementBlock("svg",vt,n[6]||(n[6]=[e.createElementVNode("g",{fill:"currentColor","fill-rule":"evenodd"},[e.createElementVNode("path",{d:"M8.354 1.646a.5.5 0 0 1 0 .708L2.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"}),e.createElementVNode("path",{d:"M12.354 1.646a.5.5 0 0 1 0 .708L6.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"})],-1)])))],2)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["bh-page-item previous-page",{disabled:u.value<=1}]),onClick:ue},[l.previousArrow?(e.openBlock(),e.createElementBlock("span",{key:0,innerHTML:l.previousArrow},null,8,ft)):(e.openBlock(),e.createElementBlock("svg",ht,n[7]||(n[7]=[e.createElementVNode("path",{fill:"currentColor","fill-rule":"evenodd",d:"M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"},null,-1)])))],2),l.showNumbers?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(se.value,i=>(e.openBlock(),e.createElementBlock("button",{key:i,type:"button",class:e.normalizeClass(["bh-page-item",{disabled:u.value===i,"bh-active":i===u.value}]),onClick:f=>ce(i)},e.toDisplayString(i),11,pt))),128)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["bh-page-item next-page",{disabled:u.value>=N.value}]),onClick:de},[l.nextArrow?(e.openBlock(),e.createElementBlock("span",{key:0,innerHTML:l.nextArrow},null,8,gt)):(e.openBlock(),e.createElementBlock("svg",kt,n[8]||(n[8]=[e.createElementVNode("path",{fill:"currentColor","fill-rule":"evenodd",d:"M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8L4.646 2.354a.5.5 0 0 1 0-.708z"},null,-1)])))],2),l.showLastPage?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:e.normalizeClass(["bh-page-item last-page",{disabled:u.value>=N.value}]),onClick:n[4]||(n[4]=i=>u.value=N.value)},[l.lastArrow?(e.openBlock(),e.createElementBlock("span",{key:0,innerHTML:l.lastArrow},null,8,bt)):(e.openBlock(),e.createElementBlock("svg",Ct,n[9]||(n[9]=[e.createElementVNode("g",{fill:"currentColor","fill-rule":"evenodd"},[e.createElementVNode("path",{d:"M3.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L9.293 8L3.646 2.354a.5.5 0 0 1 0-.708z"}),e.createElementVNode("path",{d:"M7.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L13.293 8L7.646 2.354a.5.5 0 0 1 0-.708z"})],-1)])))],2)):e.createCommentVNode("",!0)])])],2)):e.createCommentVNode("",!0)]))}});module.exports=yt;