lepu-test-platform-web/node_modules/element-ui/lib/pagination.js

946 lines
25 KiB
JavaScript

module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/dist/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 72);
/******/ })
/************************************************************************/
/******/ ({
/***/ 0:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
/* globals __VUE_SSR_CONTEXT__ */
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
// This module is a runtime utility for cleaner component module output and will
// be included in the final webpack user bundle.
function normalizeComponent (
scriptExports,
render,
staticRenderFns,
functionalTemplate,
injectStyles,
scopeId,
moduleIdentifier, /* server only */
shadowMode /* vue-cli only */
) {
// Vue.extend constructor export interop
var options = typeof scriptExports === 'function'
? scriptExports.options
: scriptExports
// render functions
if (render) {
options.render = render
options.staticRenderFns = staticRenderFns
options._compiled = true
}
// functional template
if (functionalTemplate) {
options.functional = true
}
// scopedId
if (scopeId) {
options._scopeId = 'data-v-' + scopeId
}
var hook
if (moduleIdentifier) { // server build
hook = function (context) {
// 2.3 injection
context =
context || // cached call
(this.$vnode && this.$vnode.ssrContext) || // stateful
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
// 2.2 with runInNewContext: true
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
context = __VUE_SSR_CONTEXT__
}
// inject component styles
if (injectStyles) {
injectStyles.call(this, context)
}
// register component module identifier for async chunk inferrence
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier)
}
}
// used by ssr in case component is cached and beforeCreate
// never gets called
options._ssrRegister = hook
} else if (injectStyles) {
hook = shadowMode
? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
: injectStyles
}
if (hook) {
if (options.functional) {
// for template-only hot-reload because in that case the render fn doesn't
// go through the normalizer
options._injectStyles = hook
// register for functioal component in vue file
var originalRender = options.render
options.render = function renderWithStyleInjection (h, context) {
hook.call(context)
return originalRender(h, context)
}
} else {
// inject component registration as beforeCreate hook
var existing = options.beforeCreate
options.beforeCreate = existing
? [].concat(existing, hook)
: [hook]
}
}
return {
exports: scriptExports,
options: options
}
}
/***/ }),
/***/ 10:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/input");
/***/ }),
/***/ 3:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/utils/util");
/***/ }),
/***/ 44:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/select");
/***/ }),
/***/ 45:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/option");
/***/ }),
/***/ 6:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/mixins/locale");
/***/ }),
/***/ 72:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/pagination/src/pager.vue?vue&type=template&id=7274f267&
var render = function() {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"ul",
{ staticClass: "el-pager", on: { click: _vm.onPagerClick } },
[
_vm.pageCount > 0
? _c(
"li",
{
staticClass: "number",
class: { active: _vm.currentPage === 1, disabled: _vm.disabled }
},
[_vm._v("1")]
)
: _vm._e(),
_vm.showPrevMore
? _c("li", {
staticClass: "el-icon more btn-quickprev",
class: [_vm.quickprevIconClass, { disabled: _vm.disabled }],
on: {
mouseenter: function($event) {
_vm.onMouseenter("left")
},
mouseleave: function($event) {
_vm.quickprevIconClass = "el-icon-more"
}
}
})
: _vm._e(),
_vm._l(_vm.pagers, function(pager) {
return _c(
"li",
{
key: pager,
staticClass: "number",
class: { active: _vm.currentPage === pager, disabled: _vm.disabled }
},
[_vm._v(_vm._s(pager))]
)
}),
_vm.showNextMore
? _c("li", {
staticClass: "el-icon more btn-quicknext",
class: [_vm.quicknextIconClass, { disabled: _vm.disabled }],
on: {
mouseenter: function($event) {
_vm.onMouseenter("right")
},
mouseleave: function($event) {
_vm.quicknextIconClass = "el-icon-more"
}
}
})
: _vm._e(),
_vm.pageCount > 1
? _c(
"li",
{
staticClass: "number",
class: {
active: _vm.currentPage === _vm.pageCount,
disabled: _vm.disabled
}
},
[_vm._v(_vm._s(_vm.pageCount))]
)
: _vm._e()
],
2
)
}
var staticRenderFns = []
render._withStripped = true
// CONCATENATED MODULE: ./packages/pagination/src/pager.vue?vue&type=template&id=7274f267&
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/pagination/src/pager.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var pagervue_type_script_lang_js_ = ({
name: 'ElPager',
props: {
currentPage: Number,
pageCount: Number,
pagerCount: Number,
disabled: Boolean
},
watch: {
showPrevMore: function showPrevMore(val) {
if (!val) this.quickprevIconClass = 'el-icon-more';
},
showNextMore: function showNextMore(val) {
if (!val) this.quicknextIconClass = 'el-icon-more';
}
},
methods: {
onPagerClick: function onPagerClick(event) {
var target = event.target;
if (target.tagName === 'UL' || this.disabled) {
return;
}
var newPage = Number(event.target.textContent);
var pageCount = this.pageCount;
var currentPage = this.currentPage;
var pagerCountOffset = this.pagerCount - 2;
if (target.className.indexOf('more') !== -1) {
if (target.className.indexOf('quickprev') !== -1) {
newPage = currentPage - pagerCountOffset;
} else if (target.className.indexOf('quicknext') !== -1) {
newPage = currentPage + pagerCountOffset;
}
}
/* istanbul ignore if */
if (!isNaN(newPage)) {
if (newPage < 1) {
newPage = 1;
}
if (newPage > pageCount) {
newPage = pageCount;
}
}
if (newPage !== currentPage) {
this.$emit('change', newPage);
}
},
onMouseenter: function onMouseenter(direction) {
if (this.disabled) return;
if (direction === 'left') {
this.quickprevIconClass = 'el-icon-d-arrow-left';
} else {
this.quicknextIconClass = 'el-icon-d-arrow-right';
}
}
},
computed: {
pagers: function pagers() {
var pagerCount = this.pagerCount;
var halfPagerCount = (pagerCount - 1) / 2;
var currentPage = Number(this.currentPage);
var pageCount = Number(this.pageCount);
var showPrevMore = false;
var showNextMore = false;
if (pageCount > pagerCount) {
if (currentPage > pagerCount - halfPagerCount) {
showPrevMore = true;
}
if (currentPage < pageCount - halfPagerCount) {
showNextMore = true;
}
}
var array = [];
if (showPrevMore && !showNextMore) {
var startPage = pageCount - (pagerCount - 2);
for (var i = startPage; i < pageCount; i++) {
array.push(i);
}
} else if (!showPrevMore && showNextMore) {
for (var _i = 2; _i < pagerCount; _i++) {
array.push(_i);
}
} else if (showPrevMore && showNextMore) {
var offset = Math.floor(pagerCount / 2) - 1;
for (var _i2 = currentPage - offset; _i2 <= currentPage + offset; _i2++) {
array.push(_i2);
}
} else {
for (var _i3 = 2; _i3 < pageCount; _i3++) {
array.push(_i3);
}
}
this.showPrevMore = showPrevMore;
this.showNextMore = showNextMore;
return array;
}
},
data: function data() {
return {
current: null,
showPrevMore: false,
showNextMore: false,
quicknextIconClass: 'el-icon-more',
quickprevIconClass: 'el-icon-more'
};
}
});
// CONCATENATED MODULE: ./packages/pagination/src/pager.vue?vue&type=script&lang=js&
/* harmony default export */ var src_pagervue_type_script_lang_js_ = (pagervue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
// CONCATENATED MODULE: ./packages/pagination/src/pager.vue
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
src_pagervue_type_script_lang_js_,
render,
staticRenderFns,
false,
null,
null,
null
)
/* hot reload */
if (false) { var api; }
component.options.__file = "packages/pagination/src/pager.vue"
/* harmony default export */ var pager = (component.exports);
// EXTERNAL MODULE: external "element-ui/lib/select"
var select_ = __webpack_require__(44);
var select_default = /*#__PURE__*/__webpack_require__.n(select_);
// EXTERNAL MODULE: external "element-ui/lib/option"
var option_ = __webpack_require__(45);
var option_default = /*#__PURE__*/__webpack_require__.n(option_);
// EXTERNAL MODULE: external "element-ui/lib/input"
var input_ = __webpack_require__(10);
var input_default = /*#__PURE__*/__webpack_require__.n(input_);
// EXTERNAL MODULE: external "element-ui/lib/mixins/locale"
var locale_ = __webpack_require__(6);
var locale_default = /*#__PURE__*/__webpack_require__.n(locale_);
// EXTERNAL MODULE: external "element-ui/lib/utils/util"
var util_ = __webpack_require__(3);
// CONCATENATED MODULE: ./packages/pagination/src/pagination.js
/* harmony default export */ var pagination = ({
name: 'ElPagination',
props: {
pageSize: {
type: Number,
default: 10
},
small: Boolean,
total: Number,
pageCount: Number,
pagerCount: {
type: Number,
validator: function validator(value) {
return (value | 0) === value && value > 4 && value < 22 && value % 2 === 1;
},
default: 7
},
currentPage: {
type: Number,
default: 1
},
layout: {
default: 'prev, pager, next, jumper, ->, total'
},
pageSizes: {
type: Array,
default: function _default() {
return [10, 20, 30, 40, 50, 100];
}
},
popperClass: String,
prevText: String,
nextText: String,
background: Boolean,
disabled: Boolean,
hideOnSinglePage: Boolean
},
data: function data() {
return {
internalCurrentPage: 1,
internalPageSize: 0,
lastEmittedPage: -1,
userChangePageSize: false
};
},
render: function render(h) {
var layout = this.layout;
if (!layout) return null;
if (this.hideOnSinglePage && (!this.internalPageCount || this.internalPageCount === 1)) return null;
var template = h('div', { 'class': ['el-pagination', {
'is-background': this.background,
'el-pagination--small': this.small
}] });
var TEMPLATE_MAP = {
prev: h('prev'),
jumper: h('jumper'),
pager: h('pager', {
attrs: { currentPage: this.internalCurrentPage, pageCount: this.internalPageCount, pagerCount: this.pagerCount, disabled: this.disabled },
on: {
'change': this.handleCurrentChange
}
}),
next: h('next'),
sizes: h('sizes', {
attrs: { pageSizes: this.pageSizes }
}),
slot: h('slot', [this.$slots.default ? this.$slots.default : '']),
total: h('total')
};
var components = layout.split(',').map(function (item) {
return item.trim();
});
var rightWrapper = h('div', { 'class': 'el-pagination__rightwrapper' });
var haveRightWrapper = false;
template.children = template.children || [];
rightWrapper.children = rightWrapper.children || [];
components.forEach(function (compo) {
if (compo === '->') {
haveRightWrapper = true;
return;
}
if (!haveRightWrapper) {
template.children.push(TEMPLATE_MAP[compo]);
} else {
rightWrapper.children.push(TEMPLATE_MAP[compo]);
}
});
if (haveRightWrapper) {
template.children.unshift(rightWrapper);
}
return template;
},
components: {
Prev: {
render: function render(h) {
return h(
'button',
{
attrs: {
type: 'button',
disabled: this.$parent.disabled || this.$parent.internalCurrentPage <= 1
},
'class': 'btn-prev', on: {
'click': this.$parent.prev
}
},
[this.$parent.prevText ? h('span', [this.$parent.prevText]) : h('i', { 'class': 'el-icon el-icon-arrow-left' })]
);
}
},
Next: {
render: function render(h) {
return h(
'button',
{
attrs: {
type: 'button',
disabled: this.$parent.disabled || this.$parent.internalCurrentPage === this.$parent.internalPageCount || this.$parent.internalPageCount === 0
},
'class': 'btn-next', on: {
'click': this.$parent.next
}
},
[this.$parent.nextText ? h('span', [this.$parent.nextText]) : h('i', { 'class': 'el-icon el-icon-arrow-right' })]
);
}
},
Sizes: {
mixins: [locale_default.a],
props: {
pageSizes: Array
},
watch: {
pageSizes: {
immediate: true,
handler: function handler(newVal, oldVal) {
if (Object(util_["valueEquals"])(newVal, oldVal)) return;
if (Array.isArray(newVal)) {
this.$parent.internalPageSize = newVal.indexOf(this.$parent.pageSize) > -1 ? this.$parent.pageSize : this.pageSizes[0];
}
}
}
},
render: function render(h) {
var _this = this;
return h(
'span',
{ 'class': 'el-pagination__sizes' },
[h(
'el-select',
{
attrs: {
value: this.$parent.internalPageSize,
popperClass: this.$parent.popperClass || '',
size: 'mini',
disabled: this.$parent.disabled },
on: {
'input': this.handleChange
}
},
[this.pageSizes.map(function (item) {
return h('el-option', {
attrs: {
value: item,
label: item + _this.t('el.pagination.pagesize') }
});
})]
)]
);
},
components: {
ElSelect: select_default.a,
ElOption: option_default.a
},
methods: {
handleChange: function handleChange(val) {
if (val !== this.$parent.internalPageSize) {
this.$parent.internalPageSize = val = parseInt(val, 10);
this.$parent.userChangePageSize = true;
this.$parent.$emit('update:pageSize', val);
this.$parent.$emit('size-change', val);
}
}
}
},
Jumper: {
mixins: [locale_default.a],
components: { ElInput: input_default.a },
data: function data() {
return {
userInput: null
};
},
watch: {
'$parent.internalCurrentPage': function $parentInternalCurrentPage() {
this.userInput = null;
}
},
methods: {
handleKeyup: function handleKeyup(_ref) {
var keyCode = _ref.keyCode,
target = _ref.target;
// Chrome, Safari, Firefox triggers change event on Enter
// Hack for IE: https://github.com/ElemeFE/element/issues/11710
// Drop this method when we no longer supports IE
if (keyCode === 13) {
this.handleChange(target.value);
}
},
handleInput: function handleInput(value) {
this.userInput = value;
},
handleChange: function handleChange(value) {
this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(value);
this.$parent.emitChange();
this.userInput = null;
}
},
render: function render(h) {
return h(
'span',
{ 'class': 'el-pagination__jump' },
[this.t('el.pagination.goto'), h('el-input', {
'class': 'el-pagination__editor is-in-pagination',
attrs: { min: 1,
max: this.$parent.internalPageCount,
value: this.userInput !== null ? this.userInput : this.$parent.internalCurrentPage,
type: 'number',
disabled: this.$parent.disabled
},
nativeOn: {
'keyup': this.handleKeyup
},
on: {
'input': this.handleInput,
'change': this.handleChange
}
}), this.t('el.pagination.pageClassifier')]
);
}
},
Total: {
mixins: [locale_default.a],
render: function render(h) {
return typeof this.$parent.total === 'number' ? h(
'span',
{ 'class': 'el-pagination__total' },
[this.t('el.pagination.total', { total: this.$parent.total })]
) : '';
}
},
Pager: pager
},
methods: {
handleCurrentChange: function handleCurrentChange(val) {
this.internalCurrentPage = this.getValidCurrentPage(val);
this.userChangePageSize = true;
this.emitChange();
},
prev: function prev() {
if (this.disabled) return;
var newVal = this.internalCurrentPage - 1;
this.internalCurrentPage = this.getValidCurrentPage(newVal);
this.$emit('prev-click', this.internalCurrentPage);
this.emitChange();
},
next: function next() {
if (this.disabled) return;
var newVal = this.internalCurrentPage + 1;
this.internalCurrentPage = this.getValidCurrentPage(newVal);
this.$emit('next-click', this.internalCurrentPage);
this.emitChange();
},
getValidCurrentPage: function getValidCurrentPage(value) {
value = parseInt(value, 10);
var havePageCount = typeof this.internalPageCount === 'number';
var resetValue = void 0;
if (!havePageCount) {
if (isNaN(value) || value < 1) resetValue = 1;
} else {
if (value < 1) {
resetValue = 1;
} else if (value > this.internalPageCount) {
resetValue = this.internalPageCount;
}
}
if (resetValue === undefined && isNaN(value)) {
resetValue = 1;
} else if (resetValue === 0) {
resetValue = 1;
}
return resetValue === undefined ? value : resetValue;
},
emitChange: function emitChange() {
var _this2 = this;
this.$nextTick(function () {
if (_this2.internalCurrentPage !== _this2.lastEmittedPage || _this2.userChangePageSize) {
_this2.$emit('current-change', _this2.internalCurrentPage);
_this2.lastEmittedPage = _this2.internalCurrentPage;
_this2.userChangePageSize = false;
}
});
}
},
computed: {
internalPageCount: function internalPageCount() {
if (typeof this.total === 'number') {
return Math.max(1, Math.ceil(this.total / this.internalPageSize));
} else if (typeof this.pageCount === 'number') {
return Math.max(1, this.pageCount);
}
return null;
}
},
watch: {
currentPage: {
immediate: true,
handler: function handler(val) {
this.internalCurrentPage = this.getValidCurrentPage(val);
}
},
pageSize: {
immediate: true,
handler: function handler(val) {
this.internalPageSize = isNaN(val) ? 10 : val;
}
},
internalCurrentPage: {
immediate: true,
handler: function handler(newVal) {
this.$emit('update:currentPage', newVal);
this.lastEmittedPage = -1;
}
},
internalPageCount: function internalPageCount(newVal) {
/* istanbul ignore if */
var oldPage = this.internalCurrentPage;
if (newVal > 0 && oldPage === 0) {
this.internalCurrentPage = 1;
} else if (oldPage > newVal) {
this.internalCurrentPage = newVal === 0 ? 1 : newVal;
this.userChangePageSize && this.emitChange();
}
this.userChangePageSize = false;
}
}
});
// CONCATENATED MODULE: ./packages/pagination/index.js
/* istanbul ignore next */
pagination.install = function (Vue) {
Vue.component(pagination.name, pagination);
};
/* harmony default export */ var packages_pagination = __webpack_exports__["default"] = (pagination);
/***/ })
/******/ });