bootstrap-vue
Version:
BootstrapVue provides one of the most comprehensive implementations of Bootstrap 4 components and grid system for Vue.js and with extensive and automated WAI-ARIA accessibility markup.
85 lines (82 loc) • 2.43 kB
JavaScript
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
import { assign } from '../../utils/object';
import paginationMixin from '../../mixins/pagination';
import { pickLinkProps } from '../link/link';
// Props needed for router links
var routerProps = pickLinkProps('activeClass', 'exactActiveClass', 'append', 'exact', 'replace', 'target', 'rel');
// Props object
var props = assign(
// pagination-nav specific props
{
numberOfPages: {
type: Number,
default: 1
},
baseUrl: {
type: String,
default: '/'
},
useRouter: {
type: Boolean,
default: false
},
linkGen: {
type: Function,
default: null
},
pageGen: {
type: Function,
default: null
}
},
// Router specific props
routerProps);
// Our render function is brought in via the pagination mixin
export default {
mixins: [paginationMixin],
props: props,
computed: {
// Used by render function to trigger wraping in '<nav>' element
isNav: function isNav() {
return true;
}
},
methods: {
onClick: function onClick(pageNum, evt) {
this.currentPage = pageNum;
},
makePage: function makePage(pagenum) {
if (this.pageGen && typeof this.pageGen === 'function') {
return this.pageGen(pagenum);
}
return pagenum;
},
makeLink: function makeLink(pagenum) {
if (this.linkGen && typeof this.linkGen === 'function') {
return this.linkGen(pagenum);
}
var link = '' + this.baseUrl + pagenum;
return this.useRouter ? { path: link } : link;
},
linkProps: function linkProps(pagenum) {
var link = this.makeLink(pagenum);
var props = {
href: typeof link === 'string' ? link : void 0,
target: this.target || null,
rel: this.rel || null,
disabled: this.disabled
};
if (this.useRouter || (typeof link === 'undefined' ? 'undefined' : _typeof(link)) === 'object') {
props = assign(props, {
to: link,
exact: this.exact,
activeClass: this.activeClass,
exactActiveClass: this.exactActiveClass,
append: this.append,
replace: this.replace
});
}
return props;
}
}
};