@dcodegroup-au/dsg-vue 0.1.34 → 0.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),p=require("./DsgTablePerPage.vue_vue_type_style_index_0_lang-DPCoss-A.cjs"),G=require("./dsg-vue.helpers-string.cjs"),le=require("./dsg-vue.helpers-object.cjs"),Ie=require("./dsg-vue.helpers.cjs"),Oe={class:"dsg-table--pagination"},We=["disabled"],je=["disabled"],Ke=["onClick","innerHTML"],Qe=["onClick","innerHTML"],Ye=["disabled"],Ge=["disabled"],me=e.defineComponent({__name:"DsgTablePagination",props:e.mergeModels({onEachSide:{default:3},firstPage:{default:1},showFirstLast:{type:Boolean,default:!0},firstIcon:{default:"chevron-left-double"},lastIcon:{default:"chevron-right-double"},prevIcon:{default:"chevron-left"},nextIcon:{default:"chevron-right"}},{pagination:{default:null},paginationModifiers:{}}),emits:e.mergeModels(["dsg-table:change-page"],["update:pagination"]),setup(t,{expose:x,emit:f}){const c=e.useModel(t,"pagination"),S=e.computed(()=>c.value===null?0:c.value?.last_page-t.firstPage+1),$=e.computed(()=>c.value===null?0:c.value?.last_page),g=e.computed(()=>c.value===null?!1:c.value?.current_page===t.firstPage),m=e.computed(()=>c.value===null?!1:c.value?.current_page===$.value),V=e.computed(()=>S.value<t.onEachSide*2+4),P=e.computed(()=>t.onEachSide*2+1),E=e.computed(()=>!c.value||c.value?.current_page<=t.onEachSide?1:c.value?.current_page>=S.value-t.onEachSide?S.value-t.onEachSide*2:c.value?.current_page-t.onEachSide),h=f,n=w=>{h("dsg-table:change-page",w)},u=w=>w===c.value?.current_page;return x({loadPage:n}),(w,k)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",Oe,[t.showFirstLast?(e.openBlock(),e.createElementBlock("a",{key:0,onClick:k[0]||(k[0]=y=>n(t.firstPage)),class:e.normalizeClass([[g.value?"disabled":""],"dsg-table--pagination-link"]),disabled:g.value,title:"First","aria-label":"First"},[e.createVNode(p._sfc_main,{icon:t.firstIcon,size:"sm"},null,8,["icon"])],10,We)):e.createCommentVNode("",!0),e.createElementVNode("a",{onClick:k[1]||(k[1]=y=>n("prev")),class:e.normalizeClass([[g.value?"disabled":""],"dsg-table--pagination-link"]),disabled:g.value,title:"Previous","aria-label":"Previous"},[e.createVNode(p._sfc_main,{icon:t.prevIcon,size:"sm"},null,8,["icon"])],10,je),V.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(S.value,(y,N)=>(e.openBlock(),e.createElementBlock("a",{key:N,onClick:I=>n(N+t.firstPage),class:e.normalizeClass([[u(N+t.firstPage)?"active":""],"dsg-table--pagination-link"]),innerHTML:y},null,10,Ke))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:2},e.renderList(P.value,(y,N)=>(e.openBlock(),e.createElementBlock("a",{key:N,onClick:I=>n(E.value+N+t.firstPage-1),class:e.normalizeClass([[u(E.value+N+t.firstPage-1)?"active":""],"dsg-table--pagination-link"]),innerHTML:E.value+y-1},null,10,Qe))),128)),e.createElementVNode("a",{onClick:k[2]||(k[2]=y=>n("next")),class:e.normalizeClass([[m.value?"disabled":""],"dsg-table--pagination-link"]),disabled:m.value,title:"Next","aria-label":"Next"},[e.createVNode(p._sfc_main,{icon:t.nextIcon,size:"sm"},null,8,["icon"])],10,Ye),t.showFirstLast?(e.openBlock(),e.createElementBlock("a",{key:3,onClick:k[3]||(k[3]=y=>n($.value)),class:e.normalizeClass([[m.value?"disabled":""],"dsg-table--pagination-link"]),disabled:m.value,title:"Last","aria-label":"Last"},[e.createVNode(p._sfc_main,{icon:t.lastIcon,size:"sm"},null,8,["icon"])],10,Ge)):e.createCommentVNode("",!0)],512)),[[e.vShow,c.value&&$.value>t.firstPage]])}}),Je=["innerHTML"],ve=e.defineComponent({__name:"DsgTablePaginationInfo",props:e.mergeModels({infoTemplate:{default:"Displaying {from} to {to} of {total} items"},noDataTemplate:{default:"No relevant data"}},{pagination:{default:null},paginationModifiers:{}}),emits:["update:pagination"],setup(t){const x=e.useModel(t,"pagination"),f=e.computed(()=>x.value==null||x.value.total==0?t.noDataTemplate:t.infoTemplate.replace("{from}",(x.value?.from||0).toString()).replace("{to}",(x.value?.to||0).toString()).replace("{total}",(x.value?.total||0).toString()));return(c,S)=>(e.openBlock(),e.createElementBlock("div",{class:"dsg-table--pagination-info",innerHTML:f.value},null,8,Je))}}),Xe={class:"dsg-table--actions",ref:"dsgTableActions"},Ze={class:"dsg-table--action-trigger"},_e={key:0,class:"dsg-table--actions-menu-wrapper"},et=["href","target","onClick"],tt=["textContent"],at={key:0},lt={key:1},nt=["href","target","onClick"],ot={class:"flex-1"},be=e.defineComponent({__name:"DsgTableActions",props:{placement:{default:"auto"}},emits:["dsg-table:action-edit","dsg-table:action-view","dsg-table:action-delete","dsg-table:action-archive","dsg-table:link-clicked"],setup(t,{emit:x}){const f=e.ref(!1);e.useTemplateRef("dsgTableActions");const c=e.useAttrs(),S=e.ref(c.data.rowData?.actions??null),$=e.ref(c.data.rowData?.links??null),g=e.ref(c.data.rowData??null),m=h=>{switch(h){case"edit":return"edit-05";case"view":return"eye";case"delete":return"trash-01";case"archive":return"eye-off";default:return"dots-horizontal"}},V=(h,n,u)=>{switch(n){case"edit":E("dsg-table:action-edit",u,g.value);break;case"view":E("dsg-table:action-view",u,g.value);break;case"delete":E("dsg-table:action-delete",u,g.value);break;case"archive":E("dsg-table:action-archive",u,g.value);break}},P=(h,n)=>{const u=h.actionId||h.label.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-");E("dsg-table:link-clicked",n,u,g.value)},E=x;return(h,n)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",Xe,[e.createVNode(e.unref(p.kt),{triggers:[],placement:t.placement,"handle-resize":!0,strategy:"absolute",shown:f.value,class:"dsg-table--actions__popper",onHide:n[1]||(n[1]=u=>f.value=!1),ref:"floatingVueFilterDropdown"},{popper:e.withCtx(()=>[f.value?(e.openBlock(),e.createElementBlock("div",_e,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.value,(u,w)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[["edit","view","delete","archive"].includes(String(w))?(e.openBlock(),e.createElementBlock("a",{key:w,href:u?.link,target:u?.target||"_self",onClick:k=>V(u,String(w),k)},[e.createElementVNode("div",{class:e.normalizeClass(["dsg-table--actions-menu-item",String(w)])},[e.createVNode(p._sfc_main,{icon:m(String(w)),size:"sm"},null,8,["icon"]),e.createElementVNode("span",{class:"flex-1",textContent:e.toDisplayString(e.unref(G.ucfirst)(String(w)))},null,8,tt)],2)],8,et)):e.createCommentVNode("",!0)],64))),256)),S.value&&$.value?(e.openBlock(),e.createElementBlock("hr",at)):e.createCommentVNode("",!0),$.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList($.value,u=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:u.label},[u.hasOwnProperty("component")?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(u.component),{key:0,quote:e.unref(c).data.data.rowData,"row-data":e.unref(c).data.data.rowData},null,8,["quote","row-data"])):u.hasOwnProperty("type")&&u.type=="break"?(e.openBlock(),e.createElementBlock("hr",lt)):(e.openBlock(),e.createElementBlock("a",{key:2,href:u.link,target:u.target||"_self",class:e.normalizeClass(["dsg-table--actions-menu-item",u.class]),onClick:w=>P(u,w)},[u.icon?(e.openBlock(),e.createBlock(p._sfc_main,{key:0,icon:u.icon,size:"sm"},null,8,["icon"])):e.createCommentVNode("",!0),e.createElementVNode("span",ot,e.toDisplayString(u.label),1)],10,nt))],64))),128)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]),default:e.withCtx(()=>[e.createElementVNode("div",Ze,[e.createElementVNode("button",{type:"button",class:"dsg-table--actions-button","aria-expanded":"false","aria-haspopup":"true",onClick:n[0]||(n[0]=u=>f.value=!f.value)},[e.renderSlot(h.$slots,"dsg-table-action-button-content",{},()=>[e.createVNode(p._sfc_main,{icon:"dots-vertical",size:"sm"})])])])]),_:3},8,["placement","shown"])])),[[e.unref(p.vOnClickOutside),()=>f.value=!1]])}}),st={class:"dsg-table--search"},he=e.defineComponent({__name:"DsgTableSearch",props:{name:{},id:{},placeholder:{default:"Search"},disabled:{type:Boolean,default:!1},required:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},hidden:{type:Boolean,default:!1},extraClasses:{},eventName:{},replaceState:{type:Boolean,default:!0}},emits:["dsg-table:term-changed"],setup(t,{emit:x}){const f=e.ref("");e.onMounted(()=>{const g=new URL(window.location.href).searchParams.get("term");g&&(f.value=g,c("dsg-table:term-changed",g))});const c=x,S=p.useDebounceFn($=>{if(f.value=$,t.replaceState){const g=new URL(window.location.href);f.value?g.searchParams.set("term",f.value):g.searchParams.delete("term"),window.history.pushState({},"",g.toString())}c("dsg-table:term-changed",f.value)},300);return($,g)=>(e.openBlock(),e.createElementBlock("div",st,[e.createVNode(p._sfc_main$4,{modelValue:f.value,"onUpdate:modelValue":g[0]||(g[0]=m=>f.value=m),name:t.name,id:t.id||t.name,placeholder:t.placeholder,disabled:t.disabled,required:t.required,readonly:t.readonly,hidden:t.hidden,"has-clear-button":!0,autocomplete:"off",size:"sm",icon:"search-sm","icon-clickable":!0,onIconClicked:g[1]||(g[1]=m=>e.unref(S)(m)),onEnterPressed:g[2]||(g[2]=m=>e.unref(S)(m)),onOnClear:g[3]||(g[3]=()=>e.unref(S)(""))},null,8,["modelValue","name","id","placeholder","disabled","required","readonly","hidden"])]))}}),rt={class:"dsg-table--header-row"},it={key:0,class:"dsg-table--th dsg-table--th-checkbox",scope:"col"},dt={key:1,class:"dsg-table--th dsg-table--th-expand-detail",scope:"col"},ct=["title","id","onClick"],ut={key:0,class:"dsg-table--th-sort-icon"},gt=["innerHTML"],ft=["innerHTML"],mt=["innerHTML"],vt=["innerHTML"],ke=e.defineComponent({__name:"DsgTableRowHeader",props:e.mergeModels({fields:{},scrollVisible:{type:Boolean},hasSelectAll:{type:Boolean,default:!1},showExpandDetail:{type:Boolean,default:!0},tableDataLength:{default:0}},{sortField:{default:null},sortFieldModifiers:{},selectedRows:{default:[]},selectedRowsModifiers:{},hasSelected:{type:Boolean,default:!1},hasSelectedModifiers:{}}),emits:e.mergeModels(["dsg-table:sort-field","dsg-table:on-select-all","dsg-table:on-deselect-all"],["update:sortField","update:selectedRows","update:hasSelected"]),setup(t,{emit:x}){const f=e.useModel(t,"sortField"),c=e.useModel(t,"selectedRows"),S=e.useModel(t,"hasSelected"),$=e.ref("17px"),g=E=>{S.value&&c.value.length>0&&c.value.length!==t.tableDataLength?(S.value=!0,m("dsg-table:on-select-all")):!S.value&&c.value.length===0?(S.value=!1,m("dsg-table:on-select-all")):m("dsg-table:on-deselect-all")},m=x,V=(E,h)=>[E,E+"-"+G.toSnakeCase(String(h?.name)),h.titleClass||"",{sortable:h.sortable},{"sort-active":f.value?.name===h.name}],P=E=>{E.sortable&&(f.value={name:String(E?.name),field:String(E?.sortField),direction:f.value?.name===E.name&&f.value?.direction==="asc"?"desc":"asc"},m("dsg-table:sort-field",E))};return(E,h)=>(e.openBlock(),e.createElementBlock("tr",rt,[t.hasSelectAll?(e.openBlock(),e.createElementBlock("th",it,[e.createVNode(p._sfc_main$2,{modelValue:S.value,"onUpdate:modelValue":[h[0]||(h[0]=n=>S.value=n),g],indeterminate:c.value.length>0&&c.value.length!==t.tableDataLength},null,8,["modelValue","indeterminate"])])):e.createCommentVNode("",!0),t.showExpandDetail?(e.openBlock(),e.createElementBlock("th",dt)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.fields,(n,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[n?.visible?(e.openBlock(),e.createElementBlock("th",{key:u,class:e.normalizeClass(V("dsg-table--th",n)),style:e.normalizeStyle([{width:n.width||void 0},n.style]),title:n.title+(n.sortable?" Sort":""),id:"_"+n.name,onClick:w=>P(n),scope:"col"},[n.sortable?(e.openBlock(),e.createElementBlock("div",ut,[n.tooltip?(e.openBlock(),e.createBlock(p._sfc_main$1,e.mergeProps({key:0,ref_for:!0},n.tooltip,{class:"dsg-table--th-tooltip"}),{"dsg-tooltip--trigger":e.withCtx(()=>[n.title?(e.openBlock(),e.createElementBlock("span",{key:0,class:"dsg-table--th-title",innerHTML:n.title},null,8,gt)):e.createCommentVNode("",!0),n.tooltip.icon?(e.openBlock(),e.createBlock(p._sfc_main,{key:1,icon:n.tooltip.icon,class:"inline-flex",size:"xs"},null,8,["icon"])):e.createCommentVNode("",!0)]),_:2},1040)):n.title?(e.openBlock(),e.createElementBlock("span",{key:1,class:"dsg-table--th-title",innerHTML:n.title},null,8,ft)):e.createCommentVNode("",!0),n.sortable&&f.value?.name!==n.name?(e.openBlock(),e.createBlock(p._sfc_main,{key:2,icon:"chevron-selector-vertical",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0),n.sortable&&f.value?.name===n.name&&f.value?.direction==="asc"?(e.openBlock(),e.createBlock(p._sfc_main,{key:3,icon:"chevron-down",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0),n.sortable&&f.value?.name===n.name&&f.value?.direction==="desc"?(e.openBlock(),e.createBlock(p._sfc_main,{key:4,icon:"chevron-up",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[n.tooltip?(e.openBlock(),e.createBlock(p._sfc_main$1,e.mergeProps({key:0,ref_for:!0},n.tooltip,{class:"dsg-table--th-tooltip"}),{"dsg-tooltip--trigger":e.withCtx(()=>[e.createElementVNode("span",{class:"dsg-table--th-title",innerHTML:e.unref(G.ucwords)(String(n?.title))},null,8,mt),n.tooltip.icon?(e.openBlock(),e.createBlock(p._sfc_main,{key:0,icon:n.tooltip.icon,class:"inline-flex",size:"xs"},null,8,["icon"])):e.createCommentVNode("",!0)]),_:2},1040)):(e.openBlock(),e.createElementBlock("span",{key:1,class:"dsg-table--th-title",innerHTML:e.unref(G.ucwords)(String(n?.title))},null,8,vt))],64))],14,ct)):e.createCommentVNode("",!0)],64))),256)),t.scrollVisible?(e.openBlock(),e.createElementBlock("th",{key:2,style:e.normalizeStyle({width:$.value}),class:"dsg-table--th-col-gutter"},null,4)):e.createCommentVNode("",!0)]))}}),bt=["span"],ht={key:0,class:"dsg-table--loading"},kt=["colspan"],wt=["colspan"],yt=["onClick","onDblclick","onMouseover","onMouseenter"],pt=["onClickCapture"],Bt={key:1,class:"dsg-table--tbody-cell dsg-table--tbody-cell-expand"},Ct=["aria-expanded","onClick"],St=["onClick","onDblclick","onContextmenu"],Et=["innerHTML"],Pt=["onClick"],Dt=["colspan"],xt={key:2},$t=["colspan"],Vt={class:"dsg-table--footer"},Tt=e.defineComponent({__name:"DsgTableComponent",props:e.mergeModels({fields:{default:()=>[]},isDraggable:{type:Boolean,default:!1},dragApi:{default:""},loadOnStart:{type:Boolean,default:!0},apiUrl:{default:""},httpMethod:{default:"get"},reactiveApiUrl:{type:Boolean,default:!0},apiMode:{type:Boolean,default:!0},data:{default:null},dataManager:{type:[Function,null],default:null},dataPath:{default:"data"},tableLayout:{default:"fixed"},paginationPath:{default:"links.pagination"},queryParams:{default:()=>({sort:"sort",order:"order",page:"page",perPage:"per_page"})},httpOptions:{default:()=>({})},hasDetailRow:{type:Boolean,default:!1},showExpandDetail:{type:Boolean,default:!0},expandableRows:{type:Boolean,default:!1},expandMultiple:{type:Boolean,default:!1},initialPage:{default:1},firstPage:{default:1},sortOrder:{default:()=>[]},multiSort:{type:Boolean},tableHeight:{default:null},multiSortKey:{},rowClass:{type:[String,Function],default:""},detailRowComponent:{},detailRowTransition:{default:"fade"},detailRowClass:{type:[String,Function]},detailRowOptions:{default:()=>({})},trackBy:{default:"id"},css:{default:()=>({tableWrapper:"dsg-table-wrapper",thead:"dsg-table-thead",tbody:"dsg-table-tbody",table:"dsg-table-component"})},minRows:{default:0},noDataTemplate:{default:"No Data Available"},showSortIcons:{type:Boolean},headerRows:{},transform:{type:[Function,null],default:null},sortParams:{type:[Function,null],default:null},fieldPrefix:{},eventPrefix:{},selectable:{type:Boolean,default:!1},shiftSelectHighlight:{default:()=>{}},selectedRowHighlight:{default:()=>{}},replaceState:{type:Boolean,default:!0},replaceStrategy:{default:"window"}},{filterParams:{default:{}},filterParamsModifiers:{},perPage:{default:20},perPageModifiers:{}}),emits:e.mergeModels(["dsg-table:loading","dsg-table:loaded","dsg-table:load-success","dsg-table:load-error","dsg-table:pagination-data","dsg-table:rows-selected","dsg-table:row-clicked","dsg-table:row-hover","dsg-table:row-dblclick","dsg-table:row-expanded","dsg-table:row-collapsed"],["update:filterParams","update:perPage"]),setup(t,{expose:x,emit:f}){const c=a=>a.map((l,o)=>({field:l.field||"",title:l.title||"",name:l.name||"",titleClass:l.titleClass||"",dataClass:l.dataClass||"",visible:l.visible??!0,width:l.width||void 0,sortField:l.sortField||null,sortable:l.sortField,formatter:l.formatter||null,tooltip:l.tooltip??null,$_index:o})),S=()=>{if(!t.apiMode)return null;const l=p.getQueryStrings().find(o=>o.key===t.queryParams.sort);if(l&&l.value.length>0){const o=l.value[0],v=o.startsWith("-"),d=v?o.substring(1):o,C=t.fields.find(L=>L.sortField===d||L.name===d||L.field===d);return C?{name:String(C.name||C.field),field:d,direction:v?"desc":"asc"}:{name:d,field:d,direction:v?"desc":"asc"}}return null},$=()=>{if(!(!t.apiMode||!t.replaceState)&&t.replaceStrategy==="window"){const a=new URL(window.location.href),l=new URLSearchParams(a.search);if(l.delete(t.queryParams.sort),k.value){const v=(k.value.direction==="desc"?"-":"")+k.value.field;l.set(t.queryParams.sort,v)}const o=`${a.pathname}${l.toString()?"?"+l.toString():""}`;window.history.pushState({},"",o)}},g=e.ref(c(t.fields)),m=e.ref(t.data),V=e.ref(null),P=e.ref(t.initialPage),E=e.ref("17px"),h=e.ref(!1),n=e.ref({}),u=e.ref(0),w=e.ref(!0),k=e.ref(S()),y=e.ref(null),N=e.ref(0),I=e.useModel(t,"filterParams"),j=e.useModel(t,"perPage"),D=e.ref([]),O=e.ref(!1),M=e.ref(new Set),R=e.ref(null),F=e.ref(null),z=e.ref(!1),A=e.computed(()=>t.tableHeight!=null),U=e.computed(()=>{let a=g.value.filter(l=>l.visible).length;return t.selectable&&a++,t.hasDetailRow&&t.expandableRows&&a++,a}),J=e.computed(()=>{const a={};return t.shiftSelectHighlight&&(a["--dsg-shift-select-bg"]=t.shiftSelectHighlight),t.selectedRowHighlight&&(a["--dsg-selected-row-bg"]=t.selectedRowHighlight),Object.keys(a).length>0?a:void 0});e.watch(()=>D.value.length,a=>{O.value=t.selectable&&a>0},{immediate:!0}),e.watch(()=>t.fields,a=>{g.value=c(a)},{immediate:!0,deep:!0}),e.watch(()=>I.value,a=>{q()},{deep:!0}),e.watch(()=>j.value,()=>{q()}),e.watch(()=>t.apiUrl,(a,l)=>{t.apiMode&&a!==l&&a&&q()}),e.watch(()=>k.value,()=>{$()},{deep:!0});const T=f,X=(a,l)=>a.formatter&&typeof a.formatter=="function"?a.formatter(a,l):le.data_get(l,String(a?.name),""),Z=a=>"dsg-field--"+a.name?.toLowerCase().replaceAll(/[_ ]/g,"-"),_=(a,l)=>{const o={odd:l%2===0,even:l%2!==0,"row-selected":a.selected};if(!t.rowClass)return o;let v={};if(typeof t.rowClass=="function"){const d=t.rowClass(a,l);typeof d=="string"?d.split(" ").forEach(C=>{C.trim()&&(v[C.trim()]=!0)}):Array.isArray(d)?d.forEach(C=>{typeof C=="string"&&C.trim()&&(v[C.trim()]=!0)}):typeof d=="object"&&d!==null&&(v=d)}else typeof t.rowClass=="string"&&t.rowClass.split(" ").forEach(d=>{d.trim()&&(v[d.trim()]=!0)});return{...o,...v}},H=a=>M.value.has(a[t.trackBy]),K=(a,l)=>{const o=a[t.trackBy];M.value.has(o)?(M.value.delete(o),T("dsg-table:row-collapsed",a,l)):(t.expandMultiple||M.value.clear(),M.value.add(o),T("dsg-table:row-expanded",a,l))},ee=a=>{const l=a[t.trackBy];M.value.has(l)||(t.expandMultiple||M.value.clear(),M.value.add(l))},Q=a=>{M.value.delete(a[t.trackBy])},te=()=>{m.value?.forEach(a=>{M.value.add(a[t.trackBy])})},s=()=>{M.value.clear()},r=()=>M.value,i=(a,l)=>{if(t.selectable){if(l!==void 0&&(R.value=l),a.selected)D.value.push(a);else{const o=D.value.findIndex(v=>v[t.trackBy]===a[t.trackBy]);o!==-1&&D.value.splice(o,1)}T("dsg-table:rows-selected",D.value)}},b=(a,l,o)=>{if(t.selectable&&a.shiftKey&&R.value!==null){a.stopPropagation(),a.preventDefault();const v=Math.min(R.value,o),d=Math.max(R.value,o),C=!l.selected;for(let L=v;L<=d;L++){const W=m.value?.[L];if(W){const ge=W.selected;if(W.selected=C,C&&!ge)D.value.push(W);else if(!C&&ge){const fe=D.value.findIndex(qe=>qe[t.trackBy]===W[t.trackBy]);fe!==-1&&D.value.splice(fe,1)}}}R.value=o,F.value=null,T("dsg-table:rows-selected",D.value)}},B=()=>{t.selectable&&(m.value?.forEach(a=>{a.selected=!0}),D.value=m.value?.filter(a=>a.selected)??[],R.value=null,T("dsg-table:rows-selected",D.value))},ae=()=>{t.selectable&&(m.value?.forEach(a=>{a.selected=!1}),D.value=[],R.value=null,T("dsg-table:rows-selected",D.value))},Y=a=>{m.value=Array.isArray(a)?a:[],t.selectable&&(R.value=null,m.value.forEach(l=>{l.selected=l.selected??!1}))},De=()=>m.value??[],xe=a=>{a==="prev"?P.value>t.firstPage&&P.value--:a==="next"?P.value<(V.value?.last_page??0)&&P.value++:a!=P.value&&a>=t.firstPage&&a<=(V.value?.last_page??0)&&(P.value=a),q()},$e=()=>({[t.queryParams?.sort]:k.value?(k.value?.direction==="desc"?"-":"")+k.value?.field:void 0,[t.queryParams?.order]:k.value?.direction,[t.queryParams?.page]:P.value,[t.queryParams?.perPage]:j.value}),ne=()=>{y.value&&(y.value.abort(),y.value=null)},Ve=(a,l)=>{ne(),N.value++;const o=N.value,v=new AbortController;return l.signal=v.signal,y.value=v,(t.httpMethod.toLowerCase()==="get"?p.axios.get(a,l):(()=>{const C=l.params;return delete l.params,p.axios.post(a,C,l)})()).then(C=>({...C,_requestId:o,_apiUrl:a}),C=>{throw C.name==="AbortError"||C.code==="ERR_CANCELED"?{...C,_requestId:o,_cancelled:!0}:{...C,_requestId:o}})},oe=a=>{if(a._requestId&&a._requestId!==N.value||a._apiUrl&&a._apiUrl!==t.apiUrl)return;T("dsg-table:load-success",a);const l=t.transform?t.transform(a.data):a.data;m.value=le.data_get(l,t.dataPath,null),t.selectable&&(R.value=null,m.value?.forEach(o=>{o.selected=o.selected??!1})),V.value=le.data_get(l,t.paginationPath,null)??null,u.value=m.value?.length?m.value[0].order:u,!Ie.isEmpty(t.paginationPath)&&V.value===null&&console.warn('DsgTable: pagination-path "'+t.paginationPath+`" not found. It looks like the data returned from the server does not have pagination information or you may have set it incorrectly.
2
- You can explicitly suppress this warning by setting pagination-path="".`),y.value=null,T("dsg-table:pagination-data",V.value),V.value&&P.value>(V.value?.last_page||0)&&m.value?.length===0&&(P.value=t.initialPage,q()),T("dsg-table:loaded"),w.value=!1},se=a=>{a._requestId&&a._requestId!==N.value||a._apiUrl&&a._apiUrl!==t.apiUrl||a._cancelled||(console.error("load-error",a),y.value=null,T("dsg-table:load-error",a),T("dsg-table:loaded"),w.value=!1)},re=()=>{if(t.data!==null&&Array.isArray(t.data)){Y(t.data),w.value=!1;return}if(t.dataManager&&typeof t.dataManager=="function"){const a=t.dataManager();Y(a),w.value=!1}else Y(t.data),w.value=!1},q=(a=oe,l=se,o={})=>{const v=a||oe,d=l||se;if(!t.apiMode){re();return}return w.value=!0,T("dsg-table:loading",w.value),t.httpOptions.params={...$e(),...I.value},Ve(t.apiUrl,t.httpOptions).then(v).catch(C=>d(C))},Te=(a,l,o)=>{T("dsg-table:row-clicked",a,l,o)},Ne=(a,l,o)=>{T("dsg-table:row-dblclick",a,l,o)},Re=(a,l,o)=>{},Me=(a,l,o,v)=>{},Fe=(a,l,o,v)=>{},Le=(a,l,o,v)=>{},ze=(a,l,o)=>{},ie=a=>{a.key==="Shift"&&(z.value=!0)},de=a=>{a.key==="Shift"&&(z.value=!1,F.value=null)},ce=()=>{z.value=!1,F.value=null},He=a=>{t.selectable&&z.value&&R.value!==null&&(F.value=a)},Ae=()=>{F.value=null},Ue=a=>{if(!t.selectable||!z.value||R.value===null||F.value===null)return!1;const l=Math.min(R.value,F.value),o=Math.max(R.value,F.value);return a>=l&&a<=o};e.onMounted(()=>{t.apiMode===!0?q():re(),t.selectable&&(document.addEventListener("keydown",ie),document.addEventListener("keyup",de),window.addEventListener("blur",ce))}),e.onUnmounted(()=>{t.selectable&&(document.removeEventListener("keydown",ie),document.removeEventListener("keyup",de),window.removeEventListener("blur",ce))});const ue=()=>{t.apiMode&&(D.value=[],ne(),q())};return x({changePage:xe,reload:ue,getData:De,setData:Y,setLoading:a=>{w.value=a,T("dsg-table:loading",w.value)},expandRow:ee,collapseRow:Q,toggleRowExpand:K,expandAllRows:te,collapseAllRows:s,getExpandedRows:r,isRowExpanded:H}),(a,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["dsg-table--wrapper",{"dsg-table--shift-active":t.selectable&&z.value}]),style:e.normalizeStyle(J.value)},[e.createElementVNode("div",{ref:"dsgTableBodyWrapper",class:e.normalizeClass(["dsg-table-body-wrapper",{"fixed-header":A.value}]),style:e.normalizeStyle({height:t.tableHeight||void 0})},[e.createElementVNode("table",{class:e.normalizeClass(["dsg-table-main",A.value?"fixed-header":"",n.value.table,"table-"+t.tableLayout])},[e.createElementVNode("colgroup",{span:U.value},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,(o,v)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[o?.visible?(e.openBlock(),e.createElementBlock("col",{key:v,style:e.normalizeStyle({width:o.width||void 0}),class:e.normalizeClass("dsg-table--col-"+o.name+" "+o.titleClass)},null,6)):e.createCommentVNode("",!0)],64))),256)),!A.value&&h.value?(e.openBlock(),e.createElementBlock("col",{key:0,style:e.normalizeStyle({width:E.value}),class:"dsg-table--col-gutter"},null,4)):e.createCommentVNode("",!0)],8,bt),e.createElementVNode("thead",{class:e.normalizeClass([[n.value.thead,{sticky:A.value,"top-0":A.value}],"dsg-table--head"])},[e.renderSlot(a.$slots,"tableHeader",{fields:g.value},()=>[e.createVNode(ke,{fields:g.value,"has-select-all":t.selectable,"selected-rows":D.value,"onUpdate:selectedRows":l[0]||(l[0]=o=>D.value=o),"has-selected":O.value,"onUpdate:hasSelected":l[1]||(l[1]=o=>O.value=o),"scroll-visible":h.value,"show-expand-detail":t.hasDetailRow&&t.showExpandDetail,"table-data-length":m.value?.length,"sort-field":k.value,"onUpdate:sortField":l[2]||(l[2]=o=>k.value=o),"onDsgTable:sortField":l[3]||(l[3]=o=>ue()),"onDsgTable:onSelectAll":B,"onDsgTable:onDeselectAll":ae},null,8,["fields","has-select-all","selected-rows","has-selected","scroll-visible","show-expand-detail","table-data-length","sort-field"])])],2),e.createElementVNode("tbody",{class:e.normalizeClass(["dsg-table--body",n.value.tbody])},[w.value?(e.openBlock(),e.createElementBlock("tr",ht,[e.createElementVNode("td",{colspan:U.value},[e.createElementVNode("div",{"aria-label":"Loading...",role:"status",class:"flex items-center space-x-3 h-12 w-full justify-center",colspan:U.value},[e.renderSlot(a.$slots,"dsg-table-loading",{},()=>[e.createVNode(p._sfc_main,{icon:"loading-02",class:"animate-spin"}),l[5]||(l[5]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-500"},"Loading...",-1))])],8,wt)],8,kt)])):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(m.value,(o,v)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:v},[e.createElementVNode("tr",{class:e.normalizeClass(["dsg-table--tbody-row",[_(o,v),{"dsg-table--shift-range":t.selectable&&Ue(v)}]]),onClick:d=>Te(d,v,o),onDblclick:d=>Ne(d,v,o),onMouseover:d=>Re(),onMouseenter:d=>He(v),onMouseleave:l[4]||(l[4]=d=>Ae())},[t.selectable?(e.openBlock(),e.createElementBlock("td",{key:0,class:"dsg-table--tbody-cell dsg-table--tbody-cell-checkbox",onClickCapture:d=>b(d,o,v)},[e.createVNode(p._sfc_main$2,{modelValue:o.selected,"onUpdate:modelValue":[d=>o.selected=d,d=>i(o,v)]},null,8,["modelValue","onUpdate:modelValue"])],40,pt)):e.createCommentVNode("",!0),t.hasDetailRow&&t.expandableRows?(e.openBlock(),e.createElementBlock("td",Bt,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["dsg-table--expand-toggle",{"is-expanded":H(o)}]),"aria-expanded":H(o),"aria-label":"Toggle row details",onClick:e.withModifiers(d=>K(o,v),["stop"])},[e.createVNode(p._sfc_main,{icon:"chevron-right",size:"sm",class:"dsg-table--expand-icon"})],10,Ct)])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,(d,C)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:C},[d.visible?(e.openBlock(),e.createElementBlock("td",{key:0,class:e.normalizeClass(["dsg-table--tbody-cell",d.dataClass]),style:e.normalizeStyle({width:d.width||void 0}),onClick:L=>Me(),onDblclick:L=>Fe(),onContextmenu:L=>Le()},[e.renderSlot(a.$slots,Z(d),{rowData:o,rowIndex:v,rowField:d},()=>[e.createElementVNode("span",{innerHTML:X(d,o)},null,8,Et)])],46,St)):e.createCommentVNode("",!0)],64))),128))],42,yt),t.hasDetailRow&&(!t.expandableRows||H(o))?(e.openBlock(),e.createBlock(e.Transition,{key:0,name:t.detailRowTransition},{default:e.withCtx(()=>[e.createElementVNode("tr",{class:e.normalizeClass(["dsg-table--tbody-detail-row",{"is-expanded":t.expandableRows&&H(o)}]),onClick:d=>ze()},[e.createElementVNode("td",{colspan:U.value},[e.renderSlot(a.$slots,"dsg-table-detail-row",{rowData:o,rowIndex:v,options:t.detailRowOptions,isExpanded:t.expandableRows?H(o):!0})],8,Dt)],10,Pt)]),_:2},1032,["name"])):e.createCommentVNode("",!0)],64))),128)),!w.value&&!m.value?.length&&t.noDataTemplate.length?(e.openBlock(),e.createElementBlock("tr",xt,[e.createElementVNode("td",{colspan:U.value,class:"dsg-table--empty-result"},[e.renderSlot(a.$slots,"dsg-table-empty-result",{},()=>[e.createTextVNode(e.toDisplayString(t.noDataTemplate),1)])],8,$t)])):e.createCommentVNode("",!0)],2),e.createElementVNode("tfoot",Vt,[e.renderSlot(a.$slots,"dsg-table-footer",{fields:g.value,data:m.value})])],2)],6)],6))}}),Nt={class:"dsg-table"},Rt={key:0,class:"dsg-table--pre-header"},Mt={class:"dsg-table--pre-header-left"},Ft=["textContent"],Lt={class:"dsg-table--pre-header-right"},zt={key:1,class:"dsg-table--search-header",ref:"dsgTableSearchHeaderEl"},Ht={class:"dsg-table--search-top"},At={key:2,class:"dsg-table--footer",ref:"dsgTableFooterEl"},Ut={class:"dsg-table--footer-left"},qt={class:"dsg-table--footer-center"},It={class:"dsg-table--footer-right"},Ot=e.defineComponent({__name:"DsgTable",props:{getUrl:{},fields:{},loadOnStart:{type:Boolean,default:!0},displaySearch:{type:Boolean,default:!0},displayPaginationInfo:{type:Boolean,default:!0},reloadOnChangeTimer:{type:Boolean,default:!1},selectable:{type:Boolean,default:!1},shiftSelectHighlight:{default:()=>{}},selectedRowHighlight:{default:()=>{}},trackBy:{default:"id"},title:{default:""},filters:{default:()=>{}},initialFilters:{default:()=>({})},filterEntity:{default:""},filterEndpoint:{default:""},filterSearchEndpoint:{default:""},tableLayout:{default:"fixed"},autoSortFilters:{type:Boolean,default:!0},data:{default:null},hasHeader:{type:Boolean,default:!0},hasFooter:{type:Boolean,default:!0},perPage:{default:20},paginationPath:{default:"meta"},css:{default:()=>({tableWrapper:"border-b"})},rowClass:{type:[String,Function],default:void 0},apiMode:{type:Boolean,default:!0},replaceState:{type:Boolean,default:!0},replaceStrategy:{default:"window"},hasDetailRow:{type:Boolean,default:!1},expandableRows:{type:Boolean,default:!1},expandMultiple:{type:Boolean,default:!1},showExpandDetail:{type:Boolean,default:!0},detailRowTransition:{default:"fade"},detailRowOptions:{default:()=>({})}},emits:["dsg-table:action-edit","dsg-table:action-view","dsg-table:action-delete","dsg-table:action-archive","dsg-table:link-clicked","dsg-table:rows-selected","dsg-table:row-clicked","dsg-table:row-hover","dsg-table:row-dblclick","dsg-table:filter-updated","dsg-table:term-changed","dsg-table:data-loaded","dsg-table:row-expanded","dsg-table:row-collapsed"],setup(t,{expose:x,emit:f}){const c=s=>{w.value=s},S=e.ref(t.apiMode&&!!(t.filterEntity||t.filterEndpoint||t.getUrl)),$=()=>{if(S.value){let s={};return p.getQueryStrings().forEach(r=>{if(r.key.startsWith("filter[")){const i=r.key.replace("filter[","").replace("]",""),b=r.value;s[`filter[${i}]`]=b.join(",")}}),s}else return{}},g=e.computed(()=>({...t.css,tableWrapper:"border-b "+(t.css?.tableWrapper||"")})),m=e.useSlots(),V=e.ref(!0),P=e.ref(null),E=e.ref("<p>Showing {from} to {to} of {total}</p>"),h=e.ref(null),n=e.useTemplateRef("dsgTable"),u=e.ref({perPage:t.perPage,change:c}),w=e.ref(t.perPage),k=e.ref({...$(),...t.initialFilters}),y=f,N=s=>{n.value?.changePage(s)},I=s=>{h.value=s},j=({data:s})=>{P.value=s,y("dsg-table:data-loaded",s)},D=()=>{n.value?.reload()},O=s=>{n.value?.setLoading(s)},M=s=>{const r=n.value?.getData?.()??[];n.value?.setData(r.map(i=>i.id===s.id?s:i))},R=s=>{const r=n.value?.getData?.()??[];n.value?.setData([...r,s])},F=s=>{const r=n.value?.getData?.()??[];n.value?.setData(r.filter(i=>i.id!==s.id))},z=s=>{n.value?.setData(s)},A=()=>n.value?.getData()??[],U=s=>{const r=n.value?.getData()??[],i=s(r);i&&n.value?.setData(i)},J=s=>{n.value?.expandRow(s)},T=s=>{n.value?.collapseRow(s)},X=(s,r)=>{n.value?.toggleRowExpand(s,r)},Z=()=>{n.value?.expandAllRows()},_=()=>{n.value?.collapseAllRows()},H=()=>n.value?.getExpandedRows()??new Set,K=s=>{k.value=s},ee=()=>k.value??{},Q=s=>{const r={...k.value};!s||s.trim()===""?delete r["filter[term]"]:r["filter[term]"]=s,k.value=r,e.nextTick(()=>{D()}),y("dsg-table:term-changed",s)},te=(s,r,i)=>{let b={};k.value["filter[term]"]&&(b["filter[term]"]=k.value["filter[term]"]),Object.keys(s).forEach(B=>{s[B]!==null&&s[B]!==void 0&&s[B]!==""&&(b[B]=s[B])}),k.value=b,e.nextTick(()=>{D()}),y("dsg-table:filter-updated",k.value,r,i)};return x({reloadTable:D,updateRowTable:M,addRowTable:R,deleteRowTable:F,setData:z,getData:A,mutateData:U,termChanged:Q,setFilters:K,getFilters:ee,setLoading:O,expandRow:J,collapseRow:T,toggleRowExpand:X,expandAllRows:Z,collapseAllRows:_,getExpandedRows:H,changePage:N}),(s,r)=>(e.openBlock(),e.createElementBlock("div",Nt,[t.hasHeader?(e.openBlock(),e.createElementBlock("div",Rt,[e.renderSlot(s.$slots,"dsg-table--pre-header",{},()=>[e.createElementVNode("div",Mt,[e.renderSlot(s.$slots,"dsg-table--page-title",{data:P.value,title:t.title},()=>[t.title.length>0?(e.openBlock(),e.createElementBlock("h1",{key:0,class:"dsg-table--title",textContent:e.toDisplayString(t.title)},null,8,Ft)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Lt,[e.renderSlot(s.$slots,"dsg-table--page-actions",{data:P.value})])])])):e.createCommentVNode("",!0),t.displaySearch?(e.openBlock(),e.createElementBlock("div",zt,[e.createElementVNode("div",Ht,[e.renderSlot(s.$slots,"dsg-table--search-header",{data:P.value},()=>[e.createVNode(he,{name:"term","onDsgTable:termChanged":r[0]||(r[0]=i=>Q(i))}),e.createVNode(p._sfc_main$7,{entity:t.filterEntity,"filter-endpoint":t.filterEndpoint,"search-endpoint":t.filterSearchEndpoint,"auto-sort":t.autoSortFilters,filters:t.filters,"onDsgTable:filterUpdated":r[1]||(r[1]=(i,b,B)=>te(i,b,B))},null,8,["entity","filter-endpoint","search-endpoint","auto-sort","filters"]),e.renderSlot(s.$slots,"dsg-table--search-actions",{data:P.value})])]),e.renderSlot(s.$slots,"dsg-table--search-navigation")],512)):e.createCommentVNode("",!0),e.createVNode(Tt,{ref:"dsgTable","api-url":t.getUrl,"filter-params":k.value,"onUpdate:filterParams":r[7]||(r[7]=i=>k.value=i),"per-page":w.value,"onUpdate:perPage":r[8]||(r[8]=i=>w.value=i),fields:t.fields,"load-on-start":t.loadOnStart,"pagination-path":t.paginationPath,selectable:t.selectable,"shift-select-highlight":t.shiftSelectHighlight,"selected-row-highlight":t.selectedRowHighlight,"track-by":t.trackBy,"table-layout":t.tableLayout,css:g.value,data:t.data,"row-class":t.rowClass,"api-mode":S.value,"replace-state":t.replaceState,"replace-strategy":t.replaceStrategy,"has-detail-row":t.hasDetailRow,"expandable-rows":t.expandableRows,"expand-multiple":t.expandMultiple,"show-expand-detail":t.showExpandDetail,"detail-row-transition":t.detailRowTransition,"detail-row-options":t.detailRowOptions,"onDsgTable:loading":r[9]||(r[9]=i=>V.value=!0),"onDsgTable:loaded":r[10]||(r[10]=i=>V.value=!1),"onDsgTable:paginationData":I,"onDsgTable:loadSuccess":j,"onDsgTable:rowsSelected":r[11]||(r[11]=i=>y("dsg-table:rows-selected",i)),"onDsgTable:rowClicked":r[12]||(r[12]=(i,b,B)=>y("dsg-table:row-clicked",i,b,B)),"onDsgTable:rowHover":r[13]||(r[13]=(i,b,B)=>y("dsg-table:row-hover",i,b,B)),"onDsgTable:rowDblclick":r[14]||(r[14]=(i,b,B)=>y("dsg-table:row-dblclick",i,b,B)),"onDsgTable:rowExpanded":r[15]||(r[15]=(i,b)=>y("dsg-table:row-expanded",i,b)),"onDsgTable:rowCollapsed":r[16]||(r[16]=(i,b)=>y("dsg-table:row-collapsed",i,b))},e.createSlots({"dsg-field--actions":e.withCtx(i=>[e.renderSlot(s.$slots,"dsg-table-actions",{data:i},()=>[(e.openBlock(),e.createBlock(be,{key:i.rowIndex,data:i,"onDsgTable:actionEdit":r[2]||(r[2]=(b,B)=>y("dsg-table:action-edit",b,B)),"onDsgTable:actionView":r[3]||(r[3]=(b,B)=>y("dsg-table:action-view",b,B)),"onDsgTable:actionDelete":r[4]||(r[4]=(b,B)=>y("dsg-table:action-delete",b,B)),"onDsgTable:actionArchive":r[5]||(r[5]=(b,B)=>y("dsg-table:action-archive",b,B)),"onDsgTable:linkClicked":r[6]||(r[6]=(b,B,ae)=>y("dsg-table:link-clicked",b,B,ae))},null,8,["data"]))])]),_:2},[e.renderList(e.unref(m),(i,b)=>({name:b,fn:e.withCtx(B=>[String(b)!=="dsg-field--actions"?e.renderSlot(s.$slots,b,e.normalizeProps(e.mergeProps({key:0},B))):e.createCommentVNode("",!0)])}))]),1032,["api-url","filter-params","per-page","fields","load-on-start","pagination-path","selectable","shift-select-highlight","selected-row-highlight","track-by","table-layout","css","data","row-class","api-mode","replace-state","replace-strategy","has-detail-row","expandable-rows","expand-multiple","show-expand-detail","detail-row-transition","detail-row-options"]),t.hasFooter?(e.openBlock(),e.createElementBlock("div",At,[e.createElementVNode("div",Ut,[e.renderSlot(s.$slots,"dsg-table--footer-left",{data:h.value,perPage:u.value},()=>[t.displayPaginationInfo?(e.openBlock(),e.createBlock(ve,{key:0,ref:"paginationInfoStart",pagination:h.value,"onUpdate:pagination":r[17]||(r[17]=i=>h.value=i),"info-template":E.value},null,8,["pagination","info-template"])):e.createCommentVNode("",!0),e.renderSlot(s.$slots,"dsg-table--footer-left-extras",{data:h.value,perPage:u.value})])]),e.createElementVNode("div",qt,[e.renderSlot(s.$slots,"dsg-table--footer-center",{data:h.value,perPage:u.value},()=>[e.renderSlot(s.$slots,"dsg-table--footer-center-extras",{data:h.value,perPage:u.value})])]),e.createElementVNode("div",It,[e.renderSlot(s.$slots,"dsg-table--footer-right",{data:h.value,perPage:u.value},()=>[V.value===!1&&t.displayPaginationInfo?(e.openBlock(),e.createBlock(me,{key:0,ref:"pagination",pagination:h.value,"onUpdate:pagination":r[18]||(r[18]=i=>h.value=i),"onDsgTable:changePage":N},null,8,["pagination"])):e.createCommentVNode("",!0),e.renderSlot(s.$slots,"dsg-table--footer-right-extras",{data:h.value,perPage:u.value})])])],512)):e.createCommentVNode("",!0)]))}}),Wt={class:"dsg-table--per-page"},jt=["value","textContent"],Kt=e.defineComponent({__name:"DsgTablePerPage",props:{perPageOptions:{default:()=>[10,20,30,50,100]},perPage:{}},setup(t){return(x,f)=>(e.openBlock(),e.createElementBlock("div",Wt,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":f[0]||(f[0]=c=>t.perPage.perPage=c),class:"dsg-table--per-page-select",onChange:f[1]||(f[1]=c=>t.perPage.change(t.perPage.perPage))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.perPageOptions,c=>(e.openBlock(),e.createElementBlock("option",{key:c,value:c,textContent:e.toDisplayString(c)},null,8,jt))),128))],544),[[e.vModelSelect,t.perPage.perPage]])]))}}),we=Ot,ye=be,pe=Kt,Be=p._sfc_main$7,Ce=me,Se=ve,Ee=he,Pe=ke,Qt={DsgTable:we,DsgTableActions:ye,DsgTablePerPage:pe,DsgTableFilter:Be,DsgTablePagination:Ce,DsgTablePaginationInfo:Se,DsgTableSearch:Ee,DsgTableRowHeader:Pe};exports.DsgTable=we;exports.DsgTableActions=ye;exports.DsgTableFilter=Be;exports.DsgTablePagination=Ce;exports.DsgTablePaginationInfo=Se;exports.DsgTablePerPage=pe;exports.DsgTableRowHeader=Pe;exports.DsgTableSearch=Ee;exports.default=Qt;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),p=require("./DsgTablePerPage.vue_vue_type_style_index_0_lang-DPCoss-A.cjs"),G=require("./dsg-vue.helpers-string.cjs"),le=require("./dsg-vue.helpers-object.cjs"),Ie=require("./dsg-vue.helpers.cjs"),Oe={class:"dsg-table--pagination"},We=["disabled"],je=["disabled"],Ke=["onClick","innerHTML"],Qe=["onClick","innerHTML"],Ye=["disabled"],Ge=["disabled"],me=e.defineComponent({__name:"DsgTablePagination",props:e.mergeModels({onEachSide:{default:3},firstPage:{default:1},showFirstLast:{type:Boolean,default:!0},firstIcon:{default:"chevron-left-double"},lastIcon:{default:"chevron-right-double"},prevIcon:{default:"chevron-left"},nextIcon:{default:"chevron-right"}},{pagination:{default:null},paginationModifiers:{}}),emits:e.mergeModels(["dsg-table:change-page"],["update:pagination"]),setup(t,{expose:x,emit:f}){const c=e.useModel(t,"pagination"),S=e.computed(()=>c.value===null?0:c.value?.last_page-t.firstPage+1),$=e.computed(()=>c.value===null?0:c.value?.last_page),g=e.computed(()=>c.value===null?!1:c.value?.current_page===t.firstPage),m=e.computed(()=>c.value===null?!1:c.value?.current_page===$.value),V=e.computed(()=>S.value<t.onEachSide*2+4),P=e.computed(()=>t.onEachSide*2+1),E=e.computed(()=>!c.value||c.value?.current_page<=t.onEachSide?1:c.value?.current_page>=S.value-t.onEachSide?S.value-t.onEachSide*2:c.value?.current_page-t.onEachSide),h=f,n=w=>{h("dsg-table:change-page",w)},u=w=>w===c.value?.current_page;return x({loadPage:n}),(w,k)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",Oe,[t.showFirstLast?(e.openBlock(),e.createElementBlock("a",{key:0,onClick:k[0]||(k[0]=y=>n(t.firstPage)),class:e.normalizeClass([[g.value?"disabled":""],"dsg-table--pagination-link"]),disabled:g.value,title:"First","aria-label":"First"},[e.createVNode(p._sfc_main,{icon:t.firstIcon,size:"sm"},null,8,["icon"])],10,We)):e.createCommentVNode("",!0),e.createElementVNode("a",{onClick:k[1]||(k[1]=y=>n("prev")),class:e.normalizeClass([[g.value?"disabled":""],"dsg-table--pagination-link"]),disabled:g.value,title:"Previous","aria-label":"Previous"},[e.createVNode(p._sfc_main,{icon:t.prevIcon,size:"sm"},null,8,["icon"])],10,je),V.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(S.value,(y,R)=>(e.openBlock(),e.createElementBlock("a",{key:R,onClick:I=>n(R+t.firstPage),class:e.normalizeClass([[u(R+t.firstPage)?"active":""],"dsg-table--pagination-link"]),innerHTML:y},null,10,Ke))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:2},e.renderList(P.value,(y,R)=>(e.openBlock(),e.createElementBlock("a",{key:R,onClick:I=>n(E.value+R+t.firstPage-1),class:e.normalizeClass([[u(E.value+R+t.firstPage-1)?"active":""],"dsg-table--pagination-link"]),innerHTML:E.value+y-1},null,10,Qe))),128)),e.createElementVNode("a",{onClick:k[2]||(k[2]=y=>n("next")),class:e.normalizeClass([[m.value?"disabled":""],"dsg-table--pagination-link"]),disabled:m.value,title:"Next","aria-label":"Next"},[e.createVNode(p._sfc_main,{icon:t.nextIcon,size:"sm"},null,8,["icon"])],10,Ye),t.showFirstLast?(e.openBlock(),e.createElementBlock("a",{key:3,onClick:k[3]||(k[3]=y=>n($.value)),class:e.normalizeClass([[m.value?"disabled":""],"dsg-table--pagination-link"]),disabled:m.value,title:"Last","aria-label":"Last"},[e.createVNode(p._sfc_main,{icon:t.lastIcon,size:"sm"},null,8,["icon"])],10,Ge)):e.createCommentVNode("",!0)],512)),[[e.vShow,c.value&&$.value>t.firstPage]])}}),Je=["innerHTML"],ve=e.defineComponent({__name:"DsgTablePaginationInfo",props:e.mergeModels({infoTemplate:{default:"Displaying {from} to {to} of {total} items"},noDataTemplate:{default:"No relevant data"}},{pagination:{default:null},paginationModifiers:{}}),emits:["update:pagination"],setup(t){const x=e.useModel(t,"pagination"),f=e.computed(()=>x.value==null||x.value.total==0?t.noDataTemplate:t.infoTemplate.replace("{from}",(x.value?.from||0).toString()).replace("{to}",(x.value?.to||0).toString()).replace("{total}",(x.value?.total||0).toString()));return(c,S)=>(e.openBlock(),e.createElementBlock("div",{class:"dsg-table--pagination-info",innerHTML:f.value},null,8,Je))}}),Xe={class:"dsg-table--actions",ref:"dsgTableActions"},Ze={class:"dsg-table--action-trigger"},_e={key:0,class:"dsg-table--actions-menu-wrapper"},et=["href","target","onClick"],tt=["textContent"],at={key:0},lt={key:1},nt=["href","target","onClick"],ot={class:"flex-1"},be=e.defineComponent({__name:"DsgTableActions",props:{placement:{default:"auto"}},emits:["dsg-table:action-edit","dsg-table:action-view","dsg-table:action-delete","dsg-table:action-archive","dsg-table:link-clicked"],setup(t,{emit:x}){const f=e.ref(!1);e.useTemplateRef("dsgTableActions");const c=e.useAttrs(),S=e.ref(c.data.rowData?.actions??null),$=e.ref(c.data.rowData?.links??null),g=e.ref(c.data.rowData??null),m=h=>{switch(h){case"edit":return"edit-05";case"view":return"eye";case"delete":return"trash-01";case"archive":return"eye-off";default:return"dots-horizontal"}},V=(h,n,u)=>{switch(n){case"edit":E("dsg-table:action-edit",u,g.value);break;case"view":E("dsg-table:action-view",u,g.value);break;case"delete":E("dsg-table:action-delete",u,g.value);break;case"archive":E("dsg-table:action-archive",u,g.value);break}},P=(h,n)=>{const u=h.actionId||h.label.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-");E("dsg-table:link-clicked",n,u,g.value)},E=x;return(h,n)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",Xe,[e.createVNode(e.unref(p.kt),{triggers:[],placement:t.placement,"handle-resize":!0,strategy:"absolute",shown:f.value,class:"dsg-table--actions__popper",onHide:n[1]||(n[1]=u=>f.value=!1),ref:"floatingVueFilterDropdown"},{popper:e.withCtx(()=>[f.value?(e.openBlock(),e.createElementBlock("div",_e,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.value,(u,w)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[["edit","view","delete","archive"].includes(String(w))?(e.openBlock(),e.createElementBlock("a",{key:w,href:u?.link,target:u?.target||"_self",onClick:k=>V(u,String(w),k)},[e.createElementVNode("div",{class:e.normalizeClass(["dsg-table--actions-menu-item",String(w)])},[e.createVNode(p._sfc_main,{icon:m(String(w)),size:"sm"},null,8,["icon"]),e.createElementVNode("span",{class:"flex-1",textContent:e.toDisplayString(e.unref(G.ucfirst)(String(w)))},null,8,tt)],2)],8,et)):e.createCommentVNode("",!0)],64))),256)),S.value&&$.value?(e.openBlock(),e.createElementBlock("hr",at)):e.createCommentVNode("",!0),$.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList($.value,u=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:u.label},[u.hasOwnProperty("component")?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(u.component),{key:0,quote:e.unref(c).data.data.rowData,"row-data":e.unref(c).data.data.rowData},null,8,["quote","row-data"])):u.hasOwnProperty("type")&&u.type=="break"?(e.openBlock(),e.createElementBlock("hr",lt)):(e.openBlock(),e.createElementBlock("a",{key:2,href:u.link,target:u.target||"_self",class:e.normalizeClass(["dsg-table--actions-menu-item",u.class]),onClick:w=>P(u,w)},[u.icon?(e.openBlock(),e.createBlock(p._sfc_main,{key:0,icon:u.icon,size:"sm"},null,8,["icon"])):e.createCommentVNode("",!0),e.createElementVNode("span",ot,e.toDisplayString(u.label),1)],10,nt))],64))),128)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]),default:e.withCtx(()=>[e.createElementVNode("div",Ze,[e.createElementVNode("button",{type:"button",class:"dsg-table--actions-button","aria-expanded":"false","aria-haspopup":"true",onClick:n[0]||(n[0]=u=>f.value=!f.value)},[e.renderSlot(h.$slots,"dsg-table-action-button-content",{},()=>[e.createVNode(p._sfc_main,{icon:"dots-vertical",size:"sm"})])])])]),_:3},8,["placement","shown"])])),[[e.unref(p.vOnClickOutside),()=>f.value=!1]])}}),st={class:"dsg-table--search"},he=e.defineComponent({__name:"DsgTableSearch",props:{name:{},id:{},placeholder:{default:"Search"},disabled:{type:Boolean,default:!1},required:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},hidden:{type:Boolean,default:!1},extraClasses:{},eventName:{},replaceState:{type:Boolean,default:!0}},emits:["dsg-table:term-changed"],setup(t,{emit:x}){const f=e.ref("");e.onMounted(()=>{const g=new URL(window.location.href).searchParams.get("term");g&&(f.value=g,c("dsg-table:term-changed",g))});const c=x,S=p.useDebounceFn($=>{if(f.value=$,t.replaceState){const g=new URL(window.location.href);f.value?g.searchParams.set("term",f.value):g.searchParams.delete("term"),window.history.pushState({},"",g.toString())}c("dsg-table:term-changed",f.value)},300);return($,g)=>(e.openBlock(),e.createElementBlock("div",st,[e.createVNode(p._sfc_main$4,{modelValue:f.value,"onUpdate:modelValue":g[0]||(g[0]=m=>f.value=m),name:t.name,id:t.id||t.name,placeholder:t.placeholder,disabled:t.disabled,required:t.required,readonly:t.readonly,hidden:t.hidden,"has-clear-button":!0,autocomplete:"off",size:"sm",icon:"search-sm","icon-clickable":!0,onIconClicked:g[1]||(g[1]=m=>e.unref(S)(m)),onEnterPressed:g[2]||(g[2]=m=>e.unref(S)(m)),onOnClear:g[3]||(g[3]=()=>e.unref(S)(""))},null,8,["modelValue","name","id","placeholder","disabled","required","readonly","hidden"])]))}}),rt={class:"dsg-table--header-row"},it={key:0,class:"dsg-table--th dsg-table--th-checkbox",scope:"col"},dt={key:1,class:"dsg-table--th dsg-table--th-expand-detail",scope:"col"},ct=["title","id","onClick"],ut={key:0,class:"dsg-table--th-sort-icon"},gt=["innerHTML"],ft=["innerHTML"],mt=["innerHTML"],vt=["innerHTML"],ke=e.defineComponent({__name:"DsgTableRowHeader",props:e.mergeModels({fields:{},scrollVisible:{type:Boolean},hasSelectAll:{type:Boolean,default:!1},showExpandDetail:{type:Boolean,default:!0},tableDataLength:{default:0}},{sortField:{default:null},sortFieldModifiers:{},selectedRows:{default:[]},selectedRowsModifiers:{},hasSelected:{type:Boolean,default:!1},hasSelectedModifiers:{}}),emits:e.mergeModels(["dsg-table:sort-field","dsg-table:on-select-all","dsg-table:on-deselect-all"],["update:sortField","update:selectedRows","update:hasSelected"]),setup(t,{emit:x}){const f=e.useModel(t,"sortField"),c=e.useModel(t,"selectedRows"),S=e.useModel(t,"hasSelected"),$=e.ref("17px"),g=E=>{S.value&&c.value.length>0&&c.value.length!==t.tableDataLength?(S.value=!0,m("dsg-table:on-select-all")):!S.value&&c.value.length===0?(S.value=!1,m("dsg-table:on-select-all")):m("dsg-table:on-deselect-all")},m=x,V=(E,h)=>[E,E+"-"+G.toSnakeCase(String(h?.name)),h.titleClass||"",{sortable:h.sortable},{"sort-active":f.value?.name===h.name}],P=E=>{E.sortable&&(f.value={name:String(E?.name),field:String(E?.sortField),direction:f.value?.name===E.name&&f.value?.direction==="asc"?"desc":"asc"},m("dsg-table:sort-field",E))};return(E,h)=>(e.openBlock(),e.createElementBlock("tr",rt,[t.hasSelectAll?(e.openBlock(),e.createElementBlock("th",it,[e.createVNode(p._sfc_main$2,{modelValue:S.value,"onUpdate:modelValue":[h[0]||(h[0]=n=>S.value=n),g],indeterminate:c.value.length>0&&c.value.length!==t.tableDataLength},null,8,["modelValue","indeterminate"])])):e.createCommentVNode("",!0),t.showExpandDetail?(e.openBlock(),e.createElementBlock("th",dt)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.fields,(n,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[n?.visible?(e.openBlock(),e.createElementBlock("th",{key:u,class:e.normalizeClass(V("dsg-table--th",n)),style:e.normalizeStyle([{width:n.width||void 0},n.style]),title:n.title+(n.sortable?" Sort":""),id:"_"+n.name,onClick:w=>P(n),scope:"col"},[n.sortable?(e.openBlock(),e.createElementBlock("div",ut,[n.tooltip?(e.openBlock(),e.createBlock(p._sfc_main$1,e.mergeProps({key:0,ref_for:!0},n.tooltip,{class:"dsg-table--th-tooltip"}),{"dsg-tooltip--trigger":e.withCtx(()=>[n.title?(e.openBlock(),e.createElementBlock("span",{key:0,class:"dsg-table--th-title",innerHTML:n.title},null,8,gt)):e.createCommentVNode("",!0),n.tooltip.icon?(e.openBlock(),e.createBlock(p._sfc_main,{key:1,icon:n.tooltip.icon,class:"inline-flex",size:"xs"},null,8,["icon"])):e.createCommentVNode("",!0)]),_:2},1040)):n.title?(e.openBlock(),e.createElementBlock("span",{key:1,class:"dsg-table--th-title",innerHTML:n.title},null,8,ft)):e.createCommentVNode("",!0),n.sortable&&f.value?.name!==n.name?(e.openBlock(),e.createBlock(p._sfc_main,{key:2,icon:"chevron-selector-vertical",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0),n.sortable&&f.value?.name===n.name&&f.value?.direction==="asc"?(e.openBlock(),e.createBlock(p._sfc_main,{key:3,icon:"chevron-down",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0),n.sortable&&f.value?.name===n.name&&f.value?.direction==="desc"?(e.openBlock(),e.createBlock(p._sfc_main,{key:4,icon:"chevron-up",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[n.tooltip?(e.openBlock(),e.createBlock(p._sfc_main$1,e.mergeProps({key:0,ref_for:!0},n.tooltip,{class:"dsg-table--th-tooltip"}),{"dsg-tooltip--trigger":e.withCtx(()=>[e.createElementVNode("span",{class:"dsg-table--th-title",innerHTML:e.unref(G.ucwords)(String(n?.title))},null,8,mt),n.tooltip.icon?(e.openBlock(),e.createBlock(p._sfc_main,{key:0,icon:n.tooltip.icon,class:"inline-flex",size:"xs"},null,8,["icon"])):e.createCommentVNode("",!0)]),_:2},1040)):(e.openBlock(),e.createElementBlock("span",{key:1,class:"dsg-table--th-title",innerHTML:e.unref(G.ucwords)(String(n?.title))},null,8,vt))],64))],14,ct)):e.createCommentVNode("",!0)],64))),256)),t.scrollVisible?(e.openBlock(),e.createElementBlock("th",{key:2,style:e.normalizeStyle({width:$.value}),class:"dsg-table--th-col-gutter"},null,4)):e.createCommentVNode("",!0)]))}}),bt=["span"],ht={key:0,class:"dsg-table--loading"},kt=["colspan"],wt=["colspan"],yt=["onClick","onDblclick","onMouseover","onMouseenter"],pt=["onClickCapture"],Bt={key:1,class:"dsg-table--tbody-cell dsg-table--tbody-cell-expand"},Ct=["aria-expanded","onClick"],St=["onClick","onDblclick","onContextmenu"],Et=["innerHTML"],Pt=["onClick"],Dt=["colspan"],xt={key:2},$t=["colspan"],Vt={class:"dsg-table--footer"},Tt=e.defineComponent({__name:"DsgTableComponent",props:e.mergeModels({fields:{default:()=>[]},isDraggable:{type:Boolean,default:!1},dragApi:{default:""},loadOnStart:{type:Boolean,default:!0},apiUrl:{default:""},httpMethod:{default:"get"},reactiveApiUrl:{type:Boolean,default:!0},apiMode:{type:Boolean,default:!0},data:{default:null},dataManager:{type:[Function,null],default:null},dataPath:{default:"data"},tableLayout:{default:"fixed"},paginationPath:{default:"links.pagination"},queryParams:{default:()=>({sort:"sort",order:"order",page:"page",perPage:"per_page"})},httpOptions:{default:()=>({})},hasDetailRow:{type:Boolean,default:!1},showExpandDetail:{type:Boolean,default:!0},expandableRows:{type:Boolean,default:!1},expandMultiple:{type:Boolean,default:!1},initialPage:{default:1},firstPage:{default:1},sortOrder:{default:()=>[]},multiSort:{type:Boolean},tableHeight:{default:null},multiSortKey:{},rowClass:{type:[String,Function],default:""},detailRowComponent:{},detailRowTransition:{default:"fade"},detailRowClass:{type:[String,Function]},detailRowOptions:{default:()=>({})},trackBy:{default:"id"},css:{default:()=>({tableWrapper:"dsg-table-wrapper",thead:"dsg-table-thead",tbody:"dsg-table-tbody",table:"dsg-table-component"})},minRows:{default:0},noDataTemplate:{default:"No Data Available"},showSortIcons:{type:Boolean},headerRows:{},transform:{type:[Function,null],default:null},sortParams:{type:[Function,null],default:null},fieldPrefix:{},eventPrefix:{},selectable:{type:Boolean,default:!1},shiftSelectHighlight:{default:()=>{}},selectedRowHighlight:{default:()=>{}},replaceState:{type:Boolean,default:!0},replaceStrategy:{default:"window"}},{filterParams:{default:{}},filterParamsModifiers:{},perPage:{default:20},perPageModifiers:{}}),emits:e.mergeModels(["dsg-table:loading","dsg-table:loaded","dsg-table:load-success","dsg-table:load-error","dsg-table:pagination-data","dsg-table:rows-selected","dsg-table:row-clicked","dsg-table:row-hover","dsg-table:row-dblclick","dsg-table:row-expanded","dsg-table:row-collapsed"],["update:filterParams","update:perPage"]),setup(t,{expose:x,emit:f}){const c=a=>a.map((l,o)=>({field:l.field||"",title:l.title||"",name:l.name||"",titleClass:l.titleClass||"",dataClass:l.dataClass||"",visible:l.visible??!0,width:l.width||void 0,sortField:l.sortField||null,sortable:l.sortField,formatter:l.formatter||null,tooltip:l.tooltip??null,$_index:o})),S=()=>{if(!t.apiMode)return null;const l=p.getQueryStrings().find(o=>o.key===t.queryParams.sort);if(l&&l.value.length>0){const o=l.value[0],v=o.startsWith("-"),d=v?o.substring(1):o,C=t.fields.find(F=>F.sortField===d||F.name===d||F.field===d);return C?{name:String(C.name||C.field),field:d,direction:v?"desc":"asc"}:{name:d,field:d,direction:v?"desc":"asc"}}return null},$=()=>{if(!(!t.apiMode||!t.replaceState)&&t.replaceStrategy==="window"){const a=new URL(window.location.href),l=new URLSearchParams(a.search);if(l.delete(t.queryParams.sort),k.value){const v=(k.value.direction==="desc"?"-":"")+k.value.field;l.set(t.queryParams.sort,v)}const o=`${a.pathname}${l.toString()?"?"+l.toString():""}`;window.history.pushState({},"",o)}},g=e.ref(c(t.fields)),m=e.ref(t.data),V=e.ref(null),P=e.ref(t.initialPage),E=e.ref("17px"),h=e.ref(!1),n=e.ref({}),u=e.ref(0),w=e.ref(!0),k=e.ref(S()),y=e.ref(null),R=e.ref(0),I=e.useModel(t,"filterParams"),j=e.useModel(t,"perPage"),D=e.ref([]),O=e.ref(!1),M=e.ref(new Set),N=e.ref(null),L=e.ref(null),z=e.ref(!1),A=e.computed(()=>t.tableHeight!=null),U=e.computed(()=>{let a=g.value.filter(l=>l.visible).length;return t.selectable&&a++,t.hasDetailRow&&t.expandableRows&&a++,a}),J=e.computed(()=>{const a={};return t.shiftSelectHighlight&&(a["--dsg-shift-select-bg"]=t.shiftSelectHighlight),t.selectedRowHighlight&&(a["--dsg-selected-row-bg"]=t.selectedRowHighlight),Object.keys(a).length>0?a:void 0});e.watch(()=>D.value.length,a=>{O.value=t.selectable&&a>0},{immediate:!0}),e.watch(()=>t.fields,a=>{g.value=c(a)},{immediate:!0,deep:!0}),e.watch(()=>I.value,a=>{q()},{deep:!0}),e.watch(()=>j.value,()=>{q()}),e.watch(()=>t.apiUrl,(a,l)=>{t.apiMode&&a!==l&&a&&q()}),e.watch(()=>k.value,()=>{$()},{deep:!0});const T=f,X=(a,l)=>a.formatter&&typeof a.formatter=="function"?a.formatter(a,l):le.data_get(l,String(a?.name),""),Z=a=>"dsg-field--"+a.name?.toLowerCase().replaceAll(/[_ ]/g,"-"),_=(a,l)=>{const o={odd:l%2===0,even:l%2!==0,"row-selected":a.selected};if(!t.rowClass)return o;let v={};if(typeof t.rowClass=="function"){const d=t.rowClass(a,l);typeof d=="string"?d.split(" ").forEach(C=>{C.trim()&&(v[C.trim()]=!0)}):Array.isArray(d)?d.forEach(C=>{typeof C=="string"&&C.trim()&&(v[C.trim()]=!0)}):typeof d=="object"&&d!==null&&(v=d)}else typeof t.rowClass=="string"&&t.rowClass.split(" ").forEach(d=>{d.trim()&&(v[d.trim()]=!0)});return{...o,...v}},H=a=>M.value.has(a[t.trackBy]),K=(a,l)=>{const o=a[t.trackBy];M.value.has(o)?(M.value.delete(o),T("dsg-table:row-collapsed",a,l)):(t.expandMultiple||M.value.clear(),M.value.add(o),T("dsg-table:row-expanded",a,l))},ee=a=>{const l=a[t.trackBy];M.value.has(l)||(t.expandMultiple||M.value.clear(),M.value.add(l))},Q=a=>{M.value.delete(a[t.trackBy])},te=()=>{m.value?.forEach(a=>{M.value.add(a[t.trackBy])})},s=()=>{M.value.clear()},r=()=>M.value,i=(a,l)=>{if(t.selectable){if(l!==void 0&&(N.value=l),a.selected)D.value.push(a);else{const o=D.value.findIndex(v=>v[t.trackBy]===a[t.trackBy]);o!==-1&&D.value.splice(o,1)}T("dsg-table:rows-selected",D.value)}},b=(a,l,o)=>{if(t.selectable&&a.shiftKey&&N.value!==null){a.stopPropagation(),a.preventDefault();const v=Math.min(N.value,o),d=Math.max(N.value,o),C=!l.selected;for(let F=v;F<=d;F++){if(F===N.value)continue;const W=m.value?.[F];if(W){const ge=W.selected;if(W.selected=C,C&&!ge)D.value.push(W);else if(!C&&ge){const fe=D.value.findIndex(qe=>qe[t.trackBy]===W[t.trackBy]);fe!==-1&&D.value.splice(fe,1)}}}N.value=o,L.value=null,T("dsg-table:rows-selected",D.value)}},B=()=>{t.selectable&&(m.value?.forEach(a=>{a.selected=!0}),D.value=m.value?.filter(a=>a.selected)??[],N.value=null,T("dsg-table:rows-selected",D.value))},ae=()=>{t.selectable&&(m.value?.forEach(a=>{a.selected=!1}),D.value=[],N.value=null,T("dsg-table:rows-selected",D.value))},Y=a=>{m.value=Array.isArray(a)?a:[],t.selectable&&(N.value=null,m.value.forEach(l=>{l.selected=l.selected??!1}))},De=()=>m.value??[],xe=a=>{a==="prev"?P.value>t.firstPage&&P.value--:a==="next"?P.value<(V.value?.last_page??0)&&P.value++:a!=P.value&&a>=t.firstPage&&a<=(V.value?.last_page??0)&&(P.value=a),q()},$e=()=>({[t.queryParams?.sort]:k.value?(k.value?.direction==="desc"?"-":"")+k.value?.field:void 0,[t.queryParams?.order]:k.value?.direction,[t.queryParams?.page]:P.value,[t.queryParams?.perPage]:j.value}),ne=()=>{y.value&&(y.value.abort(),y.value=null)},Ve=(a,l)=>{ne(),R.value++;const o=R.value,v=new AbortController;return l.signal=v.signal,y.value=v,(t.httpMethod.toLowerCase()==="get"?p.axios.get(a,l):(()=>{const C=l.params;return delete l.params,p.axios.post(a,C,l)})()).then(C=>({...C,_requestId:o,_apiUrl:a}),C=>{throw C.name==="AbortError"||C.code==="ERR_CANCELED"?{...C,_requestId:o,_cancelled:!0}:{...C,_requestId:o}})},oe=a=>{if(a._requestId&&a._requestId!==R.value||a._apiUrl&&a._apiUrl!==t.apiUrl)return;T("dsg-table:load-success",a);const l=t.transform?t.transform(a.data):a.data;m.value=le.data_get(l,t.dataPath,null),t.selectable&&(N.value=null,m.value?.forEach(o=>{o.selected=o.selected??!1})),V.value=le.data_get(l,t.paginationPath,null)??null,u.value=m.value?.length?m.value[0].order:u,!Ie.isEmpty(t.paginationPath)&&V.value===null&&console.warn('DsgTable: pagination-path "'+t.paginationPath+`" not found. It looks like the data returned from the server does not have pagination information or you may have set it incorrectly.
2
+ You can explicitly suppress this warning by setting pagination-path="".`),y.value=null,T("dsg-table:pagination-data",V.value),V.value&&P.value>(V.value?.last_page||0)&&m.value?.length===0&&(P.value=t.initialPage,q()),T("dsg-table:loaded"),w.value=!1},se=a=>{a._requestId&&a._requestId!==R.value||a._apiUrl&&a._apiUrl!==t.apiUrl||a._cancelled||(console.error("load-error",a),y.value=null,T("dsg-table:load-error",a),T("dsg-table:loaded"),w.value=!1)},re=()=>{if(t.data!==null&&Array.isArray(t.data)){Y(t.data),w.value=!1;return}if(t.dataManager&&typeof t.dataManager=="function"){const a=t.dataManager();Y(a),w.value=!1}else Y(t.data),w.value=!1},q=(a=oe,l=se,o={})=>{const v=a||oe,d=l||se;if(!t.apiMode){re();return}return w.value=!0,T("dsg-table:loading",w.value),t.httpOptions.params={...$e(),...I.value},Ve(t.apiUrl,t.httpOptions).then(v).catch(C=>d(C))},Te=(a,l,o)=>{T("dsg-table:row-clicked",a,l,o)},Ne=(a,l,o)=>{T("dsg-table:row-dblclick",a,l,o)},Re=(a,l,o)=>{},Me=(a,l,o,v)=>{},Fe=(a,l,o,v)=>{},Le=(a,l,o,v)=>{},ze=(a,l,o)=>{},ie=a=>{a.key==="Shift"&&(z.value=!0)},de=a=>{a.key==="Shift"&&(z.value=!1,L.value=null)},ce=()=>{z.value=!1,L.value=null},He=a=>{t.selectable&&z.value&&N.value!==null&&(L.value=a)},Ae=()=>{L.value=null},Ue=a=>{if(!t.selectable||!z.value||N.value===null||L.value===null)return!1;const l=Math.min(N.value,L.value),o=Math.max(N.value,L.value);return a>=l&&a<=o};e.onMounted(()=>{t.apiMode===!0?q():re(),t.selectable&&(document.addEventListener("keydown",ie),document.addEventListener("keyup",de),window.addEventListener("blur",ce))}),e.onUnmounted(()=>{t.selectable&&(document.removeEventListener("keydown",ie),document.removeEventListener("keyup",de),window.removeEventListener("blur",ce))});const ue=()=>{t.apiMode&&(D.value=[],ne(),q())};return x({changePage:xe,reload:ue,getData:De,setData:Y,setLoading:a=>{w.value=a,T("dsg-table:loading",w.value)},expandRow:ee,collapseRow:Q,toggleRowExpand:K,expandAllRows:te,collapseAllRows:s,getExpandedRows:r,isRowExpanded:H}),(a,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["dsg-table--wrapper",{"dsg-table--shift-active":t.selectable&&z.value}]),style:e.normalizeStyle(J.value)},[e.createElementVNode("div",{ref:"dsgTableBodyWrapper",class:e.normalizeClass(["dsg-table-body-wrapper",{"fixed-header":A.value}]),style:e.normalizeStyle({height:t.tableHeight||void 0})},[e.createElementVNode("table",{class:e.normalizeClass(["dsg-table-main",A.value?"fixed-header":"",n.value.table,"table-"+t.tableLayout])},[e.createElementVNode("colgroup",{span:U.value},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,(o,v)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[o?.visible?(e.openBlock(),e.createElementBlock("col",{key:v,style:e.normalizeStyle({width:o.width||void 0}),class:e.normalizeClass("dsg-table--col-"+o.name+" "+o.titleClass)},null,6)):e.createCommentVNode("",!0)],64))),256)),!A.value&&h.value?(e.openBlock(),e.createElementBlock("col",{key:0,style:e.normalizeStyle({width:E.value}),class:"dsg-table--col-gutter"},null,4)):e.createCommentVNode("",!0)],8,bt),e.createElementVNode("thead",{class:e.normalizeClass([[n.value.thead,{sticky:A.value,"top-0":A.value}],"dsg-table--head"])},[e.renderSlot(a.$slots,"tableHeader",{fields:g.value},()=>[e.createVNode(ke,{fields:g.value,"has-select-all":t.selectable,"selected-rows":D.value,"onUpdate:selectedRows":l[0]||(l[0]=o=>D.value=o),"has-selected":O.value,"onUpdate:hasSelected":l[1]||(l[1]=o=>O.value=o),"scroll-visible":h.value,"show-expand-detail":t.hasDetailRow&&t.showExpandDetail,"table-data-length":m.value?.length,"sort-field":k.value,"onUpdate:sortField":l[2]||(l[2]=o=>k.value=o),"onDsgTable:sortField":l[3]||(l[3]=o=>ue()),"onDsgTable:onSelectAll":B,"onDsgTable:onDeselectAll":ae},null,8,["fields","has-select-all","selected-rows","has-selected","scroll-visible","show-expand-detail","table-data-length","sort-field"])])],2),e.createElementVNode("tbody",{class:e.normalizeClass(["dsg-table--body",n.value.tbody])},[w.value?(e.openBlock(),e.createElementBlock("tr",ht,[e.createElementVNode("td",{colspan:U.value},[e.createElementVNode("div",{"aria-label":"Loading...",role:"status",class:"flex items-center space-x-3 h-12 w-full justify-center",colspan:U.value},[e.renderSlot(a.$slots,"dsg-table-loading",{},()=>[e.createVNode(p._sfc_main,{icon:"loading-02",class:"animate-spin"}),l[5]||(l[5]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-500"},"Loading...",-1))])],8,wt)],8,kt)])):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(m.value,(o,v)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:v},[e.createElementVNode("tr",{class:e.normalizeClass(["dsg-table--tbody-row",[_(o,v),{"dsg-table--shift-range":t.selectable&&Ue(v)}]]),onClick:d=>Te(d,v,o),onDblclick:d=>Ne(d,v,o),onMouseover:d=>Re(),onMouseenter:d=>He(v),onMouseleave:l[4]||(l[4]=d=>Ae())},[t.selectable?(e.openBlock(),e.createElementBlock("td",{key:0,class:"dsg-table--tbody-cell dsg-table--tbody-cell-checkbox",onClickCapture:d=>b(d,o,v)},[e.createVNode(p._sfc_main$2,{modelValue:o.selected,"onUpdate:modelValue":[d=>o.selected=d,d=>i(o,v)]},null,8,["modelValue","onUpdate:modelValue"])],40,pt)):e.createCommentVNode("",!0),t.hasDetailRow&&t.expandableRows?(e.openBlock(),e.createElementBlock("td",Bt,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["dsg-table--expand-toggle",{"is-expanded":H(o)}]),"aria-expanded":H(o),"aria-label":"Toggle row details",onClick:e.withModifiers(d=>K(o,v),["stop"])},[e.createVNode(p._sfc_main,{icon:"chevron-right",size:"sm",class:"dsg-table--expand-icon"})],10,Ct)])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,(d,C)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:C},[d.visible?(e.openBlock(),e.createElementBlock("td",{key:0,class:e.normalizeClass(["dsg-table--tbody-cell",d.dataClass]),style:e.normalizeStyle({width:d.width||void 0}),onClick:F=>Me(),onDblclick:F=>Fe(),onContextmenu:F=>Le()},[e.renderSlot(a.$slots,Z(d),{rowData:o,rowIndex:v,rowField:d},()=>[e.createElementVNode("span",{innerHTML:X(d,o)},null,8,Et)])],46,St)):e.createCommentVNode("",!0)],64))),128))],42,yt),t.hasDetailRow&&(!t.expandableRows||H(o))?(e.openBlock(),e.createBlock(e.Transition,{key:0,name:t.detailRowTransition},{default:e.withCtx(()=>[e.createElementVNode("tr",{class:e.normalizeClass(["dsg-table--tbody-detail-row",{"is-expanded":t.expandableRows&&H(o)}]),onClick:d=>ze()},[e.createElementVNode("td",{colspan:U.value},[e.renderSlot(a.$slots,"dsg-table-detail-row",{rowData:o,rowIndex:v,options:t.detailRowOptions,isExpanded:t.expandableRows?H(o):!0})],8,Dt)],10,Pt)]),_:2},1032,["name"])):e.createCommentVNode("",!0)],64))),128)),!w.value&&!m.value?.length&&t.noDataTemplate.length?(e.openBlock(),e.createElementBlock("tr",xt,[e.createElementVNode("td",{colspan:U.value,class:"dsg-table--empty-result"},[e.renderSlot(a.$slots,"dsg-table-empty-result",{},()=>[e.createTextVNode(e.toDisplayString(t.noDataTemplate),1)])],8,$t)])):e.createCommentVNode("",!0)],2),e.createElementVNode("tfoot",Vt,[e.renderSlot(a.$slots,"dsg-table-footer",{fields:g.value,data:m.value})])],2)],6)],6))}}),Nt={class:"dsg-table"},Rt={key:0,class:"dsg-table--pre-header"},Mt={class:"dsg-table--pre-header-left"},Ft=["textContent"],Lt={class:"dsg-table--pre-header-right"},zt={key:1,class:"dsg-table--search-header",ref:"dsgTableSearchHeaderEl"},Ht={class:"dsg-table--search-top"},At={key:2,class:"dsg-table--footer",ref:"dsgTableFooterEl"},Ut={class:"dsg-table--footer-left"},qt={class:"dsg-table--footer-center"},It={class:"dsg-table--footer-right"},Ot=e.defineComponent({__name:"DsgTable",props:{getUrl:{},fields:{},loadOnStart:{type:Boolean,default:!0},displaySearch:{type:Boolean,default:!0},displayPaginationInfo:{type:Boolean,default:!0},reloadOnChangeTimer:{type:Boolean,default:!1},selectable:{type:Boolean,default:!1},shiftSelectHighlight:{default:()=>{}},selectedRowHighlight:{default:()=>{}},trackBy:{default:"id"},title:{default:""},filters:{default:()=>{}},initialFilters:{default:()=>({})},filterEntity:{default:""},filterEndpoint:{default:""},filterSearchEndpoint:{default:""},tableLayout:{default:"fixed"},autoSortFilters:{type:Boolean,default:!0},data:{default:null},hasHeader:{type:Boolean,default:!0},hasFooter:{type:Boolean,default:!0},perPage:{default:20},paginationPath:{default:"meta"},css:{default:()=>({tableWrapper:"border-b"})},rowClass:{type:[String,Function],default:void 0},apiMode:{type:Boolean,default:!0},replaceState:{type:Boolean,default:!0},replaceStrategy:{default:"window"},hasDetailRow:{type:Boolean,default:!1},expandableRows:{type:Boolean,default:!1},expandMultiple:{type:Boolean,default:!1},showExpandDetail:{type:Boolean,default:!0},detailRowTransition:{default:"fade"},detailRowOptions:{default:()=>({})}},emits:["dsg-table:action-edit","dsg-table:action-view","dsg-table:action-delete","dsg-table:action-archive","dsg-table:link-clicked","dsg-table:rows-selected","dsg-table:row-clicked","dsg-table:row-hover","dsg-table:row-dblclick","dsg-table:filter-updated","dsg-table:term-changed","dsg-table:data-loaded","dsg-table:row-expanded","dsg-table:row-collapsed"],setup(t,{expose:x,emit:f}){const c=s=>{w.value=s},S=e.ref(t.apiMode&&!!(t.filterEntity||t.filterEndpoint||t.getUrl)),$=()=>{if(S.value){let s={};return p.getQueryStrings().forEach(r=>{if(r.key.startsWith("filter[")){const i=r.key.replace("filter[","").replace("]",""),b=r.value;s[`filter[${i}]`]=b.join(",")}}),s}else return{}},g=e.computed(()=>({...t.css,tableWrapper:"border-b "+(t.css?.tableWrapper||"")})),m=e.useSlots(),V=e.ref(!0),P=e.ref(null),E=e.ref("<p>Showing {from} to {to} of {total}</p>"),h=e.ref(null),n=e.useTemplateRef("dsgTable"),u=e.ref({perPage:t.perPage,change:c}),w=e.ref(t.perPage),k=e.ref({...$(),...t.initialFilters}),y=f,R=s=>{n.value?.changePage(s)},I=s=>{h.value=s},j=({data:s})=>{P.value=s,y("dsg-table:data-loaded",s)},D=()=>{n.value?.reload()},O=s=>{n.value?.setLoading(s)},M=s=>{const r=n.value?.getData?.()??[];n.value?.setData(r.map(i=>i.id===s.id?s:i))},N=s=>{const r=n.value?.getData?.()??[];n.value?.setData([...r,s])},L=s=>{const r=n.value?.getData?.()??[];n.value?.setData(r.filter(i=>i.id!==s.id))},z=s=>{n.value?.setData(s)},A=()=>n.value?.getData()??[],U=s=>{const r=n.value?.getData()??[],i=s(r);i&&n.value?.setData(i)},J=s=>{n.value?.expandRow(s)},T=s=>{n.value?.collapseRow(s)},X=(s,r)=>{n.value?.toggleRowExpand(s,r)},Z=()=>{n.value?.expandAllRows()},_=()=>{n.value?.collapseAllRows()},H=()=>n.value?.getExpandedRows()??new Set,K=s=>{k.value=s},ee=()=>k.value??{},Q=s=>{const r={...k.value};!s||s.trim()===""?delete r["filter[term]"]:r["filter[term]"]=s,k.value=r,e.nextTick(()=>{D()}),y("dsg-table:term-changed",s)},te=(s,r,i)=>{let b={};k.value["filter[term]"]&&(b["filter[term]"]=k.value["filter[term]"]),Object.keys(s).forEach(B=>{s[B]!==null&&s[B]!==void 0&&s[B]!==""&&(b[B]=s[B])}),k.value=b,e.nextTick(()=>{D()}),y("dsg-table:filter-updated",k.value,r,i)};return x({reloadTable:D,updateRowTable:M,addRowTable:N,deleteRowTable:L,setData:z,getData:A,mutateData:U,termChanged:Q,setFilters:K,getFilters:ee,setLoading:O,expandRow:J,collapseRow:T,toggleRowExpand:X,expandAllRows:Z,collapseAllRows:_,getExpandedRows:H,changePage:R}),(s,r)=>(e.openBlock(),e.createElementBlock("div",Nt,[t.hasHeader?(e.openBlock(),e.createElementBlock("div",Rt,[e.renderSlot(s.$slots,"dsg-table--pre-header",{},()=>[e.createElementVNode("div",Mt,[e.renderSlot(s.$slots,"dsg-table--page-title",{data:P.value,title:t.title},()=>[t.title.length>0?(e.openBlock(),e.createElementBlock("h1",{key:0,class:"dsg-table--title",textContent:e.toDisplayString(t.title)},null,8,Ft)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Lt,[e.renderSlot(s.$slots,"dsg-table--page-actions",{data:P.value})])])])):e.createCommentVNode("",!0),t.displaySearch?(e.openBlock(),e.createElementBlock("div",zt,[e.createElementVNode("div",Ht,[e.renderSlot(s.$slots,"dsg-table--search-header",{data:P.value},()=>[e.createVNode(he,{name:"term","onDsgTable:termChanged":r[0]||(r[0]=i=>Q(i))}),e.createVNode(p._sfc_main$7,{entity:t.filterEntity,"filter-endpoint":t.filterEndpoint,"search-endpoint":t.filterSearchEndpoint,"auto-sort":t.autoSortFilters,filters:t.filters,"onDsgTable:filterUpdated":r[1]||(r[1]=(i,b,B)=>te(i,b,B))},null,8,["entity","filter-endpoint","search-endpoint","auto-sort","filters"]),e.renderSlot(s.$slots,"dsg-table--search-actions",{data:P.value})])]),e.renderSlot(s.$slots,"dsg-table--search-navigation")],512)):e.createCommentVNode("",!0),e.createVNode(Tt,{ref:"dsgTable","api-url":t.getUrl,"filter-params":k.value,"onUpdate:filterParams":r[7]||(r[7]=i=>k.value=i),"per-page":w.value,"onUpdate:perPage":r[8]||(r[8]=i=>w.value=i),fields:t.fields,"load-on-start":t.loadOnStart,"pagination-path":t.paginationPath,selectable:t.selectable,"shift-select-highlight":t.shiftSelectHighlight,"selected-row-highlight":t.selectedRowHighlight,"track-by":t.trackBy,"table-layout":t.tableLayout,css:g.value,data:t.data,"row-class":t.rowClass,"api-mode":S.value,"replace-state":t.replaceState,"replace-strategy":t.replaceStrategy,"has-detail-row":t.hasDetailRow,"expandable-rows":t.expandableRows,"expand-multiple":t.expandMultiple,"show-expand-detail":t.showExpandDetail,"detail-row-transition":t.detailRowTransition,"detail-row-options":t.detailRowOptions,"onDsgTable:loading":r[9]||(r[9]=i=>V.value=!0),"onDsgTable:loaded":r[10]||(r[10]=i=>V.value=!1),"onDsgTable:paginationData":I,"onDsgTable:loadSuccess":j,"onDsgTable:rowsSelected":r[11]||(r[11]=i=>y("dsg-table:rows-selected",i)),"onDsgTable:rowClicked":r[12]||(r[12]=(i,b,B)=>y("dsg-table:row-clicked",i,b,B)),"onDsgTable:rowHover":r[13]||(r[13]=(i,b,B)=>y("dsg-table:row-hover",i,b,B)),"onDsgTable:rowDblclick":r[14]||(r[14]=(i,b,B)=>y("dsg-table:row-dblclick",i,b,B)),"onDsgTable:rowExpanded":r[15]||(r[15]=(i,b)=>y("dsg-table:row-expanded",i,b)),"onDsgTable:rowCollapsed":r[16]||(r[16]=(i,b)=>y("dsg-table:row-collapsed",i,b))},e.createSlots({"dsg-field--actions":e.withCtx(i=>[e.renderSlot(s.$slots,"dsg-table-actions",{data:i},()=>[(e.openBlock(),e.createBlock(be,{key:i.rowIndex,data:i,"onDsgTable:actionEdit":r[2]||(r[2]=(b,B)=>y("dsg-table:action-edit",b,B)),"onDsgTable:actionView":r[3]||(r[3]=(b,B)=>y("dsg-table:action-view",b,B)),"onDsgTable:actionDelete":r[4]||(r[4]=(b,B)=>y("dsg-table:action-delete",b,B)),"onDsgTable:actionArchive":r[5]||(r[5]=(b,B)=>y("dsg-table:action-archive",b,B)),"onDsgTable:linkClicked":r[6]||(r[6]=(b,B,ae)=>y("dsg-table:link-clicked",b,B,ae))},null,8,["data"]))])]),_:2},[e.renderList(e.unref(m),(i,b)=>({name:b,fn:e.withCtx(B=>[String(b)!=="dsg-field--actions"?e.renderSlot(s.$slots,b,e.normalizeProps(e.mergeProps({key:0},B))):e.createCommentVNode("",!0)])}))]),1032,["api-url","filter-params","per-page","fields","load-on-start","pagination-path","selectable","shift-select-highlight","selected-row-highlight","track-by","table-layout","css","data","row-class","api-mode","replace-state","replace-strategy","has-detail-row","expandable-rows","expand-multiple","show-expand-detail","detail-row-transition","detail-row-options"]),t.hasFooter?(e.openBlock(),e.createElementBlock("div",At,[e.createElementVNode("div",Ut,[e.renderSlot(s.$slots,"dsg-table--footer-left",{data:h.value,perPage:u.value},()=>[t.displayPaginationInfo?(e.openBlock(),e.createBlock(ve,{key:0,ref:"paginationInfoStart",pagination:h.value,"onUpdate:pagination":r[17]||(r[17]=i=>h.value=i),"info-template":E.value},null,8,["pagination","info-template"])):e.createCommentVNode("",!0),e.renderSlot(s.$slots,"dsg-table--footer-left-extras",{data:h.value,perPage:u.value})])]),e.createElementVNode("div",qt,[e.renderSlot(s.$slots,"dsg-table--footer-center",{data:h.value,perPage:u.value},()=>[e.renderSlot(s.$slots,"dsg-table--footer-center-extras",{data:h.value,perPage:u.value})])]),e.createElementVNode("div",It,[e.renderSlot(s.$slots,"dsg-table--footer-right",{data:h.value,perPage:u.value},()=>[V.value===!1&&t.displayPaginationInfo?(e.openBlock(),e.createBlock(me,{key:0,ref:"pagination",pagination:h.value,"onUpdate:pagination":r[18]||(r[18]=i=>h.value=i),"onDsgTable:changePage":R},null,8,["pagination"])):e.createCommentVNode("",!0),e.renderSlot(s.$slots,"dsg-table--footer-right-extras",{data:h.value,perPage:u.value})])])],512)):e.createCommentVNode("",!0)]))}}),Wt={class:"dsg-table--per-page"},jt=["value","textContent"],Kt=e.defineComponent({__name:"DsgTablePerPage",props:{perPageOptions:{default:()=>[10,20,30,50,100]},perPage:{}},setup(t){return(x,f)=>(e.openBlock(),e.createElementBlock("div",Wt,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":f[0]||(f[0]=c=>t.perPage.perPage=c),class:"dsg-table--per-page-select",onChange:f[1]||(f[1]=c=>t.perPage.change(t.perPage.perPage))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.perPageOptions,c=>(e.openBlock(),e.createElementBlock("option",{key:c,value:c,textContent:e.toDisplayString(c)},null,8,jt))),128))],544),[[e.vModelSelect,t.perPage.perPage]])]))}}),we=Ot,ye=be,pe=Kt,Be=p._sfc_main$7,Ce=me,Se=ve,Ee=he,Pe=ke,Qt={DsgTable:we,DsgTableActions:ye,DsgTablePerPage:pe,DsgTableFilter:Be,DsgTablePagination:Ce,DsgTablePaginationInfo:Se,DsgTableSearch:Ee,DsgTableRowHeader:Pe};exports.DsgTable=we;exports.DsgTableActions=ye;exports.DsgTableFilter=Be;exports.DsgTablePagination=Ce;exports.DsgTablePaginationInfo=Se;exports.DsgTablePerPage=pe;exports.DsgTableRowHeader=Pe;exports.DsgTableSearch=Ee;exports.default=Qt;
@@ -1,4 +1,4 @@
1
- import { defineComponent as X, useModel as ae, computed as N, withDirectives as De, openBlock as s, createElementBlock as d, normalizeClass as B, createVNode as I, createCommentVNode as p, createElementVNode as D, Fragment as A, renderList as Y, vShow as rt, mergeModels as le, ref as k, useTemplateRef as Ie, useAttrs as ut, unref as j, withCtx as ne, renderSlot as M, toDisplayString as re, createBlock as W, resolveDynamicComponent as ct, onMounted as qe, normalizeStyle as te, mergeProps as Pe, watch as oe, onUnmounted as gt, withModifiers as vt, Transition as ft, createTextVNode as bt, useSlots as ht, createSlots as wt, normalizeProps as mt, nextTick as Le, vModelSelect as yt } from "vue";
1
+ import { defineComponent as X, useModel as ae, computed as N, withDirectives as De, openBlock as s, createElementBlock as d, normalizeClass as B, createVNode as q, createCommentVNode as p, createElementVNode as D, Fragment as I, renderList as Y, vShow as rt, mergeModels as le, ref as k, useTemplateRef as Ie, useAttrs as ut, unref as K, withCtx as ne, renderSlot as M, toDisplayString as re, createBlock as W, resolveDynamicComponent as ct, onMounted as qe, normalizeStyle as te, mergeProps as Pe, watch as oe, onUnmounted as gt, withModifiers as vt, Transition as ft, createTextVNode as bt, useSlots as ht, createSlots as wt, normalizeProps as mt, nextTick as Le, vModelSelect as yt } from "vue";
2
2
  import { _ as O, k as kt, v as pt, f as Pt, u as Dt, c as Ve, b as He, l as ze, e as Ue, i as Oe } from "./DsgTablePerPage.vue_vue_type_style_index_0_lang-CPJO9rNB.js";
3
3
  import { ucfirst as St, ucwords as Ae, toSnakeCase as Ct } from "./dsg-vue.helpers-string.esm.js";
4
4
  import { data_get as pe } from "./dsg-vue.helpers-object.esm.js";
@@ -33,7 +33,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
33
33
  title: "First",
34
34
  "aria-label": "First"
35
35
  }, [
36
- I(O, {
36
+ q(O, {
37
37
  icon: e.firstIcon,
38
38
  size: "sm"
39
39
  }, null, 8, ["icon"])
@@ -45,20 +45,20 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
45
45
  title: "Previous",
46
46
  "aria-label": "Previous"
47
47
  }, [
48
- I(O, {
48
+ q(O, {
49
49
  icon: e.prevIcon,
50
50
  size: "sm"
51
51
  }, null, 8, ["icon"])
52
52
  ], 10, Rt),
53
- H.value ? (s(!0), d(A, { key: 1 }, Y($.value, (S, q) => (s(), d("a", {
54
- key: q,
55
- onClick: (se) => l(q + e.firstPage),
56
- class: B([[g(q + e.firstPage) ? "active" : ""], "dsg-table--pagination-link"]),
53
+ H.value ? (s(!0), d(I, { key: 1 }, Y($.value, (S, V) => (s(), d("a", {
54
+ key: V,
55
+ onClick: (se) => l(V + e.firstPage),
56
+ class: B([[g(V + e.firstPage) ? "active" : ""], "dsg-table--pagination-link"]),
57
57
  innerHTML: S
58
- }, null, 10, Mt))), 128)) : (s(!0), d(A, { key: 2 }, Y(R.value, (S, q) => (s(), d("a", {
59
- key: q,
60
- onClick: (se) => l(T.value + q + e.firstPage - 1),
61
- class: B([[g(T.value + q + e.firstPage - 1) ? "active" : ""], "dsg-table--pagination-link"]),
58
+ }, null, 10, Mt))), 128)) : (s(!0), d(I, { key: 2 }, Y(R.value, (S, V) => (s(), d("a", {
59
+ key: V,
60
+ onClick: (se) => l(T.value + V + e.firstPage - 1),
61
+ class: B([[g(T.value + V + e.firstPage - 1) ? "active" : ""], "dsg-table--pagination-link"]),
62
62
  innerHTML: T.value + S - 1
63
63
  }, null, 10, Et))), 128)),
64
64
  D("a", {
@@ -68,7 +68,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
68
68
  title: "Next",
69
69
  "aria-label": "Next"
70
70
  }, [
71
- I(O, {
71
+ q(O, {
72
72
  icon: e.nextIcon,
73
73
  size: "sm"
74
74
  }, null, 8, ["icon"])
@@ -81,7 +81,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
81
81
  title: "Last",
82
82
  "aria-label": "Last"
83
83
  }, [
84
- I(O, {
84
+ q(O, {
85
85
  icon: e.lastIcon,
86
86
  size: "sm"
87
87
  }, null, 8, ["icon"])
@@ -155,7 +155,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
155
155
  T("dsg-table:link-clicked", l, g, v.value);
156
156
  }, T = F;
157
157
  return (m, l) => De((s(), d("div", Ht, [
158
- I(j(kt), {
158
+ q(K(kt), {
159
159
  triggers: [],
160
160
  placement: e.placement,
161
161
  "handle-resize": !0,
@@ -167,7 +167,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
167
167
  }, {
168
168
  popper: ne(() => [
169
169
  f.value ? (s(), d("div", At, [
170
- (s(!0), d(A, null, Y($.value, (g, P) => (s(), d(A, null, [
170
+ (s(!0), d(I, null, Y($.value, (g, P) => (s(), d(I, null, [
171
171
  ["edit", "view", "delete", "archive"].includes(String(P)) ? (s(), d("a", {
172
172
  key: P,
173
173
  href: g?.link,
@@ -177,25 +177,25 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
177
177
  D("div", {
178
178
  class: B(["dsg-table--actions-menu-item", String(P)])
179
179
  }, [
180
- I(O, {
180
+ q(O, {
181
181
  icon: b(String(P)),
182
182
  size: "sm"
183
183
  }, null, 8, ["icon"]),
184
184
  D("span", {
185
185
  class: "flex-1",
186
- textContent: re(j(St)(String(P)))
186
+ textContent: re(K(St)(String(P)))
187
187
  }, null, 8, qt)
188
188
  ], 2)
189
189
  ], 8, It)) : p("", !0)
190
190
  ], 64))), 256)),
191
191
  $.value && L.value ? (s(), d("hr", Vt)) : p("", !0),
192
- L.value ? (s(!0), d(A, { key: 1 }, Y(L.value, (g) => (s(), d(A, {
192
+ L.value ? (s(!0), d(I, { key: 1 }, Y(L.value, (g) => (s(), d(I, {
193
193
  key: g.label
194
194
  }, [
195
195
  g.hasOwnProperty("component") ? (s(), W(ct(g.component), {
196
196
  key: 0,
197
- quote: j(c).data.data.rowData,
198
- "row-data": j(c).data.data.rowData
197
+ quote: K(c).data.data.rowData,
198
+ "row-data": K(c).data.data.rowData
199
199
  }, null, 8, ["quote", "row-data"])) : g.hasOwnProperty("type") && g.type == "break" ? (s(), d("hr", zt)) : (s(), d("a", {
200
200
  key: 2,
201
201
  href: g.link,
@@ -223,7 +223,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
223
223
  onClick: l[0] || (l[0] = (g) => f.value = !f.value)
224
224
  }, [
225
225
  M(m.$slots, "dsg-table-action-button-content", {}, () => [
226
- I(O, {
226
+ q(O, {
227
227
  icon: "dots-vertical",
228
228
  size: "sm"
229
229
  })
@@ -234,7 +234,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
234
234
  _: 3
235
235
  }, 8, ["placement", "shown"])
236
236
  ])), [
237
- [j(pt), () => f.value = !1]
237
+ [K(pt), () => f.value = !1]
238
238
  ]);
239
239
  }
240
240
  }), Nt = { class: "dsg-table--search" }, Ke = /* @__PURE__ */ X({
@@ -266,7 +266,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
266
266
  c("dsg-table:term-changed", f.value);
267
267
  }, 300);
268
268
  return (L, v) => (s(), d("div", Nt, [
269
- I(Pt, {
269
+ q(Pt, {
270
270
  modelValue: f.value,
271
271
  "onUpdate:modelValue": v[0] || (v[0] = (b) => f.value = b),
272
272
  name: e.name,
@@ -281,9 +281,9 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
281
281
  size: "sm",
282
282
  icon: "search-sm",
283
283
  "icon-clickable": !0,
284
- onIconClicked: v[1] || (v[1] = (b) => j($)(b)),
285
- onEnterPressed: v[2] || (v[2] = (b) => j($)(b)),
286
- onOnClear: v[3] || (v[3] = () => j($)(""))
284
+ onIconClicked: v[1] || (v[1] = (b) => K($)(b)),
285
+ onEnterPressed: v[2] || (v[2] = (b) => K($)(b)),
286
+ onOnClear: v[3] || (v[3] = () => K($)(""))
287
287
  }, null, 8, ["modelValue", "name", "id", "placeholder", "disabled", "required", "readonly", "hidden"])
288
288
  ]));
289
289
  }
@@ -333,7 +333,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
333
333
  };
334
334
  return (T, m) => (s(), d("tr", jt, [
335
335
  e.hasSelectAll ? (s(), d("th", Kt, [
336
- I(Ve, {
336
+ q(Ve, {
337
337
  modelValue: $.value,
338
338
  "onUpdate:modelValue": [
339
339
  m[0] || (m[0] = (l) => $.value = l),
@@ -343,7 +343,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
343
343
  }, null, 8, ["modelValue", "indeterminate"])
344
344
  ])) : p("", !0),
345
345
  e.showExpandDetail ? (s(), d("th", Qt)) : p("", !0),
346
- (s(!0), d(A, null, Y(e.fields, (l, g) => (s(), d(A, null, [
346
+ (s(!0), d(I, null, Y(e.fields, (l, g) => (s(), d(I, null, [
347
347
  l?.visible ? (s(), d("th", {
348
348
  key: g,
349
349
  class: B(H("dsg-table--th", l)),
@@ -395,7 +395,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
395
395
  class: "inline-flex",
396
396
  size: "xs"
397
397
  })) : p("", !0)
398
- ])) : (s(), d(A, { key: 1 }, [
398
+ ])) : (s(), d(I, { key: 1 }, [
399
399
  l.tooltip ? (s(), W(He, Pe({
400
400
  key: 0,
401
401
  ref_for: !0
@@ -403,7 +403,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
403
403
  "dsg-tooltip--trigger": ne(() => [
404
404
  D("span", {
405
405
  class: "dsg-table--th-title",
406
- innerHTML: j(Ae)(String(l?.title))
406
+ innerHTML: K(Ae)(String(l?.title))
407
407
  }, null, 8, Zt),
408
408
  l.tooltip.icon ? (s(), W(O, {
409
409
  key: 0,
@@ -416,7 +416,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
416
416
  }, 1040)) : (s(), d("span", {
417
417
  key: 1,
418
418
  class: "dsg-table--th-title",
419
- innerHTML: j(Ae)(String(l?.title))
419
+ innerHTML: K(Ae)(String(l?.title))
420
420
  }, null, 8, _t))
421
421
  ], 64))
422
422
  ], 14, Yt)) : p("", !0)
@@ -520,7 +520,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
520
520
  const a = ze().find((n) => n.key === e.queryParams.sort);
521
521
  if (a && a.value.length > 0) {
522
522
  const n = a.value[0], h = n.startsWith("-"), u = h ? n.substring(1) : n, x = e.fields.find(
523
- (Q) => Q.sortField === u || Q.name === u || Q.field === u
523
+ (j) => j.sortField === u || j.name === u || j.field === u
524
524
  );
525
525
  return x ? {
526
526
  name: String(x.name || x.field),
@@ -543,7 +543,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
543
543
  const n = `${t.pathname}${a.toString() ? "?" + a.toString() : ""}`;
544
544
  window.history.pushState({}, "", n);
545
545
  }
546
- }, v = k(c(e.fields)), b = k(e.data), H = k(null), R = k(e.initialPage), T = k("17px"), m = k(!1), l = k({}), g = k(0), P = k(!0), y = k($()), S = k(null), q = k(0), se = ae(e, "filterParams"), ue = ae(e, "perPage"), E = k([]), ie = k(!1), z = k(/* @__PURE__ */ new Set()), V = k(null), K = k(null), G = k(!1), Z = N(() => e.tableHeight != null), _ = N(() => {
546
+ }, v = k(c(e.fields)), b = k(e.data), H = k(null), R = k(e.initialPage), T = k("17px"), m = k(!1), l = k({}), g = k(0), P = k(!0), y = k($()), S = k(null), V = k(0), se = ae(e, "filterParams"), ue = ae(e, "perPage"), E = k([]), ie = k(!1), z = k(/* @__PURE__ */ new Set()), A = k(null), Q = k(null), G = k(!1), Z = N(() => e.tableHeight != null), _ = N(() => {
547
547
  let t = v.value.filter((a) => a.visible).length;
548
548
  return e.selectable && t++, e.hasDetailRow && e.expandableRows && t++, t;
549
549
  }), fe = N(() => {
@@ -621,7 +621,7 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
621
621
  z.value.clear();
622
622
  }, i = () => z.value, r = (t, a) => {
623
623
  if (e.selectable) {
624
- if (a !== void 0 && (V.value = a), t.selected)
624
+ if (a !== void 0 && (A.value = a), t.selected)
625
625
  E.value.push(t);
626
626
  else {
627
627
  const n = E.value.findIndex((h) => h[e.trackBy] === t[e.trackBy]);
@@ -630,11 +630,12 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
630
630
  U("dsg-table:rows-selected", E.value);
631
631
  }
632
632
  }, w = (t, a, n) => {
633
- if (e.selectable && t.shiftKey && V.value !== null) {
633
+ if (e.selectable && t.shiftKey && A.value !== null) {
634
634
  t.stopPropagation(), t.preventDefault();
635
- const h = Math.min(V.value, n), u = Math.max(V.value, n), x = !a.selected;
636
- for (let Q = h; Q <= u; Q++) {
637
- const de = b.value?.[Q];
635
+ const h = Math.min(A.value, n), u = Math.max(A.value, n), x = !a.selected;
636
+ for (let j = h; j <= u; j++) {
637
+ if (j === A.value) continue;
638
+ const de = b.value?.[j];
638
639
  if (de) {
639
640
  const Be = de.selected;
640
641
  if (de.selected = x, x && !Be)
@@ -645,18 +646,18 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
645
646
  }
646
647
  }
647
648
  }
648
- V.value = n, K.value = null, U("dsg-table:rows-selected", E.value);
649
+ A.value = n, Q.value = null, U("dsg-table:rows-selected", E.value);
649
650
  }
650
651
  }, C = () => {
651
652
  e.selectable && (b.value?.forEach((t) => {
652
653
  t.selected = !0;
653
- }), E.value = b.value?.filter((t) => t.selected) ?? [], V.value = null, U("dsg-table:rows-selected", E.value));
654
+ }), E.value = b.value?.filter((t) => t.selected) ?? [], A.value = null, U("dsg-table:rows-selected", E.value));
654
655
  }, ke = () => {
655
656
  e.selectable && (b.value?.forEach((t) => {
656
657
  t.selected = !1;
657
- }), E.value = [], V.value = null, U("dsg-table:rows-selected", E.value));
658
+ }), E.value = [], A.value = null, U("dsg-table:rows-selected", E.value));
658
659
  }, ve = (t) => {
659
- b.value = Array.isArray(t) ? t : [], e.selectable && (V.value = null, b.value.forEach((a) => {
660
+ b.value = Array.isArray(t) ? t : [], e.selectable && (A.value = null, b.value.forEach((a) => {
660
661
  a.selected = a.selected ?? !1;
661
662
  }));
662
663
  }, Ye = () => b.value ?? [], Ge = (t) => {
@@ -669,8 +670,8 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
669
670
  }), Se = () => {
670
671
  S.value && (S.value.abort(), S.value = null);
671
672
  }, Xe = (t, a) => {
672
- Se(), q.value++;
673
- const n = q.value, h = new AbortController();
673
+ Se(), V.value++;
674
+ const n = V.value, h = new AbortController();
674
675
  return a.signal = h.signal, S.value = h, (e.httpMethod.toLowerCase() === "get" ? Ue.get(t, a) : (() => {
675
676
  const x = a.params;
676
677
  return delete a.params, Ue.post(t, x, a);
@@ -681,18 +682,18 @@ const $t = { class: "dsg-table--pagination" }, Tt = ["disabled"], Rt = ["disable
681
682
  }
682
683
  );
683
684
  }, Ce = (t) => {
684
- if (t._requestId && t._requestId !== q.value || t._apiUrl && t._apiUrl !== e.apiUrl)
685
+ if (t._requestId && t._requestId !== V.value || t._apiUrl && t._apiUrl !== e.apiUrl)
685
686
  return;
686
687
  U("dsg-table:load-success", t);
687
688
  const a = e.transform ? e.transform(t.data) : t.data;
688
- b.value = pe(a, e.dataPath, null), e.selectable && (V.value = null, b.value?.forEach((n) => {
689
+ b.value = pe(a, e.dataPath, null), e.selectable && (A.value = null, b.value?.forEach((n) => {
689
690
  n.selected = n.selected ?? !1;
690
691
  })), H.value = pe(a, e.paginationPath, null) ?? null, g.value = b.value?.length ? b.value[0].order : g, !xt(e.paginationPath) && H.value === null && console.warn(
691
692
  'DsgTable: pagination-path "' + e.paginationPath + `" not found. It looks like the data returned from the server does not have pagination information or you may have set it incorrectly.
692
693
  You can explicitly suppress this warning by setting pagination-path="".`
693
694
  ), S.value = null, U("dsg-table:pagination-data", H.value), H.value && R.value > (H.value?.last_page || 0) && b.value?.length === 0 && (R.value = e.initialPage, ee()), U("dsg-table:loaded"), P.value = !1;
694
695
  }, xe = (t) => {
695
- t._requestId && t._requestId !== q.value || t._apiUrl && t._apiUrl !== e.apiUrl || t._cancelled || (console.error("load-error", t), S.value = null, U("dsg-table:load-error", t), U("dsg-table:loaded"), P.value = !1);
696
+ t._requestId && t._requestId !== V.value || t._apiUrl && t._apiUrl !== e.apiUrl || t._cancelled || (console.error("load-error", t), S.value = null, U("dsg-table:load-error", t), U("dsg-table:loaded"), P.value = !1);
696
697
  }, $e = () => {
697
698
  if (e.data !== null && Array.isArray(e.data)) {
698
699
  ve(e.data), P.value = !1;
@@ -725,17 +726,17 @@ You can explicitly suppress this warning by setting pagination-path="".`
725
726
  }, Te = (t) => {
726
727
  t.key === "Shift" && (G.value = !0);
727
728
  }, Re = (t) => {
728
- t.key === "Shift" && (G.value = !1, K.value = null);
729
+ t.key === "Shift" && (G.value = !1, Q.value = null);
729
730
  }, Me = () => {
730
- G.value = !1, K.value = null;
731
+ G.value = !1, Q.value = null;
731
732
  }, st = (t) => {
732
- e.selectable && G.value && V.value !== null && (K.value = t);
733
+ e.selectable && G.value && A.value !== null && (Q.value = t);
733
734
  }, ot = () => {
734
- K.value = null;
735
+ Q.value = null;
735
736
  }, it = (t) => {
736
- if (!e.selectable || !G.value || V.value === null || K.value === null)
737
+ if (!e.selectable || !G.value || A.value === null || Q.value === null)
737
738
  return !1;
738
- const a = Math.min(V.value, K.value), n = Math.max(V.value, K.value);
739
+ const a = Math.min(A.value, Q.value), n = Math.max(A.value, Q.value);
739
740
  return t >= a && t <= n;
740
741
  };
