primevue
Version:
PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc
2 lines (1 loc) • 6.05 kB
JavaScript
import t from"primevue/paginator";import{ObjectUtils as e}from"primevue/utils";import r from"primevue/basecomponent";import a from"primevue/dataview/style";import{resolveComponent as o,openBlock as i,createElementBlock as s,mergeProps as n,renderSlot as l,createCommentVNode as p,createBlock as u,normalizeClass as d,createSlots as g,withCtx as f,createElementVNode as c,Fragment as m,createTextVNode as y,toDisplayString as h}from"vue";function P(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function v(t,e){if(t){if("string"==typeof t)return k(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?k(t,e):void 0}}function w(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function S(t){if(Array.isArray(t))return k(t)}function k(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,a=new Array(e);r<e;r++)a[r]=t[r];return a}var $={name:"DataView",extends:{name:"BaseDataView",extends:r,props:{value:{type:Array,default:null},layout:{type:String,default:"list"},rows:{type:Number,default:0},first:{type:Number,default:0},totalRecords:{type:Number,default:0},paginator:{type:Boolean,default:!1},paginatorPosition:{type:String,default:"bottom"},alwaysShowPaginator:{type:Boolean,default:!0},paginatorTemplate:{type:String,default:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown"},pageLinkSize:{type:Number,default:5},rowsPerPageOptions:{type:Array,default:null},currentPageReportTemplate:{type:String,default:"({currentPage} of {totalPages})"},sortField:{type:[String,Function],default:null},sortOrder:{type:Number,default:null},lazy:{type:Boolean,default:!1},dataKey:{type:String,default:null}},style:a,provide:function(){return{$parentInstance:this}}},emits:["update:first","update:rows","page"],data:function(){return{d_first:this.first,d_rows:this.rows}},watch:{first:function(t){this.d_first=t},rows:function(t){this.d_rows=t},sortField:function(){this.resetPage()},sortOrder:function(){this.resetPage()}},methods:{getKey:function(t,r){return this.dataKey?e.resolveFieldData(t,this.dataKey):r},onPage:function(t){this.d_first=t.first,this.d_rows=t.rows,this.$emit("update:first",this.d_first),this.$emit("update:rows",this.d_rows),this.$emit("page",t)},sort:function(){var t,r=this;if(this.value){var a=S(t=this.value)||w(t)||v(t)||P(),o=e.localeComparator();return a.sort((function(t,a){var i=e.resolveFieldData(t,r.sortField),s=e.resolveFieldData(a,r.sortField);return e.sort(i,s,r.sortOrder,o)})),a}return null},resetPage:function(){this.d_first=0,this.$emit("update:first",this.d_first)}},computed:{getTotalRecords:function(){return this.totalRecords?this.totalRecords:this.value?this.value.length:0},empty:function(){return!this.value||0===this.value.length},emptyMessageText:function(){var t;return(null===(t=this.$primevue.config)||void 0===t||null===(t=t.locale)||void 0===t?void 0:t.emptyMessage)||""},paginatorTop:function(){return this.paginator&&("bottom"!==this.paginatorPosition||"both"===this.paginatorPosition)},paginatorBottom:function(){return this.paginator&&("top"!==this.paginatorPosition||"both"===this.paginatorPosition)},items:function(){if(this.value&&this.value.length){var t=this.value;if(t&&t.length&&this.sortField&&(t=this.sort()),this.paginator){var e=this.lazy?0:this.d_first;return t.slice(e,e+this.d_rows)}return t}return null}},components:{DVPaginator:t}};$.render=function(t,e,r,a,P,v){var w=o("DVPaginator");return i(),s("div",n({class:t.cx("root")},t.ptm("root"),{"data-pc-name":"dataview"}),[t.$slots.header?(i(),s("div",n({key:0,class:t.cx("header")},t.ptm("header")),[l(t.$slots,"header")],16)):p("",!0),v.paginatorTop?(i(),u(w,{key:1,rows:P.d_rows,first:P.d_first,totalRecords:v.getTotalRecords,pageLinkSize:t.pageLinkSize,template:t.paginatorTemplate,rowsPerPageOptions:t.rowsPerPageOptions,currentPageReportTemplate:t.currentPageReportTemplate,class:d(t.cx("paginator")),alwaysShow:t.alwaysShowPaginator,onPage:e[0]||(e[0]=function(t){return v.onPage(t)}),unstyled:t.unstyled,pt:t.ptm("paginator")},g({_:2},[t.$slots.paginatorstart?{name:"start",fn:f((function(){return[l(t.$slots,"paginatorstart")]})),key:"0"}:void 0,t.$slots.paginatorend?{name:"end",fn:f((function(){return[l(t.$slots,"paginatorend")]})),key:"1"}:void 0]),1032,["rows","first","totalRecords","pageLinkSize","template","rowsPerPageOptions","currentPageReportTemplate","class","alwaysShow","unstyled","pt"])):p("",!0),c("div",n({class:t.cx("content")},t.ptm("content")),[v.empty?(i(),s("div",n({key:1,class:t.cx("emptyMessage")},t.ptm("emptyMessage")),[l(t.$slots,"empty",{layout:t.layout},(function(){return[y(h(v.emptyMessageText),1)]}))],16)):(i(),s(m,{key:0},[t.$slots.list&&"list"===t.layout?l(t.$slots,"list",{key:0,items:v.items}):p("",!0),t.$slots.grid&&"grid"===t.layout?l(t.$slots,"grid",{key:1,items:v.items}):p("",!0)],64))],16),v.paginatorBottom?(i(),u(w,{key:2,rows:P.d_rows,first:P.d_first,totalRecords:v.getTotalRecords,pageLinkSize:t.pageLinkSize,template:t.paginatorTemplate,rowsPerPageOptions:t.rowsPerPageOptions,currentPageReportTemplate:t.currentPageReportTemplate,class:d(t.cx("paginator")),alwaysShow:t.alwaysShowPaginator,onPage:e[1]||(e[1]=function(t){return v.onPage(t)}),unstyled:t.unstyled,pt:t.ptm("paginator")},g({_:2},[t.$slots.paginatorstart?{name:"start",fn:f((function(){return[l(t.$slots,"paginatorstart")]})),key:"0"}:void 0,t.$slots.paginatorend?{name:"end",fn:f((function(){return[l(t.$slots,"paginatorend")]})),key:"1"}:void 0]),1032,["rows","first","totalRecords","pageLinkSize","template","rowsPerPageOptions","currentPageReportTemplate","class","alwaysShow","unstyled","pt"])):p("",!0),t.$slots.footer?(i(),s("div",n({key:3,class:t.cx("footer")},t.ptm("footer")),[l(t.$slots,"footer")],16)):p("",!0)],16)};export{$ as default};