import Vue from '../../utils/vue' import looseEqual from '../../utils/loose-equal' import { getComponentConfig } from '../../utils/config' import { requestAF } from '../../utils/dom' import { isBrowser } from '../../utils/env' import { isArray, isUndefined, isFunction, isObject } from '../../utils/inspect' import { toInteger } from '../../utils/number' import { computeHref, parseQuery } from '../../utils/router' import { toString } from '../../utils/string' import { warn } from '../../utils/warn' import paginationMixin from '../../mixins/pagination' const NAME = 'BPaginationNav' // Sanitize the provided number of pages (converting to a number) export const sanitizeNumberOfPages = value => { const numberOfPages = toInteger(value) || 1 return numberOfPages < 1 ? 1 : numberOfPages } const props = { size: { type: String, default: () => getComponentConfig(NAME, 'size') }, numberOfPages: { type: [Number, String], default: 1, validator(value) /* istanbul ignore next */ { const num = toInteger(value) if (isNaN(num) || num < 1) { warn('Prop "number-of-pages" must be a number greater than "0"', NAME) return false } return true } }, baseUrl: { type: String, default: '/' }, useRouter: { type: Boolean, default: false }, linkGen: { type: Function, default: null }, pageGen: { type: Function, default: null }, pages: { // Optional array of page links type: Array, default: null }, noPageDetect: { // Disable auto page number detection if true type: Boolean, default: false }, // router-link specific props activeClass: { type: String // default: undefined }, exact: { type: Boolean, default: false }, exactActiveClass: { type: String // default: undefined }, // nuxt-link specific prop(s) noPrefetch: { type: Boolean, default: false } } // The render function is brought in via the pagination mixin // @vue/component export const BPaginationNav = /*#__PURE__*/ Vue.extend({ name: NAME, mixins: [paginationMixin], props, computed: { // Used by render function to trigger wrapping in '