@dcodegroup-au/dsg-vue 0.1.19 → 0.1.20
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.
- package/dist/components/Table/DsgTable.vue.d.ts +3 -0
- package/dist/dsg-vue.table.cjs +2 -2
- package/dist/dsg-vue.table.esm.js +170 -169
- package/dist/table.d.ts +18 -0
- package/package.json +2 -2
|
@@ -347,6 +347,9 @@ declare const __VLS_component: import('vue').DefineComponent<DsgTableProps, {
|
|
|
347
347
|
mutateData: (mutator: (data: any[]) => any[] | void) => void;
|
|
348
348
|
termChanged: (term: string | null) => void;
|
|
349
349
|
setFilters: (filters: any) => void;
|
|
350
|
+
getFilters: () => {
|
|
351
|
+
[key: string]: any;
|
|
352
|
+
};
|
|
350
353
|
setLoading: (loadingState: boolean) => void;
|
|
351
354
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
352
355
|
"dsg-table:action-edit": (ev: Event, rowData: Record<string, 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"),D=require("./DsgTablePerPage.vue_vue_type_style_index_0_lang-DU5GAN6E.cjs"),Q=require("./dsg-vue.helpers-string.cjs"),K=require("./dsg-vue.helpers-object.cjs"),ke=require("./dsg-vue.helpers.cjs"),he={class:"dsg-table--pagination"},ye=["disabled"],pe=["disabled"],we=["onClick","innerHTML"],Be=["onClick","innerHTML"],Ce=["disabled"],Pe=["disabled"],X=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:S,emit:g}){const i=e.useModel(t,"pagination"),m=e.computed(()=>i.value===null?0:i.value?.last_page-t.firstPage+1),v=e.computed(()=>i.value===null?0:i.value?.last_page),u=e.computed(()=>i.value===null?!1:i.value?.current_page===t.firstPage),b=e.computed(()=>i.value===null?!1:i.value?.current_page===v.value),F=e.computed(()=>m.value<t.onEachSide*2+4),V=e.computed(()=>t.onEachSide*2+1),p=e.computed(()=>!i.value||i.value?.current_page<=t.onEachSide?1:i.value?.current_page>=m.value-t.onEachSide?m.value-t.onEachSide*2:i.value?.current_page-t.onEachSide),f=g,l=w=>{f("dsg-table:change-page",w)},d=w=>w===i.value?.current_page;return S({loadPage:l}),(w,B)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",he,[t.showFirstLast?(e.openBlock(),e.createElementBlock("a",{key:0,onClick:B[0]||(B[0]=C=>l(t.firstPage)),class:e.normalizeClass([[u.value?"disabled":""],"dsg-table--pagination-link"]),disabled:u.value,title:"First","aria-label":"First"},[e.createVNode(D._sfc_main,{icon:t.firstIcon,size:"sm"},null,8,["icon"])],10,ye)):e.createCommentVNode("",!0),e.createElementVNode("a",{onClick:B[1]||(B[1]=C=>l("prev")),class:e.normalizeClass([[u.value?"disabled":""],"dsg-table--pagination-link"]),disabled:u.value,title:"Previous","aria-label":"Previous"},[e.createVNode(D._sfc_main,{icon:t.prevIcon,size:"sm"},null,8,["icon"])],10,pe),F.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(m.value,(C,N)=>(e.openBlock(),e.createElementBlock("a",{key:N,onClick:$=>l(N+t.firstPage),class:e.normalizeClass([[d(N+t.firstPage)?"active":""],"dsg-table--pagination-link"]),innerHTML:C},null,10,we))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:2},e.renderList(V.value,(C,N)=>(e.openBlock(),e.createElementBlock("a",{key:N,onClick:$=>l(p.value+N+t.firstPage-1),class:e.normalizeClass([[d(p.value+N+t.firstPage-1)?"active":""],"dsg-table--pagination-link"]),innerHTML:p.value+C-1},null,10,Be))),128)),e.createElementVNode("a",{onClick:B[2]||(B[2]=C=>l("next")),class:e.normalizeClass([[b.value?"disabled":""],"dsg-table--pagination-link"]),disabled:b.value,title:"Next","aria-label":"Next"},[e.createVNode(D._sfc_main,{icon:t.nextIcon,size:"sm"},null,8,["icon"])],10,Ce),t.showFirstLast?(e.openBlock(),e.createElementBlock("a",{key:3,onClick:B[3]||(B[3]=C=>l(v.value)),class:e.normalizeClass([[b.value?"disabled":""],"dsg-table--pagination-link"]),disabled:b.value,title:"Last","aria-label":"Last"},[e.createVNode(D._sfc_main,{icon:t.lastIcon,size:"sm"},null,8,["icon"])],10,Pe)):e.createCommentVNode("",!0)],512)),[[e.vShow,i.value&&v.value>t.firstPage]])}}),De=["innerHTML"],Z=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 S=e.useModel(t,"pagination"),g=e.computed(()=>S.value==null||S.value.total==0?t.noDataTemplate:t.infoTemplate.replace("{from}",(S.value?.from||0).toString()).replace("{to}",(S.value?.to||0).toString()).replace("{total}",(S.value?.total||0).toString()));return(i,m)=>(e.openBlock(),e.createElementBlock("div",{class:"dsg-table--pagination-info",innerHTML:g.value},null,8,De))}}),Ee={class:"dsg-table--actions",ref:"dsgTableActions"},Se={class:"dsg-table--action-trigger"},$e={key:0,class:"dsg-table--actions-menu-wrapper"},Ve=["href","target","onClick"],Te=["textContent"],Ne={key:0},Fe={key:1},xe=["href","target","onClick"],Me={class:"flex-1"},_=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:S}){const g=e.ref(!1);e.useTemplateRef("dsgTableActions");const i=e.useAttrs(),m=e.ref(i.data.rowData?.actions??null),v=e.ref(i.data.rowData?.links??null),u=e.ref(i.data.rowData??null),b=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"}},F=(f,l,d)=>{switch(l){case"edit":p("dsg-table:action-edit",d,u.value);break;case"view":p("dsg-table:action-view",d,u.value);break;case"delete":p("dsg-table:action-delete",d,u.value);break;case"archive":p("dsg-table:action-archive",d,u.value);break}},V=(f,l)=>{const d=f.actionId||f.label.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-");p("dsg-table:link-clicked",l,d,u.value)},p=S;return(f,l)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",Ee,[e.createVNode(e.unref(D.kt),{triggers:[],placement:t.placement,"handle-resize":!0,strategy:"absolute",shown:g.value,class:"dsg-table--actions__popper",onHide:l[1]||(l[1]=d=>g.value=!1),ref:"floatingVueFilterDropdown"},{popper:e.withCtx(()=>[g.value?(e.openBlock(),e.createElementBlock("div",$e,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(d,w)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[["edit","view","delete","archive"].includes(String(w))?(e.openBlock(),e.createElementBlock("a",{key:w,href:m.value?.link,target:m.value?.target||"_self",onClick:B=>F(d,String(w),B)},[e.createElementVNode("div",{class:e.normalizeClass(["dsg-table--actions-menu-item",String(w)])},[e.createVNode(D._sfc_main,{icon:b(String(w)),size:"sm"},null,8,["icon"]),e.createElementVNode("span",{class:"flex-1",textContent:e.toDisplayString(e.unref(Q.ucfirst)(String(w)))},null,8,Te)],2)],8,Ve)):e.createCommentVNode("",!0)],64))),256)),m.value&&v.value?(e.openBlock(),e.createElementBlock("hr",Ne)):e.createCommentVNode("",!0),v.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(v.value,d=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d.label},[d.hasOwnProperty("component")?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.component),{key:0,quote:e.unref(i).data.data.rowData,"row-data":e.unref(i).data.data.rowData},null,8,["quote","row-data"])):d.hasOwnProperty("type")&&d.type=="break"?(e.openBlock(),e.createElementBlock("hr",Fe)):(e.openBlock(),e.createElementBlock("a",{key:2,href:d.link,target:d.target||"_self",class:e.normalizeClass(["dsg-table--actions-menu-item",d.class]),onClick:w=>V(d,w)},[d.icon?(e.openBlock(),e.createBlock(D._sfc_main,{key:0,icon:d.icon,size:"sm"},null,8,["icon"])):e.createCommentVNode("",!0),e.createElementVNode("span",Me,e.toDisplayString(d.label),1)],10,xe))],64))),128)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]),default:e.withCtx(()=>[e.createElementVNode("div",Se,[e.createElementVNode("button",{type:"button",class:"dsg-table--actions-button","aria-expanded":"false","aria-haspopup":"true",onClick:l[0]||(l[0]=d=>g.value=!g.value)},[e.renderSlot(f.$slots,"dsg-table-action-button-content",{},()=>[e.createVNode(D._sfc_main,{icon:"dots-vertical",size:"sm"})])])])]),_:3},8,["placement","shown"])])),[[e.unref(D.vOnClickOutside),()=>g.value=!1]])}}),Le={class:"dsg-table--search"},ee=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:S}){const g=e.ref("");e.onMounted(()=>{const u=new URL(window.location.href).searchParams.get("term");u&&(g.value=u,i("dsg-table:term-changed",u))});const i=S,m=D.useDebounceFn(v=>{if(g.value=v,t.replaceState){const u=new URL(window.location.href);g.value?u.searchParams.set("term",g.value):u.searchParams.delete("term"),window.history.pushState({},"",u.toString())}i("dsg-table:term-changed",g.value)},300);return(v,u)=>(e.openBlock(),e.createElementBlock("div",Le,[e.createVNode(D._sfc_main$4,{modelValue:g.value,"onUpdate:modelValue":u[0]||(u[0]=b=>g.value=b),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:u[1]||(u[1]=b=>e.unref(m)(b)),onEnterPressed:u[2]||(u[2]=b=>e.unref(m)(b)),onOnClear:u[3]||(u[3]=()=>e.unref(m)(""))},null,8,["modelValue","name","id","placeholder","disabled","required","readonly","hidden"])]))}}),ze={class:"dsg-table--header-row"},Re={key:0,class:"dsg-table--th dsg-table--th-checkbox",scope:"col"},Ie={key:1,class:"dsg-table--th dsg-table--th-expand-detail",scope:"col"},Ae=["title","id","onClick"],qe={key:0,class:"dsg-table--th-sort-icon"},He=["innerHTML"],Ue=["innerHTML"],te=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:S}){const g=e.useModel(t,"sortField"),i=e.useModel(t,"selectedRows"),m=e.useModel(t,"hasSelected"),v=e.ref("17px"),u=p=>{m.value&&i.value.length>0&&i.value.length!==t.tableDataLength?(m.value=!0,b("dsg-table:on-select-all")):!m.value&&i.value.length===0?(m.value=!1,b("dsg-table:on-select-all")):b("dsg-table:on-deselect-all")},b=S,F=(p,f)=>[p,p+"-"+Q.toSnakeCase(String(f?.name)),f.titleClass||"",{sortable:f.sortable},{"sort-active":g.value?.name===f.name}],V=p=>{p.sortable&&(g.value={name:String(p?.name),field:String(p?.sortField),direction:g.value?.name===p.name&&g.value?.direction==="asc"?"desc":"asc"},b("dsg-table:sort-field",p))};return(p,f)=>(e.openBlock(),e.createElementBlock("tr",ze,[t.hasSelectAll?(e.openBlock(),e.createElementBlock("th",Re,[e.createVNode(D._sfc_main$2,{modelValue:m.value,"onUpdate:modelValue":[f[0]||(f[0]=l=>m.value=l),u],indeterminate:i.value.length>0&&i.value.length!==t.tableDataLength},null,8,["modelValue","indeterminate"])])):e.createCommentVNode("",!0),t.showExpandDetail?(e.openBlock(),e.createElementBlock("th",Ie)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.fields,(l,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[l?.visible?(e.openBlock(),e.createElementBlock("th",{key:d,class:e.normalizeClass(F("dsg-table--th",l)),style:e.normalizeStyle([{width:l.width||void 0},l.style]),title:l.title+(l.sortable?" Sort":""),id:"_"+l.name,onClick:w=>V(l),scope:"col"},[l.sortable?(e.openBlock(),e.createElementBlock("div",qe,[l.title?(e.openBlock(),e.createElementBlock("span",{key:0,class:"dsg-table--th-title",innerHTML:l.title},null,8,He)):e.createCommentVNode("",!0),l.sortable&&g.value?.name!==l.name?(e.openBlock(),e.createBlock(D._sfc_main,{key:1,icon:"chevron-selector-vertical",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0),l.sortable&&g.value?.name===l.name&&g.value?.direction==="asc"?(e.openBlock(),e.createBlock(D._sfc_main,{key:2,icon:"chevron-down",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0),l.sortable&&g.value?.name===l.name&&g.value?.direction==="desc"?(e.openBlock(),e.createBlock(D._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(Q.ucwords)(String(l?.title))},null,8,Ue))],14,Ae)):e.createCommentVNode("",!0)],64))),256)),t.scrollVisible?(e.openBlock(),e.createElementBlock("th",{key:2,style:e.normalizeStyle({width:v.value}),class:"dsg-table--th-col-gutter"},null,4)):e.createCommentVNode("",!0)]))}}),Oe={class:"dsg-table--wrapper"},We=["span"],je={key:0,class:"dsg-table--loading"},Ke=["colspan"],Qe=["colspan"],Ye=["onClick","onDblclick","onMouseover"],Ge={key:0,class:"dsg-table--tbody-cell dsg-table--tbody-cell-checkbox"},Je=["onClick","onDblclick","onContextmenu"],Xe=["innerHTML"],Ze=["onClick"],_e=["colspan"],et={key:2},tt=["colspan"],at={class:"dsg-table--footer"},lt=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(t,{expose:S,emit:g}){const i=a=>a.map((n,r)=>({field:n.field||"",title:n.title||"",name:n.name||"",titleClass:n.titleClass||"",dataClass:n.dataClass||"",visible:n.visible??!0,width:n.width||void 0,sortField:n.sortField||null,sortable:n.sortField,formatter:n.formatter||null,$_index:r})),m=e.ref(i(t.fields)),v=e.ref(t.data),u=e.ref(null),b=e.ref(t.initialPage),F=e.ref("17px"),V=e.ref(!1),p=e.ref({}),f=e.ref(0),l=e.ref(!0),d=e.ref(null),w=e.ref(null),B=e.ref(0),C=e.useModel(t,"filterParams"),N=e.useModel(t,"perPage"),$=e.ref([]),R=e.ref(!1),x=e.computed(()=>t.tableHeight!=null),M=e.computed(()=>m.value.filter(a=>a.visible).length);e.watch(()=>$.value.length,a=>{R.value=t.selectable&&a>0},{immediate:!0}),e.watch(()=>t.fields,a=>{m.value=i(a)},{immediate:!0,deep:!0}),e.watch(()=>C.value,a=>{z()},{deep:!0}),e.watch(()=>N.value,()=>{z()}),e.watch(()=>t.apiUrl,(a,n)=>{t.apiMode&&a!==n&&a&&z()});const T=g,A=(a,n)=>a.formatter&&typeof a.formatter=="function"?a.formatter(a,n):K.data_get(n,String(a?.name),""),q=a=>"dsg-field--"+a.name?.toLowerCase().replaceAll(/[_ ]/g,"-"),H=(a,n)=>{const r={odd:n%2===0,even:n%2!==0,"row-selected":a.selected};if(!t.rowClass)return r;let P={};if(typeof t.rowClass=="function"){const h=t.rowClass(a,n);typeof h=="string"?h.split(" ").forEach(E=>{E.trim()&&(P[E.trim()]=!0)}):Array.isArray(h)?h.forEach(E=>{typeof E=="string"&&E.trim()&&(P[E.trim()]=!0)}):typeof h=="object"&&h!==null&&(P=h)}else typeof t.rowClass=="string"&&t.rowClass.split(" ").forEach(h=>{h.trim()&&(P[h.trim()]=!0)});return{...r,...P}},U=a=>{if(t.selectable){if(a.selected)$.value.push(a);else{const n=$.value.findIndex(r=>r[t.trackBy]===a[t.trackBy]);n!==-1&&$.value.splice(n,1)}T("dsg-table:rows-selected",$.value)}},O=()=>{t.selectable&&(v.value?.forEach(a=>{a.selected=!0}),$.value=v.value?.filter(a=>a.selected)??[],T("dsg-table:rows-selected",$.value))},W=()=>{t.selectable&&(v.value?.forEach(a=>{a.selected=!1}),$.value=[],T("dsg-table:rows-selected",$.value))},L=a=>{v.value=Array.isArray(a)?a:[],t.selectable&&v.value.forEach(n=>{n.selected=n.selected??!1})},j=()=>v.value??[],o=a=>{a==="prev"?b.value>t.firstPage&&b.value--:a==="next"?b.value<(u.value?.last_page??0)&&b.value++:a!=b.value&&a>=t.firstPage&&a<=(u.value?.last_page??0)&&(b.value=a),z()},s=()=>({[t.queryParams?.sort]:d.value?(d.value?.direction==="desc"?"-":"")+d.value?.field:void 0,[t.queryParams?.order]:d.value?.direction,[t.queryParams?.page]:b.value,[t.queryParams?.perPage]:N.value}),c=()=>{w.value&&(w.value.abort(),w.value=null)},k=(a,n)=>{c(),B.value++;const r=B.value,P=new AbortController;return n.signal=P.signal,w.value=P,(t.httpMethod.toLowerCase()==="get"?D.axios.get(a,n):(()=>{const E=n.params;return delete n.params,D.axios.post(a,E,n)})()).then(E=>({...E,_requestId:r,_apiUrl:a}),E=>{throw E.name==="AbortError"||E.code==="ERR_CANCELED"?{...E,_requestId:r,_cancelled:!0}:{...E,_requestId:r}})},y=a=>{if(a._requestId&&a._requestId!==B.value||a._apiUrl&&a._apiUrl!==t.apiUrl)return;T("dsg-table:load-success",a);const n=t.transform?t.transform(a.data):a.data;v.value=K.data_get(n,t.dataPath,null),t.selectable&&v.value?.forEach(r=>{r.selected=r.selected??!1}),u.value=K.data_get(n,t.paginationPath,null)??null,f.value=v.value?.length?v.value[0].order:f,!ke.isEmpty(t.paginationPath)&&u.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="".`),w.value=null,T("dsg-table:pagination-data",u.value),u.value&&b.value>(u.value?.last_page||0)&&v.value?.length===0&&(b.value=t.initialPage,z()),T("dsg-table:loaded"),l.value=!1},I=a=>{a._requestId&&a._requestId!==B.value||a._apiUrl&&a._apiUrl!==t.apiUrl||a._cancelled||(console.error("load-error",a),w.value=null,T("dsg-table:load-error",a),T("dsg-table:loaded"),l.value=!1)},Y=()=>{if(t.data!==null&&Array.isArray(t.data)){L(t.data),l.value=!1;return}if(t.dataManager&&typeof t.dataManager=="function"){const a=t.dataManager();L(a),l.value=!1}else L(t.data),l.value=!1},z=(a=y,n=I,r={})=>{const P=a||y,h=n||I;if(!t.apiMode){Y();return}return l.value=!0,T("dsg-table:loading",l.value),t.httpOptions.params={...s(),...C.value},k(t.apiUrl,t.httpOptions).then(P).catch(E=>h(E))},ce=(a,n,r)=>{T("dsg-table:row-clicked",a,n,r)},ue=(a,n,r)=>{T("dsg-table:row-dblclick",a,n,r)},ge=(a,n,r)=>{},me=(a,n,r,P)=>{},fe=(a,n,r,P)=>{},ve=(a,n,r,P)=>{},be=(a,n,r)=>{};e.onMounted(()=>{t.apiMode===!0?z():Y()});const G=()=>{t.apiMode&&($.value=[],c(),z())};return S({changePage:o,reload:G,getData:j,setData:L,setLoading:a=>{l.value=a,T("dsg-table:loading",l.value)}}),(a,n)=>(e.openBlock(),e.createElementBlock("div",Oe,[e.createElementVNode("div",{ref:"dsgTableBodyWrapper",class:e.normalizeClass(["dsg-table-body-wrapper",{"fixed-header":x.value}]),style:e.normalizeStyle({height:t.tableHeight||void 0})},[e.createElementVNode("table",{class:e.normalizeClass(["dsg-table-main",x.value?"fixed-header":"",p.value.table,"table-"+t.tableLayout])},[e.createElementVNode("colgroup",{span:M.value},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(r,P)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[r?.visible?(e.openBlock(),e.createElementBlock("col",{key:P,style:e.normalizeStyle({width:r.width||void 0}),class:e.normalizeClass("dsg-table--col-"+r.name+" "+r.titleClass)},null,6)):e.createCommentVNode("",!0)],64))),256)),!x.value&&V.value?(e.openBlock(),e.createElementBlock("col",{key:0,style:e.normalizeStyle({width:F.value}),class:"dsg-table--col-gutter"},null,4)):e.createCommentVNode("",!0)],8,We),e.createElementVNode("thead",{class:e.normalizeClass([[p.value.thead,{sticky:x.value,"top-0":x.value}],"dsg-table--head"])},[e.renderSlot(a.$slots,"tableHeader",{fields:m.value},()=>[e.createVNode(te,{fields:m.value,"has-select-all":t.selectable,"selected-rows":$.value,"onUpdate:selectedRows":n[0]||(n[0]=r=>$.value=r),"has-selected":R.value,"onUpdate:hasSelected":n[1]||(n[1]=r=>R.value=r),"scroll-visible":V.value,"show-expand-detail":t.hasDetailRow&&t.showExpandDetail,"table-data-length":v.value?.length,"sort-field":d.value,"onUpdate:sortField":n[2]||(n[2]=r=>d.value=r),"onDsgTable:sortField":n[3]||(n[3]=r=>G()),"onDsgTable:onSelectAll":O,"onDsgTable:onDeselectAll":W},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",p.value.tbody])},[l.value?(e.openBlock(),e.createElementBlock("tr",je,[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(a.$slots,"dsg-table-loading",{},()=>[e.createVNode(D._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,Qe)],8,Ke)])):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(v.value,(r,P)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:P},[e.createElementVNode("tr",{class:e.normalizeClass(["dsg-table--tbody-row",H(r,P)]),onClick:h=>ce(h,P,r),onDblclick:h=>ue(h,P,r),onMouseover:h=>ge()},[t.selectable?(e.openBlock(),e.createElementBlock("td",Ge,[e.createVNode(D._sfc_main$2,{modelValue:r.selected,"onUpdate:modelValue":[h=>r.selected=h,h=>U(r)]},null,8,["modelValue","onUpdate:modelValue"])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(h,E)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:E},[h.visible?(e.openBlock(),e.createElementBlock("td",{key:0,class:e.normalizeClass(["dsg-table--tbody-cell",h.dataClass]),style:e.normalizeStyle({width:h.width||void 0}),onClick:J=>me(),onDblclick:J=>fe(),onContextmenu:J=>ve()},[e.renderSlot(a.$slots,q(h),{rowData:r,rowIndex:P,rowField:h},()=>[e.createElementVNode("span",{innerHTML:A(h,r)},null,8,Xe)])],46,Je)):e.createCommentVNode("",!0)],64))),128))],42,Ye),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:h=>be()},[e.createElementVNode("td",{colspan:M.value},[e.renderSlot(a.$slots,"dsg-table-detail-row",{rowData:r,rowIndex:P,options:t.detailRowOptions})],8,_e)],8,Ze)]),_:2},1032,["name"])):e.createCommentVNode("",!0)],64))),128)),!l.value&&!v.value?.length&&t.noDataTemplate.length?(e.openBlock(),e.createElementBlock("tr",et,[e.createElementVNode("td",{colspan:M.value,class:"dsg-table--empty-result"},[e.renderSlot(a.$slots,"dsg-table-empty-result",{},()=>[e.createTextVNode(e.toDisplayString(t.noDataTemplate),1)])],8,tt)])):e.createCommentVNode("",!0)],2),e.createElementVNode("tfoot",at,[e.renderSlot(a.$slots,"dsg-table-footer",{fields:m.value,data:v.value})])],2)],6)]))}}),nt={class:"dsg-table"},ot={key:0,class:"dsg-table--pre-header"},st={class:"dsg-table--pre-header-left"},rt=["textContent"],it={class:"dsg-table--pre-header-right"},dt={key:1,class:"dsg-table--search-header",ref:"dsgTableSearchHeaderEl"},ct={class:"dsg-table--search-top"},ut={key:2,class:"dsg-table--footer",ref:"dsgTableFooterEl"},gt={class:"dsg-table--footer-left"},mt={class:"dsg-table--footer-center"},ft={class:"dsg-table--footer-right"},vt=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},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}},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(t,{expose:S,emit:g}){const i=o=>{w.value=o},m=e.ref(t.apiMode&&!!(t.filterEntity||t.filterEndpoint||t.getUrl)),v=()=>{if(m.value){let o={};return D.getQueryStrings().forEach(s=>{if(s.key.startsWith("filter[")){const c=s.key.replace("filter[","").replace("]",""),k=s.value;o[`filter[${c}]`]=k.join(",")}}),o}else return{}},u=e.computed(()=>({...t.css,tableWrapper:"border-b "+(t.css?.tableWrapper||"")})),b=e.useSlots(),F=e.ref(!0),V=e.ref(null),p=e.ref("<p>Showing {from} to {to} of {total}</p>"),f=e.ref(null),l=e.useTemplateRef("dsgTable"),d=e.ref({perPage:t.perPage,change:i}),w=e.ref(t.perPage),B=e.ref({...v(),...t.initialFilters}),C=g,N=o=>{l.value?.changePage(o)},$=o=>{f.value=o},R=({data:o})=>{V.value=o,C("dsg-table:data-loaded",o)},x=()=>{l.value?.reload()},M=o=>{l.value?.setLoading(o)},T=o=>{const s=l.value?.getData?.()??[];l.value?.setData(s.map(c=>c.id===o.id?o:c))},A=o=>{const s=l.value?.getData?.()??[];l.value?.setData([...s,o])},q=o=>{const s=l.value?.getData?.()??[];l.value?.setData(s.filter(c=>c.id!==o.id))},H=o=>{l.value?.setData(o)},U=()=>l.value?.getData()??[],O=o=>{const s=l.value?.getData()??[],c=o(s);c&&l.value?.setData(c)},W=o=>{B.value=o},L=o=>{const s={...B.value};!o||o.trim()===""?delete s["filter[term]"]:s["filter[term]"]=o,B.value=s,e.nextTick(()=>{x()}),C("dsg-table:term-changed",o)},j=(o,s,c)=>{let k={};B.value["filter[term]"]&&(k["filter[term]"]=B.value["filter[term]"]),Object.keys(o).forEach(y=>{o[y]!==null&&o[y]!==void 0&&o[y]!==""&&(k[y]=o[y])}),B.value=k,e.nextTick(()=>{x()}),C("dsg-table:filter-updated",B.value,s,c)};return S({reloadTable:x,updateRowTable:T,addRowTable:A,deleteRowTable:q,setData:H,getData:U,mutateData:O,termChanged:L,setFilters:W,setLoading:M}),(o,s)=>(e.openBlock(),e.createElementBlock("div",nt,[t.hasHeader?(e.openBlock(),e.createElementBlock("div",ot,[e.renderSlot(o.$slots,"dsg-table--pre-header",{},()=>[e.createElementVNode("div",st,[e.renderSlot(o.$slots,"dsg-table--page-title",{data:V.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,rt)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",it,[e.renderSlot(o.$slots,"dsg-table--page-actions",{data:V.value})])])])):e.createCommentVNode("",!0),t.displaySearch?(e.openBlock(),e.createElementBlock("div",dt,[e.createElementVNode("div",ct,[e.renderSlot(o.$slots,"dsg-table--search-header",{data:V.value},()=>[e.createVNode(ee,{name:"term","onDsgTable:termChanged":s[0]||(s[0]=c=>L(c))}),e.createVNode(D._sfc_main$7,{entity:t.filterEntity,"filter-endpoint":t.filterEndpoint,"search-endpoint":t.filterSearchEndpoint,"auto-sort":t.autoSortFilters,filters:t.filters,"onDsgTable:filterUpdated":s[1]||(s[1]=(c,k,y)=>j(c,k,y))},null,8,["entity","filter-endpoint","search-endpoint","auto-sort","filters"]),e.renderSlot(o.$slots,"dsg-table--search-actions",{data:V.value})])]),e.renderSlot(o.$slots,"dsg-table--search-navigation")],512)):e.createCommentVNode("",!0),e.createVNode(lt,{ref:"dsgTable","api-url":t.getUrl,"filter-params":B.value,"onUpdate:filterParams":s[7]||(s[7]=c=>B.value=c),"per-page":w.value,"onUpdate:perPage":s[8]||(s[8]=c=>w.value=c),fields:t.fields,"load-on-start":t.loadOnStart,"pagination-path":t.paginationPath,selectable:t.selectable,"track-by":t.trackBy,"table-layout":t.tableLayout,css:u.value,data:t.data,"row-class":t.rowClass,"api-mode":m.value,"onDsgTable:loading":s[9]||(s[9]=c=>F.value=!0),"onDsgTable:loaded":s[10]||(s[10]=c=>F.value=!1),"onDsgTable:paginationData":$,"onDsgTable:loadSuccess":R,"onDsgTable:rowsSelected":s[11]||(s[11]=c=>C("dsg-table:rows-selected",c)),"onDsgTable:rowClicked":s[12]||(s[12]=(c,k,y)=>C("dsg-table:row-clicked",c,k,y)),"onDsgTable:rowHover":s[13]||(s[13]=(c,k,y)=>C("dsg-table:row-hover",c,k,y)),"onDsgTable:rowDblclick":s[14]||(s[14]=(c,k,y)=>C("dsg-table:row-dblclick",c,k,y))},e.createSlots({"dsg-field--actions":e.withCtx(c=>[e.renderSlot(o.$slots,"dsg-table-actions",{data:c},()=>[(e.openBlock(),e.createBlock(_,{key:c.rowIndex,data:c,"onDsgTable:actionEdit":s[2]||(s[2]=(k,y)=>C("dsg-table:action-edit",k,y)),"onDsgTable:actionView":s[3]||(s[3]=(k,y)=>C("dsg-table:action-view",k,y)),"onDsgTable:actionDelete":s[4]||(s[4]=(k,y)=>C("dsg-table:action-delete",k,y)),"onDsgTable:actionArchive":s[5]||(s[5]=(k,y)=>C("dsg-table:action-archive",k,y)),"onDsgTable:linkClicked":s[6]||(s[6]=(k,y,I)=>C("dsg-table:link-clicked",k,y,I))},null,8,["data"]))])]),_:2},[e.renderList(e.unref(b),(c,k)=>({name:k,fn:e.withCtx(y=>[String(k)!=="dsg-field--actions"?e.renderSlot(o.$slots,k,e.normalizeProps(e.mergeProps({key:0},y))):e.createCommentVNode("",!0)])}))]),1032,["api-url","filter-params","per-page","fields","load-on-start","pagination-path","selectable","track-by","table-layout","css","data","row-class","api-mode"]),t.hasFooter?(e.openBlock(),e.createElementBlock("div",ut,[e.createElementVNode("div",gt,[e.renderSlot(o.$slots,"dsg-table--footer-left",{data:f.value,perPage:d.value},()=>[t.displayPaginationInfo?(e.openBlock(),e.createBlock(Z,{key:0,ref:"paginationInfoStart",pagination:f.value,"onUpdate:pagination":s[15]||(s[15]=c=>f.value=c),"info-template":p.value},null,8,["pagination","info-template"])):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"dsg-table--footer-left-extras",{data:f.value,perPage:d.value})])]),e.createElementVNode("div",mt,[e.renderSlot(o.$slots,"dsg-table--footer-center",{data:f.value,perPage:d.value},()=>[e.renderSlot(o.$slots,"dsg-table--footer-center-extras",{data:f.value,perPage:d.value})])]),e.createElementVNode("div",ft,[e.renderSlot(o.$slots,"dsg-table--footer-right",{data:f.value,perPage:d.value},()=>[F.value===!1&&t.displayPaginationInfo?(e.openBlock(),e.createBlock(X,{key:0,ref:"pagination",pagination:f.value,"onUpdate:pagination":s[16]||(s[16]=c=>f.value=c),"onDsgTable:changePage":N},null,8,["pagination"])):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"dsg-table--footer-right-extras",{data:f.value,perPage:d.value})])])],512)):e.createCommentVNode("",!0)]))}}),bt={class:"dsg-table--per-page"},kt=["value","textContent"],ht=e.defineComponent({__name:"DsgTablePerPage",props:{perPageOptions:{default:()=>[10,20,30,50,100]},perPage:{}},setup(t){return(S,g)=>(e.openBlock(),e.createElementBlock("div",bt,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":g[0]||(g[0]=i=>t.perPage.perPage=i),class:"dsg-table--per-page-select",onChange:g[1]||(g[1]=i=>t.perPage.change(t.perPage.perPage))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.perPageOptions,i=>(e.openBlock(),e.createElementBlock("option",{key:i,value:i,textContent:e.toDisplayString(i)},null,8,kt))),128))],544),[[e.vModelSelect,t.perPage.perPage]])]))}}),ae=vt,le=_,ne=ht,oe=D._sfc_main$7,se=X,re=Z,ie=ee,de=te,yt={DsgTable:ae,DsgTableActions:le,DsgTablePerPage:ne,DsgTableFilter:oe,DsgTablePagination:se,DsgTablePaginationInfo:re,DsgTableSearch:ie,DsgTableRowHeader:de};exports.DsgTable=ae;exports.DsgTableActions=le;exports.DsgTableFilter=oe;exports.DsgTablePagination=se;exports.DsgTablePaginationInfo=re;exports.DsgTablePerPage=ne;exports.DsgTableRowHeader=de;exports.DsgTableSearch=ie;exports.default=yt;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),D=require("./DsgTablePerPage.vue_vue_type_style_index_0_lang-DU5GAN6E.cjs"),Y=require("./dsg-vue.helpers-string.cjs"),Q=require("./dsg-vue.helpers-object.cjs"),ke=require("./dsg-vue.helpers.cjs"),he={class:"dsg-table--pagination"},ye=["disabled"],pe=["disabled"],we=["onClick","innerHTML"],Be=["onClick","innerHTML"],Ce=["disabled"],Pe=["disabled"],X=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:S,emit:g}){const i=e.useModel(t,"pagination"),m=e.computed(()=>i.value===null?0:i.value?.last_page-t.firstPage+1),v=e.computed(()=>i.value===null?0:i.value?.last_page),u=e.computed(()=>i.value===null?!1:i.value?.current_page===t.firstPage),k=e.computed(()=>i.value===null?!1:i.value?.current_page===v.value),F=e.computed(()=>m.value<t.onEachSide*2+4),V=e.computed(()=>t.onEachSide*2+1),p=e.computed(()=>!i.value||i.value?.current_page<=t.onEachSide?1:i.value?.current_page>=m.value-t.onEachSide?m.value-t.onEachSide*2:i.value?.current_page-t.onEachSide),f=g,l=B=>{f("dsg-table:change-page",B)},d=B=>B===i.value?.current_page;return S({loadPage:l}),(B,w)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",he,[t.showFirstLast?(e.openBlock(),e.createElementBlock("a",{key:0,onClick:w[0]||(w[0]=C=>l(t.firstPage)),class:e.normalizeClass([[u.value?"disabled":""],"dsg-table--pagination-link"]),disabled:u.value,title:"First","aria-label":"First"},[e.createVNode(D._sfc_main,{icon:t.firstIcon,size:"sm"},null,8,["icon"])],10,ye)):e.createCommentVNode("",!0),e.createElementVNode("a",{onClick:w[1]||(w[1]=C=>l("prev")),class:e.normalizeClass([[u.value?"disabled":""],"dsg-table--pagination-link"]),disabled:u.value,title:"Previous","aria-label":"Previous"},[e.createVNode(D._sfc_main,{icon:t.prevIcon,size:"sm"},null,8,["icon"])],10,pe),F.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(m.value,(C,N)=>(e.openBlock(),e.createElementBlock("a",{key:N,onClick:$=>l(N+t.firstPage),class:e.normalizeClass([[d(N+t.firstPage)?"active":""],"dsg-table--pagination-link"]),innerHTML:C},null,10,we))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:2},e.renderList(V.value,(C,N)=>(e.openBlock(),e.createElementBlock("a",{key:N,onClick:$=>l(p.value+N+t.firstPage-1),class:e.normalizeClass([[d(p.value+N+t.firstPage-1)?"active":""],"dsg-table--pagination-link"]),innerHTML:p.value+C-1},null,10,Be))),128)),e.createElementVNode("a",{onClick:w[2]||(w[2]=C=>l("next")),class:e.normalizeClass([[k.value?"disabled":""],"dsg-table--pagination-link"]),disabled:k.value,title:"Next","aria-label":"Next"},[e.createVNode(D._sfc_main,{icon:t.nextIcon,size:"sm"},null,8,["icon"])],10,Ce),t.showFirstLast?(e.openBlock(),e.createElementBlock("a",{key:3,onClick:w[3]||(w[3]=C=>l(v.value)),class:e.normalizeClass([[k.value?"disabled":""],"dsg-table--pagination-link"]),disabled:k.value,title:"Last","aria-label":"Last"},[e.createVNode(D._sfc_main,{icon:t.lastIcon,size:"sm"},null,8,["icon"])],10,Pe)):e.createCommentVNode("",!0)],512)),[[e.vShow,i.value&&v.value>t.firstPage]])}}),De=["innerHTML"],Z=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 S=e.useModel(t,"pagination"),g=e.computed(()=>S.value==null||S.value.total==0?t.noDataTemplate:t.infoTemplate.replace("{from}",(S.value?.from||0).toString()).replace("{to}",(S.value?.to||0).toString()).replace("{total}",(S.value?.total||0).toString()));return(i,m)=>(e.openBlock(),e.createElementBlock("div",{class:"dsg-table--pagination-info",innerHTML:g.value},null,8,De))}}),Ee={class:"dsg-table--actions",ref:"dsgTableActions"},Se={class:"dsg-table--action-trigger"},$e={key:0,class:"dsg-table--actions-menu-wrapper"},Ve=["href","target","onClick"],Te=["textContent"],Ne={key:0},Fe={key:1},xe=["href","target","onClick"],Me={class:"flex-1"},_=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:S}){const g=e.ref(!1);e.useTemplateRef("dsgTableActions");const i=e.useAttrs(),m=e.ref(i.data.rowData?.actions??null),v=e.ref(i.data.rowData?.links??null),u=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"}},F=(f,l,d)=>{switch(l){case"edit":p("dsg-table:action-edit",d,u.value);break;case"view":p("dsg-table:action-view",d,u.value);break;case"delete":p("dsg-table:action-delete",d,u.value);break;case"archive":p("dsg-table:action-archive",d,u.value);break}},V=(f,l)=>{const d=f.actionId||f.label.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-");p("dsg-table:link-clicked",l,d,u.value)},p=S;return(f,l)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",Ee,[e.createVNode(e.unref(D.kt),{triggers:[],placement:t.placement,"handle-resize":!0,strategy:"absolute",shown:g.value,class:"dsg-table--actions__popper",onHide:l[1]||(l[1]=d=>g.value=!1),ref:"floatingVueFilterDropdown"},{popper:e.withCtx(()=>[g.value?(e.openBlock(),e.createElementBlock("div",$e,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(d,B)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[["edit","view","delete","archive"].includes(String(B))?(e.openBlock(),e.createElementBlock("a",{key:B,href:m.value?.link,target:m.value?.target||"_self",onClick:w=>F(d,String(B),w)},[e.createElementVNode("div",{class:e.normalizeClass(["dsg-table--actions-menu-item",String(B)])},[e.createVNode(D._sfc_main,{icon:k(String(B)),size:"sm"},null,8,["icon"]),e.createElementVNode("span",{class:"flex-1",textContent:e.toDisplayString(e.unref(Y.ucfirst)(String(B)))},null,8,Te)],2)],8,Ve)):e.createCommentVNode("",!0)],64))),256)),m.value&&v.value?(e.openBlock(),e.createElementBlock("hr",Ne)):e.createCommentVNode("",!0),v.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(v.value,d=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d.label},[d.hasOwnProperty("component")?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.component),{key:0,quote:e.unref(i).data.data.rowData,"row-data":e.unref(i).data.data.rowData},null,8,["quote","row-data"])):d.hasOwnProperty("type")&&d.type=="break"?(e.openBlock(),e.createElementBlock("hr",Fe)):(e.openBlock(),e.createElementBlock("a",{key:2,href:d.link,target:d.target||"_self",class:e.normalizeClass(["dsg-table--actions-menu-item",d.class]),onClick:B=>V(d,B)},[d.icon?(e.openBlock(),e.createBlock(D._sfc_main,{key:0,icon:d.icon,size:"sm"},null,8,["icon"])):e.createCommentVNode("",!0),e.createElementVNode("span",Me,e.toDisplayString(d.label),1)],10,xe))],64))),128)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]),default:e.withCtx(()=>[e.createElementVNode("div",Se,[e.createElementVNode("button",{type:"button",class:"dsg-table--actions-button","aria-expanded":"false","aria-haspopup":"true",onClick:l[0]||(l[0]=d=>g.value=!g.value)},[e.renderSlot(f.$slots,"dsg-table-action-button-content",{},()=>[e.createVNode(D._sfc_main,{icon:"dots-vertical",size:"sm"})])])])]),_:3},8,["placement","shown"])])),[[e.unref(D.vOnClickOutside),()=>g.value=!1]])}}),Le={class:"dsg-table--search"},ee=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:S}){const g=e.ref("");e.onMounted(()=>{const u=new URL(window.location.href).searchParams.get("term");u&&(g.value=u,i("dsg-table:term-changed",u))});const i=S,m=D.useDebounceFn(v=>{if(g.value=v,t.replaceState){const u=new URL(window.location.href);g.value?u.searchParams.set("term",g.value):u.searchParams.delete("term"),window.history.pushState({},"",u.toString())}i("dsg-table:term-changed",g.value)},300);return(v,u)=>(e.openBlock(),e.createElementBlock("div",Le,[e.createVNode(D._sfc_main$4,{modelValue:g.value,"onUpdate:modelValue":u[0]||(u[0]=k=>g.value=k),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:u[1]||(u[1]=k=>e.unref(m)(k)),onEnterPressed:u[2]||(u[2]=k=>e.unref(m)(k)),onOnClear:u[3]||(u[3]=()=>e.unref(m)(""))},null,8,["modelValue","name","id","placeholder","disabled","required","readonly","hidden"])]))}}),ze={class:"dsg-table--header-row"},Re={key:0,class:"dsg-table--th dsg-table--th-checkbox",scope:"col"},Ie={key:1,class:"dsg-table--th dsg-table--th-expand-detail",scope:"col"},Ae=["title","id","onClick"],qe={key:0,class:"dsg-table--th-sort-icon"},He=["innerHTML"],Ue=["innerHTML"],te=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:S}){const g=e.useModel(t,"sortField"),i=e.useModel(t,"selectedRows"),m=e.useModel(t,"hasSelected"),v=e.ref("17px"),u=p=>{m.value&&i.value.length>0&&i.value.length!==t.tableDataLength?(m.value=!0,k("dsg-table:on-select-all")):!m.value&&i.value.length===0?(m.value=!1,k("dsg-table:on-select-all")):k("dsg-table:on-deselect-all")},k=S,F=(p,f)=>[p,p+"-"+Y.toSnakeCase(String(f?.name)),f.titleClass||"",{sortable:f.sortable},{"sort-active":g.value?.name===f.name}],V=p=>{p.sortable&&(g.value={name:String(p?.name),field:String(p?.sortField),direction:g.value?.name===p.name&&g.value?.direction==="asc"?"desc":"asc"},k("dsg-table:sort-field",p))};return(p,f)=>(e.openBlock(),e.createElementBlock("tr",ze,[t.hasSelectAll?(e.openBlock(),e.createElementBlock("th",Re,[e.createVNode(D._sfc_main$2,{modelValue:m.value,"onUpdate:modelValue":[f[0]||(f[0]=l=>m.value=l),u],indeterminate:i.value.length>0&&i.value.length!==t.tableDataLength},null,8,["modelValue","indeterminate"])])):e.createCommentVNode("",!0),t.showExpandDetail?(e.openBlock(),e.createElementBlock("th",Ie)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.fields,(l,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[l?.visible?(e.openBlock(),e.createElementBlock("th",{key:d,class:e.normalizeClass(F("dsg-table--th",l)),style:e.normalizeStyle([{width:l.width||void 0},l.style]),title:l.title+(l.sortable?" Sort":""),id:"_"+l.name,onClick:B=>V(l),scope:"col"},[l.sortable?(e.openBlock(),e.createElementBlock("div",qe,[l.title?(e.openBlock(),e.createElementBlock("span",{key:0,class:"dsg-table--th-title",innerHTML:l.title},null,8,He)):e.createCommentVNode("",!0),l.sortable&&g.value?.name!==l.name?(e.openBlock(),e.createBlock(D._sfc_main,{key:1,icon:"chevron-selector-vertical",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0),l.sortable&&g.value?.name===l.name&&g.value?.direction==="asc"?(e.openBlock(),e.createBlock(D._sfc_main,{key:2,icon:"chevron-down",class:"inline-flex",size:"xs"})):e.createCommentVNode("",!0),l.sortable&&g.value?.name===l.name&&g.value?.direction==="desc"?(e.openBlock(),e.createBlock(D._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(Y.ucwords)(String(l?.title))},null,8,Ue))],14,Ae)):e.createCommentVNode("",!0)],64))),256)),t.scrollVisible?(e.openBlock(),e.createElementBlock("th",{key:2,style:e.normalizeStyle({width:v.value}),class:"dsg-table--th-col-gutter"},null,4)):e.createCommentVNode("",!0)]))}}),Oe={class:"dsg-table--wrapper"},We=["span"],je={key:0,class:"dsg-table--loading"},Ke=["colspan"],Qe=["colspan"],Ye=["onClick","onDblclick","onMouseover"],Ge={key:0,class:"dsg-table--tbody-cell dsg-table--tbody-cell-checkbox"},Je=["onClick","onDblclick","onContextmenu"],Xe=["innerHTML"],Ze=["onClick"],_e=["colspan"],et={key:2},tt=["colspan"],at={class:"dsg-table--footer"},lt=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(t,{expose:S,emit:g}){const i=a=>a.map((n,r)=>({field:n.field||"",title:n.title||"",name:n.name||"",titleClass:n.titleClass||"",dataClass:n.dataClass||"",visible:n.visible??!0,width:n.width||void 0,sortField:n.sortField||null,sortable:n.sortField,formatter:n.formatter||null,$_index:r})),m=e.ref(i(t.fields)),v=e.ref(t.data),u=e.ref(null),k=e.ref(t.initialPage),F=e.ref("17px"),V=e.ref(!1),p=e.ref({}),f=e.ref(0),l=e.ref(!0),d=e.ref(null),B=e.ref(null),w=e.ref(0),C=e.useModel(t,"filterParams"),N=e.useModel(t,"perPage"),$=e.ref([]),R=e.ref(!1),x=e.computed(()=>t.tableHeight!=null),M=e.computed(()=>m.value.filter(a=>a.visible).length);e.watch(()=>$.value.length,a=>{R.value=t.selectable&&a>0},{immediate:!0}),e.watch(()=>t.fields,a=>{m.value=i(a)},{immediate:!0,deep:!0}),e.watch(()=>C.value,a=>{L()},{deep:!0}),e.watch(()=>N.value,()=>{L()}),e.watch(()=>t.apiUrl,(a,n)=>{t.apiMode&&a!==n&&a&&L()});const T=g,q=(a,n)=>a.formatter&&typeof a.formatter=="function"?a.formatter(a,n):Q.data_get(n,String(a?.name),""),H=a=>"dsg-field--"+a.name?.toLowerCase().replaceAll(/[_ ]/g,"-"),U=(a,n)=>{const r={odd:n%2===0,even:n%2!==0,"row-selected":a.selected};if(!t.rowClass)return r;let P={};if(typeof t.rowClass=="function"){const h=t.rowClass(a,n);typeof h=="string"?h.split(" ").forEach(E=>{E.trim()&&(P[E.trim()]=!0)}):Array.isArray(h)?h.forEach(E=>{typeof E=="string"&&E.trim()&&(P[E.trim()]=!0)}):typeof h=="object"&&h!==null&&(P=h)}else typeof t.rowClass=="string"&&t.rowClass.split(" ").forEach(h=>{h.trim()&&(P[h.trim()]=!0)});return{...r,...P}},O=a=>{if(t.selectable){if(a.selected)$.value.push(a);else{const n=$.value.findIndex(r=>r[t.trackBy]===a[t.trackBy]);n!==-1&&$.value.splice(n,1)}T("dsg-table:rows-selected",$.value)}},W=()=>{t.selectable&&(v.value?.forEach(a=>{a.selected=!0}),$.value=v.value?.filter(a=>a.selected)??[],T("dsg-table:rows-selected",$.value))},j=()=>{t.selectable&&(v.value?.forEach(a=>{a.selected=!1}),$.value=[],T("dsg-table:rows-selected",$.value))},z=a=>{v.value=Array.isArray(a)?a:[],t.selectable&&v.value.forEach(n=>{n.selected=n.selected??!1})},I=()=>v.value??[],K=a=>{a==="prev"?k.value>t.firstPage&&k.value--:a==="next"?k.value<(u.value?.last_page??0)&&k.value++:a!=k.value&&a>=t.firstPage&&a<=(u.value?.last_page??0)&&(k.value=a),L()},s=()=>({[t.queryParams?.sort]:d.value?(d.value?.direction==="desc"?"-":"")+d.value?.field:void 0,[t.queryParams?.order]:d.value?.direction,[t.queryParams?.page]:k.value,[t.queryParams?.perPage]:N.value}),o=()=>{B.value&&(B.value.abort(),B.value=null)},c=(a,n)=>{o(),w.value++;const r=w.value,P=new AbortController;return n.signal=P.signal,B.value=P,(t.httpMethod.toLowerCase()==="get"?D.axios.get(a,n):(()=>{const E=n.params;return delete n.params,D.axios.post(a,E,n)})()).then(E=>({...E,_requestId:r,_apiUrl:a}),E=>{throw E.name==="AbortError"||E.code==="ERR_CANCELED"?{...E,_requestId:r,_cancelled:!0}:{...E,_requestId:r}})},b=a=>{if(a._requestId&&a._requestId!==w.value||a._apiUrl&&a._apiUrl!==t.apiUrl)return;T("dsg-table:load-success",a);const n=t.transform?t.transform(a.data):a.data;v.value=Q.data_get(n,t.dataPath,null),t.selectable&&v.value?.forEach(r=>{r.selected=r.selected??!1}),u.value=Q.data_get(n,t.paginationPath,null)??null,f.value=v.value?.length?v.value[0].order:f,!ke.isEmpty(t.paginationPath)&&u.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="".`),B.value=null,T("dsg-table:pagination-data",u.value),u.value&&k.value>(u.value?.last_page||0)&&v.value?.length===0&&(k.value=t.initialPage,L()),T("dsg-table:loaded"),l.value=!1},y=a=>{a._requestId&&a._requestId!==w.value||a._apiUrl&&a._apiUrl!==t.apiUrl||a._cancelled||(console.error("load-error",a),B.value=null,T("dsg-table:load-error",a),T("dsg-table:loaded"),l.value=!1)},A=()=>{if(t.data!==null&&Array.isArray(t.data)){z(t.data),l.value=!1;return}if(t.dataManager&&typeof t.dataManager=="function"){const a=t.dataManager();z(a),l.value=!1}else z(t.data),l.value=!1},L=(a=b,n=y,r={})=>{const P=a||b,h=n||y;if(!t.apiMode){A();return}return l.value=!0,T("dsg-table:loading",l.value),t.httpOptions.params={...s(),...C.value},c(t.apiUrl,t.httpOptions).then(P).catch(E=>h(E))},ce=(a,n,r)=>{T("dsg-table:row-clicked",a,n,r)},ue=(a,n,r)=>{T("dsg-table:row-dblclick",a,n,r)},ge=(a,n,r)=>{},me=(a,n,r,P)=>{},fe=(a,n,r,P)=>{},ve=(a,n,r,P)=>{},be=(a,n,r)=>{};e.onMounted(()=>{t.apiMode===!0?L():A()});const G=()=>{t.apiMode&&($.value=[],o(),L())};return S({changePage:K,reload:G,getData:I,setData:z,setLoading:a=>{l.value=a,T("dsg-table:loading",l.value)}}),(a,n)=>(e.openBlock(),e.createElementBlock("div",Oe,[e.createElementVNode("div",{ref:"dsgTableBodyWrapper",class:e.normalizeClass(["dsg-table-body-wrapper",{"fixed-header":x.value}]),style:e.normalizeStyle({height:t.tableHeight||void 0})},[e.createElementVNode("table",{class:e.normalizeClass(["dsg-table-main",x.value?"fixed-header":"",p.value.table,"table-"+t.tableLayout])},[e.createElementVNode("colgroup",{span:M.value},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(r,P)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[r?.visible?(e.openBlock(),e.createElementBlock("col",{key:P,style:e.normalizeStyle({width:r.width||void 0}),class:e.normalizeClass("dsg-table--col-"+r.name+" "+r.titleClass)},null,6)):e.createCommentVNode("",!0)],64))),256)),!x.value&&V.value?(e.openBlock(),e.createElementBlock("col",{key:0,style:e.normalizeStyle({width:F.value}),class:"dsg-table--col-gutter"},null,4)):e.createCommentVNode("",!0)],8,We),e.createElementVNode("thead",{class:e.normalizeClass([[p.value.thead,{sticky:x.value,"top-0":x.value}],"dsg-table--head"])},[e.renderSlot(a.$slots,"tableHeader",{fields:m.value},()=>[e.createVNode(te,{fields:m.value,"has-select-all":t.selectable,"selected-rows":$.value,"onUpdate:selectedRows":n[0]||(n[0]=r=>$.value=r),"has-selected":R.value,"onUpdate:hasSelected":n[1]||(n[1]=r=>R.value=r),"scroll-visible":V.value,"show-expand-detail":t.hasDetailRow&&t.showExpandDetail,"table-data-length":v.value?.length,"sort-field":d.value,"onUpdate:sortField":n[2]||(n[2]=r=>d.value=r),"onDsgTable:sortField":n[3]||(n[3]=r=>G()),"onDsgTable:onSelectAll":W,"onDsgTable:onDeselectAll":j},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",p.value.tbody])},[l.value?(e.openBlock(),e.createElementBlock("tr",je,[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(a.$slots,"dsg-table-loading",{},()=>[e.createVNode(D._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,Qe)],8,Ke)])):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(v.value,(r,P)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:P},[e.createElementVNode("tr",{class:e.normalizeClass(["dsg-table--tbody-row",U(r,P)]),onClick:h=>ce(h,P,r),onDblclick:h=>ue(h,P,r),onMouseover:h=>ge()},[t.selectable?(e.openBlock(),e.createElementBlock("td",Ge,[e.createVNode(D._sfc_main$2,{modelValue:r.selected,"onUpdate:modelValue":[h=>r.selected=h,h=>O(r)]},null,8,["modelValue","onUpdate:modelValue"])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(h,E)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:E},[h.visible?(e.openBlock(),e.createElementBlock("td",{key:0,class:e.normalizeClass(["dsg-table--tbody-cell",h.dataClass]),style:e.normalizeStyle({width:h.width||void 0}),onClick:J=>me(),onDblclick:J=>fe(),onContextmenu:J=>ve()},[e.renderSlot(a.$slots,H(h),{rowData:r,rowIndex:P,rowField:h},()=>[e.createElementVNode("span",{innerHTML:q(h,r)},null,8,Xe)])],46,Je)):e.createCommentVNode("",!0)],64))),128))],42,Ye),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:h=>be()},[e.createElementVNode("td",{colspan:M.value},[e.renderSlot(a.$slots,"dsg-table-detail-row",{rowData:r,rowIndex:P,options:t.detailRowOptions})],8,_e)],8,Ze)]),_:2},1032,["name"])):e.createCommentVNode("",!0)],64))),128)),!l.value&&!v.value?.length&&t.noDataTemplate.length?(e.openBlock(),e.createElementBlock("tr",et,[e.createElementVNode("td",{colspan:M.value,class:"dsg-table--empty-result"},[e.renderSlot(a.$slots,"dsg-table-empty-result",{},()=>[e.createTextVNode(e.toDisplayString(t.noDataTemplate),1)])],8,tt)])):e.createCommentVNode("",!0)],2),e.createElementVNode("tfoot",at,[e.renderSlot(a.$slots,"dsg-table-footer",{fields:m.value,data:v.value})])],2)],6)]))}}),nt={class:"dsg-table"},ot={key:0,class:"dsg-table--pre-header"},st={class:"dsg-table--pre-header-left"},rt=["textContent"],it={class:"dsg-table--pre-header-right"},dt={key:1,class:"dsg-table--search-header",ref:"dsgTableSearchHeaderEl"},ct={class:"dsg-table--search-top"},ut={key:2,class:"dsg-table--footer",ref:"dsgTableFooterEl"},gt={class:"dsg-table--footer-left"},mt={class:"dsg-table--footer-center"},ft={class:"dsg-table--footer-right"},vt=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},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}},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(t,{expose:S,emit:g}){const i=s=>{B.value=s},m=e.ref(t.apiMode&&!!(t.filterEntity||t.filterEndpoint||t.getUrl)),v=()=>{if(m.value){let s={};return D.getQueryStrings().forEach(o=>{if(o.key.startsWith("filter[")){const c=o.key.replace("filter[","").replace("]",""),b=o.value;s[`filter[${c}]`]=b.join(",")}}),s}else return{}},u=e.computed(()=>({...t.css,tableWrapper:"border-b "+(t.css?.tableWrapper||"")})),k=e.useSlots(),F=e.ref(!0),V=e.ref(null),p=e.ref("<p>Showing {from} to {to} of {total}</p>"),f=e.ref(null),l=e.useTemplateRef("dsgTable"),d=e.ref({perPage:t.perPage,change:i}),B=e.ref(t.perPage),w=e.ref({...v(),...t.initialFilters}),C=g,N=s=>{l.value?.changePage(s)},$=s=>{f.value=s},R=({data:s})=>{V.value=s,C("dsg-table:data-loaded",s)},x=()=>{l.value?.reload()},M=s=>{l.value?.setLoading(s)},T=s=>{const o=l.value?.getData?.()??[];l.value?.setData(o.map(c=>c.id===s.id?s:c))},q=s=>{const o=l.value?.getData?.()??[];l.value?.setData([...o,s])},H=s=>{const o=l.value?.getData?.()??[];l.value?.setData(o.filter(c=>c.id!==s.id))},U=s=>{l.value?.setData(s)},O=()=>l.value?.getData()??[],W=s=>{const o=l.value?.getData()??[],c=s(o);c&&l.value?.setData(c)},j=s=>{w.value=s},z=()=>w.value??{},I=s=>{const o={...w.value};!s||s.trim()===""?delete o["filter[term]"]:o["filter[term]"]=s,w.value=o,e.nextTick(()=>{x()}),C("dsg-table:term-changed",s)},K=(s,o,c)=>{let b={};w.value["filter[term]"]&&(b["filter[term]"]=w.value["filter[term]"]),Object.keys(s).forEach(y=>{s[y]!==null&&s[y]!==void 0&&s[y]!==""&&(b[y]=s[y])}),w.value=b,e.nextTick(()=>{x()}),C("dsg-table:filter-updated",w.value,o,c)};return S({reloadTable:x,updateRowTable:T,addRowTable:q,deleteRowTable:H,setData:U,getData:O,mutateData:W,termChanged:I,setFilters:j,getFilters:z,setLoading:M}),(s,o)=>(e.openBlock(),e.createElementBlock("div",nt,[t.hasHeader?(e.openBlock(),e.createElementBlock("div",ot,[e.renderSlot(s.$slots,"dsg-table--pre-header",{},()=>[e.createElementVNode("div",st,[e.renderSlot(s.$slots,"dsg-table--page-title",{data:V.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,rt)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",it,[e.renderSlot(s.$slots,"dsg-table--page-actions",{data:V.value})])])])):e.createCommentVNode("",!0),t.displaySearch?(e.openBlock(),e.createElementBlock("div",dt,[e.createElementVNode("div",ct,[e.renderSlot(s.$slots,"dsg-table--search-header",{data:V.value},()=>[e.createVNode(ee,{name:"term","onDsgTable:termChanged":o[0]||(o[0]=c=>I(c))}),e.createVNode(D._sfc_main$7,{entity:t.filterEntity,"filter-endpoint":t.filterEndpoint,"search-endpoint":t.filterSearchEndpoint,"auto-sort":t.autoSortFilters,filters:t.filters,"onDsgTable:filterUpdated":o[1]||(o[1]=(c,b,y)=>K(c,b,y))},null,8,["entity","filter-endpoint","search-endpoint","auto-sort","filters"]),e.renderSlot(s.$slots,"dsg-table--search-actions",{data:V.value})])]),e.renderSlot(s.$slots,"dsg-table--search-navigation")],512)):e.createCommentVNode("",!0),e.createVNode(lt,{ref:"dsgTable","api-url":t.getUrl,"filter-params":w.value,"onUpdate:filterParams":o[7]||(o[7]=c=>w.value=c),"per-page":B.value,"onUpdate:perPage":o[8]||(o[8]=c=>B.value=c),fields:t.fields,"load-on-start":t.loadOnStart,"pagination-path":t.paginationPath,selectable:t.selectable,"track-by":t.trackBy,"table-layout":t.tableLayout,css:u.value,data:t.data,"row-class":t.rowClass,"api-mode":m.value,"onDsgTable:loading":o[9]||(o[9]=c=>F.value=!0),"onDsgTable:loaded":o[10]||(o[10]=c=>F.value=!1),"onDsgTable:paginationData":$,"onDsgTable:loadSuccess":R,"onDsgTable:rowsSelected":o[11]||(o[11]=c=>C("dsg-table:rows-selected",c)),"onDsgTable:rowClicked":o[12]||(o[12]=(c,b,y)=>C("dsg-table:row-clicked",c,b,y)),"onDsgTable:rowHover":o[13]||(o[13]=(c,b,y)=>C("dsg-table:row-hover",c,b,y)),"onDsgTable:rowDblclick":o[14]||(o[14]=(c,b,y)=>C("dsg-table:row-dblclick",c,b,y))},e.createSlots({"dsg-field--actions":e.withCtx(c=>[e.renderSlot(s.$slots,"dsg-table-actions",{data:c},()=>[(e.openBlock(),e.createBlock(_,{key:c.rowIndex,data:c,"onDsgTable:actionEdit":o[2]||(o[2]=(b,y)=>C("dsg-table:action-edit",b,y)),"onDsgTable:actionView":o[3]||(o[3]=(b,y)=>C("dsg-table:action-view",b,y)),"onDsgTable:actionDelete":o[4]||(o[4]=(b,y)=>C("dsg-table:action-delete",b,y)),"onDsgTable:actionArchive":o[5]||(o[5]=(b,y)=>C("dsg-table:action-archive",b,y)),"onDsgTable:linkClicked":o[6]||(o[6]=(b,y,A)=>C("dsg-table:link-clicked",b,y,A))},null,8,["data"]))])]),_:2},[e.renderList(e.unref(k),(c,b)=>({name:b,fn:e.withCtx(y=>[String(b)!=="dsg-field--actions"?e.renderSlot(s.$slots,b,e.normalizeProps(e.mergeProps({key:0},y))):e.createCommentVNode("",!0)])}))]),1032,["api-url","filter-params","per-page","fields","load-on-start","pagination-path","selectable","track-by","table-layout","css","data","row-class","api-mode"]),t.hasFooter?(e.openBlock(),e.createElementBlock("div",ut,[e.createElementVNode("div",gt,[e.renderSlot(s.$slots,"dsg-table--footer-left",{data:f.value,perPage:d.value},()=>[t.displayPaginationInfo?(e.openBlock(),e.createBlock(Z,{key:0,ref:"paginationInfoStart",pagination:f.value,"onUpdate:pagination":o[15]||(o[15]=c=>f.value=c),"info-template":p.value},null,8,["pagination","info-template"])):e.createCommentVNode("",!0),e.renderSlot(s.$slots,"dsg-table--footer-left-extras",{data:f.value,perPage:d.value})])]),e.createElementVNode("div",mt,[e.renderSlot(s.$slots,"dsg-table--footer-center",{data:f.value,perPage:d.value},()=>[e.renderSlot(s.$slots,"dsg-table--footer-center-extras",{data:f.value,perPage:d.value})])]),e.createElementVNode("div",ft,[e.renderSlot(s.$slots,"dsg-table--footer-right",{data:f.value,perPage:d.value},()=>[F.value===!1&&t.displayPaginationInfo?(e.openBlock(),e.createBlock(X,{key:0,ref:"pagination",pagination:f.value,"onUpdate:pagination":o[16]||(o[16]=c=>f.value=c),"onDsgTable:changePage":N},null,8,["pagination"])):e.createCommentVNode("",!0),e.renderSlot(s.$slots,"dsg-table--footer-right-extras",{data:f.value,perPage:d.value})])])],512)):e.createCommentVNode("",!0)]))}}),bt={class:"dsg-table--per-page"},kt=["value","textContent"],ht=e.defineComponent({__name:"DsgTablePerPage",props:{perPageOptions:{default:()=>[10,20,30,50,100]},perPage:{}},setup(t){return(S,g)=>(e.openBlock(),e.createElementBlock("div",bt,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":g[0]||(g[0]=i=>t.perPage.perPage=i),class:"dsg-table--per-page-select",onChange:g[1]||(g[1]=i=>t.perPage.change(t.perPage.perPage))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.perPageOptions,i=>(e.openBlock(),e.createElementBlock("option",{key:i,value:i,textContent:e.toDisplayString(i)},null,8,kt))),128))],544),[[e.vModelSelect,t.perPage.perPage]])]))}}),ae=vt,le=_,ne=ht,oe=D._sfc_main$7,se=X,re=Z,ie=ee,de=te,yt={DsgTable:ae,DsgTableActions:le,DsgTablePerPage:ne,DsgTableFilter:oe,DsgTablePagination:se,DsgTablePaginationInfo:re,DsgTableSearch:ie,DsgTableRowHeader:de};exports.DsgTable=ae;exports.DsgTableActions=le;exports.DsgTableFilter=oe;exports.DsgTablePagination=se;exports.DsgTablePaginationInfo=re;exports.DsgTablePerPage=ne;exports.DsgTableRowHeader=de;exports.DsgTableSearch=ie;exports.default=yt;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as K, mergeModels as
|
|
1
|
+
import { defineComponent as K, mergeModels as J, useModel as G, computed as V, withDirectives as ve, createElementBlock as i, openBlock as l, createCommentVNode as D, createElementVNode as P, normalizeClass as B, createVNode as I, Fragment as R, renderList as N, vShow as Re, ref as p, useTemplateRef as ye, useAttrs as Ie, unref as O, withCtx as te, renderSlot as F, toDisplayString as ae, createBlock as j, resolveDynamicComponent as Ae, onMounted as we, normalizeStyle as Z, watch as ee, Transition as He, createTextVNode as Ue, useSlots as qe, createSlots as Ve, normalizeProps as ze, mergeProps as Oe, nextTick as he, vModelSelect as Ne } from "vue";
|
|
2
2
|
import { _ as z, k as We, v as je, f as Ke, u as Qe, c as ke, e as me, i as Pe, j as Ye } from "./DsgTablePerPage.vue_vue_type_style_index_0_lang-BIxdsbw_.js";
|
|
3
3
|
import { ucfirst as Ge, ucwords as Je, toSnakeCase as Xe } from "./dsg-vue.helpers-string.esm.js";
|
|
4
|
-
import { data_get as
|
|
4
|
+
import { data_get as ge } from "./dsg-vue.helpers-object.esm.js";
|
|
5
5
|
import { isEmpty as Ze } from "./dsg-vue.helpers.esm.js";
|
|
6
6
|
const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disabled"], at = ["onClick", "innerHTML"], lt = ["onClick", "innerHTML"], st = ["disabled"], nt = ["disabled"], pe = /* @__PURE__ */ K({
|
|
7
7
|
__name: "DsgTablePagination",
|
|
8
|
-
props: /* @__PURE__ */
|
|
8
|
+
props: /* @__PURE__ */ J({
|
|
9
9
|
onEachSide: { default: 3 },
|
|
10
10
|
firstPage: { default: 1 },
|
|
11
11
|
showFirstLast: { type: Boolean, default: !0 },
|
|
@@ -17,17 +17,17 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
17
17
|
pagination: { default: null },
|
|
18
18
|
paginationModifiers: {}
|
|
19
19
|
}),
|
|
20
|
-
emits: /* @__PURE__ */
|
|
20
|
+
emits: /* @__PURE__ */ J(["dsg-table:change-page"], ["update:pagination"]),
|
|
21
21
|
setup(e, { expose: E, emit: v }) {
|
|
22
|
-
const r =
|
|
23
|
-
b("dsg-table:change-page",
|
|
24
|
-
}, u = (
|
|
22
|
+
const r = G(e, "pagination"), f = V(() => r.value === null ? 0 : r.value?.last_page - e.firstPage + 1), h = V(() => r.value === null ? 0 : r.value?.last_page), g = V(() => r.value === null ? !1 : r.value?.current_page === e.firstPage), y = V(() => r.value === null ? !1 : r.value?.current_page === h.value), q = V(() => f.value < e.onEachSide * 2 + 4), A = V(() => e.onEachSide * 2 + 1), C = V(() => !r.value || r.value?.current_page <= e.onEachSide ? 1 : r.value?.current_page >= f.value - e.onEachSide ? f.value - e.onEachSide * 2 : r.value?.current_page - e.onEachSide), b = v, a = (T) => {
|
|
23
|
+
b("dsg-table:change-page", T);
|
|
24
|
+
}, u = (T) => T === r.value?.current_page;
|
|
25
25
|
return E({
|
|
26
26
|
loadPage: a
|
|
27
|
-
}), (
|
|
27
|
+
}), (T, $) => ve((l(), i("div", _e, [
|
|
28
28
|
e.showFirstLast ? (l(), i("a", {
|
|
29
29
|
key: 0,
|
|
30
|
-
onClick:
|
|
30
|
+
onClick: $[0] || ($[0] = (S) => a(e.firstPage)),
|
|
31
31
|
class: B([[g.value ? "disabled" : ""], "dsg-table--pagination-link"]),
|
|
32
32
|
disabled: g.value,
|
|
33
33
|
title: "First",
|
|
@@ -39,7 +39,7 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
39
39
|
}, null, 8, ["icon"])
|
|
40
40
|
], 10, et)) : D("", !0),
|
|
41
41
|
P("a", {
|
|
42
|
-
onClick:
|
|
42
|
+
onClick: $[1] || ($[1] = (S) => a("prev")),
|
|
43
43
|
class: B([[g.value ? "disabled" : ""], "dsg-table--pagination-link"]),
|
|
44
44
|
disabled: g.value,
|
|
45
45
|
title: "Previous",
|
|
@@ -62,9 +62,9 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
62
62
|
innerHTML: C.value + S - 1
|
|
63
63
|
}, null, 10, lt))), 128)),
|
|
64
64
|
P("a", {
|
|
65
|
-
onClick:
|
|
66
|
-
class: B([[
|
|
67
|
-
disabled:
|
|
65
|
+
onClick: $[2] || ($[2] = (S) => a("next")),
|
|
66
|
+
class: B([[y.value ? "disabled" : ""], "dsg-table--pagination-link"]),
|
|
67
|
+
disabled: y.value,
|
|
68
68
|
title: "Next",
|
|
69
69
|
"aria-label": "Next"
|
|
70
70
|
}, [
|
|
@@ -75,9 +75,9 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
75
75
|
], 10, st),
|
|
76
76
|
e.showFirstLast ? (l(), i("a", {
|
|
77
77
|
key: 3,
|
|
78
|
-
onClick:
|
|
79
|
-
class: B([[
|
|
80
|
-
disabled:
|
|
78
|
+
onClick: $[3] || ($[3] = (S) => a(h.value)),
|
|
79
|
+
class: B([[y.value ? "disabled" : ""], "dsg-table--pagination-link"]),
|
|
80
|
+
disabled: y.value,
|
|
81
81
|
title: "Last",
|
|
82
82
|
"aria-label": "Last"
|
|
83
83
|
}, [
|
|
@@ -92,7 +92,7 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
92
92
|
}
|
|
93
93
|
}), ot = ["innerHTML"], De = /* @__PURE__ */ K({
|
|
94
94
|
__name: "DsgTablePaginationInfo",
|
|
95
|
-
props: /* @__PURE__ */
|
|
95
|
+
props: /* @__PURE__ */ J({
|
|
96
96
|
infoTemplate: { default: "Displaying {from} to {to} of {total} items" },
|
|
97
97
|
noDataTemplate: { default: "No relevant data" }
|
|
98
98
|
}, {
|
|
@@ -101,7 +101,7 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
101
101
|
}),
|
|
102
102
|
emits: ["update:pagination"],
|
|
103
103
|
setup(e) {
|
|
104
|
-
const E =
|
|
104
|
+
const E = G(e, "pagination"), v = V(() => E.value == null || E.value.total == 0 ? e.noDataTemplate : e.infoTemplate.replace("{from}", (E.value?.from || 0).toString()).replace("{to}", (E.value?.to || 0).toString()).replace("{total}", (E.value?.total || 0).toString()));
|
|
105
105
|
return (r, f) => (l(), i("div", {
|
|
106
106
|
class: "dsg-table--pagination-info",
|
|
107
107
|
innerHTML: v.value
|
|
@@ -122,7 +122,7 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
122
122
|
setup(e, { emit: E }) {
|
|
123
123
|
const v = p(!1);
|
|
124
124
|
ye("dsgTableActions");
|
|
125
|
-
const r = Ie(), f = p(r.data.rowData?.actions ?? null), h = p(r.data.rowData?.links ?? null), g = p(r.data.rowData ?? null),
|
|
125
|
+
const r = Ie(), f = p(r.data.rowData?.actions ?? null), h = p(r.data.rowData?.links ?? null), g = p(r.data.rowData ?? null), y = (b) => {
|
|
126
126
|
switch (b) {
|
|
127
127
|
case "edit":
|
|
128
128
|
return "edit-05";
|
|
@@ -154,7 +154,7 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
154
154
|
const u = b.actionId || b.label.trim().toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-");
|
|
155
155
|
C("dsg-table:link-clicked", a, u, g.value);
|
|
156
156
|
}, C = E;
|
|
157
|
-
return (b, a) =>
|
|
157
|
+
return (b, a) => ve((l(), i("div", it, [
|
|
158
158
|
I(O(We), {
|
|
159
159
|
triggers: [],
|
|
160
160
|
placement: e.placement,
|
|
@@ -167,23 +167,23 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
167
167
|
}, {
|
|
168
168
|
popper: te(() => [
|
|
169
169
|
v.value ? (l(), i("div", rt, [
|
|
170
|
-
(l(!0), i(R, null, N(f.value, (u,
|
|
171
|
-
["edit", "view", "delete", "archive"].includes(String(
|
|
172
|
-
key:
|
|
170
|
+
(l(!0), i(R, null, N(f.value, (u, T) => (l(), i(R, null, [
|
|
171
|
+
["edit", "view", "delete", "archive"].includes(String(T)) ? (l(), i("a", {
|
|
172
|
+
key: T,
|
|
173
173
|
href: f.value?.link,
|
|
174
174
|
target: f.value?.target || "_self",
|
|
175
|
-
onClick: (
|
|
175
|
+
onClick: ($) => q(u, String(T), $)
|
|
176
176
|
}, [
|
|
177
177
|
P("div", {
|
|
178
|
-
class: B(["dsg-table--actions-menu-item", String(
|
|
178
|
+
class: B(["dsg-table--actions-menu-item", String(T)])
|
|
179
179
|
}, [
|
|
180
180
|
I(z, {
|
|
181
|
-
icon:
|
|
181
|
+
icon: y(String(T)),
|
|
182
182
|
size: "sm"
|
|
183
183
|
}, null, 8, ["icon"]),
|
|
184
184
|
P("span", {
|
|
185
185
|
class: "flex-1",
|
|
186
|
-
textContent: ae(O(Ge)(String(
|
|
186
|
+
textContent: ae(O(Ge)(String(T)))
|
|
187
187
|
}, null, 8, ct)
|
|
188
188
|
], 2)
|
|
189
189
|
], 8, ut)) : D("", !0)
|
|
@@ -201,7 +201,7 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
201
201
|
href: u.link,
|
|
202
202
|
target: u.target || "_self",
|
|
203
203
|
class: B(["dsg-table--actions-menu-item", u.class]),
|
|
204
|
-
onClick: (
|
|
204
|
+
onClick: (T) => A(u, T)
|
|
205
205
|
}, [
|
|
206
206
|
u.icon ? (l(), j(z, {
|
|
207
207
|
key: 0,
|
|
@@ -268,7 +268,7 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
268
268
|
return (h, g) => (l(), i("div", ht, [
|
|
269
269
|
I(Ke, {
|
|
270
270
|
modelValue: v.value,
|
|
271
|
-
"onUpdate:modelValue": g[0] || (g[0] = (
|
|
271
|
+
"onUpdate:modelValue": g[0] || (g[0] = (y) => v.value = y),
|
|
272
272
|
name: e.name,
|
|
273
273
|
id: e.id || e.name,
|
|
274
274
|
placeholder: e.placeholder,
|
|
@@ -281,8 +281,8 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
281
281
|
size: "sm",
|
|
282
282
|
icon: "search-sm",
|
|
283
283
|
"icon-clickable": !0,
|
|
284
|
-
onIconClicked: g[1] || (g[1] = (
|
|
285
|
-
onEnterPressed: g[2] || (g[2] = (
|
|
284
|
+
onIconClicked: g[1] || (g[1] = (y) => O(f)(y)),
|
|
285
|
+
onEnterPressed: g[2] || (g[2] = (y) => O(f)(y)),
|
|
286
286
|
onOnClear: g[3] || (g[3] = () => O(f)(""))
|
|
287
287
|
}, null, 8, ["modelValue", "name", "id", "placeholder", "disabled", "required", "readonly", "hidden"])
|
|
288
288
|
]));
|
|
@@ -300,7 +300,7 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
300
300
|
class: "dsg-table--th-sort-icon"
|
|
301
301
|
}, pt = ["innerHTML"], Dt = ["innerHTML"], Te = /* @__PURE__ */ K({
|
|
302
302
|
__name: "DsgTableRowHeader",
|
|
303
|
-
props: /* @__PURE__ */
|
|
303
|
+
props: /* @__PURE__ */ J({
|
|
304
304
|
fields: {},
|
|
305
305
|
scrollVisible: { type: Boolean },
|
|
306
306
|
hasSelectAll: { type: Boolean, default: !1 },
|
|
@@ -314,11 +314,11 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
314
314
|
hasSelected: { type: Boolean, default: !1 },
|
|
315
315
|
hasSelectedModifiers: {}
|
|
316
316
|
}),
|
|
317
|
-
emits: /* @__PURE__ */
|
|
317
|
+
emits: /* @__PURE__ */ J(["dsg-table:sort-field", "dsg-table:on-select-all", "dsg-table:on-deselect-all"], ["update:sortField", "update:selectedRows", "update:hasSelected"]),
|
|
318
318
|
setup(e, { emit: E }) {
|
|
319
|
-
const v =
|
|
320
|
-
f.value && r.value.length > 0 && r.value.length !== e.tableDataLength ? (f.value = !0,
|
|
321
|
-
},
|
|
319
|
+
const v = G(e, "sortField"), r = G(e, "selectedRows"), f = G(e, "hasSelected"), h = p("17px"), g = (C) => {
|
|
320
|
+
f.value && r.value.length > 0 && r.value.length !== e.tableDataLength ? (f.value = !0, y("dsg-table:on-select-all")) : !f.value && r.value.length === 0 ? (f.value = !1, y("dsg-table:on-select-all")) : y("dsg-table:on-deselect-all");
|
|
321
|
+
}, y = E, q = (C, b) => [
|
|
322
322
|
C,
|
|
323
323
|
C + "-" + Xe(String(b?.name)),
|
|
324
324
|
b.titleClass || "",
|
|
@@ -329,7 +329,7 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
329
329
|
name: String(C?.name),
|
|
330
330
|
field: String(C?.sortField),
|
|
331
331
|
direction: v.value?.name === C.name && v.value?.direction === "asc" ? "desc" : "asc"
|
|
332
|
-
},
|
|
332
|
+
}, y("dsg-table:sort-field", C));
|
|
333
333
|
};
|
|
334
334
|
return (C, b) => (l(), i("tr", mt, [
|
|
335
335
|
e.hasSelectAll ? (l(), i("th", yt, [
|
|
@@ -350,7 +350,7 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
350
350
|
style: Z([{ width: a.width || void 0 }, a.style]),
|
|
351
351
|
title: a.title + (a.sortable ? " Sort" : ""),
|
|
352
352
|
id: "_" + a.name,
|
|
353
|
-
onClick: (
|
|
353
|
+
onClick: (T) => A(a),
|
|
354
354
|
scope: "col"
|
|
355
355
|
}, [
|
|
356
356
|
a.sortable ? (l(), i("div", Pt, [
|
|
@@ -399,7 +399,7 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
399
399
|
class: "dsg-table--tbody-cell dsg-table--tbody-cell-checkbox"
|
|
400
400
|
}, Et = ["onClick", "onDblclick", "onContextmenu"], Lt = ["innerHTML"], Bt = ["onClick"], Rt = ["colspan"], It = { key: 2 }, At = ["colspan"], Ht = { class: "dsg-table--footer" }, Ut = /* @__PURE__ */ K({
|
|
401
401
|
__name: "DsgTableComponent",
|
|
402
|
-
props: /* @__PURE__ */
|
|
402
|
+
props: /* @__PURE__ */ J({
|
|
403
403
|
fields: { default: () => [] },
|
|
404
404
|
isDraggable: { type: Boolean, default: !1 },
|
|
405
405
|
dragApi: { default: "" },
|
|
@@ -455,7 +455,7 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
455
455
|
perPage: { default: 20 },
|
|
456
456
|
perPageModifiers: {}
|
|
457
457
|
}),
|
|
458
|
-
emits: /* @__PURE__ */
|
|
458
|
+
emits: /* @__PURE__ */ J(["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"]),
|
|
459
459
|
setup(e, { expose: E, emit: v }) {
|
|
460
460
|
const r = (t) => t.map((s, d) => ({
|
|
461
461
|
field: s.field || "",
|
|
@@ -469,7 +469,7 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
469
469
|
sortable: s.sortField,
|
|
470
470
|
formatter: s.formatter || null,
|
|
471
471
|
$_index: d
|
|
472
|
-
})), f = p(r(e.fields)), h = p(e.data), g = p(null),
|
|
472
|
+
})), f = p(r(e.fields)), h = p(e.data), g = p(null), y = p(e.initialPage), q = p("17px"), A = p(!1), C = p({}), b = p(0), a = p(!0), u = p(null), T = p(null), $ = p(0), S = G(e, "filterParams"), U = G(e, "perPage"), L = p([]), _ = p(!1), W = V(() => e.tableHeight != null), Q = V(() => f.value.filter((t) => t.visible).length);
|
|
473
473
|
ee(
|
|
474
474
|
() => L.value.length,
|
|
475
475
|
(t) => {
|
|
@@ -485,21 +485,21 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
485
485
|
), ee(
|
|
486
486
|
() => S.value,
|
|
487
487
|
(t) => {
|
|
488
|
-
|
|
488
|
+
Y();
|
|
489
489
|
},
|
|
490
490
|
{ deep: !0 }
|
|
491
491
|
), ee(
|
|
492
492
|
() => U.value,
|
|
493
493
|
() => {
|
|
494
|
-
|
|
494
|
+
Y();
|
|
495
495
|
}
|
|
496
496
|
), ee(
|
|
497
497
|
() => e.apiUrl,
|
|
498
498
|
(t, s) => {
|
|
499
|
-
e.apiMode && t !== s && t &&
|
|
499
|
+
e.apiMode && t !== s && t && Y();
|
|
500
500
|
}
|
|
501
501
|
);
|
|
502
|
-
const H = v,
|
|
502
|
+
const H = v, ne = (t, s) => t.formatter && typeof t.formatter == "function" ? t.formatter(t, s) : ge(s, String(t?.name), ""), oe = (t) => "dsg-field--" + t.name?.toLowerCase().replaceAll(/[_ ]/g, "-"), ie = (t, s) => {
|
|
503
503
|
const d = {
|
|
504
504
|
odd: s % 2 === 0,
|
|
505
505
|
even: s % 2 !== 0,
|
|
@@ -519,7 +519,7 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
519
519
|
w.trim() && (x[w.trim()] = !0);
|
|
520
520
|
});
|
|
521
521
|
return { ...d, ...x };
|
|
522
|
-
},
|
|
522
|
+
}, de = (t) => {
|
|
523
523
|
if (e.selectable) {
|
|
524
524
|
if (t.selected)
|
|
525
525
|
L.value.push(t);
|
|
@@ -529,31 +529,31 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
529
529
|
}
|
|
530
530
|
H("dsg-table:rows-selected", L.value);
|
|
531
531
|
}
|
|
532
|
-
},
|
|
532
|
+
}, re = () => {
|
|
533
533
|
e.selectable && (h.value?.forEach((t) => {
|
|
534
534
|
t.selected = !0;
|
|
535
535
|
}), L.value = h.value?.filter((t) => t.selected) ?? [], H("dsg-table:rows-selected", L.value));
|
|
536
|
-
},
|
|
536
|
+
}, ue = () => {
|
|
537
537
|
e.selectable && (h.value?.forEach((t) => {
|
|
538
538
|
t.selected = !1;
|
|
539
539
|
}), L.value = [], H("dsg-table:rows-selected", L.value));
|
|
540
|
-
},
|
|
540
|
+
}, X = (t) => {
|
|
541
541
|
h.value = Array.isArray(t) ? t : [], e.selectable && h.value.forEach((s) => {
|
|
542
542
|
s.selected = s.selected ?? !1;
|
|
543
543
|
});
|
|
544
|
-
},
|
|
545
|
-
t === "prev" ?
|
|
544
|
+
}, le = () => h.value ?? [], ce = (t) => {
|
|
545
|
+
t === "prev" ? y.value > e.firstPage && y.value-- : t === "next" ? y.value < (g.value?.last_page ?? 0) && y.value++ : t != y.value && t >= e.firstPage && t <= (g.value?.last_page ?? 0) && (y.value = t), Y();
|
|
546
546
|
}, o = () => ({
|
|
547
547
|
[e.queryParams?.sort]: u.value ? (u.value?.direction === "desc" ? "-" : "") + u.value?.field : void 0,
|
|
548
548
|
[e.queryParams?.order]: u.value?.direction,
|
|
549
|
-
[e.queryParams?.page]:
|
|
549
|
+
[e.queryParams?.page]: y.value,
|
|
550
550
|
[e.queryParams?.perPage]: U.value
|
|
551
|
-
}),
|
|
552
|
-
|
|
553
|
-
},
|
|
554
|
-
|
|
555
|
-
const d =
|
|
556
|
-
return s.signal = x.signal,
|
|
551
|
+
}), n = () => {
|
|
552
|
+
T.value && (T.value.abort(), T.value = null);
|
|
553
|
+
}, c = (t, s) => {
|
|
554
|
+
n(), $.value++;
|
|
555
|
+
const d = $.value, x = new AbortController();
|
|
556
|
+
return s.signal = x.signal, T.value = x, (e.httpMethod.toLowerCase() === "get" ? me.get(t, s) : (() => {
|
|
557
557
|
const M = s.params;
|
|
558
558
|
return delete s.params, me.post(t, M, s);
|
|
559
559
|
})()).then(
|
|
@@ -562,39 +562,39 @@ const _e = { class: "dsg-table--pagination" }, et = ["disabled"], tt = ["disable
|
|
|
562
562
|
throw M.name === "AbortError" || M.code === "ERR_CANCELED" ? { ...M, _requestId: d, _cancelled: !0 } : { ...M, _requestId: d };
|
|
563
563
|
}
|
|
564
564
|
);
|
|
565
|
-
},
|
|
566
|
-
if (t._requestId && t._requestId !==
|
|
565
|
+
}, m = (t) => {
|
|
566
|
+
if (t._requestId && t._requestId !== $.value || t._apiUrl && t._apiUrl !== e.apiUrl)
|
|
567
567
|
return;
|
|
568
568
|
H("dsg-table:load-success", t);
|
|
569
569
|
const s = e.transform ? e.transform(t.data) : t.data;
|
|
570
|
-
h.value =
|
|
570
|
+
h.value = ge(s, e.dataPath, null), e.selectable && h.value?.forEach((d) => {
|
|
571
571
|
d.selected = d.selected ?? !1;
|
|
572
|
-
}), g.value =
|
|
572
|
+
}), g.value = ge(s, e.paginationPath, null) ?? null, b.value = h.value?.length ? h.value[0].order : b, !Ze(e.paginationPath) && g.value === null && console.warn(
|
|
573
573
|
'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.
|
|
574
574
|
You can explicitly suppress this warning by setting pagination-path="".`
|
|
575
|
-
),
|
|
576
|
-
},
|
|
577
|
-
t._requestId && t._requestId !==
|
|
578
|
-
},
|
|
575
|
+
), T.value = null, H("dsg-table:pagination-data", g.value), g.value && y.value > (g.value?.last_page || 0) && h.value?.length === 0 && (y.value = e.initialPage, Y()), H("dsg-table:loaded"), a.value = !1;
|
|
576
|
+
}, k = (t) => {
|
|
577
|
+
t._requestId && t._requestId !== $.value || t._apiUrl && t._apiUrl !== e.apiUrl || t._cancelled || (console.error("load-error", t), T.value = null, H("dsg-table:load-error", t), H("dsg-table:loaded"), a.value = !1);
|
|
578
|
+
}, se = () => {
|
|
579
579
|
if (e.data !== null && Array.isArray(e.data)) {
|
|
580
|
-
|
|
580
|
+
X(e.data), a.value = !1;
|
|
581
581
|
return;
|
|
582
582
|
}
|
|
583
583
|
if (e.dataManager && typeof e.dataManager == "function") {
|
|
584
584
|
const t = e.dataManager();
|
|
585
|
-
|
|
585
|
+
X(t), a.value = !1;
|
|
586
586
|
} else
|
|
587
|
-
|
|
588
|
-
},
|
|
589
|
-
const x = t ||
|
|
587
|
+
X(e.data), a.value = !1;
|
|
588
|
+
}, Y = (t = m, s = k, d = {}) => {
|
|
589
|
+
const x = t || m, w = s || k;
|
|
590
590
|
if (!e.apiMode) {
|
|
591
|
-
|
|
591
|
+
se();
|
|
592
592
|
return;
|
|
593
593
|
}
|
|
594
594
|
return a.value = !0, H("dsg-table:loading", a.value), e.httpOptions.params = {
|
|
595
595
|
...o(),
|
|
596
596
|
...S.value
|
|
597
|
-
},
|
|
597
|
+
}, c(e.apiUrl, e.httpOptions).then(x).catch((M) => w(M));
|
|
598
598
|
}, Se = (t, s, d) => {
|
|
599
599
|
H("dsg-table:row-clicked", t, s, d);
|
|
600
600
|
}, xe = (t, s, d) => {
|
|
@@ -606,16 +606,16 @@ You can explicitly suppress this warning by setting pagination-path="".`
|
|
|
606
606
|
}, Be = (t, s, d) => {
|
|
607
607
|
};
|
|
608
608
|
we(() => {
|
|
609
|
-
e.apiMode === !0 ?
|
|
609
|
+
e.apiMode === !0 ? Y() : se();
|
|
610
610
|
});
|
|
611
611
|
const fe = () => {
|
|
612
|
-
e.apiMode && (L.value = [],
|
|
612
|
+
e.apiMode && (L.value = [], n(), Y());
|
|
613
613
|
};
|
|
614
614
|
return E({
|
|
615
|
-
changePage:
|
|
615
|
+
changePage: ce,
|
|
616
616
|
reload: fe,
|
|
617
|
-
getData:
|
|
618
|
-
setData:
|
|
617
|
+
getData: le,
|
|
618
|
+
setData: X,
|
|
619
619
|
setLoading: (t) => {
|
|
620
620
|
a.value = t, H("dsg-table:loading", a.value);
|
|
621
621
|
}
|
|
@@ -659,8 +659,8 @@ You can explicitly suppress this warning by setting pagination-path="".`
|
|
|
659
659
|
"sort-field": u.value,
|
|
660
660
|
"onUpdate:sortField": s[2] || (s[2] = (d) => u.value = d),
|
|
661
661
|
"onDsgTable:sortField": s[3] || (s[3] = (d) => fe()),
|
|
662
|
-
"onDsgTable:onSelectAll":
|
|
663
|
-
"onDsgTable:onDeselectAll":
|
|
662
|
+
"onDsgTable:onSelectAll": re,
|
|
663
|
+
"onDsgTable:onDeselectAll": ue
|
|
664
664
|
}, null, 8, ["fields", "has-select-all", "selected-rows", "has-selected", "scroll-visible", "show-expand-detail", "table-data-length", "sort-field"])
|
|
665
665
|
])
|
|
666
666
|
], 2),
|
|
@@ -686,7 +686,7 @@ You can explicitly suppress this warning by setting pagination-path="".`
|
|
|
686
686
|
], 8, St)
|
|
687
687
|
])) : (l(!0), i(R, { key: 1 }, N(h.value, (d, x) => (l(), i(R, { key: x }, [
|
|
688
688
|
P("tr", {
|
|
689
|
-
class: B(["dsg-table--tbody-row",
|
|
689
|
+
class: B(["dsg-table--tbody-row", ie(d, x)]),
|
|
690
690
|
onClick: (w) => Se(w, x, d),
|
|
691
691
|
onDblclick: (w) => xe(w, x, d),
|
|
692
692
|
onMouseover: (w) => Fe()
|
|
@@ -694,7 +694,7 @@ You can explicitly suppress this warning by setting pagination-path="".`
|
|
|
694
694
|
e.selectable ? (l(), i("td", Mt, [
|
|
695
695
|
I(ke, {
|
|
696
696
|
modelValue: d.selected,
|
|
697
|
-
"onUpdate:modelValue": [(w) => d.selected = w, (w) =>
|
|
697
|
+
"onUpdate:modelValue": [(w) => d.selected = w, (w) => de(d)]
|
|
698
698
|
}, null, 8, ["modelValue", "onUpdate:modelValue"])
|
|
699
699
|
])) : D("", !0),
|
|
700
700
|
(l(!0), i(R, null, N(f.value, (w, M) => (l(), i(R, { key: M }, [
|
|
@@ -706,13 +706,13 @@ You can explicitly suppress this warning by setting pagination-path="".`
|
|
|
706
706
|
onDblclick: (be) => Ee(),
|
|
707
707
|
onContextmenu: (be) => Le()
|
|
708
708
|
}, [
|
|
709
|
-
F(t.$slots,
|
|
709
|
+
F(t.$slots, oe(w), {
|
|
710
710
|
rowData: d,
|
|
711
711
|
rowIndex: x,
|
|
712
712
|
rowField: w
|
|
713
713
|
}, () => [
|
|
714
714
|
P("span", {
|
|
715
|
-
innerHTML:
|
|
715
|
+
innerHTML: ne(w, d)
|
|
716
716
|
}, null, 8, Lt)
|
|
717
717
|
])
|
|
718
718
|
], 46, Et)) : D("", !0)
|
|
@@ -802,77 +802,78 @@ You can explicitly suppress this warning by setting pagination-path="".`
|
|
|
802
802
|
},
|
|
803
803
|
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"],
|
|
804
804
|
setup(e, { expose: E, emit: v }) {
|
|
805
|
-
const r = (
|
|
806
|
-
|
|
805
|
+
const r = (o) => {
|
|
806
|
+
T.value = o;
|
|
807
807
|
}, f = p(e.apiMode && !!(e.filterEntity || e.filterEndpoint || e.getUrl)), h = () => {
|
|
808
808
|
if (f.value) {
|
|
809
|
-
let
|
|
810
|
-
return Ye().forEach((
|
|
811
|
-
if (
|
|
812
|
-
const c =
|
|
813
|
-
|
|
809
|
+
let o = {};
|
|
810
|
+
return Ye().forEach((n) => {
|
|
811
|
+
if (n.key.startsWith("filter[")) {
|
|
812
|
+
const c = n.key.replace("filter[", "").replace("]", ""), m = n.value;
|
|
813
|
+
o[`filter[${c}]`] = m.join(",");
|
|
814
814
|
}
|
|
815
|
-
}),
|
|
815
|
+
}), o;
|
|
816
816
|
} else
|
|
817
817
|
return {};
|
|
818
818
|
}, g = V(() => ({
|
|
819
819
|
...e.css,
|
|
820
820
|
tableWrapper: "border-b " + (e.css?.tableWrapper || "")
|
|
821
|
-
})),
|
|
822
|
-
a.value?.changePage(
|
|
823
|
-
}, L = (
|
|
824
|
-
b.value =
|
|
825
|
-
}, _ = ({ data:
|
|
826
|
-
A.value =
|
|
821
|
+
})), y = qe(), q = p(!0), A = p(null), C = p("<p>Showing {from} to {to} of {total}</p>"), b = p(null), a = ye("dsgTable"), u = p({ perPage: e.perPage, change: r }), T = p(e.perPage), $ = p({ ...h(), ...e.initialFilters }), S = v, U = (o) => {
|
|
822
|
+
a.value?.changePage(o);
|
|
823
|
+
}, L = (o) => {
|
|
824
|
+
b.value = o;
|
|
825
|
+
}, _ = ({ data: o }) => {
|
|
826
|
+
A.value = o, S("dsg-table:data-loaded", o);
|
|
827
827
|
}, W = () => {
|
|
828
828
|
a.value?.reload();
|
|
829
|
-
}, Q = (
|
|
830
|
-
a.value?.setLoading(
|
|
831
|
-
}, H = (
|
|
832
|
-
const
|
|
833
|
-
a.value?.setData(
|
|
834
|
-
},
|
|
835
|
-
const
|
|
836
|
-
a.value?.setData([...
|
|
837
|
-
},
|
|
838
|
-
const
|
|
839
|
-
a.value?.setData(
|
|
840
|
-
},
|
|
841
|
-
a.value?.setData(
|
|
842
|
-
},
|
|
843
|
-
const
|
|
829
|
+
}, Q = (o) => {
|
|
830
|
+
a.value?.setLoading(o);
|
|
831
|
+
}, H = (o) => {
|
|
832
|
+
const n = a.value?.getData?.() ?? [];
|
|
833
|
+
a.value?.setData(n.map((c) => c.id === o.id ? o : c));
|
|
834
|
+
}, ne = (o) => {
|
|
835
|
+
const n = a.value?.getData?.() ?? [];
|
|
836
|
+
a.value?.setData([...n, o]);
|
|
837
|
+
}, oe = (o) => {
|
|
838
|
+
const n = a.value?.getData?.() ?? [];
|
|
839
|
+
a.value?.setData(n.filter((c) => c.id !== o.id));
|
|
840
|
+
}, ie = (o) => {
|
|
841
|
+
a.value?.setData(o);
|
|
842
|
+
}, de = () => a.value?.getData() ?? [], re = (o) => {
|
|
843
|
+
const n = a.value?.getData() ?? [], c = o(n);
|
|
844
844
|
c && a.value?.setData(c);
|
|
845
|
-
},
|
|
846
|
-
|
|
847
|
-
},
|
|
848
|
-
const
|
|
849
|
-
!
|
|
845
|
+
}, ue = (o) => {
|
|
846
|
+
$.value = o;
|
|
847
|
+
}, X = () => $.value ?? {}, le = (o) => {
|
|
848
|
+
const n = { ...$.value };
|
|
849
|
+
!o || o.trim() === "" ? delete n["filter[term]"] : n["filter[term]"] = o, $.value = n, he(() => {
|
|
850
850
|
W();
|
|
851
|
-
}), S("dsg-table:term-changed",
|
|
852
|
-
},
|
|
853
|
-
let
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
}),
|
|
851
|
+
}), S("dsg-table:term-changed", o);
|
|
852
|
+
}, ce = (o, n, c) => {
|
|
853
|
+
let m = {};
|
|
854
|
+
$.value["filter[term]"] && (m["filter[term]"] = $.value["filter[term]"]), Object.keys(o).forEach((k) => {
|
|
855
|
+
o[k] !== null && o[k] !== void 0 && o[k] !== "" && (m[k] = o[k]);
|
|
856
|
+
}), $.value = m, he(() => {
|
|
857
857
|
W();
|
|
858
|
-
}), S("dsg-table:filter-updated",
|
|
858
|
+
}), S("dsg-table:filter-updated", $.value, n, c);
|
|
859
859
|
};
|
|
860
860
|
return E({
|
|
861
861
|
reloadTable: W,
|
|
862
862
|
updateRowTable: H,
|
|
863
|
-
addRowTable:
|
|
864
|
-
deleteRowTable:
|
|
865
|
-
setData:
|
|
866
|
-
getData:
|
|
867
|
-
mutateData:
|
|
868
|
-
termChanged:
|
|
869
|
-
setFilters:
|
|
863
|
+
addRowTable: ne,
|
|
864
|
+
deleteRowTable: oe,
|
|
865
|
+
setData: ie,
|
|
866
|
+
getData: de,
|
|
867
|
+
mutateData: re,
|
|
868
|
+
termChanged: le,
|
|
869
|
+
setFilters: ue,
|
|
870
|
+
getFilters: X,
|
|
870
871
|
setLoading: Q
|
|
871
|
-
}), (
|
|
872
|
+
}), (o, n) => (l(), i("div", qt, [
|
|
872
873
|
e.hasHeader ? (l(), i("div", Vt, [
|
|
873
|
-
F(
|
|
874
|
+
F(o.$slots, "dsg-table--pre-header", {}, () => [
|
|
874
875
|
P("div", zt, [
|
|
875
|
-
F(
|
|
876
|
+
F(o.$slots, "dsg-table--page-title", {
|
|
876
877
|
data: A.value,
|
|
877
878
|
title: e.title
|
|
878
879
|
}, () => [
|
|
@@ -884,16 +885,16 @@ You can explicitly suppress this warning by setting pagination-path="".`
|
|
|
884
885
|
])
|
|
885
886
|
]),
|
|
886
887
|
P("div", Nt, [
|
|
887
|
-
F(
|
|
888
|
+
F(o.$slots, "dsg-table--page-actions", { data: A.value })
|
|
888
889
|
])
|
|
889
890
|
])
|
|
890
891
|
])) : D("", !0),
|
|
891
892
|
e.displaySearch ? (l(), i("div", Wt, [
|
|
892
893
|
P("div", jt, [
|
|
893
|
-
F(
|
|
894
|
+
F(o.$slots, "dsg-table--search-header", { data: A.value }, () => [
|
|
894
895
|
I($e, {
|
|
895
896
|
name: "term",
|
|
896
|
-
"onDsgTable:termChanged":
|
|
897
|
+
"onDsgTable:termChanged": n[0] || (n[0] = (c) => le(c))
|
|
897
898
|
}),
|
|
898
899
|
I(Pe, {
|
|
899
900
|
entity: e.filterEntity,
|
|
@@ -901,20 +902,20 @@ You can explicitly suppress this warning by setting pagination-path="".`
|
|
|
901
902
|
"search-endpoint": e.filterSearchEndpoint,
|
|
902
903
|
"auto-sort": e.autoSortFilters,
|
|
903
904
|
filters: e.filters,
|
|
904
|
-
"onDsgTable:filterUpdated":
|
|
905
|
+
"onDsgTable:filterUpdated": n[1] || (n[1] = (c, m, k) => ce(c, m, k))
|
|
905
906
|
}, null, 8, ["entity", "filter-endpoint", "search-endpoint", "auto-sort", "filters"]),
|
|
906
|
-
F(
|
|
907
|
+
F(o.$slots, "dsg-table--search-actions", { data: A.value })
|
|
907
908
|
])
|
|
908
909
|
]),
|
|
909
|
-
F(
|
|
910
|
+
F(o.$slots, "dsg-table--search-navigation")
|
|
910
911
|
], 512)) : D("", !0),
|
|
911
912
|
I(Ut, {
|
|
912
913
|
ref: "dsgTable",
|
|
913
914
|
"api-url": e.getUrl,
|
|
914
|
-
"filter-params":
|
|
915
|
-
"onUpdate:filterParams":
|
|
916
|
-
"per-page":
|
|
917
|
-
"onUpdate:perPage":
|
|
915
|
+
"filter-params": $.value,
|
|
916
|
+
"onUpdate:filterParams": n[7] || (n[7] = (c) => $.value = c),
|
|
917
|
+
"per-page": T.value,
|
|
918
|
+
"onUpdate:perPage": n[8] || (n[8] = (c) => T.value = c),
|
|
918
919
|
fields: e.fields,
|
|
919
920
|
"load-on-start": e.loadOnStart,
|
|
920
921
|
"pagination-path": e.paginationPath,
|
|
@@ -925,40 +926,40 @@ You can explicitly suppress this warning by setting pagination-path="".`
|
|
|
925
926
|
data: e.data,
|
|
926
927
|
"row-class": e.rowClass,
|
|
927
928
|
"api-mode": f.value,
|
|
928
|
-
"onDsgTable:loading":
|
|
929
|
-
"onDsgTable:loaded":
|
|
929
|
+
"onDsgTable:loading": n[9] || (n[9] = (c) => q.value = !0),
|
|
930
|
+
"onDsgTable:loaded": n[10] || (n[10] = (c) => q.value = !1),
|
|
930
931
|
"onDsgTable:paginationData": L,
|
|
931
932
|
"onDsgTable:loadSuccess": _,
|
|
932
|
-
"onDsgTable:rowsSelected":
|
|
933
|
-
"onDsgTable:rowClicked":
|
|
934
|
-
"onDsgTable:rowHover":
|
|
935
|
-
"onDsgTable:rowDblclick":
|
|
933
|
+
"onDsgTable:rowsSelected": n[11] || (n[11] = (c) => S("dsg-table:rows-selected", c)),
|
|
934
|
+
"onDsgTable:rowClicked": n[12] || (n[12] = (c, m, k) => S("dsg-table:row-clicked", c, m, k)),
|
|
935
|
+
"onDsgTable:rowHover": n[13] || (n[13] = (c, m, k) => S("dsg-table:row-hover", c, m, k)),
|
|
936
|
+
"onDsgTable:rowDblclick": n[14] || (n[14] = (c, m, k) => S("dsg-table:row-dblclick", c, m, k))
|
|
936
937
|
}, Ve({
|
|
937
938
|
"dsg-field--actions": te((c) => [
|
|
938
|
-
F(
|
|
939
|
+
F(o.$slots, "dsg-table-actions", { data: c }, () => [
|
|
939
940
|
(l(), j(Ce, {
|
|
940
941
|
key: c.rowIndex,
|
|
941
942
|
data: c,
|
|
942
|
-
"onDsgTable:actionEdit":
|
|
943
|
-
"onDsgTable:actionView":
|
|
944
|
-
"onDsgTable:actionDelete":
|
|
945
|
-
"onDsgTable:actionArchive":
|
|
946
|
-
"onDsgTable:linkClicked":
|
|
943
|
+
"onDsgTable:actionEdit": n[2] || (n[2] = (m, k) => S("dsg-table:action-edit", m, k)),
|
|
944
|
+
"onDsgTable:actionView": n[3] || (n[3] = (m, k) => S("dsg-table:action-view", m, k)),
|
|
945
|
+
"onDsgTable:actionDelete": n[4] || (n[4] = (m, k) => S("dsg-table:action-delete", m, k)),
|
|
946
|
+
"onDsgTable:actionArchive": n[5] || (n[5] = (m, k) => S("dsg-table:action-archive", m, k)),
|
|
947
|
+
"onDsgTable:linkClicked": n[6] || (n[6] = (m, k, se) => S("dsg-table:link-clicked", m, k, se))
|
|
947
948
|
}, null, 8, ["data"]))
|
|
948
949
|
])
|
|
949
950
|
]),
|
|
950
951
|
_: 2
|
|
951
952
|
}, [
|
|
952
|
-
N(O(
|
|
953
|
-
name:
|
|
953
|
+
N(O(y), (c, m) => ({
|
|
954
|
+
name: m,
|
|
954
955
|
fn: te((k) => [
|
|
955
|
-
String(
|
|
956
|
+
String(m) !== "dsg-field--actions" ? F(o.$slots, m, ze(Oe({ key: 0 }, k))) : D("", !0)
|
|
956
957
|
])
|
|
957
958
|
}))
|
|
958
959
|
]), 1032, ["api-url", "filter-params", "per-page", "fields", "load-on-start", "pagination-path", "selectable", "track-by", "table-layout", "css", "data", "row-class", "api-mode"]),
|
|
959
960
|
e.hasFooter ? (l(), i("div", Kt, [
|
|
960
961
|
P("div", Qt, [
|
|
961
|
-
F(
|
|
962
|
+
F(o.$slots, "dsg-table--footer-left", {
|
|
962
963
|
data: b.value,
|
|
963
964
|
perPage: u.value
|
|
964
965
|
}, () => [
|
|
@@ -966,28 +967,28 @@ You can explicitly suppress this warning by setting pagination-path="".`
|
|
|
966
967
|
key: 0,
|
|
967
968
|
ref: "paginationInfoStart",
|
|
968
969
|
pagination: b.value,
|
|
969
|
-
"onUpdate:pagination":
|
|
970
|
+
"onUpdate:pagination": n[15] || (n[15] = (c) => b.value = c),
|
|
970
971
|
"info-template": C.value
|
|
971
972
|
}, null, 8, ["pagination", "info-template"])) : D("", !0),
|
|
972
|
-
F(
|
|
973
|
+
F(o.$slots, "dsg-table--footer-left-extras", {
|
|
973
974
|
data: b.value,
|
|
974
975
|
perPage: u.value
|
|
975
976
|
})
|
|
976
977
|
])
|
|
977
978
|
]),
|
|
978
979
|
P("div", Yt, [
|
|
979
|
-
F(
|
|
980
|
+
F(o.$slots, "dsg-table--footer-center", {
|
|
980
981
|
data: b.value,
|
|
981
982
|
perPage: u.value
|
|
982
983
|
}, () => [
|
|
983
|
-
F(
|
|
984
|
+
F(o.$slots, "dsg-table--footer-center-extras", {
|
|
984
985
|
data: b.value,
|
|
985
986
|
perPage: u.value
|
|
986
987
|
})
|
|
987
988
|
])
|
|
988
989
|
]),
|
|
989
990
|
P("div", Gt, [
|
|
990
|
-
F(
|
|
991
|
+
F(o.$slots, "dsg-table--footer-right", {
|
|
991
992
|
data: b.value,
|
|
992
993
|
perPage: u.value
|
|
993
994
|
}, () => [
|
|
@@ -995,10 +996,10 @@ You can explicitly suppress this warning by setting pagination-path="".`
|
|
|
995
996
|
key: 0,
|
|
996
997
|
ref: "pagination",
|
|
997
998
|
pagination: b.value,
|
|
998
|
-
"onUpdate:pagination":
|
|
999
|
+
"onUpdate:pagination": n[16] || (n[16] = (c) => b.value = c),
|
|
999
1000
|
"onDsgTable:changePage": U
|
|
1000
1001
|
}, null, 8, ["pagination"])) : D("", !0),
|
|
1001
|
-
F(
|
|
1002
|
+
F(o.$slots, "dsg-table--footer-right-extras", {
|
|
1002
1003
|
data: b.value,
|
|
1003
1004
|
perPage: u.value
|
|
1004
1005
|
})
|
|
@@ -1015,7 +1016,7 @@ You can explicitly suppress this warning by setting pagination-path="".`
|
|
|
1015
1016
|
},
|
|
1016
1017
|
setup(e) {
|
|
1017
1018
|
return (E, v) => (l(), i("div", Xt, [
|
|
1018
|
-
|
|
1019
|
+
ve(P("select", {
|
|
1019
1020
|
"onUpdate:modelValue": v[0] || (v[0] = (r) => e.perPage.perPage = r),
|
|
1020
1021
|
class: "dsg-table--per-page-select",
|
|
1021
1022
|
onChange: v[1] || (v[1] = (r) => e.perPage.change(e.perPage.perPage))
|
package/dist/table.d.ts
CHANGED
|
@@ -32,6 +32,9 @@ export declare const DsgTable: {
|
|
|
32
32
|
mutateData: (mutator: (data: any[]) => any[] | void) => void;
|
|
33
33
|
termChanged: (term: string | null) => void;
|
|
34
34
|
setFilters: (filters: any) => void;
|
|
35
|
+
getFilters: () => {
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
};
|
|
35
38
|
setLoading: (loadingState: boolean) => void;
|
|
36
39
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
37
40
|
"dsg-table:action-edit": (ev: Event, rowData: Record<string, any>) => any;
|
|
@@ -295,6 +298,9 @@ export declare const DsgTable: {
|
|
|
295
298
|
mutateData: (mutator: (data: any[]) => any[] | void) => void;
|
|
296
299
|
termChanged: (term: string | null) => void;
|
|
297
300
|
setFilters: (filters: any) => void;
|
|
301
|
+
getFilters: () => {
|
|
302
|
+
[key: string]: any;
|
|
303
|
+
};
|
|
298
304
|
setLoading: (loadingState: boolean) => void;
|
|
299
305
|
}, {}, {}, {}, {}>;
|
|
300
306
|
__isFragment?: never;
|
|
@@ -323,6 +329,9 @@ export declare const DsgTable: {
|
|
|
323
329
|
mutateData: (mutator: (data: any[]) => any[] | void) => void;
|
|
324
330
|
termChanged: (term: string | null) => void;
|
|
325
331
|
setFilters: (filters: any) => void;
|
|
332
|
+
getFilters: () => {
|
|
333
|
+
[key: string]: any;
|
|
334
|
+
};
|
|
326
335
|
setLoading: (loadingState: boolean) => void;
|
|
327
336
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
328
337
|
"dsg-table:action-edit": (ev: Event, rowData: Record<string, any>) => any;
|
|
@@ -1557,6 +1566,9 @@ declare const _default: {
|
|
|
1557
1566
|
mutateData: (mutator: (data: any[]) => any[] | void) => void;
|
|
1558
1567
|
termChanged: (term: string | null) => void;
|
|
1559
1568
|
setFilters: (filters: any) => void;
|
|
1569
|
+
getFilters: () => {
|
|
1570
|
+
[key: string]: any;
|
|
1571
|
+
};
|
|
1560
1572
|
setLoading: (loadingState: boolean) => void;
|
|
1561
1573
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
1562
1574
|
"dsg-table:action-edit": (ev: Event, rowData: Record<string, any>) => any;
|
|
@@ -1820,6 +1832,9 @@ declare const _default: {
|
|
|
1820
1832
|
mutateData: (mutator: (data: any[]) => any[] | void) => void;
|
|
1821
1833
|
termChanged: (term: string | null) => void;
|
|
1822
1834
|
setFilters: (filters: any) => void;
|
|
1835
|
+
getFilters: () => {
|
|
1836
|
+
[key: string]: any;
|
|
1837
|
+
};
|
|
1823
1838
|
setLoading: (loadingState: boolean) => void;
|
|
1824
1839
|
}, {}, {}, {}, {}>;
|
|
1825
1840
|
__isFragment?: never;
|
|
@@ -1848,6 +1863,9 @@ declare const _default: {
|
|
|
1848
1863
|
mutateData: (mutator: (data: any[]) => any[] | void) => void;
|
|
1849
1864
|
termChanged: (term: string | null) => void;
|
|
1850
1865
|
setFilters: (filters: any) => void;
|
|
1866
|
+
getFilters: () => {
|
|
1867
|
+
[key: string]: any;
|
|
1868
|
+
};
|
|
1851
1869
|
setLoading: (loadingState: boolean) => void;
|
|
1852
1870
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
1853
1871
|
"dsg-table:action-edit": (ev: Event, rowData: Record<string, any>) => any;
|
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.
|
|
4
|
+
"version": "0.1.20",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"preinstall": "npx only-allow pnpm",
|
|
@@ -158,4 +158,4 @@
|
|
|
158
158
|
"plugin:storybook/recommended"
|
|
159
159
|
]
|
|
160
160
|
}
|
|
161
|
-
}
|
|
161
|
+
}
|