themesberg / flowbite-vue

Official Vue 3 components built for Flowbite and Tailwind CSS
https://flowbite-vue.com
MIT License
745 stars 118 forks source link

Pagination functionality for Vue.js #186

Closed gassio closed 12 months ago

gassio commented 1 year ago

Hi,  Thanks for this amazing project. I want to implement pagination functionality with Vue.js. Is there any way to pass an event function to the component's props? The documentation you have does not provide any event handling options. https://flowbite-vue.com/components/pagination

cogor commented 1 year ago

Hi, which event you need? I'll add click:page, click:next, click:prev as soon as possible, if you need an another event – leave a comment

gassio commented 1 year ago

Hi, I 've imported the component inside my project and I've added the event that I need. I didn't make a pull request for this yet. I send you see the changes that I made in the Pagination.vue file:

Code edited:

const emit = defineEmits(['update:modelValue', 'page-changed']); const setPage = (index: number) => { emit('update:modelValue', index) emit('page-changed', index); } const decreasePage = () => { emit('update:modelValue', props.modelValue - 1) emit('page-changed', props.modelValue - 1); } const increasePage = () => { emit('update:modelValue', props.modelValue + 1) emit('page-changed', props.modelValue + 1); }

Code added:

const goToFirstPage = () => { emit('update:modelValue', 1); emit('page-changed', 1); }

const goToLastPage = () => { const lastPage = computedTotalPages.value; emit('update:modelValue', lastPage); emit('page-changed', lastPage); }

cogor commented 12 months ago

Released in 0.0.17-next.10