Skip to content

Commit c71fdc8

Browse files
authoredNov 5, 2024··
feat(Pagination): improve slot props (#2522)

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed
 

‎docs/components/content/examples/PaginationExampleFirstLastSlots.vue

+18-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,29 @@ const items = ref(Array(55))
55

66
<template>
77
<UPagination v-model="page" :total="items.length" :ui="{ rounded: 'first-of-type:rounded-s-md last-of-type:rounded-e-md' }">
8-
<template #first="{ onClick }">
8+
<template #first="{ onClick, canGoFirst }">
99
<UTooltip text="First page">
10-
<UButton icon="i-heroicons-arrow-uturn-left" color="primary" :ui="{ rounded: 'rounded-full' }" class="rtl:[&_span:first-child]:rotate-180 me-2" @click="onClick" />
10+
<UButton
11+
icon="i-heroicons-arrow-uturn-left"
12+
color="primary"
13+
:ui="{ rounded: 'rounded-full' }"
14+
class="rtl:[&_span:first-child]:rotate-180 me-2"
15+
:disabled="!canGoFirst"
16+
@click="onClick"
17+
/>
1118
</UTooltip>
1219
</template>
1320

14-
<template #last="{ onClick }">
21+
<template #last="{ onClick, canGoLast }">
1522
<UTooltip text="Last page">
16-
<UButton icon="i-heroicons-arrow-uturn-right-20-solid" color="primary" :ui="{ rounded: 'rounded-full' }" class="rtl:[&_span:last-child]:rotate-180 ms-2" @click="onClick" />
23+
<UButton
24+
icon="i-heroicons-arrow-uturn-right-20-solid"
25+
color="primary"
26+
:ui="{ rounded: 'rounded-full' }"
27+
class="rtl:[&_span:last-child]:rotate-180 ms-2"
28+
:disabled="!canGoLast"
29+
@click="onClick"
30+
/>
1731
</UTooltip>
1832
</template>
1933
</UPagination>

‎docs/components/content/examples/PaginationExamplePrevNextSlots.vue

+18-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,29 @@ const items = ref(Array(55))
55

66
<template>
77
<UPagination v-model="page" :total="items.length" :ui="{ rounded: 'first-of-type:rounded-s-md last-of-type:rounded-e-md' }">
8-
<template #prev="{ onClick }">
8+
<template #prev="{ onClick, canGoPrev }">
99
<UTooltip text="Previous page">
10-
<UButton icon="i-heroicons-arrow-small-left-20-solid" color="primary" :ui="{ rounded: 'rounded-full' }" class="rtl:[&_span:first-child]:rotate-180 me-2" @click="onClick" />
10+
<UButton
11+
icon="i-heroicons-arrow-small-left-20-solid"
12+
color="primary"
13+
:ui="{ rounded: 'rounded-full' }"
14+
class="rtl:[&_span:first-child]:rotate-180 me-2"
15+
:disabled="!canGoPrev"
16+
@click="onClick"
17+
/>
1118
</UTooltip>
1219
</template>
1320

14-
<template #next="{ onClick }">
21+
<template #next="{ onClick, canGoNext }">
1522
<UTooltip text="Next page">
16-
<UButton icon="i-heroicons-arrow-small-right-20-solid" color="primary" :ui="{ rounded: 'rounded-full' }" class="rtl:[&_span:last-child]:rotate-180 ms-2" @click="onClick" />
23+
<UButton
24+
icon="i-heroicons-arrow-small-right-20-solid"
25+
color="primary"
26+
:ui="{ rounded: 'rounded-full' }"
27+
class="rtl:[&_span:last-child]:rotate-180 ms-2"
28+
:disabled="!canGoNext"
29+
@click="onClick"
30+
/>
1731
</UTooltip>
1832
</template>
1933
</UPagination>

‎src/runtime/components/navigation/Pagination.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div :class="ui.wrapper" v-bind="attrs">
3-
<slot name="first" :on-click="onClickFirst">
3+
<slot name="first" :on-click="onClickFirst" :can-go-first="canGoFirstOrPrev">
44
<UButton
55
v-if="firstButton && showFirst"
66
:size="size"
@@ -14,7 +14,7 @@
1414
/>
1515
</slot>
1616

17-
<slot name="prev" :on-click="onClickPrev">
17+
<slot name="prev" :on-click="onClickPrev" :can-go-prev="canGoFirstOrPrev">
1818
<UButton
1919
v-if="prevButton"
2020
:size="size"
@@ -41,7 +41,7 @@
4141
@click="() => onClickPage(page)"
4242
/>
4343

44-
<slot name="next" :on-click="onClickNext">
44+
<slot name="next" :on-click="onClickNext" :can-go-next="canGoLastOrNext">
4545
<UButton
4646
v-if="nextButton"
4747
:size="size"
@@ -55,7 +55,7 @@
5555
/>
5656
</slot>
5757

58-
<slot name="last" :on-click="onClickLast">
58+
<slot name="last" :on-click="onClickLast" :can-go-last="canGoLastOrNext">
5959
<UButton
6060
v-if="lastButton && showLast"
6161
:size="size"

0 commit comments

Comments
 (0)
Please sign in to comment.