This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/vuetify/es5/components/VPagination/VPagination.js

212 lines
7 KiB
JavaScript
Raw Permalink Normal View History

2019-08-11 18:48:02 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
require("../../../src/components/VPagination/VPagination.sass");
var _VIcon = _interopRequireDefault(require("../VIcon"));
var _resize = _interopRequireDefault(require("../../directives/resize"));
var _mixins = _interopRequireDefault(require("../../util/mixins"));
var _colorable = _interopRequireDefault(require("../../mixins/colorable"));
var _themeable = _interopRequireDefault(require("../../mixins/themeable"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/* @vue/component */
var _default = (0, _mixins.default)(_colorable.default, _themeable.default).extend({
name: 'v-pagination',
directives: {
Resize: _resize.default
},
props: {
circle: Boolean,
disabled: Boolean,
length: {
type: Number,
default: 0,
validator: function validator(val) {
return val % 1 === 0;
}
},
nextIcon: {
type: String,
default: '$vuetify.icons.next'
},
prevIcon: {
type: String,
default: '$vuetify.icons.prev'
},
totalVisible: [Number, String],
value: {
type: Number,
default: 0
}
},
data: function data() {
return {
maxButtons: 0,
selected: null
};
},
computed: {
classes: function classes() {
return _objectSpread({
'v-pagination': true,
'v-pagination--circle': this.circle,
'v-pagination--disabled': this.disabled
}, this.themeClasses);
},
items: function items() {
var maxLength = parseInt(this.totalVisible, 10) || this.maxButtons;
if (this.length <= maxLength) {
return this.range(1, this.length);
}
var even = maxLength % 2 === 0 ? 1 : 0;
var left = Math.floor(maxLength / 2);
var right = this.length - left + 1 + even;
if (this.value > left && this.value < right) {
var start = this.value - left + 2;
var end = this.value + left - 2 - even;
return [1, '...'].concat(_toConsumableArray(this.range(start, end)), ['...', this.length]);
} else if (this.value === left) {
var _end = this.value + left - 1 - even;
return [].concat(_toConsumableArray(this.range(1, _end)), ['...', this.length]);
} else if (this.value === right) {
var _start = this.value - left + 1;
return [1, '...'].concat(_toConsumableArray(this.range(_start, this.length)));
} else {
return [].concat(_toConsumableArray(this.range(1, left)), ['...'], _toConsumableArray(this.range(right, this.length)));
}
}
},
watch: {
value: function value() {
this.init();
}
},
mounted: function mounted() {
this.init();
},
methods: {
init: function init() {
var _this = this;
this.selected = null;
this.$nextTick(this.onResize); // TODO: Change this (f75dee3a, cbdf7caa)
setTimeout(function () {
return _this.selected = _this.value;
}, 100);
},
onResize: function onResize() {
var width = this.$el && this.$el.parentElement ? this.$el.parentElement.clientWidth : window.innerWidth;
this.maxButtons = Math.floor((width - 96) / 42);
},
next: function next(e) {
e.preventDefault();
this.$emit('input', this.value + 1);
this.$emit('next');
},
previous: function previous(e) {
e.preventDefault();
this.$emit('input', this.value - 1);
this.$emit('previous');
},
range: function range(from, to) {
var range = [];
from = from > 0 ? from : 1;
for (var i = from; i <= to; i++) {
range.push(i);
}
return range;
},
genIcon: function genIcon(h, icon, disabled, fn) {
return h('li', [h('button', {
staticClass: 'v-pagination__navigation',
class: {
'v-pagination__navigation--disabled': disabled
},
attrs: {
type: 'button'
},
on: disabled ? {} : {
click: fn
}
}, [h(_VIcon.default, [icon])])]);
},
genItem: function genItem(h, i) {
var _this2 = this;
var color = i === this.value && (this.color || 'primary');
return h('button', this.setBackgroundColor(color, {
staticClass: 'v-pagination__item',
class: {
'v-pagination__item--active': i === this.value
},
attrs: {
type: 'button'
},
on: {
click: function click() {
return _this2.$emit('input', i);
}
}
}), [i.toString()]);
},
genItems: function genItems(h) {
var _this3 = this;
return this.items.map(function (i, index) {
return h('li', {
key: index
}, [isNaN(Number(i)) ? h('span', {
class: 'v-pagination__more'
}, [i.toString()]) : _this3.genItem(h, i)]);
});
}
},
render: function render(h) {
var children = [this.genIcon(h, this.$vuetify.rtl ? this.nextIcon : this.prevIcon, this.value <= 1, this.previous), this.genItems(h), this.genIcon(h, this.$vuetify.rtl ? this.prevIcon : this.nextIcon, this.value >= this.length, this.next)];
return h('ul', {
directives: [{
modifiers: {
quiet: true
},
name: 'resize',
value: this.onResize
}],
class: this.classes
}, children);
}
});
exports.default = _default;
//# sourceMappingURL=VPagination.js.map