@@ -2,15 +2,26 @@ import Vue from '../../utils/vue'
22import looseEqual from '../../utils/loose-equal'
33import toString from '../../utils/to-string'
44import warn from '../../utils/warn'
5+ import { getComponentConfig } from '../../utils/config'
56import { requestAF } from '../../utils/dom'
67import { isBrowser } from '../../utils/env'
78import { isArray , isUndefined , isFunction , isObject } from '../../utils/inspect'
89import { computeHref , parseQuery } from '../../utils/router'
910import paginationMixin from '../../mixins/pagination'
1011
11- // Props object
12+ const NAME = 'BPaginationNav'
13+
14+ // Sanitize the provided number of pages (converting to a number)
15+ export const sanitizeNumberOfPages = value => {
16+ const numberOfPages = parseInt ( value , 10 ) || 1
17+ return numberOfPages < 1 ? 1 : numberOfPages
18+ }
19+
1220const props = {
13- // pagination-nav specific props
21+ size : {
22+ type : String ,
23+ default : ( ) => getComponentConfig ( NAME , 'size' )
24+ } ,
1425 numberOfPages : {
1526 type : [ Number , String ] ,
1627 default : 1 ,
@@ -70,16 +81,10 @@ const props = {
7081 }
7182}
7283
73- // TODO: move this to an instance method in pagination mixin
74- const sanitizeNumPages = value => {
75- const num = parseInt ( value , 10 ) || 1
76- return num < 1 ? 1 : num
77- }
78-
79- // Our render function is brought in via the pagination mixin
84+ // The render function is brought in via the pagination mixin
8085// @vue /component
8186export const BPaginationNav = /*#__PURE__*/ Vue . extend ( {
82- name : 'BPaginationNav' ,
87+ name : NAME ,
8388 mixins : [ paginationMixin ] ,
8489 props,
8590 computed : {
@@ -96,17 +101,17 @@ export const BPaginationNav = /*#__PURE__*/ Vue.extend({
96101 watch : {
97102 numberOfPages ( newVal , oldVal ) {
98103 this . $nextTick ( ( ) => {
99- this . setNumPages ( )
104+ this . setNumberOfPages ( )
100105 } )
101106 } ,
102107 pages ( newVal , oldVal ) {
103108 this . $nextTick ( ( ) => {
104- this . setNumPages ( )
109+ this . setNumberOfPages ( )
105110 } )
106111 }
107112 } ,
108113 created ( ) {
109- this . setNumPages ( )
114+ this . setNumberOfPages ( )
110115 } ,
111116 mounted ( ) {
112117 if ( this . $router ) {
@@ -121,11 +126,11 @@ export const BPaginationNav = /*#__PURE__*/ Vue.extend({
121126 }
122127 } ,
123128 methods : {
124- setNumPages ( ) {
129+ setNumberOfPages ( ) {
125130 if ( isArray ( this . pages ) && this . pages . length > 0 ) {
126- this . localNumPages = this . pages . length
131+ this . localNumberOfPages = this . pages . length
127132 } else {
128- this . localNumPages = sanitizeNumPages ( this . numberOfPages )
133+ this . localNumberOfPages = sanitizeNumberOfPages ( this . numberOfPages )
129134 }
130135 this . $nextTick ( ( ) => {
131136 this . guessCurrentPage ( )
@@ -263,7 +268,7 @@ export const BPaginationNav = /*#__PURE__*/ Vue.extend({
263268 ? { path : loc . pathname , hash : loc . hash , query : parseQuery ( loc . search ) }
264269 : { }
265270 // Loop through the possible pages looking for a match until found
266- for ( let page = 1 ; ! guess && page <= this . localNumPages ; page ++ ) {
271+ for ( let page = 1 ; ! guess && page <= this . localNumberOfPages ; page ++ ) {
267272 const to = this . makeLink ( page )
268273 if ( $router && ( isObject ( to ) || this . useRouter ) ) {
269274 // Resolve the page via the $router
0 commit comments