2023-05-30 13:39:08 +00:00
|
|
|
<script>
|
|
|
|
import BaseComponent from 'primevue/basecomponent';
|
|
|
|
import { useStyle } from 'primevue/usestyle';
|
|
|
|
|
|
|
|
const styles = `
|
2023-09-26 06:40:02 +00:00
|
|
|
@layer primevue.core {
|
2023-09-25 19:11:55 +00:00
|
|
|
.p-paginator-default {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-paginator {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-paginator-left-content {
|
|
|
|
margin-right: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-paginator-right-content {
|
|
|
|
margin-left: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-paginator-page,
|
|
|
|
.p-paginator-next,
|
|
|
|
.p-paginator-last,
|
|
|
|
.p-paginator-first,
|
|
|
|
.p-paginator-prev,
|
|
|
|
.p-paginator-current {
|
|
|
|
cursor: pointer;
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
line-height: 1;
|
|
|
|
user-select: none;
|
|
|
|
overflow: hidden;
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-paginator-element:focus {
|
|
|
|
z-index: 1;
|
|
|
|
position: relative;
|
|
|
|
}
|
2023-05-30 13:39:08 +00:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const classes = {
|
|
|
|
paginator: ({ instance, key }) => [
|
|
|
|
'p-paginator p-component',
|
|
|
|
{
|
|
|
|
'p-paginator-default': !instance.hasBreakpoints(),
|
|
|
|
[`p-paginator-${key}`]: instance.hasBreakpoints()
|
|
|
|
}
|
|
|
|
],
|
|
|
|
start: 'p-paginator-left-content',
|
|
|
|
end: 'p-paginator-right-content',
|
|
|
|
firstPageButton: ({ instance }) => [
|
|
|
|
'p-paginator-first p-paginator-element p-link',
|
|
|
|
{
|
|
|
|
'p-disabled': instance.$attrs.disabled
|
|
|
|
}
|
|
|
|
],
|
|
|
|
firstPageIcon: 'p-paginator-icon',
|
2023-06-20 10:03:34 +00:00
|
|
|
previousPageButton: ({ instance }) => [
|
2023-05-30 13:39:08 +00:00
|
|
|
'p-paginator-prev p-paginator-element p-link',
|
|
|
|
{
|
|
|
|
'p-disabled': instance.$attrs.disabled
|
|
|
|
}
|
|
|
|
],
|
2023-06-20 10:03:34 +00:00
|
|
|
previousPageIcon: 'p-paginator-icon',
|
2023-05-30 13:39:08 +00:00
|
|
|
nextPageButton: ({ instance }) => [
|
|
|
|
'p-paginator-next p-paginator-element p-link',
|
|
|
|
{
|
|
|
|
'p-disabled': instance.$attrs.disabled
|
|
|
|
}
|
|
|
|
],
|
|
|
|
nextPageIcon: 'p-paginator-icon',
|
|
|
|
lastPageButton: ({ instance }) => [
|
|
|
|
'p-paginator-last p-paginator-element p-link',
|
|
|
|
{
|
|
|
|
'p-disabled': instance.$attrs.disabled
|
|
|
|
}
|
|
|
|
],
|
|
|
|
lastPageIcon: 'p-paginator-icon',
|
2023-06-20 10:03:34 +00:00
|
|
|
pages: 'p-paginator-pages',
|
|
|
|
pageButton: ({ props, pageLink }) => [
|
|
|
|
'p-paginator-page p-paginator-element p-link',
|
|
|
|
{
|
|
|
|
'p-highlight': pageLink - 1 === props.page
|
|
|
|
}
|
|
|
|
],
|
2023-05-30 13:39:08 +00:00
|
|
|
current: 'p-paginator-current',
|
2023-06-20 10:03:34 +00:00
|
|
|
rowPerPageDropdown: 'p-paginator-rpp-options',
|
|
|
|
jumpToPageDropdown: 'p-paginator-page-options',
|
|
|
|
jumpToPageInput: 'p-paginator-page-input'
|
2023-05-30 13:39:08 +00:00
|
|
|
};
|
|
|
|
|
2023-07-03 22:20:35 +00:00
|
|
|
const { load: loadStyle } = useStyle(styles, { name: 'paginator', manual: true });
|
2023-05-30 13:39:08 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'BasePaginator',
|
|
|
|
extends: BaseComponent,
|
|
|
|
props: {
|
|
|
|
totalRecords: {
|
|
|
|
type: Number,
|
|
|
|
default: 0
|
|
|
|
},
|
|
|
|
rows: {
|
|
|
|
type: Number,
|
|
|
|
default: 0
|
|
|
|
},
|
|
|
|
first: {
|
|
|
|
type: Number,
|
|
|
|
default: 0
|
|
|
|
},
|
|
|
|
pageLinkSize: {
|
|
|
|
type: Number,
|
|
|
|
default: 5
|
|
|
|
},
|
|
|
|
rowsPerPageOptions: {
|
|
|
|
type: Array,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
type: [Object, String],
|
|
|
|
default: 'FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown'
|
|
|
|
},
|
|
|
|
currentPageReportTemplate: {
|
|
|
|
type: null,
|
|
|
|
default: '({currentPage} of {totalPages})'
|
|
|
|
},
|
|
|
|
alwaysShow: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
css: {
|
|
|
|
classes,
|
|
|
|
loadStyle
|
|
|
|
},
|
|
|
|
provide() {
|
|
|
|
return {
|
|
|
|
$parentInstance: this
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|