2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2023-06-20 10:03:34 +00:00
|
|
|
<span :class="cx('pages')" v-bind="ptm('pages')">
|
2022-12-08 11:04:25 +00:00
|
|
|
<button
|
|
|
|
v-for="pageLink of value"
|
|
|
|
:key="pageLink"
|
|
|
|
v-ripple
|
2024-05-02 06:27:51 +00:00
|
|
|
:class="cx('page', { pageLink })"
|
2022-12-08 11:04:25 +00:00
|
|
|
type="button"
|
|
|
|
:aria-label="ariaPageLabel(pageLink)"
|
|
|
|
:aria-current="pageLink - 1 === page ? 'page' : undefined"
|
|
|
|
@click="onPageLinkClick($event, pageLink)"
|
2024-05-02 06:27:51 +00:00
|
|
|
v-bind="getPTOptions(pageLink - 1, 'page')"
|
2024-05-24 11:07:49 +00:00
|
|
|
:data-p-active="pageLink - 1 === page"
|
2022-12-08 11:04:25 +00:00
|
|
|
>
|
|
|
|
{{ pageLink }}
|
|
|
|
</button>
|
2022-09-06 12:03:37 +00:00
|
|
|
</span>
|
|
|
|
</template>
|
2023-05-08 09:35:25 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
<script>
|
2023-05-08 09:35:25 +00:00
|
|
|
import BaseComponent from 'primevue/basecomponent';
|
2022-09-06 12:03:37 +00:00
|
|
|
import Ripple from 'primevue/ripple';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'PageLinks',
|
2023-07-04 06:29:36 +00:00
|
|
|
hostName: 'Paginator',
|
2023-05-08 09:35:25 +00:00
|
|
|
extends: BaseComponent,
|
2022-09-06 12:03:37 +00:00
|
|
|
inheritAttrs: false,
|
|
|
|
emits: ['click'],
|
|
|
|
props: {
|
|
|
|
value: Array,
|
|
|
|
page: Number
|
|
|
|
},
|
|
|
|
methods: {
|
2023-05-08 09:35:25 +00:00
|
|
|
getPTOptions(pageLink, key) {
|
|
|
|
return this.ptm(key, {
|
|
|
|
context: {
|
|
|
|
active: pageLink === this.page
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
onPageLinkClick(event, pageLink) {
|
|
|
|
this.$emit('click', {
|
|
|
|
originalEvent: event,
|
|
|
|
value: pageLink
|
|
|
|
});
|
2022-12-08 11:04:25 +00:00
|
|
|
},
|
|
|
|
ariaPageLabel(value) {
|
|
|
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.pageLabel.replace(/{page}/g, value) : undefined;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
directives: {
|
2022-09-14 11:26:01 +00:00
|
|
|
ripple: Ripple
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|