UNPKG

element-ui

Version:

A Component Library for Vue.js.

1,631 lines (1,479 loc) 146 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 = 57); /******/ }) /************************************************************************/ /******/ ([ /* 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 } } /***/ }), /* 1 */, /* 2 */ /***/ (function(module, exports) { module.exports = require("element-ui/lib/utils/dom"); /***/ }), /* 3 */ /***/ (function(module, exports) { module.exports = require("element-ui/lib/utils/util"); /***/ }), /* 4 */, /* 5 */ /***/ (function(module, exports) { module.exports = require("element-ui/lib/utils/vue-popper"); /***/ }), /* 6 */ /***/ (function(module, exports) { module.exports = require("element-ui/lib/mixins/locale"); /***/ }), /* 7 */ /***/ (function(module, exports) { module.exports = require("vue"); /***/ }), /* 8 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getCell; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return orderBy; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return getColumnById; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return getColumnByKey; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getColumnByCell; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return getRowIdentity; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return getKeysMap; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return mergeOptions; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return parseWidth; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return parseMinWidth; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return parseHeight; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return compose; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return toggleRowStatus; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return walkTreeNode; }); /* harmony import */ var element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3); /* harmony import */ var element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__); 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; }; var getCell = function getCell(event) { var cell = event.target; while (cell && cell.tagName.toUpperCase() !== 'HTML') { if (cell.tagName.toUpperCase() === 'TD') { return cell; } cell = cell.parentNode; } return null; }; var isObject = function isObject(obj) { return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object'; }; var orderBy = function orderBy(array, sortKey, reverse, sortMethod, sortBy) { if (!sortKey && !sortMethod && (!sortBy || Array.isArray(sortBy) && !sortBy.length)) { return array; } if (typeof reverse === 'string') { reverse = reverse === 'descending' ? -1 : 1; } else { reverse = reverse && reverse < 0 ? -1 : 1; } var getKey = sortMethod ? null : function (value, index) { if (sortBy) { if (!Array.isArray(sortBy)) { sortBy = [sortBy]; } return sortBy.map(function (by) { if (typeof by === 'string') { return Object(element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__["getValueByPath"])(value, by); } else { return by(value, index, array); } }); } if (sortKey !== '$key') { if (isObject(value) && '$value' in value) value = value.$value; } return [isObject(value) ? Object(element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__["getValueByPath"])(value, sortKey) : value]; }; var compare = function compare(a, b) { if (sortMethod) { return sortMethod(a.value, b.value); } for (var i = 0, len = a.key.length; i < len; i++) { if (a.key[i] < b.key[i]) { return -1; } if (a.key[i] > b.key[i]) { return 1; } } return 0; }; return array.map(function (value, index) { return { value: value, index: index, key: getKey ? getKey(value, index) : null }; }).sort(function (a, b) { var order = compare(a, b); if (!order) { // make stable https://en.wikipedia.org/wiki/Sorting_algorithm#Stability order = a.index - b.index; } return order * reverse; }).map(function (item) { return item.value; }); }; var getColumnById = function getColumnById(table, columnId) { var column = null; table.columns.forEach(function (item) { if (item.id === columnId) { column = item; } }); return column; }; var getColumnByKey = function getColumnByKey(table, columnKey) { var column = null; for (var i = 0; i < table.columns.length; i++) { var item = table.columns[i]; if (item.columnKey === columnKey) { column = item; break; } } return column; }; var getColumnByCell = function getColumnByCell(table, cell) { var matches = (cell.className || '').match(/el-table_[^\s]+/gm); if (matches) { return getColumnById(table, matches[0]); } return null; }; var getRowIdentity = function getRowIdentity(row, rowKey) { if (!row) throw new Error('row is required when get row identity'); if (typeof rowKey === 'string') { if (rowKey.indexOf('.') < 0) { return row[rowKey]; } var key = rowKey.split('.'); var current = row; for (var i = 0; i < key.length; i++) { current = current[key[i]]; } return current; } else if (typeof rowKey === 'function') { return rowKey.call(null, row); } }; var getKeysMap = function getKeysMap(array, rowKey) { var arrayMap = {}; (array || []).forEach(function (row, index) { arrayMap[getRowIdentity(row, rowKey)] = { row: row, index: index }; }); return arrayMap; }; function hasOwn(obj, key) { return Object.prototype.hasOwnProperty.call(obj, key); } function mergeOptions(defaults, config) { var options = {}; var key = void 0; for (key in defaults) { options[key] = defaults[key]; } for (key in config) { if (hasOwn(config, key)) { var value = config[key]; if (typeof value !== 'undefined') { options[key] = value; } } } return options; } function parseWidth(width) { if (width !== undefined) { width = parseInt(width, 10); if (isNaN(width)) { width = null; } } return width; } function parseMinWidth(minWidth) { if (typeof minWidth !== 'undefined') { minWidth = parseWidth(minWidth); if (isNaN(minWidth)) { minWidth = 80; } } return minWidth; }; function parseHeight(height) { if (typeof height === 'number') { return height; } if (typeof height === 'string') { if (/^\d+(?:px)?$/.test(height)) { return parseInt(height, 10); } else { return height; } } return null; } // https://github.com/reduxjs/redux/blob/master/src/compose.js function compose() { for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { funcs[_key] = arguments[_key]; } if (funcs.length === 0) { return function (arg) { return arg; }; } if (funcs.length === 1) { return funcs[0]; } return funcs.reduce(function (a, b) { return function () { return a(b.apply(undefined, arguments)); }; }); } function toggleRowStatus(statusArr, row, newVal) { var changed = false; var index = statusArr.indexOf(row); var included = index !== -1; var addRow = function addRow() { statusArr.push(row); changed = true; }; var removeRow = function removeRow() { statusArr.splice(index, 1); changed = true; }; if (typeof newVal === 'boolean') { if (newVal && !included) { addRow(); } else if (!newVal && included) { removeRow(); } } else { if (included) { removeRow(); } else { addRow(); } } return changed; } function walkTreeNode(root, cb) { var childrenKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'children'; var lazyKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'hasChildren'; var isNil = function isNil(array) { return !(Array.isArray(array) && array.length); }; function _walker(parent, children, level) { cb(parent, children, level); children.forEach(function (item) { if (item[lazyKey]) { cb(item, null, level + 1); return; } var children = item[childrenKey]; if (!isNil(children)) { _walker(item, children, level + 1); } }); } root.forEach(function (item) { if (item[lazyKey]) { cb(item, null, 0); return; } var children = item[childrenKey]; if (!isNil(children)) { _walker(item, children, 0); } }); } /***/ }), /* 9 */ /***/ (function(module, exports) { module.exports = require("element-ui/lib/utils/merge"); /***/ }), /* 10 */, /* 11 */ /***/ (function(module, exports) { module.exports = require("element-ui/lib/mixins/migrating"); /***/ }), /* 12 */ /***/ (function(module, exports) { module.exports = require("element-ui/lib/utils/clickoutside"); /***/ }), /* 13 */ /***/ (function(module, exports) { module.exports = require("element-ui/lib/utils/popup"); /***/ }), /* 14 */, /* 15 */ /***/ (function(module, exports) { module.exports = require("element-ui/lib/scrollbar"); /***/ }), /* 16 */ /***/ (function(module, exports) { module.exports = require("element-ui/lib/utils/resize-event"); /***/ }), /* 17 */, /* 18 */ /***/ (function(module, exports) { module.exports = require("throttle-debounce/debounce"); /***/ }), /* 19 */ /***/ (function(module, exports) { module.exports = require("element-ui/lib/checkbox"); /***/ }), /* 20 */, /* 21 */, /* 22 */, /* 23 */, /* 24 */, /* 25 */, /* 26 */, /* 27 */, /* 28 */, /* 29 */ /***/ (function(module, exports) { module.exports = require("element-ui/lib/tooltip"); /***/ }), /* 30 */, /* 31 */, /* 32 */, /* 33 */, /* 34 */, /* 35 */, /* 36 */, /* 37 */, /* 38 */ /***/ (function(module, exports) { module.exports = require("element-ui/lib/utils/scrollbar-width"); /***/ }), /* 39 */ /***/ (function(module, exports) { module.exports = require("element-ui/lib/checkbox-group"); /***/ }), /* 40 */, /* 41 */, /* 42 */, /* 43 */ /***/ (function(module, exports) { module.exports = require("throttle-debounce"); /***/ }), /* 44 */, /* 45 */, /* 46 */ /***/ (function(module, exports) { module.exports = require("normalize-wheel"); /***/ }), /* 47 */, /* 48 */, /* 49 */, /* 50 */, /* 51 */, /* 52 */, /* 53 */, /* 54 */, /* 55 */, /* 56 */, /* 57 */ /***/ (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/table/src/table.vue?vue&type=template&id=493fe34e& var render = function() { var _vm = this var _h = _vm.$createElement var _c = _vm._self._c || _h return _c( "div", { staticClass: "el-table", class: [ { "el-table--fit": _vm.fit, "el-table--striped": _vm.stripe, "el-table--border": _vm.border || _vm.isGroup, "el-table--hidden": _vm.isHidden, "el-table--group": _vm.isGroup, "el-table--fluid-height": _vm.maxHeight, "el-table--scrollable-x": _vm.layout.scrollX, "el-table--scrollable-y": _vm.layout.scrollY, "el-table--enable-row-hover": !_vm.store.states.isComplex, "el-table--enable-row-transition": (_vm.store.states.data || []).length !== 0 && (_vm.store.states.data || []).length < 100 }, _vm.tableSize ? "el-table--" + _vm.tableSize : "" ], on: { mouseleave: function($event) { _vm.handleMouseLeave($event) } } }, [ _c( "div", { ref: "hiddenColumns", staticClass: "hidden-columns" }, [_vm._t("default")], 2 ), _vm.showHeader ? _c( "div", { directives: [ { name: "mousewheel", rawName: "v-mousewheel", value: _vm.handleHeaderFooterMousewheel, expression: "handleHeaderFooterMousewheel" } ], ref: "headerWrapper", staticClass: "el-table__header-wrapper" }, [ _c("table-header", { ref: "tableHeader", style: { width: _vm.layout.bodyWidth ? _vm.layout.bodyWidth + "px" : "" }, attrs: { store: _vm.store, border: _vm.border, "default-sort": _vm.defaultSort } }) ], 1 ) : _vm._e(), _c( "div", { ref: "bodyWrapper", staticClass: "el-table__body-wrapper", class: [ _vm.layout.scrollX ? "is-scrolling-" + _vm.scrollPosition : "is-scrolling-none" ], style: [_vm.bodyHeight] }, [ _c("table-body", { style: { width: _vm.bodyWidth }, attrs: { context: _vm.context, store: _vm.store, stripe: _vm.stripe, "row-class-name": _vm.rowClassName, "row-style": _vm.rowStyle, highlight: _vm.highlightCurrentRow } }), !_vm.data || _vm.data.length === 0 ? _c( "div", { ref: "emptyBlock", staticClass: "el-table__empty-block", style: _vm.emptyBlockStyle }, [ _c( "span", { staticClass: "el-table__empty-text" }, [ _vm._t("empty", [ _vm._v( _vm._s(_vm.emptyText || _vm.t("el.table.emptyText")) ) ]) ], 2 ) ] ) : _vm._e(), _vm.$slots.append ? _c( "div", { ref: "appendWrapper", staticClass: "el-table__append-wrapper" }, [_vm._t("append")], 2 ) : _vm._e() ], 1 ), _vm.showSummary ? _c( "div", { directives: [ { name: "show", rawName: "v-show", value: _vm.data && _vm.data.length > 0, expression: "data && data.length > 0" }, { name: "mousewheel", rawName: "v-mousewheel", value: _vm.handleHeaderFooterMousewheel, expression: "handleHeaderFooterMousewheel" } ], ref: "footerWrapper", staticClass: "el-table__footer-wrapper" }, [ _c("table-footer", { style: { width: _vm.layout.bodyWidth ? _vm.layout.bodyWidth + "px" : "" }, attrs: { store: _vm.store, border: _vm.border, "sum-text": _vm.sumText || _vm.t("el.table.sumText"), "summary-method": _vm.summaryMethod, "default-sort": _vm.defaultSort } }) ], 1 ) : _vm._e(), _vm.fixedColumns.length > 0 ? _c( "div", { directives: [ { name: "mousewheel", rawName: "v-mousewheel", value: _vm.handleFixedMousewheel, expression: "handleFixedMousewheel" } ], ref: "fixedWrapper", staticClass: "el-table__fixed", style: [ { width: _vm.layout.fixedWidth ? _vm.layout.fixedWidth + "px" : "" }, _vm.fixedHeight ] }, [ _vm.showHeader ? _c( "div", { ref: "fixedHeaderWrapper", staticClass: "el-table__fixed-header-wrapper" }, [ _c("table-header", { ref: "fixedTableHeader", style: { width: _vm.bodyWidth }, attrs: { fixed: "left", border: _vm.border, store: _vm.store } }) ], 1 ) : _vm._e(), _c( "div", { ref: "fixedBodyWrapper", staticClass: "el-table__fixed-body-wrapper", style: [ { top: _vm.layout.headerHeight + "px" }, _vm.fixedBodyHeight ] }, [ _c("table-body", { style: { width: _vm.bodyWidth }, attrs: { fixed: "left", store: _vm.store, stripe: _vm.stripe, highlight: _vm.highlightCurrentRow, "row-class-name": _vm.rowClassName, "row-style": _vm.rowStyle } }), _vm.$slots.append ? _c("div", { staticClass: "el-table__append-gutter", style: { height: _vm.layout.appendHeight + "px" } }) : _vm._e() ], 1 ), _vm.showSummary ? _c( "div", { directives: [ { name: "show", rawName: "v-show", value: _vm.data && _vm.data.length > 0, expression: "data && data.length > 0" } ], ref: "fixedFooterWrapper", staticClass: "el-table__fixed-footer-wrapper" }, [ _c("table-footer", { style: { width: _vm.bodyWidth }, attrs: { fixed: "left", border: _vm.border, "sum-text": _vm.sumText || _vm.t("el.table.sumText"), "summary-method": _vm.summaryMethod, store: _vm.store } }) ], 1 ) : _vm._e() ] ) : _vm._e(), _vm.rightFixedColumns.length > 0 ? _c( "div", { directives: [ { name: "mousewheel", rawName: "v-mousewheel", value: _vm.handleFixedMousewheel, expression: "handleFixedMousewheel" } ], ref: "rightFixedWrapper", staticClass: "el-table__fixed-right", style: [ { width: _vm.layout.rightFixedWidth ? _vm.layout.rightFixedWidth + "px" : "", right: _vm.layout.scrollY ? (_vm.border ? _vm.layout.gutterWidth : _vm.layout.gutterWidth || 0) + "px" : "" }, _vm.fixedHeight ] }, [ _vm.showHeader ? _c( "div", { ref: "rightFixedHeaderWrapper", staticClass: "el-table__fixed-header-wrapper" }, [ _c("table-header", { ref: "rightFixedTableHeader", style: { width: _vm.bodyWidth }, attrs: { fixed: "right", border: _vm.border, store: _vm.store } }) ], 1 ) : _vm._e(), _c( "div", { ref: "rightFixedBodyWrapper", staticClass: "el-table__fixed-body-wrapper", style: [ { top: _vm.layout.headerHeight + "px" }, _vm.fixedBodyHeight ] }, [ _c("table-body", { style: { width: _vm.bodyWidth }, attrs: { fixed: "right", store: _vm.store, stripe: _vm.stripe, "row-class-name": _vm.rowClassName, "row-style": _vm.rowStyle, highlight: _vm.highlightCurrentRow } }), _vm.$slots.append ? _c("div", { staticClass: "el-table__append-gutter", style: { height: _vm.layout.appendHeight + "px" } }) : _vm._e() ], 1 ), _vm.showSummary ? _c( "div", { directives: [ { name: "show", rawName: "v-show", value: _vm.data && _vm.data.length > 0, expression: "data && data.length > 0" } ], ref: "rightFixedFooterWrapper", staticClass: "el-table__fixed-footer-wrapper" }, [ _c("table-footer", { style: { width: _vm.bodyWidth }, attrs: { fixed: "right", border: _vm.border, "sum-text": _vm.sumText || _vm.t("el.table.sumText"), "summary-method": _vm.summaryMethod, store: _vm.store } }) ], 1 ) : _vm._e() ] ) : _vm._e(), _vm.rightFixedColumns.length > 0 ? _c("div", { ref: "rightFixedPatch", staticClass: "el-table__fixed-right-patch", style: { width: _vm.layout.scrollY ? _vm.layout.gutterWidth + "px" : "0", height: _vm.layout.headerHeight + "px" } }) : _vm._e(), _c("div", { directives: [ { name: "show", rawName: "v-show", value: _vm.resizeProxyVisible, expression: "resizeProxyVisible" } ], ref: "resizeProxy", staticClass: "el-table__column-resize-proxy" }) ] ) } var staticRenderFns = [] render._withStripped = true // CONCATENATED MODULE: ./packages/table/src/table.vue?vue&type=template&id=493fe34e& // EXTERNAL MODULE: external "element-ui/lib/checkbox" var checkbox_ = __webpack_require__(19); var checkbox_default = /*#__PURE__*/__webpack_require__.n(checkbox_); // EXTERNAL MODULE: external "throttle-debounce" var external_throttle_debounce_ = __webpack_require__(43); // EXTERNAL MODULE: external "element-ui/lib/utils/resize-event" var resize_event_ = __webpack_require__(16); // EXTERNAL MODULE: external "normalize-wheel" var external_normalize_wheel_ = __webpack_require__(46); var external_normalize_wheel_default = /*#__PURE__*/__webpack_require__.n(external_normalize_wheel_); // CONCATENATED MODULE: ./src/directives/mousewheel.js var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1; var mousewheel_mousewheel = function mousewheel(element, callback) { if (element && element.addEventListener) { element.addEventListener(isFirefox ? 'DOMMouseScroll' : 'mousewheel', function (event) { var normalized = external_normalize_wheel_default()(event); callback && callback.apply(this, [event, normalized]); }); } }; /* harmony default export */ var directives_mousewheel = ({ bind: function bind(el, binding) { mousewheel_mousewheel(el, binding.value); } }); // 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/mixins/migrating" var migrating_ = __webpack_require__(11); var migrating_default = /*#__PURE__*/__webpack_require__.n(migrating_); // EXTERNAL MODULE: external "vue" var external_vue_ = __webpack_require__(7); var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_); // EXTERNAL MODULE: external "element-ui/lib/utils/merge" var merge_ = __webpack_require__(9); var merge_default = /*#__PURE__*/__webpack_require__.n(merge_); // EXTERNAL MODULE: ./packages/table/src/util.js var util = __webpack_require__(8); // CONCATENATED MODULE: ./packages/table/src/store/expand.js /* harmony default export */ var expand = ({ data: function data() { return { states: { defaultExpandAll: false, expandRows: [] } }; }, methods: { updateExpandRows: function updateExpandRows() { var _states = this.states, _states$data = _states.data, data = _states$data === undefined ? [] : _states$data, rowKey = _states.rowKey, defaultExpandAll = _states.defaultExpandAll, expandRows = _states.expandRows; if (defaultExpandAll) { this.states.expandRows = data.slice(); } else if (rowKey) { // TODO:这里的代码可以优化 var expandRowsMap = Object(util["f" /* getKeysMap */])(expandRows, rowKey); this.states.expandRows = data.reduce(function (prev, row) { var rowId = Object(util["g" /* getRowIdentity */])(row, rowKey); var rowInfo = expandRowsMap[rowId]; if (rowInfo) { prev.push(row); } return prev; }, []); } else { this.states.expandRows = []; } }, toggleRowExpansion: function toggleRowExpansion(row, expanded) { var changed = Object(util["m" /* toggleRowStatus */])(this.states.expandRows, row, expanded); if (changed) { this.table.$emit('expand-change', row, this.states.expandRows.slice()); this.scheduleLayout(); } }, setExpandRowKeys: function setExpandRowKeys(rowKeys) { this.assertRowKey(); // TODO:这里的代码可以优化 var _states2 = this.states, data = _states2.data, rowKey = _states2.rowKey; var keysMap = Object(util["f" /* getKeysMap */])(data, rowKey); this.states.expandRows = rowKeys.reduce(function (prev, cur) { var info = keysMap[cur]; if (info) { prev.push(info.row); } return prev; }, []); }, isRowExpanded: function isRowExpanded(row) { var _states3 = this.states, _states3$expandRows = _states3.expandRows, expandRows = _states3$expandRows === undefined ? [] : _states3$expandRows, rowKey = _states3.rowKey; if (rowKey) { var expandMap = Object(util["f" /* getKeysMap */])(expandRows, rowKey); return !!expandMap[Object(util["g" /* getRowIdentity */])(row, rowKey)]; } return expandRows.indexOf(row) !== -1; } } }); // EXTERNAL MODULE: external "element-ui/lib/utils/util" var util_ = __webpack_require__(3); // CONCATENATED MODULE: ./packages/table/src/store/current.js /* harmony default export */ var current = ({ data: function data() { return { states: { // 不可响应的,设置 currentRowKey 时,data 不一定存在,也许无法算出正确的 currentRow // 把该值缓存一下,当用户点击修改 currentRow 时,把该值重置为 null _currentRowKey: null, currentRow: null } }; }, methods: { setCurrentRowKey: function setCurrentRowKey(key) { this.assertRowKey(); this.states._currentRowKey = key; this.setCurrentRowByKey(key); }, restoreCurrentRowKey: function restoreCurrentRowKey() { this.states._currentRowKey = null; }, setCurrentRowByKey: function setCurrentRowByKey(key) { var states = this.states; var _states$data = states.data, data = _states$data === undefined ? [] : _states$data, rowKey = states.rowKey; var currentRow = null; if (rowKey) { currentRow = Object(util_["arrayFind"])(data, function (item) { return Object(util["g" /* getRowIdentity */])(item, rowKey) === key; }); } states.currentRow = currentRow; }, updateCurrentRow: function updateCurrentRow(currentRow) { var states = this.states, table = this.table; var oldCurrentRow = states.currentRow; if (currentRow && currentRow !== oldCurrentRow) { states.currentRow = currentRow; table.$emit('current-change', currentRow, oldCurrentRow); return; } if (!currentRow && oldCurrentRow) { states.currentRow = null; table.$emit('current-change', null, oldCurrentRow); } }, updateCurrentRowData: function updateCurrentRowData() { var states = this.states, table = this.table; var rowKey = states.rowKey, _currentRowKey = states._currentRowKey; // data 为 null 时,解构时的默认值会被忽略 var data = states.data || []; var oldCurrentRow = states.currentRow; // 当 currentRow 不在 data 中时尝试更新数据 if (data.indexOf(oldCurrentRow) === -1 && oldCurrentRow) { if (rowKey) { var currentRowKey = Object(util["g" /* getRowIdentity */])(oldCurrentRow, rowKey); this.setCurrentRowByKey(currentRowKey); } else { states.currentRow = null; } if (states.currentRow === null) { table.$emit('current-change', null, oldCurrentRow); } } else if (_currentRowKey) { // 把初始时下设置的 rowKey 转化成 rowData this.setCurrentRowByKey(_currentRowKey); this.restoreCurrentRowKey(); } } } }); // CONCATENATED MODULE: ./packages/table/src/store/tree.js var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /* harmony default export */ var tree = ({ data: function data() { return { states: { // defaultExpandAll 存在于 expand.js 中,这里不重复添加 // 在展开行中,expandRowKeys 会被转化成 expandRows,expandRowKeys 这个属性只是记录了 TreeTable 行的展开 // TODO: 拆分为独立的 TreeTable,统一用法 expandRowKeys: [], treeData: {}, indent: 16, lazy: false, lazyTreeNodeMap: {}, lazyColumnIdentifier: 'hasChildren', childrenColumnName: 'children' } }; }, computed: { // 嵌入型的数据,watch 无法是检测到变化 https://github.com/ElemeFE/element/issues/14998 // TODO: 使用 computed 解决该问题,是否会造成性能问题? // @return { id: { level, children } } normalizedData: function normalizedData() { if (!this.states.rowKey) return {}; var data = this.states.data || []; return this.normalize(data); }, // @return { id: { children } } // 针对懒加载的情形,不处理嵌套数据 normalizedLazyNode: function normalizedLazyNode() { var _states = this.states, rowKey = _states.rowKey, lazyTreeNodeMap = _states.lazyTreeNodeMap, lazyColumnIdentifier = _states.lazyColumnIdentifier; var keys = Object.keys(lazyTreeNodeMap); var res = {}; if (!keys.length) return res; keys.forEach(function (key) { if (lazyTreeNodeMap[key].length) { var item = { children: [] }; lazyTreeNodeMap[key].forEach(function (row) { var currentRowKey = Object(util["g" /* getRowIdentity */])(row, rowKey); item.children.push(currentRowKey); if (row[lazyColumnIdentifier] && !res[currentRowKey]) { res[currentRowKey] = { children: [] }; } }); res[key] = item; } }); return res; } }, watch: { normalizedData: 'updateTreeData', normalizedLazyNode: 'updateTreeData' }, methods: { normalize: function normalize(data) { var _states2 = this.states, childrenColumnName = _states2.childrenColumnName, lazyColumnIdentifier = _states2.lazyColumnIdentifier, rowKey = _states2.rowKey, lazy = _states2.lazy; var res = {}; Object(util["n" /* walkTreeNode */])(data, function (parent, children, level) { var parentId = Object(util["g" /* getRowIdentity */])(parent, rowKey); if (Array.isArray(children)) { res[parentId] = { children: children.map(function (row) { return Object(util["g" /* getRowIdentity */])(row, rowKey); }), level: level }; } else if (lazy) { // 当 children 不存在且 lazy 为 true,该节点即为懒加载的节点 res[parentId] = { children: [], lazy: true, level: level }; } }, childrenColumnName, lazyColumnIdentifier); return res; }, updateTreeData: function updateTreeData() { var nested = this.normalizedData; var normalizedLazyNode = this.normalizedLazyNode; var keys = Object.keys(nested); var newTreeData = {}; if (keys.length) { var _states3 = this.states, oldTreeData = _states3.treeData, defaultExpandAll = _states3.defaultExpandAll, expandRowKeys = _states3.expandRowKeys, lazy = _states3.lazy; var rootLazyRowKeys = []; var getExpanded = function getExpanded(oldValue, key) { var included = defaultExpandAll || expandRowKeys && expandRowKeys.indexOf(key) !== -1; return !!(oldValue && oldValue.expanded || included); }; // 合并 expanded 与 display,确保数据刷新后,状态不变 keys.forEach(function (key) { var oldValue = oldTreeData[key]; var newValue = _extends({}, nested[key]); newValue.expanded = getExpanded(oldValue, key); if (newValue.lazy) { var _ref = oldValue || {}, _ref$loaded = _ref.loaded, loaded = _ref$loaded === undefined ? false : _ref$loaded, _ref$loading = _ref.loading, loading = _ref$loading === undefined ? false : _ref$loading; newValue.loaded = !!loaded; newValue.loading = !!loading; rootLazyRowKeys.push(key); } newTreeData[key] = newValue; }); // 根据懒加载数据更新 treeData var lazyKeys = Object.keys(normalizedLazyNode); if (lazy && lazyKeys.length && rootLazyRowKeys.length) { lazyKeys.forEach(function (key) { var oldValue = oldTreeData[key]; var lazyNodeChildren = normalizedLazyNode[key].children; if (rootLazyRowKeys.indexOf(key) !== -1) { // 懒加载的 root 节点,更新一下原有的数据,原来的 children 一定是空数组 if (newTreeData[key].children.length !== 0) { throw new Error('[ElTable]children must be an empty array.'); } newTreeData[key].children = lazyNodeChildren; } else { var _ref2 = oldValue || {}, _ref2$loaded = _ref2.loaded, loaded = _ref2$loaded === undefined ? false : _ref2$loaded, _ref2$loading = _ref2.loading, loading = _ref2$loading === undefined ? false : _ref2$loading; newTreeData[key] = { lazy: true, loaded: !!loaded, loading: !!loading, expanded: getExpanded(oldValue, key), children: lazyNodeChildren, level: '' }; } }); } } this.states.treeData = newTreeData; this.updateTableScrollY(); }, updateTreeExpandKeys: function updateTreeExpandKeys(value) { this.states.expandRowKeys = value; this.updateTreeData(); }, toggleTreeExpansion: function toggleTreeExpansion(row, expanded) { this.assertRowKey(); var _states4 = this.states, rowKey = _states4.rowKey, treeData = _states4.treeData; var id = Object(util["g" /* getRowIdentity */])(row, rowKey); var data = id && treeData[id]; if (id && data && 'expanded' in data) { var oldExpanded = data.expanded; expanded = typeof expanded === 'undefined' ? !data.expanded : expanded; treeData[id].expanded = expanded; if (oldExpanded !== expanded) { this.table.$emit('expand-change', row, expanded); } this.updateTableScrollY(); } }, loadOrToggle: function loadOrToggle(row) { this.assertRowKey(); var _states5 = this.states, lazy = _states5.lazy, treeData = _states5.treeData, rowKey = _states5.rowKey; var id = Object(util["g" /* getRowIdentity */])(row, rowKey); var data = treeData[id]; if (lazy && data && 'loaded' in data && !data.loaded) { this.loadData(row, id, data); } else { this.toggleTreeExpansion(row); } }, loadData: function loadData(row, key, treeNode) { var _this = this; var load = this.table.load; var rawTreeData = this.states.treeData; if (load && !rawTreeData[key].loaded) { rawTreeData[key].loading = true; load(row, treeNode, function (data) { if (!Array.isArray(data)) { throw new Error('[ElTable] data must be an array'); } var _states6 = _this.states, lazyTreeNodeMap = _states6.lazyTreeNodeMap, treeData = _states6.treeData; treeData[key].loading = false; treeData[key].loaded = true; treeData[key].expanded = true; if (data.length) { _this.$set(lazyTreeNodeMap, key, data); } _this.table.$emit('expand-change', row, true); }); } } } }); // CONCATENATED MODULE: ./packages/table/src/store/watcher.js var watcher_sortData = function sortData(data, states) { var sortingColumn = states.sortingColumn; if (!sortingColumn || typeof sortingColumn.sortable === 'string') { return data; } return Object(util["i" /* orderBy */])(data, states.sortProp, states.sortOrder, sortingColumn.sortMethod, sortingColumn.sortBy); }; var doFlattenColumns = function doFlattenColumns(columns) { var result = []; columns.forEach(function (column) { if (column.children) { result.push.apply(result, doFlattenColumns(column.children)); } else { result.push(column); } }); return result; }; /* harmony default export */ var watcher = (external_vue_default.a.extend({ data: function data() { return { states: { // 3.0 版本后要求必须设置该属性 rowKey: null, // 渲染的数据来源,是对 table 中的 data 过滤排序后的结果 data: [], // 是否包含固定列 isComplex: false, // 列 _columns: [], // 不可响应的 originColumns: [], columns: [], fixedColumns: [], rightFixedColumns: [], leafColumns: [], fixedLeafColumns: [], rightFixedLeafColumns: [], leafColumnsLength: 0, fixedLeafColumnsLength: 0, rightFixedLeafColumnsLength: 0, // 选择 isAllSelected: false, selection: [], reserveSelection: false, selectOnIndeterminate: false, selectable: null, // 过滤 filters: {}, // 不可响应的 filteredData: null, // 排序 sortingColumn: null, sortProp: null, sortOrder: null, hoverRow: null } }; }, mixins: [expand, current, tree], methods: { // 检查 rowKey 是否存在 assertRowKey: function assertRowKey() { var rowKey = this.states.rowKey; if (!rowKey) throw new Error('[ElTable] prop row-key is required'); }, // 更新列 updateColumns: function updateColumns() { var states = this.states; var _columns = states._columns || []; states.fixedColumns = _columns.filter(function (column) { return column.fixed === true || column.fixed === 'left'; }); states.rightFixedColumns = _columns.filter(function (column) { return column.fixed === 'right'; }); if (states.fixedColumns.length > 0 && _columns[0] && _columns[0].type === 'selection' && !_columns[0].fixed) { _columns[0].fixed = true; states.fixedColumns.unshift(_columns[0]); } var notFixedColumns = _columns.filter(function (column) { return !column.fixed; }); states.originColumn