Skip to content

Commit 1b7e7de

Browse files
toadkickermosinve
authored andcommitted
feat(pagination): added slots for first, prev, next, last, and ellipsis. Fixes #1870. (#1980)
1 parent a28c2cd commit 1b7e7de

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

src/components/pagination/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ values for `total-rows` and `per-page`.
6161
| `hide-ellipsis` | never show ellipsis indicators
6262
| `hide-goto-end-buttons` | never display goto first/last buttons
6363

64+
| Slot | Description
65+
|----- | -----------
66+
| `first-text` | The "goto first page" button text (html supported)
67+
| `prev-text` | The "goto previous page" button text (html supported)
68+
| `next-text` | The "goto next page" button text (html supported)
69+
| `last-text` | The "goto last page" button text (html supported)
70+
| `ellipsis-text` | the `...` indicator text (html supported)
71+
72+
6473
Ellipsis inidcator(s) will only be ever shown at the front and/or end of
6574
the page number buttons. For `limit` values less than or equal to `3`, the ellipsis
6675
indicator(s) will never be shown for practical display reasons.

src/components/pagination/fixtures/pagination.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ <h6>Default</h6>
2929
<b-pagination hide-goto-end-buttons :total-rows="100" v-model="currentPage" :limit="4" :per-page="10">
3030
</b-pagination>
3131

32+
<br><br>
33+
34+
<b-pagination :total-rows="100" v-model="currentPage" :limit="4" :per-page="10">
35+
<template slot="first-text">First</template>
36+
<template slot="prev-text">Prev</template>
37+
<template slot="next-text">Next</template>
38+
<template slot="last-text">Last</template>
39+
<template slot="ellipsis-text">...</template>
40+
</b-pagination>
41+
3242
<br><br>
3343
<div>currentPage: {{currentPage}}</div>
3444
</div>

src/mixins/pagination.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ export default {
178178
attrs: { role: 'separator' }
179179
},
180180
[
181+
this.$slots['ellipsis-text'] ||
181182
h('span', {
182183
class: ['page-link'],
183184
domProps: { innerHTML: this.ellipsisText }
@@ -190,11 +191,11 @@ export default {
190191
buttons.push(
191192
this.hideGotoEndButtons
192193
? h(false)
193-
: makeEndBtns(1, this.labelFirstPage, this.firstText)
194+
: makeEndBtns(1, this.labelFirstPage, this.$slots['first-text'] || this.firstText)
194195
)
195196

196197
// Goto Previous page button
197-
buttons.push(makeEndBtns(this.currentPage - 1, this.labelPrevPage, this.prevText, 1))
198+
buttons.push(makeEndBtns(this.currentPage - 1, this.labelPrevPage, this.$slots['prev-text'] || this.prevText, 1))
198199

199200
// First Ellipsis Bookend
200201
buttons.push(this.showFirstDots ? makeEllipsis() : h(false))
@@ -257,7 +258,7 @@ export default {
257258
makeEndBtns(
258259
this.currentPage + 1,
259260
this.labelNextPage,
260-
this.nextText,
261+
this.$slots['next-text'] || this.nextText,
261262
this.numberOfPages
262263
)
263264
)
@@ -266,7 +267,7 @@ export default {
266267
buttons.push(
267268
this.hideGotoEndButtons
268269
? h(false)
269-
: makeEndBtns(this.numberOfPages, this.labelLastPage, this.lastText)
270+
: makeEndBtns(this.numberOfPages, this.labelLastPage, this.$slots['last-text'] || this.lastText)
270271
)
271272

272273
// Assemble the paginatiom buttons

0 commit comments

Comments
 (0)