primevue-mirror/components/lib/paginator/PageLinks.vue

57 lines
1.5 KiB
Vue
Raw Normal View History

2022-09-06 12:03:37 +00:00
<template>
<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
: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)"
v-bind="getPTOptions(pageLink - 1, 'page')"
: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-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>