UNPKG

element-ui

Version:

A Component Library for Vue.js.

862 lines (722 loc) 20.5 kB
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] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ // Flag the module as loaded /******/ module.loaded = 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; /******/ // __webpack_public_path__ /******/ __webpack_require__.p = "/dist/"; /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) /************************************************************************/ /******/ ({ /***/ 0: /***/ function(module, exports, __webpack_require__) { module.exports = __webpack_require__(225); /***/ }, /***/ 3: /***/ function(module, exports) { /* globals __VUE_SSR_CONTEXT__ */ // this module is a runtime utility for cleaner component module output and will // be included in the final webpack user bundle module.exports = function normalizeComponent ( rawScriptExports, compiledTemplate, injectStyles, scopeId, moduleIdentifier /* server only */ ) { var esModule var scriptExports = rawScriptExports = rawScriptExports || {} // ES6 modules interop var type = typeof rawScriptExports.default if (type === 'object' || type === 'function') { esModule = rawScriptExports scriptExports = rawScriptExports.default } // Vue.extend constructor export interop var options = typeof scriptExports === 'function' ? scriptExports.options : scriptExports // render functions if (compiledTemplate) { options.render = compiledTemplate.render options.staticRenderFns = compiledTemplate.staticRenderFns } // scopedId if (scopeId) { options._scopeId = scopeId } var hook if (moduleIdentifier) { // server build hook = function (context) { // 2.3 injection context = context || (this.$vnode && this.$vnode.ssrContext) // 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 = injectStyles } if (hook) { // inject component registration as beforeCreate hook var existing = options.beforeCreate options.beforeCreate = existing ? [].concat(existing, hook) : [hook] } return { esModule: esModule, exports: scriptExports, options: options } } /***/ }, /***/ 61: /***/ function(module, exports) { module.exports = require("element-ui/lib/mixins/locale"); /***/ }, /***/ 225: /***/ function(module, exports, __webpack_require__) { 'use strict'; exports.__esModule = true; var _pagination = __webpack_require__(226); var _pagination2 = _interopRequireDefault(_pagination); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /* istanbul ignore next */ _pagination2.default.install = function (Vue) { Vue.component(_pagination2.default.name, _pagination2.default); }; exports.default = _pagination2.default; /***/ }, /***/ 226: /***/ function(module, exports, __webpack_require__) { 'use strict'; exports.__esModule = true; var _pager = __webpack_require__(227); var _pager2 = _interopRequireDefault(_pager); var _select = __webpack_require__(230); var _select2 = _interopRequireDefault(_select); var _option = __webpack_require__(231); var _option2 = _interopRequireDefault(_option); var _locale = __webpack_require__(61); var _locale2 = _interopRequireDefault(_locale); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = { name: 'ElPagination', props: { pageSize: { type: Number, default: 10 }, small: Boolean, total: Number, pageCount: Number, 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]; } } }, data: function data() { return { internalCurrentPage: 1, internalPageSize: 0 }; }, render: function render(h) { var template = h( 'div', { 'class': 'el-pagination' }, [] ); var layout = this.layout || ''; if (!layout) return; var TEMPLATE_MAP = { prev: h( 'prev', null, [] ), jumper: h( 'jumper', null, [] ), pager: h( 'pager', { attrs: { currentPage: this.internalCurrentPage, pageCount: this.internalPageCount }, on: { 'change': this.handleCurrentChange } }, [] ), next: h( 'next', null, [] ), sizes: h( 'sizes', { attrs: { pageSizes: this.pageSizes } }, [] ), slot: h( 'my-slot', null, [] ), total: h( 'total', null, [] ) }; var components = layout.split(',').map(function (item) { return item.trim(); }); var rightWrapper = h( 'div', { 'class': 'el-pagination__rightwrapper' }, [] ); var haveRightWrapper = false; if (this.small) { template.data.class += ' el-pagination--small'; } 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: { MySlot: { render: function render(h) { return this.$parent.$slots.default ? this.$parent.$slots.default[0] : ''; } }, Prev: { render: function render(h) { return h( 'button', { attrs: { type: 'button' }, 'class': ['btn-prev', { disabled: this.$parent.internalCurrentPage <= 1 }], on: { 'click': this.$parent.prev } }, [h( 'i', { 'class': 'el-icon el-icon-arrow-left' }, [] )] ); } }, Next: { render: function render(h) { return h( 'button', { attrs: { type: 'button' }, 'class': ['btn-next', { disabled: this.$parent.internalCurrentPage === this.$parent.internalPageCount || this.$parent.internalPageCount === 0 }], on: { 'click': this.$parent.next } }, [h( 'i', { 'class': 'el-icon el-icon-arrow-right' }, [] )] ); } }, Sizes: { mixins: [_locale2.default], props: { pageSizes: Array }, watch: { pageSizes: { immediate: true, handler: function handler(value) { if (Array.isArray(value)) { this.$parent.internalPageSize = value.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 }, 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: _select2.default, ElOption: _option2.default }, methods: { handleChange: function handleChange(val) { if (val !== this.$parent.internalPageSize) { this.$parent.internalPageSize = val = parseInt(val, 10); this.$parent.$emit('size-change', val); } } } }, Jumper: { mixins: [_locale2.default], data: function data() { return { oldValue: null }; }, methods: { handleFocus: function handleFocus(event) { this.oldValue = event.target.value; }, handleBlur: function handleBlur(_ref) { var target = _ref.target; this.reassignMaxValue(target); }, handleKeyUp: function handleKeyUp(event) { var key = event.key || ''; var keyCode = event.keyCode || ''; if (key && key === 'Enter' || keyCode && keyCode === 13) { this.reassignMaxValue(event.target); this.handleChange({ target: event.target }); } }, handleChange: function handleChange(_ref2) { var target = _ref2.target; this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(target.value); this.oldValue = null; }, reassignMaxValue: function reassignMaxValue(target) { if (+target.value > this.$parent.internalPageCount) { target.value = this.$parent.internalPageCount; } } }, render: function render(h) { return h( 'span', { 'class': 'el-pagination__jump' }, [this.t('el.pagination.goto'), h( 'input', { 'class': 'el-pagination__editor', attrs: { type: 'number', min: 1, max: this.$parent.internalPageCount, value: this.$parent.internalCurrentPage, number: true }, domProps: { 'value': this.$parent.internalCurrentPage }, on: { 'change': this.handleChange, 'focus': this.handleFocus, 'blur': this.handleBlur, 'keyup': this.handleKeyUp } }, [] ), this.t('el.pagination.pageClassifier')] ); } }, Total: { mixins: [_locale2.default], 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: _pager2.default }, methods: { handleCurrentChange: function handleCurrentChange(val) { this.internalCurrentPage = this.getValidCurrentPage(val); }, prev: function prev() { var newVal = this.internalCurrentPage - 1; this.internalCurrentPage = this.getValidCurrentPage(newVal); }, next: function next() { var newVal = this.internalCurrentPage + 1; this.internalCurrentPage = this.getValidCurrentPage(newVal); }, 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; } }, computed: { internalPageCount: function internalPageCount() { if (typeof this.total === 'number') { return Math.ceil(this.total / this.internalPageSize); } else if (typeof this.pageCount === 'number') { return this.pageCount; } return null; } }, watch: { currentPage: { immediate: true, handler: function handler(val) { this.internalCurrentPage = val; } }, pageSize: { immediate: true, handler: function handler(val) { this.internalPageSize = val; } }, internalCurrentPage: function internalCurrentPage(newVal, oldVal) { var _this2 = this; newVal = parseInt(newVal, 10); /* istanbul ignore if */ if (isNaN(newVal)) { newVal = oldVal || 1; } else { newVal = this.getValidCurrentPage(newVal); } if (newVal !== undefined) { this.$nextTick(function () { _this2.internalCurrentPage = newVal; if (oldVal !== newVal) { _this2.$emit('update:currentPage', newVal); _this2.$emit('current-change', _this2.internalCurrentPage); } }); } else { this.$emit('update:currentPage', newVal); this.$emit('current-change', this.internalCurrentPage); } }, 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; } } } }; /***/ }, /***/ 227: /***/ function(module, exports, __webpack_require__) { var Component = __webpack_require__(3)( /* script */ __webpack_require__(228), /* template */ __webpack_require__(229), /* styles */ null, /* scopeId */ null, /* moduleIdentifier (server only) */ null ) module.exports = Component.exports /***/ }, /***/ 228: /***/ function(module, exports) { 'use strict'; exports.__esModule = true; // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // exports.default = { name: 'ElPager', props: { currentPage: Number, pageCount: Number }, 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') { return; } var newPage = Number(event.target.textContent); var pageCount = this.pageCount; var currentPage = this.currentPage; if (target.className.indexOf('more') !== -1) { if (target.className.indexOf('quickprev') !== -1) { newPage = currentPage - 5; } else if (target.className.indexOf('quicknext') !== -1) { newPage = currentPage + 5; } } /* istanbul ignore if */ if (!isNaN(newPage)) { if (newPage < 1) { newPage = 1; } if (newPage > pageCount) { newPage = pageCount; } } if (newPage !== currentPage) { this.$emit('change', newPage); } } }, computed: { pagers: function pagers() { var pagerCount = 7; var currentPage = Number(this.currentPage); var pageCount = Number(this.pageCount); var showPrevMore = false; var showNextMore = false; if (pageCount > pagerCount) { if (currentPage > pagerCount - 3) { showPrevMore = true; } if (currentPage < pageCount - 3) { 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' }; } }; /***/ }, /***/ 229: /***/ function(module, exports) { module.exports={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 } }, [_vm._v("1")]) : _vm._e(), (_vm.showPrevMore) ? _c('li', { staticClass: "el-icon more btn-quickprev", class: [_vm.quickprevIconClass], on: { "mouseenter": function($event) { _vm.quickprevIconClass = 'el-icon-d-arrow-left' }, "mouseleave": function($event) { _vm.quickprevIconClass = 'el-icon-more' } } }) : _vm._e(), _vm._l((_vm.pagers), function(pager) { return _c('li', { staticClass: "number", class: { active: _vm.currentPage === pager } }, [_vm._v(_vm._s(pager))]) }), (_vm.showNextMore) ? _c('li', { staticClass: "el-icon more btn-quicknext", class: [_vm.quicknextIconClass], on: { "mouseenter": function($event) { _vm.quicknextIconClass = 'el-icon-d-arrow-right' }, "mouseleave": function($event) { _vm.quicknextIconClass = 'el-icon-more' } } }) : _vm._e(), (_vm.pageCount > 1) ? _c('li', { staticClass: "number", class: { active: _vm.currentPage === _vm.pageCount } }, [_vm._v(_vm._s(_vm.pageCount))]) : _vm._e()], 2) },staticRenderFns: []} /***/ }, /***/ 230: /***/ function(module, exports) { module.exports = require("element-ui/lib/select"); /***/ }, /***/ 231: /***/ function(module, exports) { module.exports = require("element-ui/lib/option"); /***/ } /******/ });