@dcodegroup-au/dsg-vue 0.1.4 → 0.1.6
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.
|
@@ -197,6 +197,8 @@ declare function __VLS_template(): {
|
|
|
197
197
|
}>, {
|
|
198
198
|
changePage: (page: "next" | "prev" | number) => void;
|
|
199
199
|
reload: () => void;
|
|
200
|
+
getData: () => any[] | null;
|
|
201
|
+
setData: (rows: any[] | null) => void;
|
|
200
202
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
201
203
|
"update:filterParams": (value: any) => any;
|
|
202
204
|
"update:perPage": (value: any) => any;
|
|
@@ -245,9 +247,11 @@ declare function __VLS_template(): {
|
|
|
245
247
|
"onDsg-table:row-dblclick"?: ((ev: Event, rowIndex: number, rowData: Record<string, any>) => any) | undefined;
|
|
246
248
|
"onUpdate:filterParams"?: ((value: any) => any) | undefined;
|
|
247
249
|
"onUpdate:perPage"?: ((value: any) => any) | undefined;
|
|
248
|
-
}>, "changePage" | "reload"> & import('vue').ShallowUnwrapRef<{
|
|
250
|
+
}>, "changePage" | "reload" | "getData" | "setData"> & import('vue').ShallowUnwrapRef<{
|
|
249
251
|
changePage: (page: "next" | "prev" | number) => void;
|
|
250
252
|
reload: () => void;
|
|
253
|
+
getData: () => any[] | null;
|
|
254
|
+
setData: (rows: any[] | null) => void;
|
|
251
255
|
}> & {} & import('vue').ComponentCustomProperties & {} & {
|
|
252
256
|
$slots: Partial<Record<string, (_: {
|
|
253
257
|
rowData: any;
|
|
@@ -322,6 +326,8 @@ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
|
322
326
|
declare const __VLS_component: import('vue').DefineComponent<DsgTableProps, {
|
|
323
327
|
reloadTable: () => void;
|
|
324
328
|
updateRowTable: (rowData: any) => void;
|
|
329
|
+
addRowTable: (rowData: any) => void;
|
|
330
|
+
deleteRowTable: (rowData: any) => void;
|
|
325
331
|
termChanged: (term: string | null) => void;
|
|
326
332
|
setFilters: (filters: any) => void;
|
|
327
333
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
@@ -445,6 +451,8 @@ declare const __VLS_component: import('vue').DefineComponent<DsgTableProps, {
|
|
|
445
451
|
}>, {
|
|
446
452
|
changePage: (page: "next" | "prev" | number) => void;
|
|
447
453
|
reload: () => void;
|
|
454
|
+
getData: () => any[] | null;
|
|
455
|
+
setData: (rows: any[] | null) => void;
|
|
448
456
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
449
457
|
"update:filterParams": (value: any) => any;
|
|
450
458
|
"update:perPage": (value: any) => any;
|
|
@@ -493,9 +501,11 @@ declare const __VLS_component: import('vue').DefineComponent<DsgTableProps, {
|
|
|
493
501
|
"onDsg-table:row-dblclick"?: ((ev: Event, rowIndex: number, rowData: Record<string, any>) => any) | undefined;
|
|
494
502
|
"onUpdate:filterParams"?: ((value: any) => any) | undefined;
|
|
495
503
|
"onUpdate:perPage"?: ((value: any) => any) | undefined;
|
|
496
|
-
}>, "changePage" | "reload"> & import('vue').ShallowUnwrapRef<{
|
|
504
|
+
}>, "changePage" | "reload" | "getData" | "setData"> & import('vue').ShallowUnwrapRef<{
|
|
497
505
|
changePage: (page: "next" | "prev" | number) => void;
|
|
498
506
|
reload: () => void;
|
|
507
|
+
getData: () => any[] | null;
|
|
508
|
+
setData: (rows: any[] | null) => void;
|
|
499
509
|
}> & {} & import('vue').ComponentCustomProperties & {} & {
|
|
500
510
|
$slots: Partial<Record<string, (_: {
|
|
501
511
|
rowData: any;
|
|
@@ -116,6 +116,8 @@ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
|
116
116
|
declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps, {
|
|
117
117
|
changePage: (page: "next" | "prev" | number) => void;
|
|
118
118
|
reload: () => void;
|
|
119
|
+
getData: () => any[] | null;
|
|
120
|
+
setData: (rows: any[] | null) => void;
|
|
119
121
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
120
122
|
"update:filterParams": (value: any) => any;
|
|
121
123
|
"update:perPage": (value: any) => any;
|
package/dist/dsg-vue.table.cjs
CHANGED
|
@@ -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-DEG12JOR.cjs"),U=require("./dsg-vue.helpers-string.cjs"),O=require("./dsg-vue.helpers-object.cjs"),ge={class:"dsg-table--pagination"},me=["disabled"],be=["disabled"],fe=["onClick","innerHTML"],ve=["onClick","innerHTML"],pe=["disabled"],ke=["disabled"],Q=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(a,{expose:y,emit:u}){const i=e.useModel(a,"pagination"),f=e.computed(()=>i.value===null?0:i.value?.last_page-a.firstPage+1),g=e.computed(()=>i.value===null?0:i.value?.last_page),p=e.computed(()=>i.value===null?!1:i.value?.current_page===a.firstPage),k=e.computed(()=>i.value===null?!1:i.value?.current_page===g.value),T=e.computed(()=>f.value<a.onEachSide*2+4),$=e.computed(()=>a.onEachSide*2+1),v=e.computed(()=>!i.value||i.value?.current_page<=a.onEachSide?1:i.value?.current_page>=f.value-a.onEachSide?f.value-a.onEachSide*2:i.value?.current_page-a.onEachSide),m=u,o=c=>{m("dsg-table:change-page",c)},r=c=>c===i.value?.current_page;return y({loadPage:o}),(c,E)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",ge,[c.showFirstLast?(e.openBlock(),e.createElementBlock("a",{key:0,onClick:E[0]||(E[0]=B=>o(c.firstPage)),class:e.normalizeClass([[p.value?"disabled":""],"dsg-table--pagination-link"]),disabled:p.value,title:"First","aria-label":"First"},[e.createVNode(P._sfc_main,{icon:c.firstIcon,size:"sm"},null,8,["icon"])],10,me)):e.createCommentVNode("",!0),e.createElementVNode("a",{onClick:E[1]||(E[1]=B=>o("prev")),class:e.normalizeClass([[p.value?"disabled":""],"dsg-table--pagination-link"]),disabled:p.value,title:"Previous","aria-label":"Previous"},[e.createVNode(P._sfc_main,{icon:c.prevIcon,size:"sm"},null,8,["icon"])],10,be),T.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(f.value,(B,w)=>(e.openBlock(),e.createElementBlock("a",{key:w,onClick:N=>o(w+c.firstPage),class:e.normalizeClass([[r(w+c.firstPage)?"active":""],"dsg-table--pagination-link"]),innerHTML:B},null,10,fe))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:2},e.renderList($.value,(B,w)=>(e.openBlock(),e.createElementBlock("a",{key:w,onClick:N=>o(v.value+w+c.firstPage-1),class:e.normalizeClass([[r(v.value+w+c.firstPage-1)?"active":""],"dsg-table--pagination-link"]),innerHTML:v.value+B-1},null,10,ve))),128)),e.createElementVNode("a",{onClick:E[2]||(E[2]=B=>o("next")),class:e.normalizeClass([[k.value?"disabled":""],"dsg-table--pagination-link"]),disabled:k.value,title:"Next","aria-label":"Next"},[e.createVNode(P._sfc_main,{icon:c.nextIcon,size:"sm"},null,8,["icon"])],10,pe),c.showFirstLast?(e.openBlock(),e.createElementBlock("a",{key:3,onClick:E[3]||(E[3]=B=>o(g.value)),class:e.normalizeClass([[k.value?"disabled":""],"dsg-table--pagination-link"]),disabled:k.value,title:"Last","aria-label":"Last"},[e.createVNode(P._sfc_main,{icon:c.lastIcon,size:"sm"},null,8,["icon"])],10,ke)):e.createCommentVNode("",!0)],512)),[[e.vShow,i.value&&g.value>c.firstPage]])}}),he=["innerHTML"],Y=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(a){const y=e.useModel(a,"pagination"),u=e.computed(()=>y.value==null||y.value.total==0?a.noDataTemplate:a.infoTemplate.replace("{from}",(y.value?.from||0).toString()).replace("{to}",(y.value?.to||0).toString()).replace("{total}",(y.value?.total||0).toString()));return(i,f)=>(e.openBlock(),e.createElementBlock("div",{class:"dsg-table--pagination-info",innerHTML:u.value},null,8,he))}}),ye={class:"dsg-table--actions",ref:"dsgTableActions"},Be={class:"dsg-table--action-trigger"},we={key:0,class:"dsg-table--actions-menu-wrapper"},Ce=["href","target","onClick"],Pe=["textContent"],Ee={key:0},De={key:1},Se=["href","target","onClick"],$e={class:"flex-1"},G=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(a,{emit:y}){const u=e.ref(!1);e.useTemplateRef("dsgTableActions");const i=e.useAttrs(),f=e.ref(i.data.rowData?.actions??null),g=e.ref(i.data.rowData?.links??null),p=e.ref(i.data.rowData??null),k=m=>{switch(m){case"edit":return"edit-05";case"view":return"eye";case"delete":return"trash-01";case"archive":return"eye-off";default:return"dots-horizontal"}},T=(m,o,r)=>{switch(o){case"edit":v("dsg-table:action-edit",r,p.value);break;case"view":v("dsg-table:action-view",r,p.value);break;case"delete":v("dsg-table:action-delete",r,p.value);break;case"archive":v("dsg-table:action-archive",r,p.value);break}},$=(m,o)=>{const r=m.actionId||m.label.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-");v("dsg-table:link-clicked",o,r,p.value)},v=y;return(m,o)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",ye,[e.createVNode(e.unref(P.kt),{triggers:[],placement:m.placement,"handle-resize":!0,strategy:"absolute",shown:u.value,class:"dsg-table--actions__popper",onHide:o[1]||(o[1]=r=>u.value=!1),ref:"floatingVueFilterDropdown"},{popper:e.withCtx(()=>[u.value?(e.openBlock(),e.createElementBlock("div",we,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(r,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[["edit","view","delete","archive"].includes(String(c))?(e.openBlock(),e.createElementBlock("a",{key:c,href:f.value?.link,target:f.value?.target||"_self",onClick:E=>T(r,String(c),E)},[e.createElementVNode("div",{class:e.normalizeClass(["dsg-table--actions-menu-item",String(c)])},[e.createVNode(P._sfc_main,{icon:k(String(c)),size:"sm"},null,8,["icon"]),e.createElementVNode("span",{class:"flex-1",textContent:e.toDisplayString(e.unref(U.ucfirst)(String(c)))},null,8,Pe)],2)],8,Ce)):e.createCommentVNode("",!0)],64))),256)),f.value&&g.value?(e.openBlock(),e.createElementBlock("hr",Ee)):e.createCommentVNode("",!0),g.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(g.value,r=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:r.label},[r.hasOwnProperty("component")?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.component),{key:0,quote:e.unref(i).data.data.rowData,"row-data":e.unref(i).data.data.rowData},null,8,["quote","row-data"])):r.hasOwnProperty("type")&&r.type=="break"?(e.openBlock(),e.createElementBlock("hr",De)):(e.openBlock(),e.createElementBlock("a",{key:2,href:r.link,target:r.target||"_self",class:e.normalizeClass(["dsg-table--actions-menu-item",r.class]),onClick:c=>$(r,c)},[r.icon?(e.openBlock(),e.createBlock(P._sfc_main,{key:0,icon:r.icon,size:"sm"},null,8,["icon"])):e.createCommentVNode("",!0),e.createElementVNode("span",$e,e.toDisplayString(r.label),1)],10,Se))],64))),128)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]),default:e.withCtx(()=>[e.createElementVNode("div",Be,[e.createElementVNode("button",{type:"button",class:"dsg-table--actions-button","aria-expanded":"false","aria-haspopup":"true",onClick:o[0]||(o[0]=r=>u.value=!u.value)},[e.renderSlot(m.$slots,"dsg-table-action-button-content",{},()=>[e.createVNode(P._sfc_main,{icon:"dots-vertical",size:"sm"})])])])]),_:3},8,["placement","shown"])])),[[e.unref(P.vOnClickOutside),()=>u.value=!1]])}}),Ve={class:"dsg-table--search"},J=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:{}},emits:["dsg-table:term-changed"],setup(a,{emit:y}){const u=e.ref(""),i=y,f=P.useDebounceFn(g=>{u.value=g,i("dsg-table:term-changed",u.value)},300);return(g,p)=>(e.openBlock(),e.createElementBlock("div",Ve,[e.createVNode(P._sfc_main$4,{value:u.value,"onUpdate:value":p[0]||(p[0]=k=>u.value=k),name:g.name,id:g.id||g.name,placeholder:g.placeholder,disabled:g.disabled,required:g.required,readonly:g.readonly,hidden:g.hidden,"has-clear-button":!0,autocomplete:"off",size:"sm",icon:"search-sm","icon-clickable":!0,onIconClicked:p[1]||(p[1]=k=>e.unref(f)(k)),onEnterPressed:p[2]||(p[2]=k=>e.unref(f)(k)),onOnClear:p[3]||(p[3]=()=>e.unref(f)(""))},null,8,["value","name","id","placeholder","disabled","required","readonly","hidden"])]))}}),Te={class:"dsg-table--header-row"},Ne={key:0,class:"dsg-table--th dsg-table--th-checkbox",scope:"col"},Fe={key:1,class:"dsg-table--th dsg-table--th-expand-detail",scope:"col"},Me=["title","id","onClick"],Le={key:0,class:"dsg-table--th-sort-icon"},ze=["innerHTML"],Re=["innerHTML"],X=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(a,{emit:y}){const u=e.useModel(a,"sortField"),i=e.useModel(a,"selectedRows"),f=e.useModel(a,"hasSelected"),g=e.ref("17px"),p=v=>{f.value&&i.value.length>0&&i.value.length!==a.tableDataLength?(f.value=!0,k("dsg-table:on-select-all")):!f.value&&i.value.length===0?(f.value=!1,k("dsg-table:on-select-all")):k("dsg-table:on-deselect-all")},k=y,T=(v,m)=>[v,v+"-"+U.toSnakeCase(String(m?.name)),m.titleClass||"",{sortable:m.sortable},{"sort-active":u.value?.name===m.name}],$=v=>{v.sortable&&(u.value={name:String(v?.name),field:String(v?.sortField),direction:u.value?.name===v.name&&u.value?.direction==="asc"?"desc":"asc"},k("dsg-table:sort-field",v))};return(v,m)=>(e.openBlock(),e.createElementBlock("tr",Te,[v.hasSelectAll?(e.openBlock(),e.createElementBlock("th",Ne,[e.createVNode(P._sfc_main$2,{modelValue:f.value,"onUpdate:modelValue":[m[0]||(m[0]=o=>f.value=o),p],indeterminate:i.value.length>0&&i.value.length!==v.tableDataLength},null,8,["modelValue","indeterminate"])])):e.createCommentVNode("",!0),v.showExpandDetail?(e.openBlock(),e.createElementBlock("th",Fe)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.fields,(o,r)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[o?.visible?(e.openBlock(),e.createElementBlock("th",{key:r,class:e.normalizeClass(T("dsg-table--th",o)),style:e.normalizeStyle([{width:o.width||void 0},o.style]),title:o.title+(o.sortable?" Sort":""),id:"_"+o.name,onClick:c=>$(o),scope:"col"},[o.sortable?(e.openBlock(),e.createElementBlock("div",Le,[o.title?(e.openBlock(),e.createElementBlock("span",{key:0,class:"dsg-table--th-title",innerHTML:o.title},null,8,ze)):e.createCommentVNode("",!0),o.sortable&&u.value?.name!==o.name?(e.openBlock(),e.createBlock(P._sfc_main,{key:1,icon:"chevron-selector-vertical",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0),o.sortable&&u.value?.name===o.name&&u.value?.direction==="asc"?(e.openBlock(),e.createBlock(P._sfc_main,{key:2,icon:"chevron-down",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0),o.sortable&&u.value?.name===o.name&&u.value?.direction==="desc"?(e.openBlock(),e.createBlock(P._sfc_main,{key:3,icon:"chevron-up",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",{key:1,class:"dsg-table--th-title",innerHTML:e.unref(U.ucwords)(String(o?.title))},null,8,Re))],14,Me)):e.createCommentVNode("",!0)],64))),256)),v.scrollVisible?(e.openBlock(),e.createElementBlock("th",{key:2,style:e.normalizeStyle({width:g.value}),class:"dsg-table--th-col-gutter"},null,4)):e.createCommentVNode("",!0)]))}}),He={class:"dsg-table--wrapper"},Ie=["span"],Ae={key:0,class:"dsg-table--loading"},Oe=["colspan"],Ue=["colspan"],qe=["onClick","onDblclick","onMouseover"],We={key:0,class:"dsg-table--tbody-cell dsg-table--tbody-cell-checkbox"},je=["onClick","onDblclick","onContextmenu"],Ke=["innerHTML"],Qe=["onClick"],Ye=["colspan"],Ge={key:2},Je=["colspan"],Xe={class:"dsg-table--footer"},Ze=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},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}},{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"],["update:filterParams","update:perPage"]),setup(a,{expose:y,emit:u}){const i=t=>t.map((n,d)=>({field:n.field||"",title:n.title||"",name:n.name||"",titleClass:n.titleClass||"",dataClass:n.dataClass||"",visible:n.visible!==!1,width:n.width||void 0,sortField:n.sortField||null,sortable:n.sortField,formatter:n.formatter||null,$_index:d})),f=e.ref(i(a.fields)),g=e.ref(a.data),p=e.ref(null),k=e.ref(a.initialPage),T=e.ref("17px"),$=e.ref(!1),v=e.ref({}),m=e.ref(0),o=e.ref(!0),r=e.ref(null),c=e.ref(null),E=e.useModel(a,"filterParams"),B=e.useModel(a,"perPage"),w=e.ref([]),N=e.ref(!1),F=e.computed(()=>a.tableHeight!=null),M=e.computed(()=>f.value.filter(t=>t.visible).length);e.watch(()=>w.value.length,t=>{N.value=a.selectable&&t>0},{immediate:!0}),e.watch(()=>a.fields,t=>{f.value=i(t)},{immediate:!0}),e.watch(()=>E.value,()=>{L()},{deep:!0}),e.watch(()=>B.value,()=>{L()});const V=u,R=(t,n)=>t.formatter&&typeof t.formatter=="function"?t.formatter(t,n):O.data_get(n,String(t?.name),""),z=t=>"dsg-field--"+t.name?.toLowerCase().replaceAll(/[_ ]/g,"-"),H=t=>{if(a.selectable){if(t.selected)w.value.push(t);else{const n=w.value.findIndex(d=>d[a.trackBy]===t[a.trackBy]);n!==-1&&w.value.splice(n,1)}V("dsg-table:rows-selected",w.value)}},l=()=>{a.selectable&&(g.value?.forEach(t=>{t.selected=!0}),w.value=g.value?.filter(t=>t.selected)??[],V("dsg-table:rows-selected",w.value))},s=()=>{a.selectable&&(g.value?.forEach(t=>{t.selected=!1}),w.value=[],V("dsg-table:rows-selected",w.value))},b=t=>{t==="prev"?k.value>a.firstPage&&k.value--:t==="next"?k.value<(p.value?.last_page??0)&&k.value++:t!=k.value&&t>=a.firstPage&&t<=(p.value?.last_page??0)&&(k.value=t),L()},h=()=>({[a.queryParams?.sort]:r.value?(r.value?.direction==="desc"?"-":"")+r.value?.field:void 0,[a.queryParams?.order]:r.value?.direction,[a.queryParams?.page]:k.value,[a.queryParams?.perPage]:B.value}),C=()=>{c.value&&(c.value.abort(),c.value=null)},I=async(t,n)=>{C();const d=new AbortController;if(n.signal=d.signal,c.value=d,a.httpMethod.toLowerCase()==="get")return await P.axios.get(t,n);{const S=n.params;return delete n.params,await P.axios.post(t,S,n)}},q=t=>{V("dsg-table:load-success",t);const n=a.transform?a.transform(t.data):t.data;g.value=O.data_get(n,a.dataPath,null),a.selectable&&g.value?.forEach(d=>{d.selected=d.selected??!1}),p.value=O.data_get(n,a.paginationPath,null)??null,m.value=g.value?.length?g.value[0].order:m,p.value===null&&console.warn('DsgTable: pagination-path "'+a.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="".`),V("dsg-table:pagination-data",p.value),k.value>(p.value?.to||0)&&(k.value=a.initialPage),V("dsg-table:loaded"),o.value=!1},W=t=>{console.error("load-error",t),V("dsg-table:load-error",t),V("dsg-table:loaded"),o.value=!1},L=(t=q,n=W,d={})=>{const S=t||q,D=n||W;if(a.apiMode)return o.value=!0,V("dsg-table:loading",o.value),a.httpOptions.params={...h(),...E.value},I(a.apiUrl,a.httpOptions).then(S).catch(A=>D(A))},ne=(t,n,d)=>{V("dsg-table:row-clicked",t,n,d)},se=(t,n,d)=>{V("dsg-table:row-dblclick",t,n,d)},re=(t,n,d)=>{},ie=(t,n,d,S)=>{},de=(t,n,d,S)=>{},ce=(t,n,d,S)=>{},ue=(t,n,d)=>{};e.onMounted(()=>{a.apiMode===!0&&L()});const j=()=>{a.apiMode&&(w.value=[],C(),L())};return y({changePage:b,reload:j}),(t,n)=>(e.openBlock(),e.createElementBlock("div",He,[e.createElementVNode("div",{ref:"dsgTableBodyWrapper",class:e.normalizeClass(["dsg-table-body-wrapper",{"fixed-header":F.value}]),style:e.normalizeStyle({height:t.tableHeight||void 0})},[e.createElementVNode("table",{class:e.normalizeClass(["dsg-table-main",F.value?"fixed-header":"",v.value.table,"table-"+t.tableLayout])},[e.createElementVNode("colgroup",{span:M.value},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(d,S)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[d?.visible?(e.openBlock(),e.createElementBlock("col",{key:S,style:e.normalizeStyle({width:d.width||void 0}),class:e.normalizeClass("dsg-table--col-"+d.name+" "+d.titleClass)},null,6)):e.createCommentVNode("",!0)],64))),256)),!F.value&&$.value?(e.openBlock(),e.createElementBlock("col",{key:0,style:e.normalizeStyle({width:T.value}),class:"dsg-table--col-gutter"},null,4)):e.createCommentVNode("",!0)],8,Ie),e.createElementVNode("thead",{class:e.normalizeClass([[v.value.thead,{sticky:F.value,"top-0":F.value}],"dsg-table--head"])},[e.renderSlot(t.$slots,"tableHeader",{fields:f.value},()=>[e.createVNode(X,{fields:f.value,"has-select-all":t.selectable,"selected-rows":w.value,"onUpdate:selectedRows":n[0]||(n[0]=d=>w.value=d),"has-selected":N.value,"onUpdate:hasSelected":n[1]||(n[1]=d=>N.value=d),"scroll-visible":$.value,"show-expand-detail":t.hasDetailRow&&t.showExpandDetail,"table-data-length":g.value?.length,"sort-field":r.value,"onUpdate:sortField":n[2]||(n[2]=d=>r.value=d),"onDsgTable:sortField":n[3]||(n[3]=d=>j()),"onDsgTable:onSelectAll":l,"onDsgTable:onDeselectAll":s},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",v.value.tbody])},[o.value?(e.openBlock(),e.createElementBlock("tr",Ae,[e.createElementVNode("td",{colspan:M.value},[e.createElementVNode("div",{"aria-label":"Loading...",role:"status",class:"flex items-center space-x-3 h-12 w-full justify-center",colspan:M.value},[e.renderSlot(t.$slots,"dsg-table-loading",{},()=>[e.createVNode(P._sfc_main,{icon:"loading-02",class:"animate-spin"}),n[4]||(n[4]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-500"},"Loading...",-1))])],8,Ue)],8,Oe)])):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(g.value,(d,S)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:S},[e.createElementVNode("tr",{class:e.normalizeClass(["dsg-table--tbody-row",{odd:S%2===0,even:S%2!==0,"row-selected":d.selected}]),onClick:D=>ne(D,S,d),onDblclick:D=>se(D,S,d),onMouseover:D=>re()},[t.selectable?(e.openBlock(),e.createElementBlock("td",We,[e.createVNode(P._sfc_main$2,{modelValue:d.selected,"onUpdate:modelValue":[D=>d.selected=D,D=>H(d)]},null,8,["modelValue","onUpdate:modelValue"])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(D,A)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:A},[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:K=>ie(),onDblclick:K=>de(),onContextmenu:K=>ce()},[e.renderSlot(t.$slots,z(D),{rowData:d,rowIndex:S,rowField:D},()=>[e.createElementVNode("span",{innerHTML:R(D,d)},null,8,Ke)])],46,je)):e.createCommentVNode("",!0)],64))),128))],42,qe),t.hasDetailRow?(e.openBlock(),e.createBlock(e.Transition,{key:0,name:t.detailRowTransition},{default:e.withCtx(()=>[e.createElementVNode("tr",{class:"dsg-table--tbody-detail-row",onClick:D=>ue()},[e.createElementVNode("td",{colspan:M.value},[e.renderSlot(t.$slots,"dsg-table-detail-row",{rowData:d,rowIndex:S,options:t.detailRowOptions})],8,Ye)],8,Qe)]),_:2},1032,["name"])):e.createCommentVNode("",!0)],64))),128)),!o.value&&!g.value?.length&&t.noDataTemplate.length?(e.openBlock(),e.createElementBlock("tr",Ge,[e.createElementVNode("td",{colspan:M.value,class:"dsg-table--empty-result"},[e.renderSlot(t.$slots,"dsg-table-empty-result",{},()=>[e.createTextVNode(e.toDisplayString(t.noDataTemplate),1)])],8,Je)])):e.createCommentVNode("",!0)],2),e.createElementVNode("tfoot",Xe,[e.renderSlot(t.$slots,"dsg-table-footer",{fields:f.value,data:g.value})])],2)],6)]))}}),xe={class:"dsg-table"},_e={key:0,class:"dsg-table--pre-header"},et={class:"dsg-table--pre-header-left"},tt=["textContent"],at={class:"dsg-table--pre-header-right"},lt={key:1,class:"dsg-table--search-header",ref:"dsgTableSearchHeaderEl"},ot={class:"dsg-table--search-top"},nt={key:2,class:"dsg-table--footer",ref:"dsgTableFooterEl"},st={class:"dsg-table--footer-left"},rt={class:"dsg-table--footer-center"},it={class:"dsg-table--footer-right"},dt=e.defineComponent({__name:"DsgTable",props:{getUrl:{},fields:{},loadOnStart:{type:Boolean,default:!0},displayPaginationInfo:{type:Boolean,default:!0},reloadOnChangeTimer:{type:Boolean,default:!1},selectable:{type:Boolean,default:!1},trackBy:{default:"id"},title:{default:""},filters:{default:()=>{}},initialFilters:{default:()=>({})},filterEntity:{default:""},filterEndpoint:{default:""},filterSearchEndpoint:{default:""},tableLayout:{default:"fixed"},data:{default:null},hasHeader:{type:Boolean,default:!0},hasFooter:{type:Boolean,default:!0},css:{default:()=>({tableWrapper:"border-b"})}},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"],setup(a,{expose:y,emit:u}){const i=l=>{c.value=l},f=e.ref(!!(a.filterEntity||a.filterEndpoint)),g=()=>{if(f.value){let l={};return P.getQueryStrings().forEach(s=>{if(s.key.startsWith("filter[")){const b=s.key.replace("filter[","").replace("]",""),h=s.value;l[`filter[${b}]`]=h.join(",")}}),l}else return{}},p=e.computed(()=>({...a.css,tableWrapper:"border-b "+(a.css?.tableWrapper||"")})),k=e.useSlots(),T=e.ref(!0),$=e.ref(null),v=e.ref("<p>Showing {from} to {to} of {total}</p>"),m=e.ref(null),o=e.useTemplateRef("dsgTable"),r=e.ref({perPage:20,change:i}),c=e.ref(20),E=e.ref({...g(),...a.initialFilters}),B=u,w=l=>{o.value?.changePage(l)},N=l=>{m.value=l},F=({data:l})=>{$.value=l,B("dsg-table:data-loaded",l)},M=()=>{T.value===!1&&o.value?.reload()},V=l=>{o.value?.setData(o.value?.tableData.map(s=>s.id===l.id?l:s))},R=l=>{E.value=l},z=l=>{E.value["filter[term]"]=l,B("dsg-table:term-changed",l)},H=(l,s,b)=>{E.value={"filter[term]":E.value["filter[term]"],...l},B("dsg-table:filter-updated",E.value,s,b)};return y({reloadTable:M,updateRowTable:V,termChanged:z,setFilters:R}),(l,s)=>(e.openBlock(),e.createElementBlock("div",xe,[l.hasHeader?(e.openBlock(),e.createElementBlock("div",_e,[e.renderSlot(l.$slots,"dsg-table--pre-header",{},()=>[e.createElementVNode("div",et,[e.renderSlot(l.$slots,"dsg-table--page-title",{data:$.value,title:l.title},()=>[l.title.length>0?(e.openBlock(),e.createElementBlock("h1",{key:0,class:"dsg-table--title",textContent:e.toDisplayString(l.title)},null,8,tt)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",at,[e.renderSlot(l.$slots,"dsg-table--page-actions",{data:$.value})])])])):e.createCommentVNode("",!0),l.displayPaginationInfo?(e.openBlock(),e.createElementBlock("div",lt,[e.createElementVNode("div",ot,[e.renderSlot(l.$slots,"dsg-table--search-header",{data:$.value},()=>[e.createVNode(J,{name:"term","onDsgTable:termChanged":s[0]||(s[0]=b=>z(b))}),e.createVNode(P._sfc_main$7,{entity:l.filterEntity,"filter-endpoint":l.filterEndpoint,"search-endpoint":l.filterSearchEndpoint,filters:l.filters,"onDsgTable:filterUpdated":s[1]||(s[1]=(b,h,C)=>H(b,h,C))},null,8,["entity","filter-endpoint","search-endpoint","filters"]),e.renderSlot(l.$slots,"dsg-table--search-actions",{data:$.value})])]),e.renderSlot(l.$slots,"dsg-table--search-navigation")],512)):e.createCommentVNode("",!0),e.createVNode(Ze,{ref:"dsgTable","api-url":l.getUrl,"filter-params":E.value,"onUpdate:filterParams":s[7]||(s[7]=b=>E.value=b),"per-page":c.value,"onUpdate:perPage":s[8]||(s[8]=b=>c.value=b),fields:l.fields,"load-on-start":l.loadOnStart,"pagination-path":"meta",selectable:l.selectable,"track-by":l.trackBy,"table-layout":l.tableLayout,css:p.value,data:l.data,"onDsgTable:loading":s[9]||(s[9]=b=>T.value=!0),"onDsgTable:loaded":s[10]||(s[10]=b=>T.value=!1),"onDsgTable:paginationData":N,"onDsgTable:loadSuccess":F,"onDsgTable:rowsSelected":s[11]||(s[11]=b=>B("dsg-table:rows-selected",b)),"onDsgTable:rowClicked":s[12]||(s[12]=(b,h,C)=>B("dsg-table:row-clicked",b,h,C)),"onDsgTable:rowHover":s[13]||(s[13]=(b,h,C)=>B("dsg-table:row-hover",b,h,C)),"onDsgTable:rowDblclick":s[14]||(s[14]=(b,h,C)=>B("dsg-table:row-dblclick",b,h,C))},e.createSlots({"dsg-field--actions":e.withCtx(b=>[e.renderSlot(l.$slots,"dsg-table-actions",{data:b},()=>[(e.openBlock(),e.createBlock(G,{key:b.rowIndex,data:b,"onDsgTable:actionEdit":s[2]||(s[2]=(h,C)=>B("dsg-table:action-edit",h,C)),"onDsgTable:actionView":s[3]||(s[3]=(h,C)=>B("dsg-table:action-view",h,C)),"onDsgTable:actionDelete":s[4]||(s[4]=(h,C)=>B("dsg-table:action-delete",h,C)),"onDsgTable:actionArchive":s[5]||(s[5]=(h,C)=>B("dsg-table:action-archive",h,C)),"onDsgTable:linkClicked":s[6]||(s[6]=(h,C,I)=>B("dsg-table:link-clicked",h,C,I))},null,8,["data"]))])]),_:2},[e.renderList(e.unref(k),(b,h)=>({name:h,fn:e.withCtx(C=>[String(h)!=="dsg-field--actions"?e.renderSlot(l.$slots,h,e.normalizeProps(e.mergeProps({key:0},C))):e.createCommentVNode("",!0)])}))]),1032,["api-url","filter-params","per-page","fields","load-on-start","selectable","track-by","table-layout","css","data"]),l.hasFooter?(e.openBlock(),e.createElementBlock("div",nt,[e.createElementVNode("div",st,[e.renderSlot(l.$slots,"dsg-table--footer-left",{data:m.value,perPage:r.value},()=>[e.createVNode(Y,{ref:"paginationInfoStart",pagination:m.value,"onUpdate:pagination":s[15]||(s[15]=b=>m.value=b),"info-template":v.value},null,8,["pagination","info-template"]),e.renderSlot(l.$slots,"dsg-table--footer-left-extras",{data:m.value,perPage:r.value})])]),e.createElementVNode("div",rt,[e.renderSlot(l.$slots,"dsg-table--footer-center",{data:m.value,perPage:r.value},()=>[e.renderSlot(l.$slots,"dsg-table--footer-center-extras",{data:m.value,perPage:r.value})])]),e.createElementVNode("div",it,[e.renderSlot(l.$slots,"dsg-table--footer-right",{data:m.value,perPage:r.value},()=>[T.value===!1?(e.openBlock(),e.createBlock(Q,{key:0,ref:"pagination",pagination:m.value,"onUpdate:pagination":s[16]||(s[16]=b=>m.value=b),"onDsgTable:changePage":w},null,8,["pagination"])):e.createCommentVNode("",!0),e.renderSlot(l.$slots,"dsg-table--footer-right-extras",{data:m.value,perPage:r.value})])])],512)):e.createCommentVNode("",!0)]))}}),ct={class:"dsg-table--per-page"},ut=["value","textContent"],gt=e.defineComponent({__name:"DsgTablePerPage",props:{perPageOptions:{default:()=>[10,20,30,50,100]},perPage:{}},setup(a){return(y,u)=>(e.openBlock(),e.createElementBlock("div",ct,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":u[0]||(u[0]=i=>y.perPage.perPage=i),class:"dsg-table--per-page-select",onChange:u[1]||(u[1]=i=>y.perPage.change(y.perPage.perPage))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.perPageOptions,i=>(e.openBlock(),e.createElementBlock("option",{key:i,value:i,textContent:e.toDisplayString(i)},null,8,ut))),128))],544),[[e.vModelSelect,y.perPage.perPage]])]))}}),Z=dt,x=G,_=gt,ee=P._sfc_main$7,te=Q,ae=Y,le=J,oe=X,mt={DsgTable:Z,DsgTableActions:x,DsgTablePerPage:_,DsgTableFilter:ee,DsgTablePagination:te,DsgTablePaginationInfo:ae,DsgTableSearch:le,DsgTableRowHeader:oe};exports.DsgTable=Z;exports.DsgTableActions=x;exports.DsgTableFilter=ee;exports.DsgTablePagination=te;exports.DsgTablePaginationInfo=ae;exports.DsgTablePerPage=_;exports.DsgTableRowHeader=oe;exports.DsgTableSearch=le;exports.default=mt;
|
|
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-DEG12JOR.cjs"),W=require("./dsg-vue.helpers-string.cjs"),q=require("./dsg-vue.helpers-object.cjs"),fe={class:"dsg-table--pagination"},be=["disabled"],ve=["disabled"],pe=["onClick","innerHTML"],ke=["onClick","innerHTML"],he=["disabled"],ye=["disabled"],G=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(a,{expose:y,emit:m}){const i=e.useModel(a,"pagination"),b=e.computed(()=>i.value===null?0:i.value?.last_page-a.firstPage+1),c=e.computed(()=>i.value===null?0:i.value?.last_page),p=e.computed(()=>i.value===null?!1:i.value?.current_page===a.firstPage),k=e.computed(()=>i.value===null?!1:i.value?.current_page===c.value),T=e.computed(()=>b.value<a.onEachSide*2+4),$=e.computed(()=>a.onEachSide*2+1),v=e.computed(()=>!i.value||i.value?.current_page<=a.onEachSide?1:i.value?.current_page>=b.value-a.onEachSide?b.value-a.onEachSide*2:i.value?.current_page-a.onEachSide),f=m,o=g=>{f("dsg-table:change-page",g)},r=g=>g===i.value?.current_page;return y({loadPage:o}),(g,E)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",fe,[g.showFirstLast?(e.openBlock(),e.createElementBlock("a",{key:0,onClick:E[0]||(E[0]=B=>o(g.firstPage)),class:e.normalizeClass([[p.value?"disabled":""],"dsg-table--pagination-link"]),disabled:p.value,title:"First","aria-label":"First"},[e.createVNode(P._sfc_main,{icon:g.firstIcon,size:"sm"},null,8,["icon"])],10,be)):e.createCommentVNode("",!0),e.createElementVNode("a",{onClick:E[1]||(E[1]=B=>o("prev")),class:e.normalizeClass([[p.value?"disabled":""],"dsg-table--pagination-link"]),disabled:p.value,title:"Previous","aria-label":"Previous"},[e.createVNode(P._sfc_main,{icon:g.prevIcon,size:"sm"},null,8,["icon"])],10,ve),T.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(b.value,(B,w)=>(e.openBlock(),e.createElementBlock("a",{key:w,onClick:N=>o(w+g.firstPage),class:e.normalizeClass([[r(w+g.firstPage)?"active":""],"dsg-table--pagination-link"]),innerHTML:B},null,10,pe))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:2},e.renderList($.value,(B,w)=>(e.openBlock(),e.createElementBlock("a",{key:w,onClick:N=>o(v.value+w+g.firstPage-1),class:e.normalizeClass([[r(v.value+w+g.firstPage-1)?"active":""],"dsg-table--pagination-link"]),innerHTML:v.value+B-1},null,10,ke))),128)),e.createElementVNode("a",{onClick:E[2]||(E[2]=B=>o("next")),class:e.normalizeClass([[k.value?"disabled":""],"dsg-table--pagination-link"]),disabled:k.value,title:"Next","aria-label":"Next"},[e.createVNode(P._sfc_main,{icon:g.nextIcon,size:"sm"},null,8,["icon"])],10,he),g.showFirstLast?(e.openBlock(),e.createElementBlock("a",{key:3,onClick:E[3]||(E[3]=B=>o(c.value)),class:e.normalizeClass([[k.value?"disabled":""],"dsg-table--pagination-link"]),disabled:k.value,title:"Last","aria-label":"Last"},[e.createVNode(P._sfc_main,{icon:g.lastIcon,size:"sm"},null,8,["icon"])],10,ye)):e.createCommentVNode("",!0)],512)),[[e.vShow,i.value&&c.value>g.firstPage]])}}),Be=["innerHTML"],J=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(a){const y=e.useModel(a,"pagination"),m=e.computed(()=>y.value==null||y.value.total==0?a.noDataTemplate:a.infoTemplate.replace("{from}",(y.value?.from||0).toString()).replace("{to}",(y.value?.to||0).toString()).replace("{total}",(y.value?.total||0).toString()));return(i,b)=>(e.openBlock(),e.createElementBlock("div",{class:"dsg-table--pagination-info",innerHTML:m.value},null,8,Be))}}),we={class:"dsg-table--actions",ref:"dsgTableActions"},Ce={class:"dsg-table--action-trigger"},Pe={key:0,class:"dsg-table--actions-menu-wrapper"},Ee=["href","target","onClick"],De=["textContent"],Se={key:0},$e={key:1},Ve=["href","target","onClick"],Te={class:"flex-1"},X=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(a,{emit:y}){const m=e.ref(!1);e.useTemplateRef("dsgTableActions");const i=e.useAttrs(),b=e.ref(i.data.rowData?.actions??null),c=e.ref(i.data.rowData?.links??null),p=e.ref(i.data.rowData??null),k=f=>{switch(f){case"edit":return"edit-05";case"view":return"eye";case"delete":return"trash-01";case"archive":return"eye-off";default:return"dots-horizontal"}},T=(f,o,r)=>{switch(o){case"edit":v("dsg-table:action-edit",r,p.value);break;case"view":v("dsg-table:action-view",r,p.value);break;case"delete":v("dsg-table:action-delete",r,p.value);break;case"archive":v("dsg-table:action-archive",r,p.value);break}},$=(f,o)=>{const r=f.actionId||f.label.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-");v("dsg-table:link-clicked",o,r,p.value)},v=y;return(f,o)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",we,[e.createVNode(e.unref(P.kt),{triggers:[],placement:f.placement,"handle-resize":!0,strategy:"absolute",shown:m.value,class:"dsg-table--actions__popper",onHide:o[1]||(o[1]=r=>m.value=!1),ref:"floatingVueFilterDropdown"},{popper:e.withCtx(()=>[m.value?(e.openBlock(),e.createElementBlock("div",Pe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,(r,g)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[["edit","view","delete","archive"].includes(String(g))?(e.openBlock(),e.createElementBlock("a",{key:g,href:b.value?.link,target:b.value?.target||"_self",onClick:E=>T(r,String(g),E)},[e.createElementVNode("div",{class:e.normalizeClass(["dsg-table--actions-menu-item",String(g)])},[e.createVNode(P._sfc_main,{icon:k(String(g)),size:"sm"},null,8,["icon"]),e.createElementVNode("span",{class:"flex-1",textContent:e.toDisplayString(e.unref(W.ucfirst)(String(g)))},null,8,De)],2)],8,Ee)):e.createCommentVNode("",!0)],64))),256)),b.value&&c.value?(e.openBlock(),e.createElementBlock("hr",Se)):e.createCommentVNode("",!0),c.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(c.value,r=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:r.label},[r.hasOwnProperty("component")?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.component),{key:0,quote:e.unref(i).data.data.rowData,"row-data":e.unref(i).data.data.rowData},null,8,["quote","row-data"])):r.hasOwnProperty("type")&&r.type=="break"?(e.openBlock(),e.createElementBlock("hr",$e)):(e.openBlock(),e.createElementBlock("a",{key:2,href:r.link,target:r.target||"_self",class:e.normalizeClass(["dsg-table--actions-menu-item",r.class]),onClick:g=>$(r,g)},[r.icon?(e.openBlock(),e.createBlock(P._sfc_main,{key:0,icon:r.icon,size:"sm"},null,8,["icon"])):e.createCommentVNode("",!0),e.createElementVNode("span",Te,e.toDisplayString(r.label),1)],10,Ve))],64))),128)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]),default:e.withCtx(()=>[e.createElementVNode("div",Ce,[e.createElementVNode("button",{type:"button",class:"dsg-table--actions-button","aria-expanded":"false","aria-haspopup":"true",onClick:o[0]||(o[0]=r=>m.value=!m.value)},[e.renderSlot(f.$slots,"dsg-table-action-button-content",{},()=>[e.createVNode(P._sfc_main,{icon:"dots-vertical",size:"sm"})])])])]),_:3},8,["placement","shown"])])),[[e.unref(P.vOnClickOutside),()=>m.value=!1]])}}),Ne={class:"dsg-table--search"},Z=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:{}},emits:["dsg-table:term-changed"],setup(a,{emit:y}){const m=e.ref(""),i=y,b=P.useDebounceFn(c=>{m.value=c,i("dsg-table:term-changed",m.value)},300);return(c,p)=>(e.openBlock(),e.createElementBlock("div",Ne,[e.createVNode(P._sfc_main$4,{value:m.value,"onUpdate:value":p[0]||(p[0]=k=>m.value=k),name:c.name,id:c.id||c.name,placeholder:c.placeholder,disabled:c.disabled,required:c.required,readonly:c.readonly,hidden:c.hidden,"has-clear-button":!0,autocomplete:"off",size:"sm",icon:"search-sm","icon-clickable":!0,onIconClicked:p[1]||(p[1]=k=>e.unref(b)(k)),onEnterPressed:p[2]||(p[2]=k=>e.unref(b)(k)),onOnClear:p[3]||(p[3]=()=>e.unref(b)(""))},null,8,["value","name","id","placeholder","disabled","required","readonly","hidden"])]))}}),Fe={class:"dsg-table--header-row"},Me={key:0,class:"dsg-table--th dsg-table--th-checkbox",scope:"col"},Le={key:1,class:"dsg-table--th dsg-table--th-expand-detail",scope:"col"},ze=["title","id","onClick"],Re={key:0,class:"dsg-table--th-sort-icon"},He=["innerHTML"],Ae=["innerHTML"],x=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(a,{emit:y}){const m=e.useModel(a,"sortField"),i=e.useModel(a,"selectedRows"),b=e.useModel(a,"hasSelected"),c=e.ref("17px"),p=v=>{b.value&&i.value.length>0&&i.value.length!==a.tableDataLength?(b.value=!0,k("dsg-table:on-select-all")):!b.value&&i.value.length===0?(b.value=!1,k("dsg-table:on-select-all")):k("dsg-table:on-deselect-all")},k=y,T=(v,f)=>[v,v+"-"+W.toSnakeCase(String(f?.name)),f.titleClass||"",{sortable:f.sortable},{"sort-active":m.value?.name===f.name}],$=v=>{v.sortable&&(m.value={name:String(v?.name),field:String(v?.sortField),direction:m.value?.name===v.name&&m.value?.direction==="asc"?"desc":"asc"},k("dsg-table:sort-field",v))};return(v,f)=>(e.openBlock(),e.createElementBlock("tr",Fe,[v.hasSelectAll?(e.openBlock(),e.createElementBlock("th",Me,[e.createVNode(P._sfc_main$2,{modelValue:b.value,"onUpdate:modelValue":[f[0]||(f[0]=o=>b.value=o),p],indeterminate:i.value.length>0&&i.value.length!==v.tableDataLength},null,8,["modelValue","indeterminate"])])):e.createCommentVNode("",!0),v.showExpandDetail?(e.openBlock(),e.createElementBlock("th",Le)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.fields,(o,r)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[o?.visible?(e.openBlock(),e.createElementBlock("th",{key:r,class:e.normalizeClass(T("dsg-table--th",o)),style:e.normalizeStyle([{width:o.width||void 0},o.style]),title:o.title+(o.sortable?" Sort":""),id:"_"+o.name,onClick:g=>$(o),scope:"col"},[o.sortable?(e.openBlock(),e.createElementBlock("div",Re,[o.title?(e.openBlock(),e.createElementBlock("span",{key:0,class:"dsg-table--th-title",innerHTML:o.title},null,8,He)):e.createCommentVNode("",!0),o.sortable&&m.value?.name!==o.name?(e.openBlock(),e.createBlock(P._sfc_main,{key:1,icon:"chevron-selector-vertical",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0),o.sortable&&m.value?.name===o.name&&m.value?.direction==="asc"?(e.openBlock(),e.createBlock(P._sfc_main,{key:2,icon:"chevron-down",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0),o.sortable&&m.value?.name===o.name&&m.value?.direction==="desc"?(e.openBlock(),e.createBlock(P._sfc_main,{key:3,icon:"chevron-up",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",{key:1,class:"dsg-table--th-title",innerHTML:e.unref(W.ucwords)(String(o?.title))},null,8,Ae))],14,ze)):e.createCommentVNode("",!0)],64))),256)),v.scrollVisible?(e.openBlock(),e.createElementBlock("th",{key:2,style:e.normalizeStyle({width:c.value}),class:"dsg-table--th-col-gutter"},null,4)):e.createCommentVNode("",!0)]))}}),Ie={class:"dsg-table--wrapper"},Oe=["span"],Ue={key:0,class:"dsg-table--loading"},qe=["colspan"],We=["colspan"],je=["onClick","onDblclick","onMouseover"],Ke={key:0,class:"dsg-table--tbody-cell dsg-table--tbody-cell-checkbox"},Qe=["onClick","onDblclick","onContextmenu"],Ye=["innerHTML"],Ge=["onClick"],Je=["colspan"],Xe={key:2},Ze=["colspan"],xe={class:"dsg-table--footer"},_e=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},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}},{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"],["update:filterParams","update:perPage"]),setup(a,{expose:y,emit:m}){const i=t=>t.map((n,d)=>({field:n.field||"",title:n.title||"",name:n.name||"",titleClass:n.titleClass||"",dataClass:n.dataClass||"",visible:n.visible!==!1,width:n.width||void 0,sortField:n.sortField||null,sortable:n.sortField,formatter:n.formatter||null,$_index:d})),b=e.ref(i(a.fields)),c=e.ref(a.data),p=e.ref(null),k=e.ref(a.initialPage),T=e.ref("17px"),$=e.ref(!1),v=e.ref({}),f=e.ref(0),o=e.ref(!0),r=e.ref(null),g=e.ref(null),E=e.useModel(a,"filterParams"),B=e.useModel(a,"perPage"),w=e.ref([]),N=e.ref(!1),F=e.computed(()=>a.tableHeight!=null),M=e.computed(()=>b.value.filter(t=>t.visible).length);e.watch(()=>w.value.length,t=>{N.value=a.selectable&&t>0},{immediate:!0}),e.watch(()=>a.fields,t=>{b.value=i(t)},{immediate:!0}),e.watch(()=>E.value,()=>{L()},{deep:!0}),e.watch(()=>B.value,()=>{L()});const V=m,R=(t,n)=>t.formatter&&typeof t.formatter=="function"?t.formatter(t,n):q.data_get(n,String(t?.name),""),H=t=>"dsg-field--"+t.name?.toLowerCase().replaceAll(/[_ ]/g,"-"),A=t=>{if(a.selectable){if(t.selected)w.value.push(t);else{const n=w.value.findIndex(d=>d[a.trackBy]===t[a.trackBy]);n!==-1&&w.value.splice(n,1)}V("dsg-table:rows-selected",w.value)}},z=()=>{a.selectable&&(c.value?.forEach(t=>{t.selected=!0}),w.value=c.value?.filter(t=>t.selected)??[],V("dsg-table:rows-selected",w.value))},I=()=>{a.selectable&&(c.value?.forEach(t=>{t.selected=!1}),w.value=[],V("dsg-table:rows-selected",w.value))},l=t=>{c.value=Array.isArray(t)?t:[],a.selectable&&c.value.forEach(n=>{n.selected=n.selected??!1})},s=()=>c.value??[],u=t=>{t==="prev"?k.value>a.firstPage&&k.value--:t==="next"?k.value<(p.value?.last_page??0)&&k.value++:t!=k.value&&t>=a.firstPage&&t<=(p.value?.last_page??0)&&(k.value=t),L()},h=()=>({[a.queryParams?.sort]:r.value?(r.value?.direction==="desc"?"-":"")+r.value?.field:void 0,[a.queryParams?.order]:r.value?.direction,[a.queryParams?.page]:k.value,[a.queryParams?.perPage]:B.value}),C=()=>{g.value&&(g.value.abort(),g.value=null)},O=async(t,n)=>{C();const d=new AbortController;if(n.signal=d.signal,g.value=d,a.httpMethod.toLowerCase()==="get")return await P.axios.get(t,n);{const S=n.params;return delete n.params,await P.axios.post(t,S,n)}},j=t=>{V("dsg-table:load-success",t);const n=a.transform?a.transform(t.data):t.data;c.value=q.data_get(n,a.dataPath,null),a.selectable&&c.value?.forEach(d=>{d.selected=d.selected??!1}),p.value=q.data_get(n,a.paginationPath,null)??null,f.value=c.value?.length?c.value[0].order:f,p.value===null&&console.warn('DsgTable: pagination-path "'+a.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="".`),V("dsg-table:pagination-data",p.value),k.value>(p.value?.to||0)&&(k.value=a.initialPage),V("dsg-table:loaded"),o.value=!1},K=t=>{console.error("load-error",t),V("dsg-table:load-error",t),V("dsg-table:loaded"),o.value=!1},L=(t=j,n=K,d={})=>{const S=t||j,D=n||K;if(a.apiMode)return o.value=!0,V("dsg-table:loading",o.value),a.httpOptions.params={...h(),...E.value},O(a.apiUrl,a.httpOptions).then(S).catch(U=>D(U))},re=(t,n,d)=>{V("dsg-table:row-clicked",t,n,d)},ie=(t,n,d)=>{V("dsg-table:row-dblclick",t,n,d)},de=(t,n,d)=>{},ce=(t,n,d,S)=>{},ue=(t,n,d,S)=>{},ge=(t,n,d,S)=>{},me=(t,n,d)=>{};e.onMounted(()=>{a.apiMode===!0&&L()});const Q=()=>{a.apiMode&&(w.value=[],C(),L())};return y({changePage:u,reload:Q,getData:s,setData:l}),(t,n)=>(e.openBlock(),e.createElementBlock("div",Ie,[e.createElementVNode("div",{ref:"dsgTableBodyWrapper",class:e.normalizeClass(["dsg-table-body-wrapper",{"fixed-header":F.value}]),style:e.normalizeStyle({height:t.tableHeight||void 0})},[e.createElementVNode("table",{class:e.normalizeClass(["dsg-table-main",F.value?"fixed-header":"",v.value.table,"table-"+t.tableLayout])},[e.createElementVNode("colgroup",{span:M.value},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,(d,S)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[d?.visible?(e.openBlock(),e.createElementBlock("col",{key:S,style:e.normalizeStyle({width:d.width||void 0}),class:e.normalizeClass("dsg-table--col-"+d.name+" "+d.titleClass)},null,6)):e.createCommentVNode("",!0)],64))),256)),!F.value&&$.value?(e.openBlock(),e.createElementBlock("col",{key:0,style:e.normalizeStyle({width:T.value}),class:"dsg-table--col-gutter"},null,4)):e.createCommentVNode("",!0)],8,Oe),e.createElementVNode("thead",{class:e.normalizeClass([[v.value.thead,{sticky:F.value,"top-0":F.value}],"dsg-table--head"])},[e.renderSlot(t.$slots,"tableHeader",{fields:b.value},()=>[e.createVNode(x,{fields:b.value,"has-select-all":t.selectable,"selected-rows":w.value,"onUpdate:selectedRows":n[0]||(n[0]=d=>w.value=d),"has-selected":N.value,"onUpdate:hasSelected":n[1]||(n[1]=d=>N.value=d),"scroll-visible":$.value,"show-expand-detail":t.hasDetailRow&&t.showExpandDetail,"table-data-length":c.value?.length,"sort-field":r.value,"onUpdate:sortField":n[2]||(n[2]=d=>r.value=d),"onDsgTable:sortField":n[3]||(n[3]=d=>Q()),"onDsgTable:onSelectAll":z,"onDsgTable:onDeselectAll":I},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",v.value.tbody])},[o.value?(e.openBlock(),e.createElementBlock("tr",Ue,[e.createElementVNode("td",{colspan:M.value},[e.createElementVNode("div",{"aria-label":"Loading...",role:"status",class:"flex items-center space-x-3 h-12 w-full justify-center",colspan:M.value},[e.renderSlot(t.$slots,"dsg-table-loading",{},()=>[e.createVNode(P._sfc_main,{icon:"loading-02",class:"animate-spin"}),n[4]||(n[4]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-500"},"Loading...",-1))])],8,We)],8,qe)])):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(c.value,(d,S)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:S},[e.createElementVNode("tr",{class:e.normalizeClass(["dsg-table--tbody-row",{odd:S%2===0,even:S%2!==0,"row-selected":d.selected}]),onClick:D=>re(D,S,d),onDblclick:D=>ie(D,S,d),onMouseover:D=>de()},[t.selectable?(e.openBlock(),e.createElementBlock("td",Ke,[e.createVNode(P._sfc_main$2,{modelValue:d.selected,"onUpdate:modelValue":[D=>d.selected=D,D=>A(d)]},null,8,["modelValue","onUpdate:modelValue"])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,(D,U)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:U},[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:Y=>ce(),onDblclick:Y=>ue(),onContextmenu:Y=>ge()},[e.renderSlot(t.$slots,H(D),{rowData:d,rowIndex:S,rowField:D},()=>[e.createElementVNode("span",{innerHTML:R(D,d)},null,8,Ye)])],46,Qe)):e.createCommentVNode("",!0)],64))),128))],42,je),t.hasDetailRow?(e.openBlock(),e.createBlock(e.Transition,{key:0,name:t.detailRowTransition},{default:e.withCtx(()=>[e.createElementVNode("tr",{class:"dsg-table--tbody-detail-row",onClick:D=>me()},[e.createElementVNode("td",{colspan:M.value},[e.renderSlot(t.$slots,"dsg-table-detail-row",{rowData:d,rowIndex:S,options:t.detailRowOptions})],8,Je)],8,Ge)]),_:2},1032,["name"])):e.createCommentVNode("",!0)],64))),128)),!o.value&&!c.value?.length&&t.noDataTemplate.length?(e.openBlock(),e.createElementBlock("tr",Xe,[e.createElementVNode("td",{colspan:M.value,class:"dsg-table--empty-result"},[e.renderSlot(t.$slots,"dsg-table-empty-result",{},()=>[e.createTextVNode(e.toDisplayString(t.noDataTemplate),1)])],8,Ze)])):e.createCommentVNode("",!0)],2),e.createElementVNode("tfoot",xe,[e.renderSlot(t.$slots,"dsg-table-footer",{fields:b.value,data:c.value})])],2)],6)]))}}),et={class:"dsg-table"},tt={key:0,class:"dsg-table--pre-header"},at={class:"dsg-table--pre-header-left"},lt=["textContent"],ot={class:"dsg-table--pre-header-right"},nt={key:1,class:"dsg-table--search-header",ref:"dsgTableSearchHeaderEl"},st={class:"dsg-table--search-top"},rt={key:2,class:"dsg-table--footer",ref:"dsgTableFooterEl"},it={class:"dsg-table--footer-left"},dt={class:"dsg-table--footer-center"},ct={class:"dsg-table--footer-right"},ut=e.defineComponent({__name:"DsgTable",props:{getUrl:{},fields:{},loadOnStart:{type:Boolean,default:!0},displayPaginationInfo:{type:Boolean,default:!0},reloadOnChangeTimer:{type:Boolean,default:!1},selectable:{type:Boolean,default:!1},trackBy:{default:"id"},title:{default:""},filters:{default:()=>{}},initialFilters:{default:()=>({})},filterEntity:{default:""},filterEndpoint:{default:""},filterSearchEndpoint:{default:""},tableLayout:{default:"fixed"},data:{default:null},hasHeader:{type:Boolean,default:!0},hasFooter:{type:Boolean,default:!0},css:{default:()=>({tableWrapper:"border-b"})}},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"],setup(a,{expose:y,emit:m}){const i=l=>{g.value=l},b=e.ref(!!(a.filterEntity||a.filterEndpoint)),c=()=>{if(b.value){let l={};return P.getQueryStrings().forEach(s=>{if(s.key.startsWith("filter[")){const u=s.key.replace("filter[","").replace("]",""),h=s.value;l[`filter[${u}]`]=h.join(",")}}),l}else return{}},p=e.computed(()=>({...a.css,tableWrapper:"border-b "+(a.css?.tableWrapper||"")})),k=e.useSlots(),T=e.ref(!0),$=e.ref(null),v=e.ref("<p>Showing {from} to {to} of {total}</p>"),f=e.ref(null),o=e.useTemplateRef("dsgTable"),r=e.ref({perPage:20,change:i}),g=e.ref(20),E=e.ref({...c(),...a.initialFilters}),B=m,w=l=>{o.value?.changePage(l)},N=l=>{f.value=l},F=({data:l})=>{$.value=l,B("dsg-table:data-loaded",l)},M=()=>{T.value===!1&&o.value?.reload()},V=l=>{const s=o.value?.getData?.()??[];o.value?.setData(s.map(u=>u.id===l.id?l:u))},R=l=>{const s=o.value?.getData?.()??[];o.value?.setData([...s,l])},H=l=>{const s=o.value?.getData?.()??[];o.value?.setData(s.filter(u=>u.id!==l.id))},A=l=>{E.value=l},z=l=>{E.value["filter[term]"]=l,B("dsg-table:term-changed",l)},I=(l,s,u)=>{E.value={"filter[term]":E.value["filter[term]"],...l},B("dsg-table:filter-updated",E.value,s,u)};return y({reloadTable:M,updateRowTable:V,addRowTable:R,deleteRowTable:H,termChanged:z,setFilters:A}),(l,s)=>(e.openBlock(),e.createElementBlock("div",et,[l.hasHeader?(e.openBlock(),e.createElementBlock("div",tt,[e.renderSlot(l.$slots,"dsg-table--pre-header",{},()=>[e.createElementVNode("div",at,[e.renderSlot(l.$slots,"dsg-table--page-title",{data:$.value,title:l.title},()=>[l.title.length>0?(e.openBlock(),e.createElementBlock("h1",{key:0,class:"dsg-table--title",textContent:e.toDisplayString(l.title)},null,8,lt)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",ot,[e.renderSlot(l.$slots,"dsg-table--page-actions",{data:$.value})])])])):e.createCommentVNode("",!0),l.displayPaginationInfo?(e.openBlock(),e.createElementBlock("div",nt,[e.createElementVNode("div",st,[e.renderSlot(l.$slots,"dsg-table--search-header",{data:$.value},()=>[e.createVNode(Z,{name:"term","onDsgTable:termChanged":s[0]||(s[0]=u=>z(u))}),e.createVNode(P._sfc_main$7,{entity:l.filterEntity,"filter-endpoint":l.filterEndpoint,"search-endpoint":l.filterSearchEndpoint,filters:l.filters,"onDsgTable:filterUpdated":s[1]||(s[1]=(u,h,C)=>I(u,h,C))},null,8,["entity","filter-endpoint","search-endpoint","filters"]),e.renderSlot(l.$slots,"dsg-table--search-actions",{data:$.value})])]),e.renderSlot(l.$slots,"dsg-table--search-navigation")],512)):e.createCommentVNode("",!0),e.createVNode(_e,{ref:"dsgTable","api-url":l.getUrl,"filter-params":E.value,"onUpdate:filterParams":s[7]||(s[7]=u=>E.value=u),"per-page":g.value,"onUpdate:perPage":s[8]||(s[8]=u=>g.value=u),fields:l.fields,"load-on-start":l.loadOnStart,"pagination-path":"meta",selectable:l.selectable,"track-by":l.trackBy,"table-layout":l.tableLayout,css:p.value,data:l.data,"onDsgTable:loading":s[9]||(s[9]=u=>T.value=!0),"onDsgTable:loaded":s[10]||(s[10]=u=>T.value=!1),"onDsgTable:paginationData":N,"onDsgTable:loadSuccess":F,"onDsgTable:rowsSelected":s[11]||(s[11]=u=>B("dsg-table:rows-selected",u)),"onDsgTable:rowClicked":s[12]||(s[12]=(u,h,C)=>B("dsg-table:row-clicked",u,h,C)),"onDsgTable:rowHover":s[13]||(s[13]=(u,h,C)=>B("dsg-table:row-hover",u,h,C)),"onDsgTable:rowDblclick":s[14]||(s[14]=(u,h,C)=>B("dsg-table:row-dblclick",u,h,C))},e.createSlots({"dsg-field--actions":e.withCtx(u=>[e.renderSlot(l.$slots,"dsg-table-actions",{data:u},()=>[(e.openBlock(),e.createBlock(X,{key:u.rowIndex,data:u,"onDsgTable:actionEdit":s[2]||(s[2]=(h,C)=>B("dsg-table:action-edit",h,C)),"onDsgTable:actionView":s[3]||(s[3]=(h,C)=>B("dsg-table:action-view",h,C)),"onDsgTable:actionDelete":s[4]||(s[4]=(h,C)=>B("dsg-table:action-delete",h,C)),"onDsgTable:actionArchive":s[5]||(s[5]=(h,C)=>B("dsg-table:action-archive",h,C)),"onDsgTable:linkClicked":s[6]||(s[6]=(h,C,O)=>B("dsg-table:link-clicked",h,C,O))},null,8,["data"]))])]),_:2},[e.renderList(e.unref(k),(u,h)=>({name:h,fn:e.withCtx(C=>[String(h)!=="dsg-field--actions"?e.renderSlot(l.$slots,h,e.normalizeProps(e.mergeProps({key:0},C))):e.createCommentVNode("",!0)])}))]),1032,["api-url","filter-params","per-page","fields","load-on-start","selectable","track-by","table-layout","css","data"]),l.hasFooter?(e.openBlock(),e.createElementBlock("div",rt,[e.createElementVNode("div",it,[e.renderSlot(l.$slots,"dsg-table--footer-left",{data:f.value,perPage:r.value},()=>[e.createVNode(J,{ref:"paginationInfoStart",pagination:f.value,"onUpdate:pagination":s[15]||(s[15]=u=>f.value=u),"info-template":v.value},null,8,["pagination","info-template"]),e.renderSlot(l.$slots,"dsg-table--footer-left-extras",{data:f.value,perPage:r.value})])]),e.createElementVNode("div",dt,[e.renderSlot(l.$slots,"dsg-table--footer-center",{data:f.value,perPage:r.value},()=>[e.renderSlot(l.$slots,"dsg-table--footer-center-extras",{data:f.value,perPage:r.value})])]),e.createElementVNode("div",ct,[e.renderSlot(l.$slots,"dsg-table--footer-right",{data:f.value,perPage:r.value},()=>[T.value===!1?(e.openBlock(),e.createBlock(G,{key:0,ref:"pagination",pagination:f.value,"onUpdate:pagination":s[16]||(s[16]=u=>f.value=u),"onDsgTable:changePage":w},null,8,["pagination"])):e.createCommentVNode("",!0),e.renderSlot(l.$slots,"dsg-table--footer-right-extras",{data:f.value,perPage:r.value})])])],512)):e.createCommentVNode("",!0)]))}}),gt={class:"dsg-table--per-page"},mt=["value","textContent"],ft=e.defineComponent({__name:"DsgTablePerPage",props:{perPageOptions:{default:()=>[10,20,30,50,100]},perPage:{}},setup(a){return(y,m)=>(e.openBlock(),e.createElementBlock("div",gt,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":m[0]||(m[0]=i=>y.perPage.perPage=i),class:"dsg-table--per-page-select",onChange:m[1]||(m[1]=i=>y.perPage.change(y.perPage.perPage))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.perPageOptions,i=>(e.openBlock(),e.createElementBlock("option",{key:i,value:i,textContent:e.toDisplayString(i)},null,8,mt))),128))],544),[[e.vModelSelect,y.perPage.perPage]])]))}}),_=ut,ee=X,te=ft,ae=P._sfc_main$7,le=G,oe=J,ne=Z,se=x,bt={DsgTable:_,DsgTableActions:ee,DsgTablePerPage:te,DsgTableFilter:ae,DsgTablePagination:le,DsgTablePaginationInfo:oe,DsgTableSearch:ne,DsgTableRowHeader:se};exports.DsgTable=_;exports.DsgTableActions=ee;exports.DsgTableFilter=ae;exports.DsgTablePagination=le;exports.DsgTablePaginationInfo=oe;exports.DsgTablePerPage=te;exports.DsgTableRowHeader=se;exports.DsgTableSearch=ne;exports.default=bt;
|