741
742
  qe(() => {
@@ -774,7 +775,7 @@ You can explicitly suppress this warning by setting pagination-path="".`
774
775
  class: B(["dsg-table-main", Z.value ? "fixed-header" : "", l.value.table, "table-" + e.tableLayout])
775
776
  }, [
776
777
  D("colgroup", { span: _.value }, [
777
- (s(!0), d(A, null, Y(v.value, (n, h) => (s(), d(A, null, [
778
+ (s(!0), d(I, null, Y(v.value, (n, h) => (s(), d(I, null, [
778
779
  n?.visible ? (s(), d("col", {
779
780
  key: h,
780
781
  style: te({ width: n.width || void 0 }),
@@ -791,7 +792,7 @@ You can explicitly suppress this warning by setting pagination-path="".`
791
792
  class: B([[l.value.thead, { sticky: Z.value, "top-0": Z.value }], "dsg-table--head"])
792
793
  }, [
793
794
  M(t.$slots, "tableHeader", { fields: v.value }, () => [
794
- I(Qe, {
795
+ q(Qe, {
795
796
  fields: v.value,
796
797
  "has-select-all": e.selectable,
797
798
  "selected-rows": E.value,
@@ -821,7 +822,7 @@ You can explicitly suppress this warning by setting pagination-path="".`
821
822
  colspan: _.value
822
823
  }, [
823
824
  M(t.$slots, "dsg-table-loading", {}, () => [
824
- I(O, {
825
+ q(O, {
825
826
  icon: "loading-02",
826
827
  class: "animate-spin"
827
828
  }),
@@ -829,7 +830,7 @@ You can explicitly suppress this warning by setting pagination-path="".`
829
830
  ])
830
831
  ], 8, la)
831
832
  ], 8, aa)
832
- ])) : (s(!0), d(A, { key: 1 }, Y(b.value, (n, h) => (s(), d(A, { key: h }, [
833
+ ])) : (s(!0), d(I, { key: 1 }, Y(b.value, (n, h) => (s(), d(I, { key: h }, [
833
834
  D("tr", {
834
835
  class: B(["dsg-table--tbody-row", [we(n, h), { "dsg-table--shift-range": e.selectable && it(h) }]]),
835
836
  onClick: (u) => Ze(u, h, n),
@@ -843,7 +844,7 @@ You can explicitly suppress this warning by setting pagination-path="".`
843
844
  class: "dsg-table--tbody-cell dsg-table--tbody-cell-checkbox",
844
845
  onClickCapture: (u) => w(u, n, h)
845
846
  }, [
846
- I(Ve, {
847
+ q(Ve, {
847
848
  modelValue: n.selected,
848
849
  "onUpdate:modelValue": [(u) => n.selected = u, (u) => r(n, h)]
849
850
  }, null, 8, ["modelValue", "onUpdate:modelValue"])
@@ -856,21 +857,21 @@ You can explicitly suppress this warning by setting pagination-path="".`
856
857
  "aria-label": "Toggle row details",
857
858
  onClick: vt((u) => ce(n, h), ["stop"])
858
859
  }, [
859
- I(O, {
860
+ q(O, {
860
861
  icon: "chevron-right",
861
862
  size: "sm",
862
863
  class: "dsg-table--expand-icon"
863
864
  })
864
865
  ], 10, ia)
865
866
  ])) : p("", !0),
866
- (s(!0), d(A, null, Y(v.value, (u, x) => (s(), d(A, { key: x }, [
867
+ (s(!0), d(I, null, Y(v.value, (u, x) => (s(), d(I, { key: x }, [
867
868
  u.visible ? (s(), d("td", {
868
869
  key: 0,
869
870
  class: B(["dsg-table--tbody-cell", u.dataClass]),
870
871
  style: te({ width: u.width || void 0 }),
871
- onClick: (Q) => tt(),
872
- onDblclick: (Q) => at(),
873
- onContextmenu: (Q) => lt()
872
+ onClick: (j) => tt(),
873
+ onDblclick: (j) => at(),
874
+ onContextmenu: (j) => lt()
874
875
  }, [
875
876
  M(t.$slots, he(u), {
876
877
  rowData: n,
@@ -997,7 +998,7 @@ You can explicitly suppress this warning by setting pagination-path="".`
997
998
  }, v = N(() => ({
998
999
  ...e.css,
999
1000
  tableWrapper: "border-b " + (e.css?.tableWrapper || "")
1000
- })), b = ht(), H = k(!0), R = k(null), T = k("<p>Showing {from} to {to} of {total}</p>"), m = k(null), l = Ie("dsgTable"), g = k({ perPage: e.perPage, change: c }), P = k(e.perPage), y = k({ ...L(), ...e.initialFilters }), S = f, q = (o) => {
1001
+ })), b = ht(), H = k(!0), R = k(null), T = k("<p>Showing {from} to {to} of {total}</p>"), m = k(null), l = Ie("dsgTable"), g = k({ perPage: e.perPage, change: c }), P = k(e.perPage), y = k({ ...L(), ...e.initialFilters }), S = f, V = (o) => {
1001
1002
  l.value?.changePage(o);
1002
1003
  }, se = (o) => {
1003
1004
  m.value = o;
@@ -1010,10 +1011,10 @@ You can explicitly suppress this warning by setting pagination-path="".`
1010
1011
  }, z = (o) => {
1011
1012
  const i = l.value?.getData?.() ?? [];
1012
1013
  l.value?.setData(i.map((r) => r.id === o.id ? o : r));
1013
- }, V = (o) => {
1014
+ }, A = (o) => {
1014
1015
  const i = l.value?.getData?.() ?? [];
1015
1016
  l.value?.setData([...i, o]);
1016
- }, K = (o) => {
1017
+ }, Q = (o) => {
1017
1018
  const i = l.value?.getData?.() ?? [];
1018
1019
  l.value?.setData(i.filter((r) => r.id !== o.id));
1019
1020
  }, G = (o) => {
@@ -1049,8 +1050,8 @@ You can explicitly suppress this warning by setting pagination-path="".`
1049
1050
  return F({
1050
1051
  reloadTable: E,
1051
1052
  updateRowTable: z,
1052
- addRowTable: V,
1053
- deleteRowTable: K,
1053
+ addRowTable: A,
1054
+ deleteRowTable: Q,
1054
1055
  setData: G,
1055
1056
  getData: Z,
1056
1057
  mutateData: _,
@@ -1064,7 +1065,7 @@ You can explicitly suppress this warning by setting pagination-path="".`
1064
1065
  expandAllRows: he,
1065
1066
  collapseAllRows: we,
1066
1067
  getExpandedRows: J,
1067
- changePage: q
1068
+ changePage: V
1068
1069
  }), (o, i) => (s(), d("div", ha, [
1069
1070
  e.hasHeader ? (s(), d("div", wa, [
1070
1071
  M(o.$slots, "dsg-table--pre-header", {}, () => [
@@ -1088,11 +1089,11 @@ You can explicitly suppress this warning by setting pagination-path="".`
1088
1089
  e.displaySearch ? (s(), d("div", pa, [
1089
1090
  D("div", Pa, [
1090
1091
  M(o.$slots, "dsg-table--search-header", { data: R.value }, () => [
1091
- I(Ke, {
1092
+ q(Ke, {
1092
1093
  name: "term",
1093
1094
  "onDsgTable:termChanged": i[0] || (i[0] = (r) => ge(r))
1094
1095
  }),
1095
- I(Oe, {
1096
+ q(Oe, {
1096
1097
  entity: e.filterEntity,
1097
1098
  "filter-endpoint": e.filterEndpoint,
1098
1099
  "search-endpoint": e.filterSearchEndpoint,
@@ -1105,7 +1106,7 @@ You can explicitly suppress this warning by setting pagination-path="".`
1105
1106
  ]),
1106
1107
  M(o.$slots, "dsg-table--search-navigation")
1107
1108
  ], 512)) : p("", !0),
1108
- I(ba, {
1109
+ q(ba, {
1109
1110
  ref: "dsgTable",
1110
1111
  "api-url": e.getUrl,
1111
1112
  "filter-params": y.value,
@@ -1158,7 +1159,7 @@ You can explicitly suppress this warning by setting pagination-path="".`
1158
1159
  ]),
1159
1160
  _: 2
1160
1161
  }, [
1161
- Y(j(b), (r, w) => ({
1162
+ Y(K(b), (r, w) => ({
1162
1163
  name: w,
1163
1164
  fn: ne((C) => [
1164
1165
  String(w) !== "dsg-field--actions" ? M(o.$slots, w, mt(Pe({ key: 0 }, C))) : p("", !0)
@@ -1205,7 +1206,7 @@ You can explicitly suppress this warning by setting pagination-path="".`
1205
1206
  ref: "pagination",
1206
1207
  pagination: m.value,
1207
1208
  "onUpdate:pagination": i[18] || (i[18] = (r) => m.value = r),
1208
- "onDsgTable:changePage": q
1209
+ "onDsgTable:changePage": V
1209
1210
  }, null, 8, ["pagination"])) : p("", !0),
1210
1211
  M(o.$slots, "dsg-table--footer-right-extras", {
1211
1212
  data: m.value,
@@ -1229,7 +1230,7 @@ You can explicitly suppress this warning by setting pagination-path="".`
1229
1230
  class: "dsg-table--per-page-select",
1230
1231
  onChange: f[1] || (f[1] = (c) => e.perPage.change(e.perPage.perPage))
1231
1232
  }, [
1232
- (s(!0), d(A, null, Y(e.perPageOptions, (c) => (s(), d("option", {
1233
+ (s(!0), d(I, null, Y(e.perPageOptions, (c) => (s(), d("option", {
1233
1234
  key: c,
1234
1235
  value: c,
1235
1236
  textContent: re(c)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dcodegroup-au/dsg-vue",
3
3
  "description": "Front-end Vue/Tailwind DSG for UntitledUI.",
4
- "version": "0.1.34",
4
+ "version": "0.1.35",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "preinstall": "npx only-allow pnpm",
@@ -131,13 +131,13 @@
131
131
  "jsdom": "^26.1.0",
132
132
  "only-allow": "^1.2.2",
133
133
  "phone": "^3.1.71",
134
- "prettier": "^3.8.1",
134
+ "prettier": "^3.8.3",
135
135
  "sass": "^1.99.0",
136
136
  "semantic-release": "^24.2.9",
137
137
  "storybook": "^8.6.18",
138
138
  "tailwindcss": "^3.4.19",
139
139
  "typescript": "^5.9.3",
140
- "typescript-eslint": "^8.58.1",
140
+ "typescript-eslint": "^8.59.0",
141
141
  "ua-parser-js": "^2.0.9",
142
142
  "uuid": "^11.1.0",
143
143
  "vditor": "^3.11.2",