UNPKG

element-nice-ui

Version:

A Component Library for Vue.js.

841 lines (783 loc) 25.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] = { /******/ 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 = 199); /******/ }) /************************************************************************/ /******/ ({ /***/ 160: /***/ (function(module, exports) { module.exports = require("element-nice-ui/lib/select"); /***/ }), /***/ 161: /***/ (function(module, exports) { module.exports = require("element-nice-ui/lib/option"); /***/ }), /***/ 19: /***/ (function(module, exports) { module.exports = require("element-nice-ui/lib/mixins/locale"); /***/ }), /***/ 199: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.18_css-loader@5.2.7_webpack@4.47.0__lodash@4.1_bb9a19950a80e648dc95ba33c71fa343/node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.18_css-loader@5.2.7_webpack@4.47.0__lodash@4.1_bb9a19950a80e648dc95ba33c71fa343/node_modules/vue-loader/lib??vue-loader-options!./packages/pagination/src/pager.vue?vue&type=template&id=44448c28 var render = function render() { var _vm = this, _c = _vm._self._c 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) { return _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) { return _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=44448c28 // CONCATENATED MODULE: ./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.28.0_webpack@4.47.0/node_modules/babel-loader/lib!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.18_css-loader@5.2.7_webpack@4.47.0__lodash@4.1_bb9a19950a80e648dc95ba33c71fa343/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(val) { if (!val) this.quickprevIconClass = 'el-icon-more'; }, showNextMore(val) { if (!val) this.quicknextIconClass = 'el-icon-more'; } }, methods: { onPagerClick(event) { const target = event.target; if (target.tagName === 'UL' || this.disabled) { return; } let newPage = Number(event.target.textContent); const pageCount = this.pageCount; const currentPage = this.currentPage; const 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(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() { const pagerCount = this.pagerCount; const halfPagerCount = (pagerCount - 1) / 2; const currentPage = Number(this.currentPage); const pageCount = Number(this.pageCount); let showPrevMore = false; let showNextMore = false; if (pageCount > pagerCount) { if (currentPage > pagerCount - halfPagerCount) { showPrevMore = true; } if (currentPage < pageCount - halfPagerCount) { showNextMore = true; } } const array = []; if (showPrevMore && !showNextMore) { const startPage = pageCount - (pagerCount - 2); for (let i = startPage; i < pageCount; i++) { array.push(i); } } else if (!showPrevMore && showNextMore) { for (let i = 2; i < pagerCount; i++) { array.push(i); } } else if (showPrevMore && showNextMore) { const offset = Math.floor(pagerCount / 2) - 1; for (let i = currentPage - offset; i <= currentPage + offset; i++) { array.push(i); } } else { for (let i = 2; i < pageCount; i++) { array.push(i); } } this.showPrevMore = showPrevMore; this.showNextMore = showNextMore; return array; } }, 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/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.18_css-loader@5.2.7_webpack@4.47.0__lodash@4.1_bb9a19950a80e648dc95ba33c71fa343/node_modules/vue-loader/lib/runtime/componentNormalizer.js var componentNormalizer = __webpack_require__(2); // 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 ) /* harmony default export */ var pager = (component.exports); // EXTERNAL MODULE: external "element-nice-ui/lib/select" var select_ = __webpack_require__(160); var select_default = /*#__PURE__*/__webpack_require__.n(select_); // EXTERNAL MODULE: external "element-nice-ui/lib/option" var option_ = __webpack_require__(161); var option_default = /*#__PURE__*/__webpack_require__.n(option_); // EXTERNAL MODULE: external "element-nice-ui/lib/input" var input_ = __webpack_require__(22); var input_default = /*#__PURE__*/__webpack_require__.n(input_); // EXTERNAL MODULE: external "element-nice-ui/lib/mixins/locale" var locale_ = __webpack_require__(19); var locale_default = /*#__PURE__*/__webpack_require__.n(locale_); // EXTERNAL MODULE: external "element-nice-ui/lib/utils/util" var util_ = __webpack_require__(5); // 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(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() { return [10, 20, 30, 40, 50, 100]; } }, popperClass: String, prevText: String, nextText: String, background: Boolean, disabled: Boolean, hideOnSinglePage: Boolean }, data() { return { internalCurrentPage: 1, internalPageSize: 0, lastEmittedPage: -1, userChangePageSize: false }; }, render(h) { const layout = this.layout; if (!layout) return null; if (this.hideOnSinglePage && (!this.internalPageCount || this.internalPageCount === 1)) return null; let template = h("div", { "class": ['el-pagination', { 'is-background': this.background, 'el-pagination--small': this.small }] }); const 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") }; const components = layout.split(',').map(item => item.trim()); const rightWrapper = h("div", { "class": 'el-pagination__rightwrapper' }); let haveRightWrapper = false; template.children = template.children || []; rightWrapper.children = rightWrapper.children || []; components.forEach(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(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(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(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(h) { let options = this.pageSizes.map(size => ({ value: size, label: size + this.t('el.pagination.pagesize') })); return h("span", { "class": 'el-pagination__sizes' }, [h("el-select", { "attrs": { "value": this.$parent.internalPageSize, "popperClass": this.$parent.popperClass || '', "size": 'mini', "clearable": false, "disabled": this.$parent.disabled, "options": options }, "on": { "input": this.handleChange } })]); }, components: { ElSelect: select_default.a, ElOption: option_default.a }, methods: { 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() { return { userInput: null }; }, watch: { '$parent.internalCurrentPage'() { this.userInput = null; } }, methods: { handleKeyup(_ref) { let { keyCode, target } = _ref; // 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(value) { this.userInput = value; }, handleChange(value) { this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(value); this.$parent.emitChange(); this.userInput = null; } }, 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', "clearable": false, "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(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(val) { this.internalCurrentPage = this.getValidCurrentPage(val); this.userChangePageSize = true; this.emitChange(); }, prev() { if (this.disabled) return; const newVal = this.internalCurrentPage - 1; this.internalCurrentPage = this.getValidCurrentPage(newVal); this.$emit('prev-click', this.internalCurrentPage); this.emitChange(); }, next() { if (this.disabled) return; const newVal = this.internalCurrentPage + 1; this.internalCurrentPage = this.getValidCurrentPage(newVal); this.$emit('next-click', this.internalCurrentPage); this.emitChange(); }, getValidCurrentPage(value) { value = parseInt(value, 10); const havePageCount = typeof this.internalPageCount === 'number'; let resetValue; 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() { this.$nextTick(() => { if (this.internalCurrentPage !== this.lastEmittedPage || this.userChangePageSize) { this.$emit('current-change', this.internalCurrentPage); this.lastEmittedPage = this.internalCurrentPage; this.userChangePageSize = false; } }); } }, computed: { 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(val) { this.internalCurrentPage = this.getValidCurrentPage(val); } }, pageSize: { immediate: true, handler(val) { this.internalPageSize = isNaN(val) ? 10 : val; } }, internalCurrentPage: { immediate: true, handler(newVal) { this.$emit('update:currentPage', newVal); this.lastEmittedPage = -1; } }, internalPageCount(newVal) { /* istanbul ignore if */ const 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); /***/ }), /***/ 2: /***/ (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, (options.functional ? this.parent : 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 functional 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 } } /***/ }), /***/ 22: /***/ (function(module, exports) { module.exports = require("element-nice-ui/lib/input"); /***/ }), /***/ 5: /***/ (function(module, exports) { module.exports = require("element-nice-ui/lib/utils/util"); /***/ }) /******/ });