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
|
2023-06-20 10:03:34 +00:00
|
|
|
:class="cx('pageButton', { 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)"
|
2023-05-08 09:35:25 +00:00
|
|
|
v-bind="getPTOptions(pageLink - 1, 'pageButton')"
|
2023-06-20 10:03:34 +00:00
|
|
|
:data-p-highlight="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-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>
|