框架源码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6013 lines
172 KiB

4 years ago
  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "/dist/";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = 517);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 10:
  90. /***/ (function(module, exports) {
  91. module.exports = require("tis-ui/lib/utils/util");
  92. /***/ }),
  93. /***/ 102:
  94. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95. "use strict";
  96. // ESM COMPAT FLAG
  97. __webpack_require__.r(__webpack_exports__);
  98. // EXTERNAL MODULE: external "tis-ui/lib/utils/vue-popper"
  99. var vue_popper_ = __webpack_require__(34);
  100. var vue_popper_default = /*#__PURE__*/__webpack_require__.n(vue_popper_);
  101. // EXTERNAL MODULE: external "throttle-debounce/debounce"
  102. var debounce_ = __webpack_require__(62);
  103. var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce_);
  104. // EXTERNAL MODULE: external "tis-ui/lib/utils/dom"
  105. var dom_ = __webpack_require__(7);
  106. // EXTERNAL MODULE: external "tis-ui/lib/utils/util"
  107. var util_ = __webpack_require__(10);
  108. // EXTERNAL MODULE: external "vue"
  109. var external_vue_ = __webpack_require__(4);
  110. var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
  111. // CONCATENATED MODULE: ./packages/tooltip/src/main.js
  112. /* harmony default export */ var main = ({
  113. name: 'TisTooltip',
  114. mixins: [vue_popper_default.a],
  115. props: {
  116. openDelay: {
  117. type: Number,
  118. default: 0
  119. },
  120. disabled: Boolean,
  121. manual: Boolean,
  122. effect: {
  123. type: String,
  124. default: 'dark'
  125. },
  126. arrowOffset: {
  127. type: Number,
  128. default: 0
  129. },
  130. popperClass: String,
  131. content: String,
  132. visibleArrow: {
  133. default: true
  134. },
  135. transition: {
  136. type: String,
  137. default: 'el-fade-in-linear'
  138. },
  139. popperOptions: {
  140. default: function _default() {
  141. return {
  142. boundariesPadding: 10,
  143. gpuAcceleration: false
  144. };
  145. }
  146. },
  147. enterable: {
  148. type: Boolean,
  149. default: true
  150. },
  151. hideAfter: {
  152. type: Number,
  153. default: 0
  154. },
  155. tabindex: {
  156. type: Number,
  157. default: 0
  158. }
  159. },
  160. data: function data() {
  161. return {
  162. tooltipId: 'el-tooltip-' + Object(util_["generateId"])(),
  163. timeoutPending: null,
  164. focusing: false
  165. };
  166. },
  167. beforeCreate: function beforeCreate() {
  168. var _this = this;
  169. if (this.$isServer) return;
  170. this.popperVM = new external_vue_default.a({
  171. data: { node: '' },
  172. render: function render(h) {
  173. return this.node;
  174. }
  175. }).$mount();
  176. this.debounceClose = debounce_default()(200, function () {
  177. return _this.handleClosePopper();
  178. });
  179. },
  180. render: function render(h) {
  181. var _this2 = this;
  182. if (this.popperVM) {
  183. this.popperVM.node = h(
  184. 'transition',
  185. {
  186. attrs: {
  187. name: this.transition
  188. },
  189. on: {
  190. 'afterLeave': this.doDestroy
  191. }
  192. },
  193. [h(
  194. 'div',
  195. {
  196. on: {
  197. 'mouseleave': function mouseleave() {
  198. _this2.setExpectedState(false);_this2.debounceClose();
  199. },
  200. 'mouseenter': function mouseenter() {
  201. _this2.setExpectedState(true);
  202. }
  203. },
  204. ref: 'popper',
  205. attrs: { role: 'tooltip',
  206. id: this.tooltipId,
  207. 'aria-hidden': this.disabled || !this.showPopper ? 'true' : 'false'
  208. },
  209. directives: [{
  210. name: 'show',
  211. value: !this.disabled && this.showPopper
  212. }],
  213. 'class': ['el-tooltip__popper', 'is-' + this.effect, this.popperClass] },
  214. [this.$slots.content || this.content]
  215. )]
  216. );
  217. }
  218. var firstElement = this.getFirstElement();
  219. if (!firstElement) return null;
  220. var data = firstElement.data = firstElement.data || {};
  221. data.staticClass = this.addTooltipClass(data.staticClass);
  222. return firstElement;
  223. },
  224. mounted: function mounted() {
  225. var _this3 = this;
  226. this.referenceElm = this.$el;
  227. if (this.$el.nodeType === 1) {
  228. this.$el.setAttribute('aria-describedby', this.tooltipId);
  229. this.$el.setAttribute('tabindex', this.tabindex);
  230. Object(dom_["on"])(this.referenceElm, 'mouseenter', this.show);
  231. Object(dom_["on"])(this.referenceElm, 'mouseleave', this.hide);
  232. Object(dom_["on"])(this.referenceElm, 'focus', function () {
  233. if (!_this3.$slots.default || !_this3.$slots.default.length) {
  234. _this3.handleFocus();
  235. return;
  236. }
  237. var instance = _this3.$slots.default[0].componentInstance;
  238. if (instance && instance.focus) {
  239. instance.focus();
  240. } else {
  241. _this3.handleFocus();
  242. }
  243. });
  244. Object(dom_["on"])(this.referenceElm, 'blur', this.handleBlur);
  245. Object(dom_["on"])(this.referenceElm, 'click', this.removeFocusing);
  246. }
  247. // fix issue https://github.com/ElemeFE/element/issues/14424
  248. if (this.value && this.popperVM) {
  249. this.popperVM.$nextTick(function () {
  250. if (_this3.value) {
  251. _this3.updatePopper();
  252. }
  253. });
  254. }
  255. },
  256. watch: {
  257. focusing: function focusing(val) {
  258. if (val) {
  259. Object(dom_["addClass"])(this.referenceElm, 'focusing');
  260. } else {
  261. Object(dom_["removeClass"])(this.referenceElm, 'focusing');
  262. }
  263. }
  264. },
  265. methods: {
  266. show: function show() {
  267. this.setExpectedState(true);
  268. this.handleShowPopper();
  269. },
  270. hide: function hide() {
  271. this.setExpectedState(false);
  272. this.debounceClose();
  273. },
  274. handleFocus: function handleFocus() {
  275. this.focusing = true;
  276. this.show();
  277. },
  278. handleBlur: function handleBlur() {
  279. this.focusing = false;
  280. this.hide();
  281. },
  282. removeFocusing: function removeFocusing() {
  283. this.focusing = false;
  284. },
  285. addTooltipClass: function addTooltipClass(prev) {
  286. if (!prev) {
  287. return 'el-tooltip';
  288. } else {
  289. return 'el-tooltip ' + prev.replace('el-tooltip', '');
  290. }
  291. },
  292. handleShowPopper: function handleShowPopper() {
  293. var _this4 = this;
  294. if (!this.expectedState || this.manual) return;
  295. clearTimeout(this.timeout);
  296. this.timeout = setTimeout(function () {
  297. _this4.showPopper = true;
  298. }, this.openDelay);
  299. if (this.hideAfter > 0) {
  300. this.timeoutPending = setTimeout(function () {
  301. _this4.showPopper = false;
  302. }, this.hideAfter);
  303. }
  304. },
  305. handleClosePopper: function handleClosePopper() {
  306. if (this.enterable && this.expectedState || this.manual) return;
  307. clearTimeout(this.timeout);
  308. if (this.timeoutPending) {
  309. clearTimeout(this.timeoutPending);
  310. }
  311. this.showPopper = false;
  312. if (this.disabled) {
  313. this.doDestroy();
  314. }
  315. },
  316. setExpectedState: function setExpectedState(expectedState) {
  317. if (expectedState === false) {
  318. clearTimeout(this.timeoutPending);
  319. }
  320. this.expectedState = expectedState;
  321. },
  322. getFirstElement: function getFirstElement() {
  323. var slots = this.$slots.default;
  324. if (!Array.isArray(slots)) return null;
  325. var element = null;
  326. for (var index = 0; index < slots.length; index++) {
  327. if (slots[index] && slots[index].tag) {
  328. element = slots[index];
  329. };
  330. }
  331. return element;
  332. }
  333. },
  334. beforeDestroy: function beforeDestroy() {
  335. this.popperVM && this.popperVM.$destroy();
  336. },
  337. destroyed: function destroyed() {
  338. var reference = this.referenceElm;
  339. if (reference.nodeType === 1) {
  340. Object(dom_["off"])(reference, 'mouseenter', this.show);
  341. Object(dom_["off"])(reference, 'mouseleave', this.hide);
  342. Object(dom_["off"])(reference, 'focus', this.handleFocus);
  343. Object(dom_["off"])(reference, 'blur', this.handleBlur);
  344. Object(dom_["off"])(reference, 'click', this.removeFocusing);
  345. }
  346. }
  347. });
  348. // CONCATENATED MODULE: ./packages/tooltip/index.js
  349. /* istanbul ignore next */
  350. main.install = function (Vue) {
  351. Vue.component(main.name, main);
  352. };
  353. /* harmony default export */ var tooltip = __webpack_exports__["default"] = (main);
  354. /***/ }),
  355. /***/ 121:
  356. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  357. "use strict";
  358. // ESM COMPAT FLAG
  359. __webpack_require__.r(__webpack_exports__);
  360. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/checkbox/src/checkbox-group.vue?vue&type=template&id=7289a290&
  361. var render = function() {
  362. var _vm = this
  363. var _h = _vm.$createElement
  364. var _c = _vm._self._c || _h
  365. return _c(
  366. "div",
  367. {
  368. staticClass: "el-checkbox-group",
  369. attrs: { role: "group", "aria-label": "checkbox-group" }
  370. },
  371. [_vm._t("default")],
  372. 2
  373. )
  374. }
  375. var staticRenderFns = []
  376. render._withStripped = true
  377. // CONCATENATED MODULE: ./packages/checkbox/src/checkbox-group.vue?vue&type=template&id=7289a290&
  378. // EXTERNAL MODULE: external "tis-ui/lib/mixins/emitter"
  379. var emitter_ = __webpack_require__(13);
  380. var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
  381. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/checkbox/src/checkbox-group.vue?vue&type=script&lang=js&
  382. /* harmony default export */ var checkbox_groupvue_type_script_lang_js_ = ({
  383. name: 'TisCheckboxGroup',
  384. componentName: 'TisCheckboxGroup',
  385. mixins: [emitter_default.a],
  386. inject: {
  387. elFormItem: {
  388. default: ''
  389. }
  390. },
  391. props: {
  392. value: {},
  393. disabled: Boolean,
  394. min: Number,
  395. max: Number,
  396. size: String,
  397. fill: String,
  398. textColor: String
  399. },
  400. computed: {
  401. _elFormItemSize: function _elFormItemSize() {
  402. return (this.elFormItem || {}).elFormItemSize;
  403. },
  404. checkboxGroupSize: function checkboxGroupSize() {
  405. return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
  406. }
  407. },
  408. watch: {
  409. value: function value(_value) {
  410. this.dispatch('TisFormItem', 'el.form.change', [_value]);
  411. }
  412. }
  413. });
  414. // CONCATENATED MODULE: ./packages/checkbox/src/checkbox-group.vue?vue&type=script&lang=js&
  415. /* harmony default export */ var src_checkbox_groupvue_type_script_lang_js_ = (checkbox_groupvue_type_script_lang_js_);
  416. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  417. var componentNormalizer = __webpack_require__(2);
  418. // CONCATENATED MODULE: ./packages/checkbox/src/checkbox-group.vue
  419. /* normalize component */
  420. var component = Object(componentNormalizer["a" /* default */])(
  421. src_checkbox_groupvue_type_script_lang_js_,
  422. render,
  423. staticRenderFns,
  424. false,
  425. null,
  426. null,
  427. null
  428. )
  429. /* hot reload */
  430. if (false) { var api; }
  431. component.options.__file = "packages/checkbox/src/checkbox-group.vue"
  432. /* harmony default export */ var checkbox_group = (component.exports);
  433. // CONCATENATED MODULE: ./packages/checkbox-group/index.js
  434. /* istanbul ignore next */
  435. checkbox_group.install = function (Vue) {
  436. Vue.component(checkbox_group.name, checkbox_group);
  437. };
  438. /* harmony default export */ var packages_checkbox_group = __webpack_exports__["default"] = (checkbox_group);
  439. /***/ }),
  440. /***/ 13:
  441. /***/ (function(module, exports) {
  442. module.exports = require("tis-ui/lib/mixins/emitter");
  443. /***/ }),
  444. /***/ 193:
  445. /***/ (function(module, exports) {
  446. module.exports = require("throttle-debounce");
  447. /***/ }),
  448. /***/ 2:
  449. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  450. "use strict";
  451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
  452. /* globals __VUE_SSR_CONTEXT__ */
  453. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  454. // This module is a runtime utility for cleaner component module output and will
  455. // be included in the final webpack user bundle.
  456. function normalizeComponent (
  457. scriptExports,
  458. render,
  459. staticRenderFns,
  460. functionalTemplate,
  461. injectStyles,
  462. scopeId,
  463. moduleIdentifier, /* server only */
  464. shadowMode /* vue-cli only */
  465. ) {
  466. // Vue.extend constructor export interop
  467. var options = typeof scriptExports === 'function'
  468. ? scriptExports.options
  469. : scriptExports
  470. // render functions
  471. if (render) {
  472. options.render = render
  473. options.staticRenderFns = staticRenderFns
  474. options._compiled = true
  475. }
  476. // functional template
  477. if (functionalTemplate) {
  478. options.functional = true
  479. }
  480. // scopedId
  481. if (scopeId) {
  482. options._scopeId = 'data-v-' + scopeId
  483. }
  484. var hook
  485. if (moduleIdentifier) { // server build
  486. hook = function (context) {
  487. // 2.3 injection
  488. context =
  489. context || // cached call
  490. (this.$vnode && this.$vnode.ssrContext) || // stateful
  491. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  492. // 2.2 with runInNewContext: true
  493. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  494. context = __VUE_SSR_CONTEXT__
  495. }
  496. // inject component styles
  497. if (injectStyles) {
  498. injectStyles.call(this, context)
  499. }
  500. // register component module identifier for async chunk inferrence
  501. if (context && context._registeredComponents) {
  502. context._registeredComponents.add(moduleIdentifier)
  503. }
  504. }
  505. // used by ssr in case component is cached and beforeCreate
  506. // never gets called
  507. options._ssrRegister = hook
  508. } else if (injectStyles) {
  509. hook = shadowMode
  510. ? function () {
  511. injectStyles.call(
  512. this,
  513. (options.functional ? this.parent : this).$root.$options.shadowRoot
  514. )
  515. }
  516. : injectStyles
  517. }
  518. if (hook) {
  519. if (options.functional) {
  520. // for template-only hot-reload because in that case the render fn doesn't
  521. // go through the normalizer
  522. options._injectStyles = hook
  523. // register for functional component in vue file
  524. var originalRender = options.render
  525. options.render = function renderWithStyleInjection (h, context) {
  526. hook.call(context)
  527. return originalRender(h, context)
  528. }
  529. } else {
  530. // inject component registration as beforeCreate hook
  531. var existing = options.beforeCreate
  532. options.beforeCreate = existing
  533. ? [].concat(existing, hook)
  534. : [hook]
  535. }
  536. }
  537. return {
  538. exports: scriptExports,
  539. options: options
  540. }
  541. }
  542. /***/ }),
  543. /***/ 245:
  544. /***/ (function(module, exports) {
  545. module.exports = require("normalize-wheel");
  546. /***/ }),
  547. /***/ 33:
  548. /***/ (function(module, exports) {
  549. module.exports = require("tis-ui/lib/utils/merge");
  550. /***/ }),
  551. /***/ 34:
  552. /***/ (function(module, exports) {
  553. module.exports = require("tis-ui/lib/utils/vue-popper");
  554. /***/ }),
  555. /***/ 36:
  556. /***/ (function(module, exports) {
  557. module.exports = require("tis-ui/lib/mixins/migrating");
  558. /***/ }),
  559. /***/ 38:
  560. /***/ (function(module, exports) {
  561. module.exports = require("tis-ui/lib/mixins/locale");
  562. /***/ }),
  563. /***/ 4:
  564. /***/ (function(module, exports) {
  565. module.exports = require("vue");
  566. /***/ }),
  567. /***/ 44:
  568. /***/ (function(module, exports) {
  569. module.exports = require("tis-ui/lib/utils/resize-event");
  570. /***/ }),
  571. /***/ 50:
  572. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  573. "use strict";
  574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getCell; });
  575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return orderBy; });
  576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return getColumnById; });
  577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return getColumnByKey; });
  578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getColumnByCell; });
  579. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return getRowIdentity; });
  580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return getKeysMap; });
  581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return mergeOptions; });
  582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return parseWidth; });
  583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return parseMinWidth; });
  584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return parseHeight; });
  585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return compose; });
  586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return toggleRowStatus; });
  587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return walkTreeNode; });
  588. /* harmony import */ var tis_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
  589. /* harmony import */ var tis_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(tis_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__);
  590. 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; };
  591. var getCell = function getCell(event) {
  592. var cell = event.target;
  593. while (cell && cell.tagName.toUpperCase() !== 'HTML') {
  594. if (cell.tagName.toUpperCase() === 'TD') {
  595. return cell;
  596. }
  597. cell = cell.parentNode;
  598. }
  599. return null;
  600. };
  601. var isObject = function isObject(obj) {
  602. return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
  603. };
  604. var orderBy = function orderBy(array, sortKey, reverse, sortMethod, sortBy) {
  605. if (!sortKey && !sortMethod && (!sortBy || Array.isArray(sortBy) && !sortBy.length)) {
  606. return array;
  607. }
  608. if (typeof reverse === 'string') {
  609. reverse = reverse === 'descending' ? -1 : 1;
  610. } else {
  611. reverse = reverse && reverse < 0 ? -1 : 1;
  612. }
  613. var getKey = sortMethod ? null : function (value, index) {
  614. if (sortBy) {
  615. if (!Array.isArray(sortBy)) {
  616. sortBy = [sortBy];
  617. }
  618. return sortBy.map(function (by) {
  619. if (typeof by === 'string') {
  620. return Object(tis_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__["getValueByPath"])(value, by);
  621. } else {
  622. return by(value, index, array);
  623. }
  624. });
  625. }
  626. if (sortKey !== '$key') {
  627. if (isObject(value) && '$value' in value) value = value.$value;
  628. }
  629. return [isObject(value) ? Object(tis_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__["getValueByPath"])(value, sortKey) : value];
  630. };
  631. var compare = function compare(a, b) {
  632. if (sortMethod) {
  633. return sortMethod(a.value, b.value);
  634. }
  635. for (var i = 0, len = a.key.length; i < len; i++) {
  636. if (a.key[i] < b.key[i]) {
  637. return -1;
  638. }
  639. if (a.key[i] > b.key[i]) {
  640. return 1;
  641. }
  642. }
  643. return 0;
  644. };
  645. return array.map(function (value, index) {
  646. return {
  647. value: value,
  648. index: index,
  649. key: getKey ? getKey(value, index) : null
  650. };
  651. }).sort(function (a, b) {
  652. var order = compare(a, b);
  653. if (!order) {
  654. // make stable https://en.wikipedia.org/wiki/Sorting_algorithm#Stability
  655. order = a.index - b.index;
  656. }
  657. return order * reverse;
  658. }).map(function (item) {
  659. return item.value;
  660. });
  661. };
  662. var getColumnById = function getColumnById(table, columnId) {
  663. var column = null;
  664. table.columns.forEach(function (item) {
  665. if (item.id === columnId) {
  666. column = item;
  667. }
  668. });
  669. return column;
  670. };
  671. var getColumnByKey = function getColumnByKey(table, columnKey) {
  672. var column = null;
  673. for (var i = 0; i < table.columns.length; i++) {
  674. var item = table.columns[i];
  675. if (item.columnKey === columnKey) {
  676. column = item;
  677. break;
  678. }
  679. }
  680. return column;
  681. };
  682. var getColumnByCell = function getColumnByCell(table, cell) {
  683. var matches = (cell.className || '').match(/el-table_[^\s]+/gm);
  684. if (matches) {
  685. return getColumnById(table, matches[0]);
  686. }
  687. return null;
  688. };
  689. var getRowIdentity = function getRowIdentity(row, rowKey) {
  690. if (!row) throw new Error('row is required when get row identity');
  691. if (typeof rowKey === 'string') {
  692. if (rowKey.indexOf('.') < 0) {
  693. return row[rowKey];
  694. }
  695. var key = rowKey.split('.');
  696. var current = row;
  697. for (var i = 0; i < key.length; i++) {
  698. current = current[key[i]];
  699. }
  700. return current;
  701. } else if (typeof rowKey === 'function') {
  702. return rowKey.call(null, row);
  703. }
  704. };
  705. var getKeysMap = function getKeysMap(array, rowKey) {
  706. var arrayMap = {};
  707. (array || []).forEach(function (row, index) {
  708. arrayMap[getRowIdentity(row, rowKey)] = { row: row, index: index };
  709. });
  710. return arrayMap;
  711. };
  712. function hasOwn(obj, key) {
  713. return Object.prototype.hasOwnProperty.call(obj, key);
  714. }
  715. function mergeOptions(defaults, config) {
  716. var options = {};
  717. var key = void 0;
  718. for (key in defaults) {
  719. options[key] = defaults[key];
  720. }
  721. for (key in config) {
  722. if (hasOwn(config, key)) {
  723. var value = config[key];
  724. if (typeof value !== 'undefined') {
  725. options[key] = value;
  726. }
  727. }
  728. }
  729. return options;
  730. }
  731. function parseWidth(width) {
  732. if (width !== undefined) {
  733. width = parseInt(width, 10);
  734. if (isNaN(width)) {
  735. width = null;
  736. }
  737. }
  738. return width;
  739. }
  740. function parseMinWidth(minWidth) {
  741. if (typeof minWidth !== 'undefined') {
  742. minWidth = parseWidth(minWidth);
  743. if (isNaN(minWidth)) {
  744. minWidth = 80;
  745. }
  746. }
  747. return minWidth;
  748. };
  749. function parseHeight(height) {
  750. if (typeof height === 'number') {
  751. return height;
  752. }
  753. if (typeof height === 'string') {
  754. if (/^\d+(?:px)?$/.test(height)) {
  755. return parseInt(height, 10);
  756. } else {
  757. return height;
  758. }
  759. }
  760. return null;
  761. }
  762. // https://github.com/reduxjs/redux/blob/master/src/compose.js
  763. function compose() {
  764. for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
  765. funcs[_key] = arguments[_key];
  766. }
  767. if (funcs.length === 0) {
  768. return function (arg) {
  769. return arg;
  770. };
  771. }
  772. if (funcs.length === 1) {
  773. return funcs[0];
  774. }
  775. return funcs.reduce(function (a, b) {
  776. return function () {
  777. return a(b.apply(undefined, arguments));
  778. };
  779. });
  780. }
  781. function toggleRowStatus(statusArr, row, newVal) {
  782. var changed = false;
  783. var index = statusArr.indexOf(row);
  784. var included = index !== -1;
  785. var addRow = function addRow() {
  786. statusArr.push(row);
  787. changed = true;
  788. };
  789. var removeRow = function removeRow() {
  790. statusArr.splice(index, 1);
  791. changed = true;
  792. };
  793. if (typeof newVal === 'boolean') {
  794. if (newVal && !included) {
  795. addRow();
  796. } else if (!newVal && included) {
  797. removeRow();
  798. }
  799. } else {
  800. if (included) {
  801. removeRow();
  802. } else {
  803. addRow();
  804. }
  805. }
  806. return changed;
  807. }
  808. function walkTreeNode(root, cb) {
  809. var childrenKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'children';
  810. var lazyKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'hasChildren';
  811. var isNil = function isNil(array) {
  812. return !(Array.isArray(array) && array.length);
  813. };
  814. function _walker(parent, children, level) {
  815. cb(parent, children, level);
  816. children.forEach(function (item) {
  817. if (item[lazyKey]) {
  818. cb(item, null, level + 1);
  819. return;
  820. }
  821. var children = item[childrenKey];
  822. if (!isNil(children)) {
  823. _walker(item, children, level + 1);
  824. }
  825. });
  826. }
  827. root.forEach(function (item) {
  828. if (item[lazyKey]) {
  829. cb(item, null, 0);
  830. return;
  831. }
  832. var children = item[childrenKey];
  833. if (!isNil(children)) {
  834. _walker(item, children, 0);
  835. }
  836. });
  837. }
  838. /***/ }),
  839. /***/ 517:
  840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  841. "use strict";
  842. // ESM COMPAT FLAG
  843. __webpack_require__.r(__webpack_exports__);
  844. // 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&
  845. var render = function() {
  846. var _vm = this
  847. var _h = _vm.$createElement
  848. var _c = _vm._self._c || _h
  849. return _c(
  850. "div",
  851. {
  852. staticClass: "el-table",
  853. class: [
  854. {
  855. "el-table--fit": _vm.fit,
  856. "el-table--striped": _vm.stripe,
  857. "el-table--border": _vm.border || _vm.isGroup,
  858. "el-table--hidden": _vm.isHidden,
  859. "el-table--group": _vm.isGroup,
  860. "el-table--fluid-height": _vm.maxHeight,
  861. "el-table--scrollable-x": _vm.layout.scrollX,
  862. "el-table--scrollable-y": _vm.layout.scrollY,
  863. "el-table--enable-row-hover": !_vm.store.states.isComplex,
  864. "el-table--enable-row-transition":
  865. (_vm.store.states.data || []).length !== 0 &&
  866. (_vm.store.states.data || []).length < 100
  867. },
  868. _vm.tableSize ? "el-table--" + _vm.tableSize : ""
  869. ],
  870. on: {
  871. mouseleave: function($event) {
  872. _vm.handleMouseLeave($event)
  873. }
  874. }
  875. },
  876. [
  877. _c(
  878. "div",
  879. { ref: "hiddenColumns", staticClass: "hidden-columns" },
  880. [_vm._t("default")],
  881. 2
  882. ),
  883. _vm.showHeader
  884. ? _c(
  885. "div",
  886. {
  887. directives: [
  888. {
  889. name: "mousewheel",
  890. rawName: "v-mousewheel",
  891. value: _vm.handleHeaderFooterMousewheel,
  892. expression: "handleHeaderFooterMousewheel"
  893. }
  894. ],
  895. ref: "headerWrapper",
  896. staticClass: "el-table__header-wrapper"
  897. },
  898. [
  899. _c("table-header", {
  900. ref: "tableHeader",
  901. style: {
  902. width: _vm.layout.bodyWidth ? _vm.layout.bodyWidth + "px" : ""
  903. },
  904. attrs: {
  905. store: _vm.store,
  906. border: _vm.border,
  907. "default-sort": _vm.defaultSort
  908. }
  909. })
  910. ],
  911. 1
  912. )
  913. : _vm._e(),
  914. _c(
  915. "div",
  916. {
  917. ref: "bodyWrapper",
  918. staticClass: "el-table__body-wrapper",
  919. class: [
  920. _vm.layout.scrollX
  921. ? "is-scrolling-" + _vm.scrollPosition
  922. : "is-scrolling-none"
  923. ],
  924. style: [_vm.bodyHeight]
  925. },
  926. [
  927. _c("table-body", {
  928. style: {
  929. width: _vm.bodyWidth
  930. },
  931. attrs: {
  932. context: _vm.context,
  933. store: _vm.store,
  934. stripe: _vm.stripe,
  935. "row-class-name": _vm.rowClassName,
  936. "row-style": _vm.rowStyle,
  937. highlight: _vm.highlightCurrentRow
  938. }
  939. }),
  940. !_vm.data || _vm.data.length === 0
  941. ? _c(
  942. "div",
  943. {
  944. ref: "emptyBlock",
  945. staticClass: "el-table__empty-block",
  946. style: _vm.emptyBlockStyle
  947. },
  948. [
  949. _c(
  950. "span",
  951. { staticClass: "el-table__empty-text" },
  952. [
  953. _vm._t("empty", [
  954. _vm._v(
  955. _vm._s(_vm.emptyText || _vm.t("el.table.emptyText"))
  956. )
  957. ])
  958. ],
  959. 2
  960. )
  961. ]
  962. )
  963. : _vm._e(),
  964. _vm.$slots.append
  965. ? _c(
  966. "div",
  967. {
  968. ref: "appendWrapper",
  969. staticClass: "el-table__append-wrapper"
  970. },
  971. [_vm._t("append")],
  972. 2
  973. )
  974. : _vm._e()
  975. ],
  976. 1
  977. ),
  978. _vm.showSummary
  979. ? _c(
  980. "div",
  981. {
  982. directives: [
  983. {
  984. name: "show",
  985. rawName: "v-show",
  986. value: _vm.data && _vm.data.length > 0,
  987. expression: "data && data.length > 0"
  988. },
  989. {
  990. name: "mousewheel",
  991. rawName: "v-mousewheel",
  992. value: _vm.handleHeaderFooterMousewheel,
  993. expression: "handleHeaderFooterMousewheel"
  994. }
  995. ],
  996. ref: "footerWrapper",
  997. staticClass: "el-table__footer-wrapper"
  998. },
  999. [
  1000. _c("table-footer", {
  1001. style: {
  1002. width: _vm.layout.bodyWidth ? _vm.layout.bodyWidth + "px" : ""
  1003. },
  1004. attrs: {
  1005. store: _vm.store,
  1006. border: _vm.border,
  1007. "sum-text": _vm.sumText || _vm.t("el.table.sumText"),
  1008. "summary-method": _vm.summaryMethod,
  1009. "default-sort": _vm.defaultSort
  1010. }
  1011. })
  1012. ],
  1013. 1
  1014. )
  1015. : _vm._e(),
  1016. _vm.fixedColumns.length > 0
  1017. ? _c(
  1018. "div",
  1019. {
  1020. directives: [
  1021. {
  1022. name: "mousewheel",
  1023. rawName: "v-mousewheel",
  1024. value: _vm.handleFixedMousewheel,
  1025. expression: "handleFixedMousewheel"
  1026. }
  1027. ],
  1028. ref: "fixedWrapper",
  1029. staticClass: "el-table__fixed",
  1030. style: [
  1031. {
  1032. width: _vm.layout.fixedWidth
  1033. ? _vm.layout.fixedWidth + "px"
  1034. : ""
  1035. },
  1036. _vm.fixedHeight
  1037. ]
  1038. },
  1039. [
  1040. _vm.showHeader
  1041. ? _c(
  1042. "div",
  1043. {
  1044. ref: "fixedHeaderWrapper",
  1045. staticClass: "el-table__fixed-header-wrapper"
  1046. },
  1047. [
  1048. _c("table-header", {
  1049. ref: "fixedTableHeader",
  1050. style: {
  1051. width: _vm.bodyWidth
  1052. },
  1053. attrs: {
  1054. fixed: "left",
  1055. border: _vm.border,
  1056. store: _vm.store
  1057. }
  1058. })
  1059. ],
  1060. 1
  1061. )
  1062. : _vm._e(),
  1063. _c(
  1064. "div",
  1065. {
  1066. ref: "fixedBodyWrapper",
  1067. staticClass: "el-table__fixed-body-wrapper",
  1068. style: [
  1069. {
  1070. top: _vm.layout.headerHeight + "px"
  1071. },
  1072. _vm.fixedBodyHeight
  1073. ]
  1074. },
  1075. [
  1076. _c("table-body", {
  1077. style: {
  1078. width: _vm.bodyWidth
  1079. },
  1080. attrs: {
  1081. fixed: "left",
  1082. store: _vm.store,
  1083. stripe: _vm.stripe,
  1084. highlight: _vm.highlightCurrentRow,
  1085. "row-class-name": _vm.rowClassName,
  1086. "row-style": _vm.rowStyle
  1087. }
  1088. }),
  1089. _vm.$slots.append
  1090. ? _c("div", {
  1091. staticClass: "el-table__append-gutter",
  1092. style: { height: _vm.layout.appendHeight + "px" }
  1093. })
  1094. : _vm._e()
  1095. ],
  1096. 1
  1097. ),
  1098. _vm.showSummary
  1099. ? _c(
  1100. "div",
  1101. {
  1102. directives: [
  1103. {
  1104. name: "show",
  1105. rawName: "v-show",
  1106. value: _vm.data && _vm.data.length > 0,
  1107. expression: "data && data.length > 0"
  1108. }
  1109. ],
  1110. ref: "fixedFooterWrapper",
  1111. staticClass: "el-table__fixed-footer-wrapper"
  1112. },
  1113. [
  1114. _c("table-footer", {
  1115. style: {
  1116. width: _vm.bodyWidth
  1117. },
  1118. attrs: {
  1119. fixed: "left",
  1120. border: _vm.border,
  1121. "sum-text": _vm.sumText || _vm.t("el.table.sumText"),
  1122. "summary-method": _vm.summaryMethod,
  1123. store: _vm.store
  1124. }
  1125. })
  1126. ],
  1127. 1
  1128. )
  1129. : _vm._e()
  1130. ]
  1131. )
  1132. : _vm._e(),
  1133. _vm.rightFixedColumns.length > 0
  1134. ? _c(
  1135. "div",
  1136. {
  1137. directives: [
  1138. {
  1139. name: "mousewheel",
  1140. rawName: "v-mousewheel",
  1141. value: _vm.handleFixedMousewheel,
  1142. expression: "handleFixedMousewheel"
  1143. }
  1144. ],
  1145. ref: "rightFixedWrapper",
  1146. staticClass: "el-table__fixed-right",
  1147. style: [
  1148. {
  1149. width: _vm.layout.rightFixedWidth
  1150. ? _vm.layout.rightFixedWidth + "px"
  1151. : "",
  1152. right: _vm.layout.scrollY
  1153. ? (_vm.border
  1154. ? _vm.layout.gutterWidth
  1155. : _vm.layout.gutterWidth || 0) + "px"
  1156. : ""
  1157. },
  1158. _vm.fixedHeight
  1159. ]
  1160. },
  1161. [
  1162. _vm.showHeader
  1163. ? _c(
  1164. "div",
  1165. {
  1166. ref: "rightFixedHeaderWrapper",
  1167. staticClass: "el-table__fixed-header-wrapper"
  1168. },
  1169. [
  1170. _c("table-header", {
  1171. ref: "rightFixedTableHeader",
  1172. style: {
  1173. width: _vm.bodyWidth
  1174. },
  1175. attrs: {
  1176. fixed: "right",
  1177. border: _vm.border,
  1178. store: _vm.store
  1179. }
  1180. })
  1181. ],
  1182. 1
  1183. )
  1184. : _vm._e(),
  1185. _c(
  1186. "div",
  1187. {
  1188. ref: "rightFixedBodyWrapper",
  1189. staticClass: "el-table__fixed-body-wrapper",
  1190. style: [
  1191. {
  1192. top: _vm.layout.headerHeight + "px"
  1193. },
  1194. _vm.fixedBodyHeight
  1195. ]
  1196. },
  1197. [
  1198. _c("table-body", {
  1199. style: {
  1200. width: _vm.bodyWidth
  1201. },
  1202. attrs: {
  1203. fixed: "right",
  1204. store: _vm.store,
  1205. stripe: _vm.stripe,
  1206. "row-class-name": _vm.rowClassName,
  1207. "row-style": _vm.rowStyle,
  1208. highlight: _vm.highlightCurrentRow
  1209. }
  1210. }),
  1211. _vm.$slots.append
  1212. ? _c("div", {
  1213. staticClass: "el-table__append-gutter",
  1214. style: { height: _vm.layout.appendHeight + "px" }
  1215. })
  1216. : _vm._e()
  1217. ],
  1218. 1
  1219. ),
  1220. _vm.showSummary
  1221. ? _c(
  1222. "div",
  1223. {
  1224. directives: [
  1225. {
  1226. name: "show",
  1227. rawName: "v-show",
  1228. value: _vm.data && _vm.data.length > 0,
  1229. expression: "data && data.length > 0"
  1230. }
  1231. ],
  1232. ref: "rightFixedFooterWrapper",
  1233. staticClass: "el-table__fixed-footer-wrapper"
  1234. },
  1235. [
  1236. _c("table-footer", {
  1237. style: {
  1238. width: _vm.bodyWidth
  1239. },
  1240. attrs: {
  1241. fixed: "right",
  1242. border: _vm.border,
  1243. "sum-text": _vm.sumText || _vm.t("el.table.sumText"),
  1244. "summary-method": _vm.summaryMethod,
  1245. store: _vm.store
  1246. }
  1247. })
  1248. ],
  1249. 1
  1250. )
  1251. : _vm._e()
  1252. ]
  1253. )
  1254. : _vm._e(),
  1255. _vm.rightFixedColumns.length > 0
  1256. ? _c("div", {
  1257. ref: "rightFixedPatch",
  1258. staticClass: "el-table__fixed-right-patch",
  1259. style: {
  1260. width: _vm.layout.scrollY ? _vm.layout.gutterWidth + "px" : "0",
  1261. height: _vm.layout.headerHeight + "px"
  1262. }
  1263. })
  1264. : _vm._e(),
  1265. _c("div", {
  1266. directives: [
  1267. {
  1268. name: "show",
  1269. rawName: "v-show",
  1270. value: _vm.resizeProxyVisible,
  1271. expression: "resizeProxyVisible"
  1272. }
  1273. ],
  1274. ref: "resizeProxy",
  1275. staticClass: "el-table__column-resize-proxy"
  1276. })
  1277. ]
  1278. )
  1279. }
  1280. var staticRenderFns = []
  1281. render._withStripped = true
  1282. // CONCATENATED MODULE: ./packages/table/src/table.vue?vue&type=template&id=493fe34e&
  1283. // EXTERNAL MODULE: ./packages/checkbox/index.js + 5 modules
  1284. var packages_checkbox = __webpack_require__(68);
  1285. // EXTERNAL MODULE: external "throttle-debounce"
  1286. var external_throttle_debounce_ = __webpack_require__(193);
  1287. // EXTERNAL MODULE: external "tis-ui/lib/utils/resize-event"
  1288. var resize_event_ = __webpack_require__(44);
  1289. // EXTERNAL MODULE: external "normalize-wheel"
  1290. var external_normalize_wheel_ = __webpack_require__(245);
  1291. var external_normalize_wheel_default = /*#__PURE__*/__webpack_require__.n(external_normalize_wheel_);
  1292. // CONCATENATED MODULE: ./src/directives/mousewheel.js
  1293. var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  1294. var mousewheel_mousewheel = function mousewheel(element, callback) {
  1295. if (element && element.addEventListener) {
  1296. element.addEventListener(isFirefox ? 'DOMMouseScroll' : 'mousewheel', function (event) {
  1297. var normalized = external_normalize_wheel_default()(event);
  1298. callback && callback.apply(this, [event, normalized]);
  1299. });
  1300. }
  1301. };
  1302. /* harmony default export */ var directives_mousewheel = ({
  1303. bind: function bind(el, binding) {
  1304. mousewheel_mousewheel(el, binding.value);
  1305. }
  1306. });
  1307. // EXTERNAL MODULE: external "tis-ui/lib/mixins/locale"
  1308. var locale_ = __webpack_require__(38);
  1309. var locale_default = /*#__PURE__*/__webpack_require__.n(locale_);
  1310. // EXTERNAL MODULE: external "tis-ui/lib/mixins/migrating"
  1311. var migrating_ = __webpack_require__(36);
  1312. var migrating_default = /*#__PURE__*/__webpack_require__.n(migrating_);
  1313. // EXTERNAL MODULE: external "vue"
  1314. var external_vue_ = __webpack_require__(4);
  1315. var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
  1316. // EXTERNAL MODULE: external "tis-ui/lib/utils/merge"
  1317. var merge_ = __webpack_require__(33);
  1318. var merge_default = /*#__PURE__*/__webpack_require__.n(merge_);
  1319. // EXTERNAL MODULE: ./packages/table/src/util.js
  1320. var util = __webpack_require__(50);
  1321. // CONCATENATED MODULE: ./packages/table/src/store/expand.js
  1322. /* harmony default export */ var expand = ({
  1323. data: function data() {
  1324. return {
  1325. states: {
  1326. defaultExpandAll: false,
  1327. expandRows: []
  1328. }
  1329. };
  1330. },
  1331. methods: {
  1332. updateExpandRows: function updateExpandRows() {
  1333. var _states = this.states,
  1334. _states$data = _states.data,
  1335. data = _states$data === undefined ? [] : _states$data,
  1336. rowKey = _states.rowKey,
  1337. defaultExpandAll = _states.defaultExpandAll,
  1338. expandRows = _states.expandRows;
  1339. if (defaultExpandAll) {
  1340. this.states.expandRows = data.slice();
  1341. } else if (rowKey) {
  1342. // TODO:这里的代码可以优化
  1343. var expandRowsMap = Object(util["f" /* getKeysMap */])(expandRows, rowKey);
  1344. this.states.expandRows = data.reduce(function (prev, row) {
  1345. var rowId = Object(util["g" /* getRowIdentity */])(row, rowKey);
  1346. var rowInfo = expandRowsMap[rowId];
  1347. if (rowInfo) {
  1348. prev.push(row);
  1349. }
  1350. return prev;
  1351. }, []);
  1352. } else {
  1353. this.states.expandRows = [];
  1354. }
  1355. },
  1356. toggleRowExpansion: function toggleRowExpansion(row, expanded) {
  1357. var changed = Object(util["m" /* toggleRowStatus */])(this.states.expandRows, row, expanded);
  1358. if (changed) {
  1359. this.table.$emit('expand-change', row, this.states.expandRows.slice());
  1360. this.scheduleLayout();
  1361. }
  1362. },
  1363. setExpandRowKeys: function setExpandRowKeys(rowKeys) {
  1364. this.assertRowKey();
  1365. // TODO:这里的代码可以优化
  1366. var _states2 = this.states,
  1367. data = _states2.data,
  1368. rowKey = _states2.rowKey;
  1369. var keysMap = Object(util["f" /* getKeysMap */])(data, rowKey);
  1370. this.states.expandRows = rowKeys.reduce(function (prev, cur) {
  1371. var info = keysMap[cur];
  1372. if (info) {
  1373. prev.push(info.row);
  1374. }
  1375. return prev;
  1376. }, []);
  1377. },
  1378. isRowExpanded: function isRowExpanded(row) {
  1379. var _states3 = this.states,
  1380. _states3$expandRows = _states3.expandRows,
  1381. expandRows = _states3$expandRows === undefined ? [] : _states3$expandRows,
  1382. rowKey = _states3.rowKey;
  1383. if (rowKey) {
  1384. var expandMap = Object(util["f" /* getKeysMap */])(expandRows, rowKey);
  1385. return !!expandMap[Object(util["g" /* getRowIdentity */])(row, rowKey)];
  1386. }
  1387. return expandRows.indexOf(row) !== -1;
  1388. }
  1389. }
  1390. });
  1391. // EXTERNAL MODULE: external "tis-ui/lib/utils/util"
  1392. var util_ = __webpack_require__(10);
  1393. // CONCATENATED MODULE: ./packages/table/src/store/current.js
  1394. /* harmony default export */ var current = ({
  1395. data: function data() {
  1396. return {
  1397. states: {
  1398. // 不可响应的,设置 currentRowKey 时,data 不一定存在,也许无法算出正确的 currentRow
  1399. // 把该值缓存一下,当用户点击修改 currentRow 时,把该值重置为 null
  1400. _currentRowKey: null,
  1401. currentRow: null
  1402. }
  1403. };
  1404. },
  1405. methods: {
  1406. setCurrentRowKey: function setCurrentRowKey(key) {
  1407. this.assertRowKey();
  1408. this.states._currentRowKey = key;
  1409. this.setCurrentRowByKey(key);
  1410. },
  1411. restoreCurrentRowKey: function restoreCurrentRowKey() {
  1412. this.states._currentRowKey = null;
  1413. },
  1414. setCurrentRowByKey: function setCurrentRowByKey(key) {
  1415. var states = this.states;
  1416. var _states$data = states.data,
  1417. data = _states$data === undefined ? [] : _states$data,
  1418. rowKey = states.rowKey;
  1419. var currentRow = null;
  1420. if (rowKey) {
  1421. currentRow = Object(util_["arrayFind"])(data, function (item) {
  1422. return Object(util["g" /* getRowIdentity */])(item, rowKey) === key;
  1423. });
  1424. }
  1425. states.currentRow = currentRow;
  1426. },
  1427. updateCurrentRow: function updateCurrentRow(currentRow) {
  1428. var states = this.states,
  1429. table = this.table;
  1430. var oldCurrentRow = states.currentRow;
  1431. if (currentRow && currentRow !== oldCurrentRow) {
  1432. states.currentRow = currentRow;
  1433. table.$emit('current-change', currentRow, oldCurrentRow);
  1434. return;
  1435. }
  1436. if (!currentRow && oldCurrentRow) {
  1437. states.currentRow = null;
  1438. table.$emit('current-change', null, oldCurrentRow);
  1439. }
  1440. },
  1441. updateCurrentRowData: function updateCurrentRowData() {
  1442. var states = this.states,
  1443. table = this.table;
  1444. var rowKey = states.rowKey,
  1445. _currentRowKey = states._currentRowKey;
  1446. // data 为 null 时,解构时的默认值会被忽略
  1447. var data = states.data || [];
  1448. var oldCurrentRow = states.currentRow;
  1449. // 当 currentRow 不在 data 中时尝试更新数据
  1450. if (data.indexOf(oldCurrentRow) === -1 && oldCurrentRow) {
  1451. if (rowKey) {
  1452. var currentRowKey = Object(util["g" /* getRowIdentity */])(oldCurrentRow, rowKey);
  1453. this.setCurrentRowByKey(currentRowKey);
  1454. } else {
  1455. states.currentRow = null;
  1456. }
  1457. if (states.currentRow === null) {
  1458. table.$emit('current-change', null, oldCurrentRow);
  1459. }
  1460. } else if (_currentRowKey) {
  1461. // 把初始时下设置的 rowKey 转化成 rowData
  1462. this.setCurrentRowByKey(_currentRowKey);
  1463. this.restoreCurrentRowKey();
  1464. }
  1465. }
  1466. }
  1467. });
  1468. // CONCATENATED MODULE: ./packages/table/src/store/tree.js
  1469. 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; };
  1470. /* harmony default export */ var tree = ({
  1471. data: function data() {
  1472. return {
  1473. states: {
  1474. // defaultExpandAll 存在于 expand.js 中,这里不重复添加
  1475. // 在展开行中,expandRowKeys 会被转化成 expandRows,expandRowKeys 这个属性只是记录了 TreeTable 行的展开
  1476. // TODO: 拆分为独立的 TreeTable,统一用法
  1477. expandRowKeys: [],
  1478. treeData: {},
  1479. indent: 16,
  1480. lazy: false,
  1481. lazyTreeNodeMap: {},
  1482. lazyColumnIdentifier: 'hasChildren',
  1483. childrenColumnName: 'children'
  1484. }
  1485. };
  1486. },
  1487. computed: {
  1488. // 嵌入型的数据,watch 无法是检测到变化 https://github.com/ElemeFE/element/issues/14998
  1489. // TODO: 使用 computed 解决该问题,是否会造成性能问题?
  1490. // @return { id: { level, children } }
  1491. normalizedData: function normalizedData() {
  1492. if (!this.states.rowKey) return {};
  1493. var data = this.states.data || [];
  1494. return this.normalize(data);
  1495. },
  1496. // @return { id: { children } }
  1497. // 针对懒加载的情形,不处理嵌套数据
  1498. normalizedLazyNode: function normalizedLazyNode() {
  1499. var _states = this.states,
  1500. rowKey = _states.rowKey,
  1501. lazyTreeNodeMap = _states.lazyTreeNodeMap,
  1502. lazyColumnIdentifier = _states.lazyColumnIdentifier;
  1503. var keys = Object.keys(lazyTreeNodeMap);
  1504. var res = {};
  1505. if (!keys.length) return res;
  1506. keys.forEach(function (key) {
  1507. if (lazyTreeNodeMap[key].length) {
  1508. var item = { children: [] };
  1509. lazyTreeNodeMap[key].forEach(function (row) {
  1510. var currentRowKey = Object(util["g" /* getRowIdentity */])(row, rowKey);
  1511. item.children.push(currentRowKey);
  1512. if (row[lazyColumnIdentifier] && !res[currentRowKey]) {
  1513. res[currentRowKey] = { children: [] };
  1514. }
  1515. });
  1516. res[key] = item;
  1517. }
  1518. });
  1519. return res;
  1520. }
  1521. },
  1522. watch: {
  1523. normalizedData: 'updateTreeData',
  1524. normalizedLazyNode: 'updateTreeData'
  1525. },
  1526. methods: {
  1527. normalize: function normalize(data) {
  1528. var _states2 = this.states,
  1529. childrenColumnName = _states2.childrenColumnName,
  1530. lazyColumnIdentifier = _states2.lazyColumnIdentifier,
  1531. rowKey = _states2.rowKey,
  1532. lazy = _states2.lazy;
  1533. var res = {};
  1534. Object(util["n" /* walkTreeNode */])(data, function (parent, children, level) {
  1535. var parentId = Object(util["g" /* getRowIdentity */])(parent, rowKey);
  1536. if (Array.isArray(children)) {
  1537. res[parentId] = {
  1538. children: children.map(function (row) {
  1539. return Object(util["g" /* getRowIdentity */])(row, rowKey);
  1540. }),
  1541. level: level
  1542. };
  1543. } else if (lazy) {
  1544. // 当 children 不存在且 lazy 为 true,该节点即为懒加载的节点
  1545. res[parentId] = {
  1546. children: [],
  1547. lazy: true,
  1548. level: level
  1549. };
  1550. }
  1551. }, childrenColumnName, lazyColumnIdentifier);
  1552. return res;
  1553. },
  1554. updateTreeData: function updateTreeData() {
  1555. var nested = this.normalizedData;
  1556. var normalizedLazyNode = this.normalizedLazyNode;
  1557. var keys = Object.keys(nested);
  1558. var newTreeData = {};
  1559. if (keys.length) {
  1560. var _states3 = this.states,
  1561. oldTreeData = _states3.treeData,
  1562. defaultExpandAll = _states3.defaultExpandAll,
  1563. expandRowKeys = _states3.expandRowKeys,
  1564. lazy = _states3.lazy;
  1565. var rootLazyRowKeys = [];
  1566. var getExpanded = function getExpanded(oldValue, key) {
  1567. var included = defaultExpandAll || expandRowKeys && expandRowKeys.indexOf(key) !== -1;
  1568. return !!(oldValue && oldValue.expanded || included);
  1569. };
  1570. // 合并 expanded 与 display,确保数据刷新后,状态不变
  1571. keys.forEach(function (key) {
  1572. var oldValue = oldTreeData[key];
  1573. var newValue = _extends({}, nested[key]);
  1574. newValue.expanded = getExpanded(oldValue, key);
  1575. if (newValue.lazy) {
  1576. var _ref = oldValue || {},
  1577. _ref$loaded = _ref.loaded,
  1578. loaded = _ref$loaded === undefined ? false : _ref$loaded,
  1579. _ref$loading = _ref.loading,
  1580. loading = _ref$loading === undefined ? false : _ref$loading;
  1581. newValue.loaded = !!loaded;
  1582. newValue.loading = !!loading;
  1583. rootLazyRowKeys.push(key);
  1584. }
  1585. newTreeData[key] = newValue;
  1586. });
  1587. // 根据懒加载数据更新 treeData
  1588. var lazyKeys = Object.keys(normalizedLazyNode);
  1589. if (lazy && lazyKeys.length && rootLazyRowKeys.length) {
  1590. lazyKeys.forEach(function (key) {
  1591. var oldValue = oldTreeData[key];
  1592. var lazyNodeChildren = normalizedLazyNode[key].children;
  1593. if (rootLazyRowKeys.indexOf(key) !== -1) {
  1594. // 懒加载的 root 节点,更新一下原有的数据,原来的 children 一定是空数组
  1595. if (newTreeData[key].children.length !== 0) {
  1596. throw new Error('[ElTable]children must be an empty array.');
  1597. }
  1598. newTreeData[key].children = lazyNodeChildren;
  1599. } else {
  1600. var _ref2 = oldValue || {},
  1601. _ref2$loaded = _ref2.loaded,
  1602. loaded = _ref2$loaded === undefined ? false : _ref2$loaded,
  1603. _ref2$loading = _ref2.loading,
  1604. loading = _ref2$loading === undefined ? false : _ref2$loading;
  1605. newTreeData[key] = {
  1606. lazy: true,
  1607. loaded: !!loaded,
  1608. loading: !!loading,
  1609. expanded: getExpanded(oldValue, key),
  1610. children: lazyNodeChildren,
  1611. level: ''
  1612. };
  1613. }
  1614. });
  1615. }
  1616. }
  1617. this.states.treeData = newTreeData;
  1618. this.updateTableScrollY();
  1619. },
  1620. updateTreeExpandKeys: function updateTreeExpandKeys(value) {
  1621. this.states.expandRowKeys = value;
  1622. this.updateTreeData();
  1623. },
  1624. toggleTreeExpansion: function toggleTreeExpansion(row, expanded) {
  1625. this.assertRowKey();
  1626. var _states4 = this.states,
  1627. rowKey = _states4.rowKey,
  1628. treeData = _states4.treeData;
  1629. var id = Object(util["g" /* getRowIdentity */])(row, rowKey);
  1630. var data = id && treeData[id];
  1631. if (id && data && 'expanded' in data) {
  1632. var oldExpanded = data.expanded;
  1633. expanded = typeof expanded === 'undefined' ? !data.expanded : expanded;
  1634. treeData[id].expanded = expanded;
  1635. if (oldExpanded !== expanded) {
  1636. this.table.$emit('expand-change', row, expanded);
  1637. }
  1638. this.updateTableScrollY();
  1639. }
  1640. },
  1641. loadOrToggle: function loadOrToggle(row) {
  1642. this.assertRowKey();
  1643. var _states5 = this.states,
  1644. lazy = _states5.lazy,
  1645. treeData = _states5.treeData,
  1646. rowKey = _states5.rowKey;
  1647. var id = Object(util["g" /* getRowIdentity */])(row, rowKey);
  1648. var data = treeData[id];
  1649. if (lazy && data && 'loaded' in data && !data.loaded) {
  1650. this.loadData(row, id, data);
  1651. } else {
  1652. this.toggleTreeExpansion(row);
  1653. }
  1654. },
  1655. loadData: function loadData(row, key, treeNode) {
  1656. var _this = this;
  1657. var load = this.table.load;
  1658. var _states6 = this.states,
  1659. lazyTreeNodeMap = _states6.lazyTreeNodeMap,
  1660. treeData = _states6.treeData;
  1661. if (load && !treeData[key].loaded) {
  1662. treeData[key].loading = true;
  1663. load(row, treeNode, function (data) {
  1664. if (!Array.isArray(data)) {
  1665. throw new Error('[ElTable] data must be an array');
  1666. }
  1667. treeData[key].loading = false;
  1668. treeData[key].loaded = true;
  1669. treeData[key].expanded = true;
  1670. if (data.length) {
  1671. _this.$set(lazyTreeNodeMap, key, data);
  1672. }
  1673. _this.table.$emit('expand-change', row, true);
  1674. });
  1675. }
  1676. }
  1677. }
  1678. });
  1679. // CONCATENATED MODULE: ./packages/table/src/store/watcher.js
  1680. var watcher_sortData = function sortData(data, states) {
  1681. var sortingColumn = states.sortingColumn;
  1682. if (!sortingColumn || typeof sortingColumn.sortable === 'string') {
  1683. return data;
  1684. }
  1685. return Object(util["i" /* orderBy */])(data, states.sortProp, states.sortOrder, sortingColumn.sortMethod, sortingColumn.sortBy);
  1686. };
  1687. var doFlattenColumns = function doFlattenColumns(columns) {
  1688. var result = [];
  1689. columns.forEach(function (column) {
  1690. if (column.children) {
  1691. result.push.apply(result, doFlattenColumns(column.children));
  1692. } else {
  1693. result.push(column);
  1694. }
  1695. });
  1696. return result;
  1697. };
  1698. /* harmony default export */ var watcher = (external_vue_default.a.extend({
  1699. data: function data() {
  1700. return {
  1701. states: {
  1702. // 3.0 版本后要求必须设置该属性
  1703. rowKey: null,
  1704. // 渲染的数据来源,是对 table 中的 data 过滤排序后的结果
  1705. data: [],
  1706. // 是否包含固定列
  1707. isComplex: false,
  1708. // 列
  1709. _columns: [], // 不可响应的
  1710. originColumns: [],
  1711. columns: [],
  1712. fixedColumns: [],
  1713. rightFixedColumns: [],
  1714. leafColumns: [],
  1715. fixedLeafColumns: [],
  1716. rightFixedLeafColumns: [],
  1717. leafColumnsLength: 0,
  1718. fixedLeafColumnsLength: 0,
  1719. rightFixedLeafColumnsLength: 0,
  1720. // 选择
  1721. isAllSelected: false,
  1722. selection: [],
  1723. reserveSelection: false,
  1724. selectOnIndeterminate: false,
  1725. selectable: null,
  1726. // 过滤
  1727. filters: {}, // 不可响应的
  1728. filteredData: null,
  1729. // 排序
  1730. sortingColumn: null,
  1731. sortProp: null,
  1732. sortOrder: null,
  1733. hoverRow: null
  1734. }
  1735. };
  1736. },
  1737. mixins: [expand, current, tree],
  1738. methods: {
  1739. // 检查 rowKey 是否存在
  1740. assertRowKey: function assertRowKey() {
  1741. var rowKey = this.states.rowKey;
  1742. if (!rowKey) throw new Error('[ElTable] prop row-key is required');
  1743. },
  1744. // 更新列
  1745. updateColumns: function updateColumns() {
  1746. var states = this.states;
  1747. var _columns = states._columns || [];
  1748. states.fixedColumns = _columns.filter(function (column) {
  1749. return column.fixed === true || column.fixed === 'left';
  1750. });
  1751. states.rightFixedColumns = _columns.filter(function (column) {
  1752. return column.fixed === 'right';
  1753. });
  1754. if (states.fixedColumns.length > 0 && _columns[0] && _columns[0].type === 'selection' && !_columns[0].fixed) {
  1755. _columns[0].fixed = true;
  1756. states.fixedColumns.unshift(_columns[0]);
  1757. }
  1758. var notFixedColumns = _columns.filter(function (column) {
  1759. return !column.fixed;
  1760. });
  1761. states.originColumns = [].concat(states.fixedColumns).concat(notFixedColumns).concat(states.rightFixedColumns);
  1762. var leafColumns = doFlattenColumns(notFixedColumns);
  1763. var fixedLeafColumns = doFlattenColumns(states.fixedColumns);
  1764. var rightFixedLeafColumns = doFlattenColumns(states.rightFixedColumns);
  1765. states.leafColumnsLength = leafColumns.length;
  1766. states.fixedLeafColumnsLength = fixedLeafColumns.length;
  1767. states.rightFixedLeafColumnsLength = rightFixedLeafColumns.length;
  1768. states.columns = [].concat(fixedLeafColumns).concat(leafColumns).concat(rightFixedLeafColumns);
  1769. states.isComplex = states.fixedColumns.length > 0 || states.rightFixedColumns.length > 0;
  1770. },
  1771. // 更新 DOM
  1772. scheduleLayout: function scheduleLayout(needUpdateColumns) {
  1773. if (needUpdateColumns) {
  1774. this.updateColumns();
  1775. }
  1776. this.table.debouncedUpdateLayout();
  1777. },
  1778. // 选择
  1779. isSelected: function isSelected(row) {
  1780. var _states$selection = this.states.selection,
  1781. selection = _states$selection === undefined ? [] : _states$selection;
  1782. return selection.indexOf(row) > -1;
  1783. },
  1784. clearSelection: function clearSelection() {
  1785. var states = this.states;
  1786. states.isAllSelected = false;
  1787. var oldSelection = states.selection;
  1788. if (oldSelection.length) {
  1789. states.selection = [];
  1790. this.table.$emit('selection-change', []);
  1791. }
  1792. },
  1793. cleanSelection: function cleanSelection() {
  1794. var states = this.states;
  1795. var data = states.data,
  1796. rowKey = states.rowKey,
  1797. selection = states.selection;
  1798. var deleted = void 0;
  1799. if (rowKey) {
  1800. deleted = [];
  1801. var selectedMap = Object(util["f" /* getKeysMap */])(selection, rowKey);
  1802. var dataMap = Object(util["f" /* getKeysMap */])(data, rowKey);
  1803. for (var key in selectedMap) {
  1804. if (selectedMap.hasOwnProperty(key) && !dataMap[key]) {
  1805. deleted.push(selectedMap[key].row);
  1806. }
  1807. }
  1808. } else {
  1809. deleted = selection.filter(function (item) {
  1810. return data.indexOf(item) === -1;
  1811. });
  1812. }
  1813. if (deleted.length) {
  1814. var newSelection = selection.filter(function (item) {
  1815. return deleted.indexOf(item) === -1;
  1816. });
  1817. states.selection = newSelection;
  1818. this.table.$emit('selection-change', newSelection.slice());
  1819. }
  1820. },
  1821. toggleRowSelection: function toggleRowSelection(row, selected) {
  1822. var emitChange = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  1823. var changed = Object(util["m" /* toggleRowStatus */])(this.states.selection, row, selected);
  1824. if (changed) {
  1825. var newSelection = (this.states.selection || []).slice();
  1826. // 调用 API 修改选中值,不触发 select 事件
  1827. if (emitChange) {
  1828. this.table.$emit('select', newSelection, row);
  1829. }
  1830. this.table.$emit('selection-change', newSelection);
  1831. }
  1832. },
  1833. _toggleAllSelection: function _toggleAllSelection() {
  1834. var states = this.states;
  1835. var _states$data = states.data,
  1836. data = _states$data === undefined ? [] : _states$data,
  1837. selection = states.selection;
  1838. // when only some rows are selected (but not all), select or deselect all of them
  1839. // depending on the value of selectOnIndeterminate
  1840. var value = states.selectOnIndeterminate ? !states.isAllSelected : !(states.isAllSelected || selection.length);
  1841. states.isAllSelected = value;
  1842. var selectionChanged = false;
  1843. data.forEach(function (row, index) {
  1844. if (states.selectable) {
  1845. if (states.selectable.call(null, row, index) && Object(util["m" /* toggleRowStatus */])(selection, row, value)) {
  1846. selectionChanged = true;
  1847. }
  1848. } else {
  1849. if (Object(util["m" /* toggleRowStatus */])(selection, row, value)) {
  1850. selectionChanged = true;
  1851. }
  1852. }
  1853. });
  1854. if (selectionChanged) {
  1855. this.table.$emit('selection-change', selection ? selection.slice() : []);
  1856. }
  1857. this.table.$emit('select-all', selection);
  1858. },
  1859. updateSelectionByRowKey: function updateSelectionByRowKey() {
  1860. var states = this.states;
  1861. var selection = states.selection,
  1862. rowKey = states.rowKey,
  1863. data = states.data;
  1864. var selectedMap = Object(util["f" /* getKeysMap */])(selection, rowKey);
  1865. data.forEach(function (row) {
  1866. var rowId = Object(util["g" /* getRowIdentity */])(row, rowKey);
  1867. var rowInfo = selectedMap[rowId];
  1868. if (rowInfo) {
  1869. selection[rowInfo.index] = row;
  1870. }
  1871. });
  1872. },
  1873. updateAllSelected: function updateAllSelected() {
  1874. var states = this.states;
  1875. var selection = states.selection,
  1876. rowKey = states.rowKey,
  1877. selectable = states.selectable;
  1878. // data 为 null 时,解构时的默认值会被忽略
  1879. var data = states.data || [];
  1880. if (data.length === 0) {
  1881. states.isAllSelected = false;
  1882. return;
  1883. }
  1884. var selectedMap = void 0;
  1885. if (rowKey) {
  1886. selectedMap = Object(util["f" /* getKeysMap */])(selection, rowKey);
  1887. }
  1888. var isSelected = function isSelected(row) {
  1889. if (selectedMap) {
  1890. return !!selectedMap[Object(util["g" /* getRowIdentity */])(row, rowKey)];
  1891. } else {
  1892. return selection.indexOf(row) !== -1;
  1893. }
  1894. };
  1895. var isAllSelected = true;
  1896. var selectedCount = 0;
  1897. for (var i = 0, j = data.length; i < j; i++) {
  1898. var item = data[i];
  1899. var isRowSelectable = selectable && selectable.call(null, item, i);
  1900. if (!isSelected(item)) {
  1901. if (!selectable || isRowSelectable) {
  1902. isAllSelected = false;
  1903. break;
  1904. }
  1905. } else {
  1906. selectedCount++;
  1907. }
  1908. }
  1909. if (selectedCount === 0) isAllSelected = false;
  1910. states.isAllSelected = isAllSelected;
  1911. },
  1912. // 过滤与排序
  1913. updateFilters: function updateFilters(columns, values) {
  1914. if (!Array.isArray(columns)) {
  1915. columns = [columns];
  1916. }
  1917. var states = this.states;
  1918. var filters = {};
  1919. columns.forEach(function (col) {
  1920. states.filters[col.id] = values;
  1921. filters[col.columnKey || col.id] = values;
  1922. });
  1923. return filters;
  1924. },
  1925. updateSort: function updateSort(column, prop, order) {
  1926. if (this.states.sortingColumn && this.states.sortingColumn !== column) {
  1927. this.states.sortingColumn.order = null;
  1928. }
  1929. this.states.sortingColumn = column;
  1930. this.states.sortProp = prop;
  1931. this.states.sortOrder = order;
  1932. },
  1933. execFilter: function execFilter() {
  1934. var _this = this;
  1935. var states = this.states;
  1936. var _data = states._data,
  1937. filters = states.filters;
  1938. var data = _data;
  1939. Object.keys(filters).forEach(function (columnId) {
  1940. var values = states.filters[columnId];
  1941. if (!values || values.length === 0) return;
  1942. var column = Object(util["d" /* getColumnById */])(_this.states, columnId);
  1943. if (column && column.filterMethod) {
  1944. data = data.filter(function (row) {
  1945. return values.some(function (value) {
  1946. return column.filterMethod.call(null, value, row, column);
  1947. });
  1948. });
  1949. }
  1950. });
  1951. states.filteredData = data;
  1952. },
  1953. execSort: function execSort() {
  1954. var states = this.states;
  1955. states.data = watcher_sortData(states.filteredData, states);
  1956. },
  1957. // 根据 filters 与 sort 去过滤 data
  1958. execQuery: function execQuery(ignore) {
  1959. if (!(ignore && ignore.filter)) {
  1960. this.execFilter();
  1961. }
  1962. this.execSort();
  1963. },
  1964. clearFilter: function clearFilter(columnKeys) {
  1965. var states = this.states;
  1966. var _table$$refs = this.table.$refs,
  1967. tableHeader = _table$$refs.tableHeader,
  1968. fixedTableHeader = _table$$refs.fixedTableHeader,
  1969. rightFixedTableHeader = _table$$refs.rightFixedTableHeader;
  1970. var panels = {};
  1971. if (tableHeader) panels = merge_default()(panels, tableHeader.filterPanels);
  1972. if (fixedTableHeader) panels = merge_default()(panels, fixedTableHeader.filterPanels);
  1973. if (rightFixedTableHeader) panels = merge_default()(panels, rightFixedTableHeader.filterPanels);
  1974. var keys = Object.keys(panels);
  1975. if (!keys.length) return;
  1976. if (typeof columnKeys === 'string') {
  1977. columnKeys = [columnKeys];
  1978. }
  1979. if (Array.isArray(columnKeys)) {
  1980. var columns = columnKeys.map(function (key) {
  1981. return Object(util["e" /* getColumnByKey */])(states, key);
  1982. });
  1983. keys.forEach(function (key) {
  1984. var column = columns.find(function (col) {
  1985. return col.id === key;
  1986. });
  1987. if (column) {
  1988. // TODO: 优化这里的代码
  1989. panels[key].filteredValue = [];
  1990. }
  1991. });
  1992. this.commit('filterChange', {
  1993. column: columns,
  1994. values: [],
  1995. silent: true,
  1996. multi: true
  1997. });
  1998. } else {
  1999. keys.forEach(function (key) {
  2000. // TODO: 优化这里的代码
  2001. panels[key].filteredValue = [];
  2002. });
  2003. states.filters = {};
  2004. this.commit('filterChange', {
  2005. column: {},
  2006. values: [],
  2007. silent: true
  2008. });
  2009. }
  2010. },
  2011. clearSort: function clearSort() {
  2012. var states = this.states;
  2013. if (!states.sortingColumn) return;
  2014. this.updateSort(null, null, null);
  2015. this.commit('changeSortCondition', {
  2016. silent: true
  2017. });
  2018. },
  2019. // 适配层,expand-row-keys 在 Expand 与 TreeTable 中都有使用
  2020. setExpandRowKeysAdapter: function setExpandRowKeysAdapter(val) {
  2021. // 这里会触发额外的计算,但为了兼容性,暂时这么做
  2022. this.setExpandRowKeys(val);
  2023. this.updateTreeExpandKeys(val);
  2024. },
  2025. // 展开行与 TreeTable 都要使用
  2026. toggleRowExpansionAdapter: function toggleRowExpansionAdapter(row, expanded) {
  2027. var hasExpandColumn = this.states.columns.some(function (_ref) {
  2028. var type = _ref.type;
  2029. return type === 'expand';
  2030. });
  2031. if (hasExpandColumn) {
  2032. this.toggleRowExpansion(row, expanded);
  2033. } else {
  2034. this.toggleTreeExpansion(row, expanded);
  2035. }
  2036. }
  2037. }
  2038. }));
  2039. // CONCATENATED MODULE: ./packages/table/src/store/index.js
  2040. watcher.prototype.mutations = {
  2041. setData: function setData(states, data) {
  2042. var dataInstanceChanged = states._data !== data;
  2043. states._data = data;
  2044. this.execQuery();
  2045. // 数据变化,更新部分数据。
  2046. // 没有使用 computed,而是手动更新部分数据 https://github.com/vuejs/vue/issues/6660#issuecomment-331417140
  2047. this.updateCurrentRowData();
  2048. this.updateExpandRows();
  2049. if (states.reserveSelection) {
  2050. this.assertRowKey();
  2051. this.updateSelectionByRowKey();
  2052. } else {
  2053. if (dataInstanceChanged) {
  2054. this.clearSelection();
  2055. } else {
  2056. this.cleanSelection();
  2057. }
  2058. }
  2059. this.updateAllSelected();
  2060. this.updateTableScrollY();
  2061. },
  2062. insertColumn: function insertColumn(states, column, index, parent) {
  2063. var array = states._columns;
  2064. if (parent) {
  2065. array = parent.children;
  2066. if (!array) array = parent.children = [];
  2067. }
  2068. if (typeof index !== 'undefined') {
  2069. array.splice(index, 0, column);
  2070. } else {
  2071. array.push(column);
  2072. }
  2073. if (column.type === 'selection') {
  2074. states.selectable = column.selectable;
  2075. states.reserveSelection = column.reserveSelection;
  2076. }
  2077. if (this.table.$ready) {
  2078. this.updateColumns(); // hack for dynamics insert column
  2079. this.scheduleLayout();
  2080. }
  2081. },
  2082. removeColumn: function removeColumn(states, column, parent) {
  2083. var array = states._columns;
  2084. if (parent) {
  2085. array = parent.children;
  2086. if (!array) array = parent.children = [];
  2087. }
  2088. if (array) {
  2089. array.splice(array.indexOf(column), 1);
  2090. }
  2091. if (this.table.$ready) {
  2092. this.updateColumns(); // hack for dynamics remove column
  2093. this.scheduleLayout();
  2094. }
  2095. },
  2096. sort: function sort(states, options) {
  2097. var prop = options.prop,
  2098. order = options.order,
  2099. init = options.init;
  2100. if (prop) {
  2101. var column = Object(util_["arrayFind"])(states.columns, function (column) {
  2102. return column.property === prop;
  2103. });
  2104. if (column) {
  2105. column.order = order;
  2106. this.updateSort(column, prop, order);
  2107. this.commit('changeSortCondition', { init: init });
  2108. }
  2109. }
  2110. },
  2111. changeSortCondition: function changeSortCondition(states, options) {
  2112. // 修复 pr https://github.com/ElemeFE/element/pull/15012 导致的 bug
  2113. var column = states.sortingColumn,
  2114. prop = states.sortProp,
  2115. order = states.sortOrder;
  2116. if (order === null) {
  2117. states.sortingColumn = null;
  2118. states.sortProp = null;
  2119. }
  2120. var ingore = { filter: true };
  2121. this.execQuery(ingore);
  2122. if (!options || !(options.silent || options.init)) {
  2123. this.table.$emit('sort-change', {
  2124. column: column,
  2125. prop: prop,
  2126. order: order
  2127. });
  2128. }
  2129. this.updateTableScrollY();
  2130. },
  2131. filterChange: function filterChange(states, options) {
  2132. var column = options.column,
  2133. values = options.values,
  2134. silent = options.silent;
  2135. var newFilters = this.updateFilters(column, values);
  2136. this.execQuery();
  2137. if (!silent) {
  2138. this.table.$emit('filter-change', newFilters);
  2139. }
  2140. this.updateTableScrollY();
  2141. },
  2142. toggleAllSelection: function toggleAllSelection() {
  2143. this.toggleAllSelection();
  2144. },
  2145. rowSelectedChanged: function rowSelectedChanged(states, row) {
  2146. this.toggleRowSelection(row);
  2147. this.updateAllSelected();
  2148. },
  2149. setHoverRow: function setHoverRow(states, row) {
  2150. states.hoverRow = row;
  2151. },
  2152. setCurrentRow: function setCurrentRow(states, row) {
  2153. this.updateCurrentRow(row);
  2154. }
  2155. };
  2156. watcher.prototype.commit = function (name) {
  2157. var mutations = this.mutations;
  2158. if (mutations[name]) {
  2159. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  2160. args[_key - 1] = arguments[_key];
  2161. }
  2162. mutations[name].apply(this, [this.states].concat(args));
  2163. } else {
  2164. throw new Error('Action not found: ' + name);
  2165. }
  2166. };
  2167. watcher.prototype.updateTableScrollY = function () {
  2168. external_vue_default.a.nextTick(this.table.updateScrollY);
  2169. };
  2170. /* harmony default export */ var src_store = (watcher);
  2171. // EXTERNAL MODULE: external "throttle-debounce/debounce"
  2172. var debounce_ = __webpack_require__(62);
  2173. var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce_);
  2174. // CONCATENATED MODULE: ./packages/table/src/store/helper.js
  2175. function createStore(table) {
  2176. var initialState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2177. if (!table) {
  2178. throw new Error('Table is required.');
  2179. }
  2180. var store = new src_store();
  2181. store.table = table;
  2182. // fix https://github.com/ElemeFE/element/issues/14075
  2183. // related pr https://github.com/ElemeFE/element/pull/14146
  2184. store.toggleAllSelection = debounce_default()(10, store._toggleAllSelection);
  2185. Object.keys(initialState).forEach(function (key) {
  2186. store.states[key] = initialState[key];
  2187. });
  2188. return store;
  2189. }
  2190. function mapStates(mapper) {
  2191. var res = {};
  2192. Object.keys(mapper).forEach(function (key) {
  2193. var value = mapper[key];
  2194. var fn = void 0;
  2195. if (typeof value === 'string') {
  2196. fn = function fn() {
  2197. return this.store.states[value];
  2198. };
  2199. } else if (typeof value === 'function') {
  2200. fn = function fn() {
  2201. return value.call(this, this.store.states);
  2202. };
  2203. } else {
  2204. console.error('invalid value type');
  2205. }
  2206. if (fn) {
  2207. res[key] = fn;
  2208. }
  2209. });
  2210. return res;
  2211. };
  2212. // EXTERNAL MODULE: external "tis-ui/lib/utils/scrollbar-width"
  2213. var scrollbar_width_ = __webpack_require__(65);
  2214. var scrollbar_width_default = /*#__PURE__*/__webpack_require__.n(scrollbar_width_);
  2215. // CONCATENATED MODULE: ./packages/table/src/table-layout.js
  2216. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2217. var table_layout_TableLayout = function () {
  2218. function TableLayout(options) {
  2219. _classCallCheck(this, TableLayout);
  2220. this.observers = [];
  2221. this.table = null;
  2222. this.store = null;
  2223. this.columns = null;
  2224. this.fit = true;
  2225. this.showHeader = true;
  2226. this.height = null;
  2227. this.scrollX = false;
  2228. this.scrollY = false;
  2229. this.bodyWidth = null;
  2230. this.fixedWidth = null;
  2231. this.rightFixedWidth = null;
  2232. this.tableHeight = null;
  2233. this.headerHeight = 44; // Table Header Height
  2234. this.appendHeight = 0; // Append Slot Height
  2235. this.footerHeight = 44; // Table Footer Height
  2236. this.viewportHeight = null; // Table Height - Scroll Bar Height
  2237. this.bodyHeight = null; // Table Height - Table Header Height
  2238. this.fixedBodyHeight = null; // Table Height - Table Header Height - Scroll Bar Height
  2239. this.gutterWidth = scrollbar_width_default()();
  2240. for (var name in options) {
  2241. if (options.hasOwnProperty(name)) {
  2242. this[name] = options[name];
  2243. }
  2244. }
  2245. if (!this.table) {
  2246. throw new Error('table is required for Table Layout');
  2247. }
  2248. if (!this.store) {
  2249. throw new Error('store is required for Table Layout');
  2250. }
  2251. }
  2252. TableLayout.prototype.updateScrollY = function updateScrollY() {
  2253. var height = this.height;
  2254. if (height === null) return false;
  2255. var bodyWrapper = this.table.bodyWrapper;
  2256. if (this.table.$el && bodyWrapper) {
  2257. var body = bodyWrapper.querySelector('.el-table__body');
  2258. var prevScrollY = this.scrollY;
  2259. var scrollY = body.offsetHeight > this.bodyHeight;
  2260. this.scrollY = scrollY;
  2261. return prevScrollY !== scrollY;
  2262. }
  2263. return false;
  2264. };
  2265. TableLayout.prototype.setHeight = function setHeight(value) {
  2266. var _this = this;
  2267. var prop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'height';
  2268. if (external_vue_default.a.prototype.$isServer) return;
  2269. var el = this.table.$el;
  2270. value = Object(util["j" /* parseHeight */])(value);
  2271. this.height = value;
  2272. if (!el && (value || value === 0)) return external_vue_default.a.nextTick(function () {
  2273. return _this.setHeight(value, prop);
  2274. });
  2275. if (typeof value === 'number') {
  2276. el.style[prop] = value + 'px';
  2277. this.updateElsHeight();
  2278. } else if (typeof value === 'string') {
  2279. el.style[prop] = value;
  2280. this.updateElsHeight();
  2281. }
  2282. };
  2283. TableLayout.prototype.setMaxHeight = function setMaxHeight(value) {
  2284. this.setHeight(value, 'max-height');
  2285. };
  2286. TableLayout.prototype.getFlattenColumns = function getFlattenColumns() {
  2287. var flattenColumns = [];
  2288. var columns = this.table.columns;
  2289. columns.forEach(function (column) {
  2290. if (column.isColumnGroup) {
  2291. flattenColumns.push.apply(flattenColumns, column.columns);
  2292. } else {
  2293. flattenColumns.push(column);
  2294. }
  2295. });
  2296. return flattenColumns;
  2297. };
  2298. TableLayout.prototype.updateElsHeight = function updateElsHeight() {
  2299. var _this2 = this;
  2300. if (!this.table.$ready) return external_vue_default.a.nextTick(function () {
  2301. return _this2.updateElsHeight();
  2302. });
  2303. var _table$$refs = this.table.$refs,
  2304. headerWrapper = _table$$refs.headerWrapper,
  2305. appendWrapper = _table$$refs.appendWrapper,
  2306. footerWrapper = _table$$refs.footerWrapper;
  2307. this.appendHeight = appendWrapper ? appendWrapper.offsetHeight : 0;
  2308. if (this.showHeader && !headerWrapper) return;
  2309. // fix issue (https://github.com/ElemeFE/element/pull/16956)
  2310. var headerTrElm = headerWrapper ? headerWrapper.querySelector('.el-table__header tr') : null;
  2311. var noneHeader = this.headerDisplayNone(headerTrElm);
  2312. var headerHeight = this.headerHeight = !this.showHeader ? 0 : headerWrapper.offsetHeight;
  2313. if (this.showHeader && !noneHeader && headerWrapper.offsetWidth > 0 && (this.table.columns || []).length > 0 && headerHeight < 2) {
  2314. return external_vue_default.a.nextTick(function () {
  2315. return _this2.updateElsHeight();
  2316. });
  2317. }
  2318. var tableHeight = this.tableHeight = this.table.$el.clientHeight;
  2319. var footerHeight = this.footerHeight = footerWrapper ? footerWrapper.offsetHeight : 0;
  2320. if (this.height !== null) {
  2321. this.bodyHeight = tableHeight - headerHeight - footerHeight + (footerWrapper ? 1 : 0);
  2322. }
  2323. this.fixedBodyHeight = this.scrollX ? this.bodyHeight - this.gutterWidth : this.bodyHeight;
  2324. var noData = !(this.store.states.data && this.store.states.data.length);
  2325. this.viewportHeight = this.scrollX ? tableHeight - (noData ? 0 : this.gutterWidth) : tableHeight;
  2326. this.updateScrollY();
  2327. this.notifyObservers('scrollable');
  2328. };
  2329. TableLayout.prototype.headerDisplayNone = function headerDisplayNone(elm) {
  2330. if (!elm) return true;
  2331. var headerChild = elm;
  2332. while (headerChild.tagName !== 'DIV') {
  2333. if (getComputedStyle(headerChild).display === 'none') {
  2334. return true;
  2335. }
  2336. headerChild = headerChild.parentElement;
  2337. }
  2338. return false;
  2339. };
  2340. TableLayout.prototype.updateColumnsWidth = function updateColumnsWidth() {
  2341. if (external_vue_default.a.prototype.$isServer) return;
  2342. var fit = this.fit;
  2343. var bodyWidth = this.table.$el.clientWidth;
  2344. var bodyMinWidth = 0;
  2345. var flattenColumns = this.getFlattenColumns();
  2346. var flexColumns = flattenColumns.filter(function (column) {
  2347. return typeof column.width !== 'number';
  2348. });
  2349. flattenColumns.forEach(function (column) {
  2350. // Clean those columns whose width changed from flex to unflex
  2351. if (typeof column.width === 'number' && column.realWidth) column.realWidth = null;
  2352. });
  2353. if (flexColumns.length > 0 && fit) {
  2354. flattenColumns.forEach(function (column) {
  2355. bodyMinWidth += column.width || column.minWidth || 80;
  2356. });
  2357. var scrollYWidth = this.scrollY ? this.gutterWidth : 0;
  2358. if (bodyMinWidth <= bodyWidth - scrollYWidth) {
  2359. // DON'T HAVE SCROLL BAR
  2360. this.scrollX = false;
  2361. var totalFlexWidth = bodyWidth - scrollYWidth - bodyMinWidth;
  2362. if (flexColumns.length === 1) {
  2363. flexColumns[0].realWidth = (flexColumns[0].minWidth || 80) + totalFlexWidth;
  2364. } else {
  2365. var allColumnsWidth = flexColumns.reduce(function (prev, column) {
  2366. return prev + (column.minWidth || 80);
  2367. }, 0);
  2368. var flexWidthPerPixel = totalFlexWidth / allColumnsWidth;
  2369. var noneFirstWidth = 0;
  2370. flexColumns.forEach(function (column, index) {
  2371. if (index === 0) return;
  2372. var flexWidth = Math.floor((column.minWidth || 80) * flexWidthPerPixel);
  2373. noneFirstWidth += flexWidth;
  2374. column.realWidth = (column.minWidth || 80) + flexWidth;
  2375. });
  2376. flexColumns[0].realWidth = (flexColumns[0].minWidth || 80) + totalFlexWidth - noneFirstWidth;
  2377. }
  2378. } else {
  2379. // HAVE HORIZONTAL SCROLL BAR
  2380. this.scrollX = true;
  2381. flexColumns.forEach(function (column) {
  2382. column.realWidth = column.minWidth;
  2383. });
  2384. }
  2385. this.bodyWidth = Math.max(bodyMinWidth, bodyWidth);
  2386. this.table.resizeState.width = this.bodyWidth;
  2387. } else {
  2388. flattenColumns.forEach(function (column) {
  2389. if (!column.width && !column.minWidth) {
  2390. column.realWidth = 80;
  2391. } else {
  2392. column.realWidth = column.width || column.minWidth;
  2393. }
  2394. bodyMinWidth += column.realWidth;
  2395. });
  2396. this.scrollX = bodyMinWidth > bodyWidth;
  2397. this.bodyWidth = bodyMinWidth;
  2398. }
  2399. var fixedColumns = this.store.states.fixedColumns;
  2400. if (fixedColumns.length > 0) {
  2401. var fixedWidth = 0;
  2402. fixedColumns.forEach(function (column) {
  2403. fixedWidth += column.realWidth || column.width;
  2404. });
  2405. this.fixedWidth = fixedWidth;
  2406. }
  2407. var rightFixedColumns = this.store.states.rightFixedColumns;
  2408. if (rightFixedColumns.length > 0) {
  2409. var rightFixedWidth = 0;
  2410. rightFixedColumns.forEach(function (column) {
  2411. rightFixedWidth += column.realWidth || column.width;
  2412. });
  2413. this.rightFixedWidth = rightFixedWidth;
  2414. }
  2415. this.notifyObservers('columns');
  2416. };
  2417. TableLayout.prototype.addObserver = function addObserver(observer) {
  2418. this.observers.push(observer);
  2419. };
  2420. TableLayout.prototype.removeObserver = function removeObserver(observer) {
  2421. var index = this.observers.indexOf(observer);
  2422. if (index !== -1) {
  2423. this.observers.splice(index, 1);
  2424. }
  2425. };
  2426. TableLayout.prototype.notifyObservers = function notifyObservers(event) {
  2427. var _this3 = this;
  2428. var observers = this.observers;
  2429. observers.forEach(function (observer) {
  2430. switch (event) {
  2431. case 'columns':
  2432. observer.onColumnsChange(_this3);
  2433. break;
  2434. case 'scrollable':
  2435. observer.onScrollableChange(_this3);
  2436. break;
  2437. default:
  2438. throw new Error('Table Layout don\'t have event ' + event + '.');
  2439. }
  2440. });
  2441. };
  2442. return TableLayout;
  2443. }();
  2444. /* harmony default export */ var table_layout = (table_layout_TableLayout);
  2445. // EXTERNAL MODULE: external "tis-ui/lib/utils/dom"
  2446. var dom_ = __webpack_require__(7);
  2447. // EXTERNAL MODULE: ./packages/tooltip/index.js + 1 modules
  2448. var packages_tooltip = __webpack_require__(102);
  2449. // CONCATENATED MODULE: ./packages/table/src/layout-observer.js
  2450. /* harmony default export */ var layout_observer = ({
  2451. created: function created() {
  2452. this.tableLayout.addObserver(this);
  2453. },
  2454. destroyed: function destroyed() {
  2455. this.tableLayout.removeObserver(this);
  2456. },
  2457. computed: {
  2458. tableLayout: function tableLayout() {
  2459. var layout = this.layout;
  2460. if (!layout && this.table) {
  2461. layout = this.table.layout;
  2462. }
  2463. if (!layout) {
  2464. throw new Error('Can not find table layout.');
  2465. }
  2466. return layout;
  2467. }
  2468. },
  2469. mounted: function mounted() {
  2470. this.onColumnsChange(this.tableLayout);
  2471. this.onScrollableChange(this.tableLayout);
  2472. },
  2473. updated: function updated() {
  2474. if (this.__updated__) return;
  2475. this.onColumnsChange(this.tableLayout);
  2476. this.onScrollableChange(this.tableLayout);
  2477. this.__updated__ = true;
  2478. },
  2479. methods: {
  2480. onColumnsChange: function onColumnsChange(layout) {
  2481. var cols = this.$el.querySelectorAll('colgroup > col');
  2482. if (!cols.length) return;
  2483. var flattenColumns = layout.getFlattenColumns();
  2484. var columnsMap = {};
  2485. flattenColumns.forEach(function (column) {
  2486. columnsMap[column.id] = column;
  2487. });
  2488. for (var i = 0, j = cols.length; i < j; i++) {
  2489. var col = cols[i];
  2490. var name = col.getAttribute('name');
  2491. var column = columnsMap[name];
  2492. if (column) {
  2493. col.setAttribute('width', column.realWidth || column.width);
  2494. }
  2495. }
  2496. },
  2497. onScrollableChange: function onScrollableChange(layout) {
  2498. var cols = this.$el.querySelectorAll('colgroup > col[name=gutter]');
  2499. for (var i = 0, j = cols.length; i < j; i++) {
  2500. var col = cols[i];
  2501. col.setAttribute('width', layout.scrollY ? layout.gutterWidth : '0');
  2502. }
  2503. var ths = this.$el.querySelectorAll('th.gutter');
  2504. for (var _i = 0, _j = ths.length; _i < _j; _i++) {
  2505. var th = ths[_i];
  2506. th.style.width = layout.scrollY ? layout.gutterWidth + 'px' : '0';
  2507. th.style.display = layout.scrollY ? '' : 'none';
  2508. }
  2509. }
  2510. }
  2511. });
  2512. // CONCATENATED MODULE: ./packages/table/src/table-body.js
  2513. 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; };
  2514. var table_body_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; };
  2515. /* harmony default export */ var table_body = ({
  2516. name: 'TisTableBody',
  2517. mixins: [layout_observer],
  2518. components: {
  2519. ElCheckbox: packages_checkbox["default"],
  2520. ElTooltip: packages_tooltip["default"]
  2521. },
  2522. props: {
  2523. store: {
  2524. required: true
  2525. },
  2526. stripe: Boolean,
  2527. context: {},
  2528. rowClassName: [String, Function],
  2529. rowStyle: [Object, Function],
  2530. fixed: String,
  2531. highlight: Boolean
  2532. },
  2533. render: function render(h) {
  2534. var _this = this;
  2535. var data = this.data || [];
  2536. return h(
  2537. 'table',
  2538. {
  2539. 'class': 'el-table__body',
  2540. attrs: { cellspacing: '0',
  2541. cellpadding: '0',
  2542. border: '0' }
  2543. },
  2544. [h('colgroup', [this.columns.map(function (column) {
  2545. return h('col', {
  2546. attrs: { name: column.id },
  2547. key: column.id });
  2548. })]), h('tbody', [data.reduce(function (acc, row) {
  2549. return acc.concat(_this.wrappedRowRender(row, acc.length));
  2550. }, []), h('tis-tooltip', {
  2551. attrs: { effect: this.table.tooltipEffect, placement: 'top', content: this.tooltipContent },
  2552. ref: 'tooltip' })])]
  2553. );
  2554. },
  2555. computed: table_body_extends({
  2556. table: function table() {
  2557. return this.$parent;
  2558. }
  2559. }, mapStates({
  2560. data: 'data',
  2561. columns: 'columns',
  2562. treeIndent: 'indent',
  2563. leftFixedLeafCount: 'fixedLeafColumnsLength',
  2564. rightFixedLeafCount: 'rightFixedLeafColumnsLength',
  2565. columnsCount: function columnsCount(states) {
  2566. return states.columns.length;
  2567. },
  2568. leftFixedCount: function leftFixedCount(states) {
  2569. return states.fixedColumns.length;
  2570. },
  2571. rightFixedCount: function rightFixedCount(states) {
  2572. return states.rightFixedColumns.length;
  2573. },
  2574. hasExpandColumn: function hasExpandColumn(states) {
  2575. return states.columns.some(function (_ref) {
  2576. var type = _ref.type;
  2577. return type === 'expand';
  2578. });
  2579. }
  2580. }), {
  2581. firstDefaultColumnIndex: function firstDefaultColumnIndex() {
  2582. return Object(util_["arrayFindIndex"])(this.columns, function (_ref2) {
  2583. var type = _ref2.type;
  2584. return type === 'default';
  2585. });
  2586. }
  2587. }),
  2588. watch: {
  2589. // don't trigger getter of currentRow in getCellClass. see https://jsfiddle.net/oe2b4hqt/
  2590. // update DOM manually. see https://github.com/ElemeFE/element/pull/13954/files#diff-9b450c00d0a9dec0ffad5a3176972e40
  2591. 'store.states.hoverRow': function storeStatesHoverRow(newVal, oldVal) {
  2592. var _this2 = this;
  2593. if (!this.store.states.isComplex || this.$isServer) return;
  2594. var raf = window.requestAnimationFrame;
  2595. if (!raf) {
  2596. raf = function raf(fn) {
  2597. return setTimeout(fn, 16);
  2598. };
  2599. }
  2600. raf(function () {
  2601. var rows = _this2.$el.querySelectorAll('.el-table__row');
  2602. var oldRow = rows[oldVal];
  2603. var newRow = rows[newVal];
  2604. if (oldRow) {
  2605. Object(dom_["removeClass"])(oldRow, 'hover-row');
  2606. }
  2607. if (newRow) {
  2608. Object(dom_["addClass"])(newRow, 'hover-row');
  2609. }
  2610. });
  2611. }
  2612. },
  2613. data: function data() {
  2614. return {
  2615. tooltipContent: ''
  2616. };
  2617. },
  2618. created: function created() {
  2619. this.activateTooltip = debounce_default()(50, function (tooltip) {
  2620. return tooltip.handleShowPopper();
  2621. });
  2622. },
  2623. methods: {
  2624. getKeyOfRow: function getKeyOfRow(row, index) {
  2625. var rowKey = this.table.rowKey;
  2626. if (rowKey) {
  2627. return Object(util["g" /* getRowIdentity */])(row, rowKey);
  2628. }
  2629. return index;
  2630. },
  2631. isColumnHidden: function isColumnHidden(index) {
  2632. if (this.fixed === true || this.fixed === 'left') {
  2633. return index >= this.leftFixedLeafCount;
  2634. } else if (this.fixed === 'right') {
  2635. return index < this.columnsCount - this.rightFixedLeafCount;
  2636. } else {
  2637. return index < this.leftFixedLeafCount || index >= this.columnsCount - this.rightFixedLeafCount;
  2638. }
  2639. },
  2640. getSpan: function getSpan(row, column, rowIndex, columnIndex) {
  2641. var rowspan = 1;
  2642. var colspan = 1;
  2643. var fn = this.table.spanMethod;
  2644. if (typeof fn === 'function') {
  2645. var result = fn({
  2646. row: row,
  2647. column: column,
  2648. rowIndex: rowIndex,
  2649. columnIndex: columnIndex
  2650. });
  2651. if (Array.isArray(result)) {
  2652. rowspan = result[0];
  2653. colspan = result[1];
  2654. } else if ((typeof result === 'undefined' ? 'undefined' : _typeof(result)) === 'object') {
  2655. rowspan = result.rowspan;
  2656. colspan = result.colspan;
  2657. }
  2658. }
  2659. return { rowspan: rowspan, colspan: colspan };
  2660. },
  2661. getRowStyle: function getRowStyle(row, rowIndex) {
  2662. var rowStyle = this.table.rowStyle;
  2663. if (typeof rowStyle === 'function') {
  2664. return rowStyle.call(null, {
  2665. row: row,
  2666. rowIndex: rowIndex
  2667. });
  2668. }
  2669. return rowStyle || null;
  2670. },
  2671. getRowClass: function getRowClass(row, rowIndex) {
  2672. var classes = ['el-table__row'];
  2673. if (this.table.highlightCurrentRow && row === this.store.states.currentRow) {
  2674. classes.push('current-row');
  2675. }
  2676. if (this.stripe && rowIndex % 2 === 1) {
  2677. classes.push('el-table__row--striped');
  2678. }
  2679. var rowClassName = this.table.rowClassName;
  2680. if (typeof rowClassName === 'string') {
  2681. classes.push(rowClassName);
  2682. } else if (typeof rowClassName === 'function') {
  2683. classes.push(rowClassName.call(null, {
  2684. row: row,
  2685. rowIndex: rowIndex
  2686. }));
  2687. }
  2688. if (this.store.states.expandRows.indexOf(row) > -1) {
  2689. classes.push('expanded');
  2690. }
  2691. return classes;
  2692. },
  2693. getCellStyle: function getCellStyle(rowIndex, columnIndex, row, column) {
  2694. var cellStyle = this.table.cellStyle;
  2695. if (typeof cellStyle === 'function') {
  2696. return cellStyle.call(null, {
  2697. rowIndex: rowIndex,
  2698. columnIndex: columnIndex,
  2699. row: row,
  2700. column: column
  2701. });
  2702. }
  2703. return cellStyle;
  2704. },
  2705. getCellClass: function getCellClass(rowIndex, columnIndex, row, column) {
  2706. var classes = [column.id, column.align, column.className];
  2707. if (this.isColumnHidden(columnIndex)) {
  2708. classes.push('is-hidden');
  2709. }
  2710. var cellClassName = this.table.cellClassName;
  2711. if (typeof cellClassName === 'string') {
  2712. classes.push(cellClassName);
  2713. } else if (typeof cellClassName === 'function') {
  2714. classes.push(cellClassName.call(null, {
  2715. rowIndex: rowIndex,
  2716. columnIndex: columnIndex,
  2717. row: row,
  2718. column: column
  2719. }));
  2720. }
  2721. return classes.join(' ');
  2722. },
  2723. getColspanRealWidth: function getColspanRealWidth(columns, colspan, index) {
  2724. if (colspan < 1) {
  2725. return columns[index].realWidth;
  2726. }
  2727. var widthArr = columns.map(function (_ref3) {
  2728. var realWidth = _ref3.realWidth;
  2729. return realWidth;
  2730. }).slice(index, index + colspan);
  2731. return widthArr.reduce(function (acc, width) {
  2732. return acc + width;
  2733. }, -1);
  2734. },
  2735. handleCellMouseEnter: function handleCellMouseEnter(event, row) {
  2736. var table = this.table;
  2737. var cell = Object(util["b" /* getCell */])(event);
  2738. if (cell) {
  2739. var column = Object(util["c" /* getColumnByCell */])(table, cell);
  2740. var hoverState = table.hoverState = { cell: cell, column: column, row: row };
  2741. table.$emit('cell-mouse-enter', hoverState.row, hoverState.column, hoverState.cell, event);
  2742. }
  2743. // 判断是否text-overflow, 如果是就显示tooltip
  2744. var cellChild = event.target.querySelector('.cell');
  2745. if (!(Object(dom_["hasClass"])(cellChild, 'el-tooltip') && cellChild.childNodes.length)) {
  2746. return;
  2747. }
  2748. // use range width instead of scrollWidth to determine whether the text is overflowing
  2749. // to address a potential FireFox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1074543#c3
  2750. var range = document.createRange();
  2751. range.setStart(cellChild, 0);
  2752. range.setEnd(cellChild, cellChild.childNodes.length);
  2753. var rangeWidth = range.getBoundingClientRect().width;
  2754. var padding = (parseInt(Object(dom_["getStyle"])(cellChild, 'paddingLeft'), 10) || 0) + (parseInt(Object(dom_["getStyle"])(cellChild, 'paddingRight'), 10) || 0);
  2755. if ((rangeWidth + padding > cellChild.offsetWidth || cellChild.scrollWidth > cellChild.offsetWidth) && this.$refs.tooltip) {
  2756. var tooltip = this.$refs.tooltip;
  2757. // TODO 会引起整个 Table 的重新渲染,需要优化
  2758. this.tooltipContent = cell.innerText || cell.textContent;
  2759. tooltip.referenceElm = cell;
  2760. tooltip.$refs.popper && (tooltip.$refs.popper.style.display = 'none');
  2761. tooltip.doDestroy();
  2762. tooltip.setExpectedState(true);
  2763. this.activateTooltip(tooltip);
  2764. }
  2765. },
  2766. handleCellMouseLeave: function handleCellMouseLeave(event) {
  2767. var tooltip = this.$refs.tooltip;
  2768. if (tooltip) {
  2769. tooltip.setExpectedState(false);
  2770. tooltip.handleClosePopper();
  2771. }
  2772. var cell = Object(util["b" /* getCell */])(event);
  2773. if (!cell) return;
  2774. var oldHoverState = this.table.hoverState || {};
  2775. this.table.$emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, event);
  2776. },
  2777. handleMouseEnter: debounce_default()(30, function (index) {
  2778. this.store.commit('setHoverRow', index);
  2779. }),
  2780. handleMouseLeave: debounce_default()(30, function () {
  2781. this.store.commit('setHoverRow', null);
  2782. }),
  2783. handleContextMenu: function handleContextMenu(event, row) {
  2784. this.handleEvent(event, row, 'contextmenu');
  2785. },
  2786. handleDoubleClick: function handleDoubleClick(event, row) {
  2787. this.handleEvent(event, row, 'dblclick');
  2788. },
  2789. handleClick: function handleClick(event, row) {
  2790. this.store.commit('setCurrentRow', row);
  2791. this.handleEvent(event, row, 'click');
  2792. },
  2793. handleEvent: function handleEvent(event, row, name) {
  2794. var table = this.table;
  2795. var cell = Object(util["b" /* getCell */])(event);
  2796. var column = void 0;
  2797. if (cell) {
  2798. column = Object(util["c" /* getColumnByCell */])(table, cell);
  2799. if (column) {
  2800. table.$emit('cell-' + name, row, column, cell, event);
  2801. }
  2802. }
  2803. table.$emit('row-' + name, row, column, event);
  2804. },
  2805. rowRender: function rowRender(row, $index, treeRowData) {
  2806. var _this3 = this;
  2807. var h = this.$createElement;
  2808. var treeIndent = this.treeIndent,
  2809. columns = this.columns,
  2810. firstDefaultColumnIndex = this.firstDefaultColumnIndex;
  2811. var columnsHidden = columns.map(function (column, index) {
  2812. return _this3.isColumnHidden(index);
  2813. });
  2814. var rowClasses = this.getRowClass(row, $index);
  2815. var display = true;
  2816. if (treeRowData) {
  2817. rowClasses.push('el-table__row--level-' + treeRowData.level);
  2818. display = treeRowData.display;
  2819. }
  2820. // 指令 v-show 会覆盖 row-style 中 display
  2821. // 使用 :style 代替 v-show https://github.com/ElemeFE/element/issues/16995
  2822. var displayStyle = display ? null : {
  2823. display: 'none'
  2824. };
  2825. return h(
  2826. 'tr',
  2827. {
  2828. style: [displayStyle, this.getRowStyle(row, $index)],
  2829. 'class': rowClasses,
  2830. key: this.getKeyOfRow(row, $index),
  2831. on: {
  2832. 'dblclick': function dblclick($event) {
  2833. return _this3.handleDoubleClick($event, row);
  2834. },
  2835. 'click': function click($event) {
  2836. return _this3.handleClick($event, row);
  2837. },
  2838. 'contextmenu': function contextmenu($event) {
  2839. return _this3.handleContextMenu($event, row);
  2840. },
  2841. 'mouseenter': function mouseenter(_) {
  2842. return _this3.handleMouseEnter($index);
  2843. },
  2844. 'mouseleave': this.handleMouseLeave
  2845. }
  2846. },
  2847. [columns.map(function (column, cellIndex) {
  2848. var _getSpan = _this3.getSpan(row, column, $index, cellIndex),
  2849. rowspan = _getSpan.rowspan,
  2850. colspan = _getSpan.colspan;
  2851. if (!rowspan || !colspan) {
  2852. return null;
  2853. }
  2854. var columnData = table_body_extends({}, column);
  2855. columnData.realWidth = _this3.getColspanRealWidth(columns, colspan, cellIndex);
  2856. var data = {
  2857. store: _this3.store,
  2858. _self: _this3.context || _this3.table.$vnode.context,
  2859. column: columnData,
  2860. row: row,
  2861. $index: $index
  2862. };
  2863. if (cellIndex === firstDefaultColumnIndex && treeRowData) {
  2864. data.treeNode = {
  2865. indent: treeRowData.level * treeIndent,
  2866. level: treeRowData.level
  2867. };
  2868. if (typeof treeRowData.expanded === 'boolean') {
  2869. data.treeNode.expanded = treeRowData.expanded;
  2870. // 表明是懒加载
  2871. if ('loading' in treeRowData) {
  2872. data.treeNode.loading = treeRowData.loading;
  2873. }
  2874. if ('noLazyChildren' in treeRowData) {
  2875. data.treeNode.noLazyChildren = treeRowData.noLazyChildren;
  2876. }
  2877. }
  2878. }
  2879. return h(
  2880. 'td',
  2881. {
  2882. style: _this3.getCellStyle($index, cellIndex, row, column),
  2883. 'class': _this3.getCellClass($index, cellIndex, row, column),
  2884. attrs: { rowspan: rowspan,
  2885. colspan: colspan
  2886. },
  2887. on: {
  2888. 'mouseenter': function mouseenter($event) {
  2889. return _this3.handleCellMouseEnter($event, row);
  2890. },
  2891. 'mouseleave': _this3.handleCellMouseLeave
  2892. }
  2893. },
  2894. [column.renderCell.call(_this3._renderProxy, _this3.$createElement, data, columnsHidden[cellIndex])]
  2895. );
  2896. })]
  2897. );
  2898. },
  2899. wrappedRowRender: function wrappedRowRender(row, $index) {
  2900. var _this4 = this;
  2901. var h = this.$createElement;
  2902. var store = this.store;
  2903. var isRowExpanded = store.isRowExpanded,
  2904. assertRowKey = store.assertRowKey;
  2905. var _store$states = store.states,
  2906. treeData = _store$states.treeData,
  2907. lazyTreeNodeMap = _store$states.lazyTreeNodeMap,
  2908. childrenColumnName = _store$states.childrenColumnName,
  2909. rowKey = _store$states.rowKey;
  2910. if (this.hasExpandColumn && isRowExpanded(row)) {
  2911. var renderExpanded = this.table.renderExpanded;
  2912. var tr = this.rowRender(row, $index);
  2913. if (!renderExpanded) {
  2914. console.error('[Element Error]renderExpanded is required.');
  2915. return tr;
  2916. }
  2917. // 使用二维数组,避免修改 $index
  2918. return [[tr, h(
  2919. 'tr',
  2920. { key: 'expanded-row__' + tr.key },
  2921. [h(
  2922. 'td',
  2923. {
  2924. attrs: { colspan: this.columnsCount },
  2925. 'class': 'el-table__expanded-cell' },
  2926. [renderExpanded(this.$createElement, { row: row, $index: $index, store: this.store })]
  2927. )]
  2928. )]];
  2929. } else if (Object.keys(treeData).length) {
  2930. assertRowKey();
  2931. // TreeTable 时,rowKey 必须由用户设定,不使用 getKeyOfRow 计算
  2932. // 在调用 rowRender 函数时,仍然会计算 rowKey,不太好的操作
  2933. var key = Object(util["g" /* getRowIdentity */])(row, rowKey);
  2934. var cur = treeData[key];
  2935. var treeRowData = null;
  2936. if (cur) {
  2937. treeRowData = {
  2938. expanded: cur.expanded,
  2939. level: cur.level,
  2940. display: true
  2941. };
  2942. if (typeof cur.lazy === 'boolean') {
  2943. if (typeof cur.loaded === 'boolean' && cur.loaded) {
  2944. treeRowData.noLazyChildren = !(cur.children && cur.children.length);
  2945. }
  2946. treeRowData.loading = cur.loading;
  2947. }
  2948. }
  2949. var tmp = [this.rowRender(row, $index, treeRowData)];
  2950. // 渲染嵌套数据
  2951. if (cur) {
  2952. // currentRow 记录的是 index,所以还需主动增加 TreeTable 的 index
  2953. var i = 0;
  2954. var traverse = function traverse(children, parent) {
  2955. if (!(children && children.length && parent)) return;
  2956. children.forEach(function (node) {
  2957. // 父节点的 display 状态影响子节点的显示状态
  2958. var innerTreeRowData = {
  2959. display: parent.display && parent.expanded,
  2960. level: parent.level + 1
  2961. };
  2962. var childKey = Object(util["g" /* getRowIdentity */])(node, rowKey);
  2963. if (childKey === undefined || childKey === null) {
  2964. throw new Error('for nested data item, row-key is required.');
  2965. }
  2966. cur = table_body_extends({}, treeData[childKey]);
  2967. // 对于当前节点,分成有无子节点两种情况。
  2968. // 如果包含子节点的,设置 expanded 属性。
  2969. // 对于它子节点的 display 属性由它本身的 expanded 与 display 共同决定。
  2970. if (cur) {
  2971. innerTreeRowData.expanded = cur.expanded;
  2972. // 懒加载的某些节点,level 未知
  2973. cur.level = cur.level || innerTreeRowData.level;
  2974. cur.display = !!(cur.expanded && innerTreeRowData.display);
  2975. if (typeof cur.lazy === 'boolean') {
  2976. if (typeof cur.loaded === 'boolean' && cur.loaded) {
  2977. innerTreeRowData.noLazyChildren = !(cur.children && cur.children.length);
  2978. }
  2979. innerTreeRowData.loading = cur.loading;
  2980. }
  2981. }
  2982. i++;
  2983. tmp.push(_this4.rowRender(node, $index + i, innerTreeRowData));
  2984. if (cur) {
  2985. var _nodes = lazyTreeNodeMap[childKey] || node[childrenColumnName];
  2986. traverse(_nodes, cur);
  2987. }
  2988. });
  2989. };
  2990. // 对于 root 节点,display 一定为 true
  2991. cur.display = true;
  2992. var nodes = lazyTreeNodeMap[key] || row[childrenColumnName];
  2993. traverse(nodes, cur);
  2994. }
  2995. return tmp;
  2996. } else {
  2997. return this.rowRender(row, $index);
  2998. }
  2999. }
  3000. }
  3001. });
  3002. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/table/src/filter-panel.vue?vue&type=template&id=7f2c919f&
  3003. var filter_panelvue_type_template_id_7f2c919f_render = function() {
  3004. var _vm = this
  3005. var _h = _vm.$createElement
  3006. var _c = _vm._self._c || _h
  3007. return _c("transition", { attrs: { name: "el-zoom-in-top" } }, [
  3008. _vm.multiple
  3009. ? _c(
  3010. "div",
  3011. {
  3012. directives: [
  3013. {
  3014. name: "clickoutside",
  3015. rawName: "v-clickoutside",
  3016. value: _vm.handleOutsideClick,
  3017. expression: "handleOutsideClick"
  3018. },
  3019. {
  3020. name: "show",
  3021. rawName: "v-show",
  3022. value: _vm.showPopper,
  3023. expression: "showPopper"
  3024. }
  3025. ],
  3026. staticClass: "el-table-filter"
  3027. },
  3028. [
  3029. _c(
  3030. "div",
  3031. { staticClass: "el-table-filter__content" },
  3032. [
  3033. _c(
  3034. "tis-scrollbar",
  3035. { attrs: { "wrap-class": "el-table-filter__wrap" } },
  3036. [
  3037. _c(
  3038. "tis-checkbox-group",
  3039. {
  3040. staticClass: "el-table-filter__checkbox-group",
  3041. model: {
  3042. value: _vm.filteredValue,
  3043. callback: function($$v) {
  3044. _vm.filteredValue = $$v
  3045. },
  3046. expression: "filteredValue"
  3047. }
  3048. },
  3049. _vm._l(_vm.filters, function(filter) {
  3050. return _c(
  3051. "tis-checkbox",
  3052. { key: filter.value, attrs: { label: filter.value } },
  3053. [_vm._v(_vm._s(filter.text))]
  3054. )
  3055. }),
  3056. 1
  3057. )
  3058. ],
  3059. 1
  3060. )
  3061. ],
  3062. 1
  3063. ),
  3064. _c("div", { staticClass: "el-table-filter__bottom" }, [
  3065. _c(
  3066. "button",
  3067. {
  3068. class: { "is-disabled": _vm.filteredValue.length === 0 },
  3069. attrs: { disabled: _vm.filteredValue.length === 0 },
  3070. on: { click: _vm.handleConfirm }
  3071. },
  3072. [_vm._v(_vm._s(_vm.t("el.table.confirmFilter")))]
  3073. ),
  3074. _c("button", { on: { click: _vm.handleReset } }, [
  3075. _vm._v(_vm._s(_vm.t("el.table.resetFilter")))
  3076. ])
  3077. ])
  3078. ]
  3079. )
  3080. : _c(
  3081. "div",
  3082. {
  3083. directives: [
  3084. {
  3085. name: "clickoutside",
  3086. rawName: "v-clickoutside",
  3087. value: _vm.handleOutsideClick,
  3088. expression: "handleOutsideClick"
  3089. },
  3090. {
  3091. name: "show",
  3092. rawName: "v-show",
  3093. value: _vm.showPopper,
  3094. expression: "showPopper"
  3095. }
  3096. ],
  3097. staticClass: "el-table-filter"
  3098. },
  3099. [
  3100. _c(
  3101. "ul",
  3102. { staticClass: "el-table-filter__list" },
  3103. [
  3104. _c(
  3105. "li",
  3106. {
  3107. staticClass: "el-table-filter__list-item",
  3108. class: {
  3109. "is-active":
  3110. _vm.filterValue === undefined ||
  3111. _vm.filterValue === null
  3112. },
  3113. on: {
  3114. click: function($event) {
  3115. _vm.handleSelect(null)
  3116. }
  3117. }
  3118. },
  3119. [_vm._v(_vm._s(_vm.t("el.table.clearFilter")))]
  3120. ),
  3121. _vm._l(_vm.filters, function(filter) {
  3122. return _c(
  3123. "li",
  3124. {
  3125. key: filter.value,
  3126. staticClass: "el-table-filter__list-item",
  3127. class: { "is-active": _vm.isActive(filter) },
  3128. attrs: { label: filter.value },
  3129. on: {
  3130. click: function($event) {
  3131. _vm.handleSelect(filter.value)
  3132. }
  3133. }
  3134. },
  3135. [_vm._v(_vm._s(filter.text))]
  3136. )
  3137. })
  3138. ],
  3139. 2
  3140. )
  3141. ]
  3142. )
  3143. ])
  3144. }
  3145. var filter_panelvue_type_template_id_7f2c919f_staticRenderFns = []
  3146. filter_panelvue_type_template_id_7f2c919f_render._withStripped = true
  3147. // CONCATENATED MODULE: ./packages/table/src/filter-panel.vue?vue&type=template&id=7f2c919f&
  3148. // EXTERNAL MODULE: external "tis-ui/lib/utils/vue-popper"
  3149. var vue_popper_ = __webpack_require__(34);
  3150. var vue_popper_default = /*#__PURE__*/__webpack_require__.n(vue_popper_);
  3151. // EXTERNAL MODULE: external "tis-ui/lib/utils/popup"
  3152. var popup_ = __webpack_require__(77);
  3153. // EXTERNAL MODULE: external "tis-ui/lib/utils/clickoutside"
  3154. var clickoutside_ = __webpack_require__(61);
  3155. var clickoutside_default = /*#__PURE__*/__webpack_require__.n(clickoutside_);
  3156. // CONCATENATED MODULE: ./packages/table/src/dropdown.js
  3157. var dropdowns = [];
  3158. !external_vue_default.a.prototype.$isServer && document.addEventListener('click', function (event) {
  3159. dropdowns.forEach(function (dropdown) {
  3160. var target = event.target;
  3161. if (!dropdown || !dropdown.$el) return;
  3162. if (target === dropdown.$el || dropdown.$el.contains(target)) {
  3163. return;
  3164. }
  3165. dropdown.handleOutsideClick && dropdown.handleOutsideClick(event);
  3166. });
  3167. });
  3168. /* harmony default export */ var dropdown = ({
  3169. open: function open(instance) {
  3170. if (instance) {
  3171. dropdowns.push(instance);
  3172. }
  3173. },
  3174. close: function close(instance) {
  3175. var index = dropdowns.indexOf(instance);
  3176. if (index !== -1) {
  3177. dropdowns.splice(instance, 1);
  3178. }
  3179. }
  3180. });
  3181. // EXTERNAL MODULE: ./packages/checkbox-group/index.js + 5 modules
  3182. var checkbox_group = __webpack_require__(121);
  3183. // EXTERNAL MODULE: ./packages/scrollbar/index.js + 3 modules
  3184. var scrollbar = __webpack_require__(66);
  3185. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/table/src/filter-panel.vue?vue&type=script&lang=js&
  3186. //
  3187. //
  3188. //
  3189. //
  3190. //
  3191. //
  3192. //
  3193. //
  3194. //
  3195. //
  3196. //
  3197. //
  3198. //
  3199. //
  3200. //
  3201. //
  3202. //
  3203. //
  3204. //
  3205. //
  3206. //
  3207. //
  3208. //
  3209. //
  3210. //
  3211. //
  3212. //
  3213. //
  3214. //
  3215. //
  3216. //
  3217. //
  3218. //
  3219. //
  3220. //
  3221. //
  3222. //
  3223. //
  3224. //
  3225. //
  3226. //
  3227. //
  3228. //
  3229. //
  3230. /* harmony default export */ var filter_panelvue_type_script_lang_js_ = ({
  3231. name: 'TisTableFilterPanel',
  3232. mixins: [vue_popper_default.a, locale_default.a],
  3233. directives: {
  3234. Clickoutside: clickoutside_default.a
  3235. },
  3236. components: {
  3237. ElCheckbox: packages_checkbox["default"],
  3238. ElCheckboxGroup: checkbox_group["default"],
  3239. ElScrollbar: scrollbar["default"]
  3240. },
  3241. props: {
  3242. placement: {
  3243. type: String,
  3244. default: 'bottom-end'
  3245. }
  3246. },
  3247. methods: {
  3248. isActive: function isActive(filter) {
  3249. return filter.value === this.filterValue;
  3250. },
  3251. handleOutsideClick: function handleOutsideClick() {
  3252. var _this = this;
  3253. setTimeout(function () {
  3254. _this.showPopper = false;
  3255. }, 16);
  3256. },
  3257. handleConfirm: function handleConfirm() {
  3258. this.confirmFilter(this.filteredValue);
  3259. this.handleOutsideClick();
  3260. },
  3261. handleReset: function handleReset() {
  3262. this.filteredValue = [];
  3263. this.confirmFilter(this.filteredValue);
  3264. this.handleOutsideClick();
  3265. },
  3266. handleSelect: function handleSelect(filterValue) {
  3267. this.filterValue = filterValue;
  3268. if (typeof filterValue !== 'undefined' && filterValue !== null) {
  3269. this.confirmFilter(this.filteredValue);
  3270. } else {
  3271. this.confirmFilter([]);
  3272. }
  3273. this.handleOutsideClick();
  3274. },
  3275. confirmFilter: function confirmFilter(filteredValue) {
  3276. this.table.store.commit('filterChange', {
  3277. column: this.column,
  3278. values: filteredValue
  3279. });
  3280. this.table.store.updateAllSelected();
  3281. }
  3282. },
  3283. data: function data() {
  3284. return {
  3285. table: null,
  3286. cell: null,
  3287. column: null
  3288. };
  3289. },
  3290. computed: {
  3291. filters: function filters() {
  3292. return this.column && this.column.filters;
  3293. },
  3294. filterValue: {
  3295. get: function get() {
  3296. return (this.column.filteredValue || [])[0];
  3297. },
  3298. set: function set(value) {
  3299. if (this.filteredValue) {
  3300. if (typeof value !== 'undefined' && value !== null) {
  3301. this.filteredValue.splice(0, 1, value);
  3302. } else {
  3303. this.filteredValue.splice(0, 1);
  3304. }
  3305. }
  3306. }
  3307. },
  3308. filteredValue: {
  3309. get: function get() {
  3310. if (this.column) {
  3311. return this.column.filteredValue || [];
  3312. }
  3313. return [];
  3314. },
  3315. set: function set(value) {
  3316. if (this.column) {
  3317. this.column.filteredValue = value;
  3318. }
  3319. }
  3320. },
  3321. multiple: function multiple() {
  3322. if (this.column) {
  3323. return this.column.filterMultiple;
  3324. }
  3325. return true;
  3326. }
  3327. },
  3328. mounted: function mounted() {
  3329. var _this2 = this;
  3330. this.popperElm = this.$el;
  3331. this.referenceElm = this.cell;
  3332. this.table.bodyWrapper.addEventListener('scroll', function () {
  3333. _this2.updatePopper();
  3334. });
  3335. this.$watch('showPopper', function (value) {
  3336. if (_this2.column) _this2.column.filterOpened = value;
  3337. if (value) {
  3338. dropdown.open(_this2);
  3339. } else {
  3340. dropdown.close(_this2);
  3341. }
  3342. });
  3343. },
  3344. watch: {
  3345. showPopper: function showPopper(val) {
  3346. if (val === true && parseInt(this.popperJS._popper.style.zIndex, 10) < popup_["PopupManager"].zIndex) {
  3347. this.popperJS._popper.style.zIndex = popup_["PopupManager"].nextZIndex();
  3348. }
  3349. }
  3350. }
  3351. });
  3352. // CONCATENATED MODULE: ./packages/table/src/filter-panel.vue?vue&type=script&lang=js&
  3353. /* harmony default export */ var src_filter_panelvue_type_script_lang_js_ = (filter_panelvue_type_script_lang_js_);
  3354. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  3355. var componentNormalizer = __webpack_require__(2);
  3356. // CONCATENATED MODULE: ./packages/table/src/filter-panel.vue
  3357. /* normalize component */
  3358. var component = Object(componentNormalizer["a" /* default */])(
  3359. src_filter_panelvue_type_script_lang_js_,
  3360. filter_panelvue_type_template_id_7f2c919f_render,
  3361. filter_panelvue_type_template_id_7f2c919f_staticRenderFns,
  3362. false,
  3363. null,
  3364. null,
  3365. null
  3366. )
  3367. /* hot reload */
  3368. if (false) { var api; }
  3369. component.options.__file = "packages/table/src/filter-panel.vue"
  3370. /* harmony default export */ var filter_panel = (component.exports);
  3371. // CONCATENATED MODULE: ./packages/table/src/table-header.js
  3372. var table_header_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; };
  3373. var getAllColumns = function getAllColumns(columns) {
  3374. var result = [];
  3375. columns.forEach(function (column) {
  3376. if (column.children) {
  3377. result.push(column);
  3378. result.push.apply(result, getAllColumns(column.children));
  3379. } else {
  3380. result.push(column);
  3381. }
  3382. });
  3383. return result;
  3384. };
  3385. var convertToRows = function convertToRows(originColumns) {
  3386. var maxLevel = 1;
  3387. var traverse = function traverse(column, parent) {
  3388. if (parent) {
  3389. column.level = parent.level + 1;
  3390. if (maxLevel < column.level) {
  3391. maxLevel = column.level;
  3392. }
  3393. }
  3394. if (column.children) {
  3395. var colSpan = 0;
  3396. column.children.forEach(function (subColumn) {
  3397. traverse(subColumn, column);
  3398. colSpan += subColumn.colSpan;
  3399. });
  3400. column.colSpan = colSpan;
  3401. } else {
  3402. column.colSpan = 1;
  3403. }
  3404. };
  3405. originColumns.forEach(function (column) {
  3406. column.level = 1;
  3407. traverse(column);
  3408. });
  3409. var rows = [];
  3410. for (var i = 0; i < maxLevel; i++) {
  3411. rows.push([]);
  3412. }
  3413. var allColumns = getAllColumns(originColumns);
  3414. allColumns.forEach(function (column) {
  3415. if (!column.children) {
  3416. column.rowSpan = maxLevel - column.level + 1;
  3417. } else {
  3418. column.rowSpan = 1;
  3419. }
  3420. rows[column.level - 1].push(column);
  3421. });
  3422. return rows;
  3423. };
  3424. /* harmony default export */ var table_header = ({
  3425. name: 'TisTableHeader',
  3426. mixins: [layout_observer],
  3427. render: function render(h) {
  3428. var _this = this;
  3429. var originColumns = this.store.states.originColumns;
  3430. var columnRows = convertToRows(originColumns, this.columns);
  3431. // 是否拥有多级表头
  3432. var isGroup = columnRows.length > 1;
  3433. if (isGroup) this.$parent.isGroup = true;
  3434. return h(
  3435. 'table',
  3436. {
  3437. 'class': 'el-table__header',
  3438. attrs: { cellspacing: '0',
  3439. cellpadding: '0',
  3440. border: '0' }
  3441. },
  3442. [h('colgroup', [this.columns.map(function (column) {
  3443. return h('col', {
  3444. attrs: { name: column.id },
  3445. key: column.id });
  3446. }), this.hasGutter ? h('col', {
  3447. attrs: { name: 'gutter' }
  3448. }) : '']), h(
  3449. 'thead',
  3450. { 'class': [{ 'is-group': isGroup, 'has-gutter': this.hasGutter }] },
  3451. [this._l(columnRows, function (columns, rowIndex) {
  3452. return h(
  3453. 'tr',
  3454. {
  3455. style: _this.getHeaderRowStyle(rowIndex),
  3456. 'class': _this.getHeaderRowClass(rowIndex)
  3457. },
  3458. [columns.map(function (column, cellIndex) {
  3459. return h(
  3460. 'th',
  3461. {
  3462. attrs: {
  3463. colspan: column.colSpan,
  3464. rowspan: column.rowSpan
  3465. },
  3466. on: {
  3467. 'mousemove': function mousemove($event) {
  3468. return _this.handleMouseMove($event, column);
  3469. },
  3470. 'mouseout': _this.handleMouseOut,
  3471. 'mousedown': function mousedown($event) {
  3472. return _this.handleMouseDown($event, column);
  3473. },
  3474. 'click': function click($event) {
  3475. return _this.handleHeaderClick($event, column);
  3476. },
  3477. 'contextmenu': function contextmenu($event) {
  3478. return _this.handleHeaderContextMenu($event, column);
  3479. }
  3480. },
  3481. style: _this.getHeaderCellStyle(rowIndex, cellIndex, columns, column),
  3482. 'class': _this.getHeaderCellClass(rowIndex, cellIndex, columns, column),
  3483. key: column.id },
  3484. [h(
  3485. 'div',
  3486. { 'class': ['cell', column.filteredValue && column.filteredValue.length > 0 ? 'highlight' : '', column.labelClassName] },
  3487. [column.renderHeader ? column.renderHeader.call(_this._renderProxy, h, { column: column, $index: cellIndex, store: _this.store, _self: _this.$parent.$vnode.context }) : column.label, column.sortable ? h(
  3488. 'span',
  3489. {
  3490. 'class': 'caret-wrapper',
  3491. on: {
  3492. 'click': function click($event) {
  3493. return _this.handleSortClick($event, column);
  3494. }
  3495. }
  3496. },
  3497. [h('i', { 'class': 'sort-caret ascending',
  3498. on: {
  3499. 'click': function click($event) {
  3500. return _this.handleSortClick($event, column, 'ascending');
  3501. }
  3502. }
  3503. }), h('i', { 'class': 'sort-caret descending',
  3504. on: {
  3505. 'click': function click($event) {
  3506. return _this.handleSortClick($event, column, 'descending');
  3507. }
  3508. }
  3509. })]
  3510. ) : '', column.filterable ? h(
  3511. 'span',
  3512. {
  3513. 'class': 'el-table__column-filter-trigger',
  3514. on: {
  3515. 'click': function click($event) {
  3516. return _this.handleFilterClick($event, column);
  3517. }
  3518. }
  3519. },
  3520. [h('i', { 'class': ['el-icon-arrow-down', column.filterOpened ? 'el-icon-arrow-up' : ''] })]
  3521. ) : '']
  3522. )]
  3523. );
  3524. }), _this.hasGutter ? h('th', { 'class': 'gutter' }) : '']
  3525. );
  3526. })]
  3527. )]
  3528. );
  3529. },
  3530. props: {
  3531. fixed: String,
  3532. store: {
  3533. required: true
  3534. },
  3535. border: Boolean,
  3536. defaultSort: {
  3537. type: Object,
  3538. default: function _default() {
  3539. return {
  3540. prop: '',
  3541. order: ''
  3542. };
  3543. }
  3544. }
  3545. },
  3546. components: {
  3547. ElCheckbox: packages_checkbox["default"]
  3548. },
  3549. computed: table_header_extends({
  3550. table: function table() {
  3551. return this.$parent;
  3552. },
  3553. hasGutter: function hasGutter() {
  3554. return !this.fixed && this.tableLayout.gutterWidth;
  3555. }
  3556. }, mapStates({
  3557. columns: 'columns',
  3558. isAllSelected: 'isAllSelected',
  3559. leftFixedLeafCount: 'fixedLeafColumnsLength',
  3560. rightFixedLeafCount: 'rightFixedLeafColumnsLength',
  3561. columnsCount: function columnsCount(states) {
  3562. return states.columns.length;
  3563. },
  3564. leftFixedCount: function leftFixedCount(states) {
  3565. return states.fixedColumns.length;
  3566. },
  3567. rightFixedCount: function rightFixedCount(states) {
  3568. return states.rightFixedColumns.length;
  3569. }
  3570. })),
  3571. created: function created() {
  3572. this.filterPanels = {};
  3573. },
  3574. mounted: function mounted() {
  3575. var _this2 = this;
  3576. // nextTick 是有必要的 https://github.com/ElemeFE/element/pull/11311
  3577. this.$nextTick(function () {
  3578. var _defaultSort = _this2.defaultSort,
  3579. prop = _defaultSort.prop,
  3580. order = _defaultSort.order;
  3581. var init = true;
  3582. _this2.store.commit('sort', { prop: prop, order: order, init: init });
  3583. });
  3584. },
  3585. beforeDestroy: function beforeDestroy() {
  3586. var panels = this.filterPanels;
  3587. for (var prop in panels) {
  3588. if (panels.hasOwnProperty(prop) && panels[prop]) {
  3589. panels[prop].$destroy(true);
  3590. }
  3591. }
  3592. },
  3593. methods: {
  3594. isCellHidden: function isCellHidden(index, columns) {
  3595. var start = 0;
  3596. for (var i = 0; i < index; i++) {
  3597. start += columns[i].colSpan;
  3598. }
  3599. var after = start + columns[index].colSpan - 1;
  3600. if (this.fixed === true || this.fixed === 'left') {
  3601. return after >= this.leftFixedLeafCount;
  3602. } else if (this.fixed === 'right') {
  3603. return start < this.columnsCount - this.rightFixedLeafCount;
  3604. } else {
  3605. return after < this.leftFixedLeafCount || start >= this.columnsCount - this.rightFixedLeafCount;
  3606. }
  3607. },
  3608. getHeaderRowStyle: function getHeaderRowStyle(rowIndex) {
  3609. var headerRowStyle = this.table.headerRowStyle;
  3610. if (typeof headerRowStyle === 'function') {
  3611. return headerRowStyle.call(null, { rowIndex: rowIndex });
  3612. }
  3613. return headerRowStyle;
  3614. },
  3615. getHeaderRowClass: function getHeaderRowClass(rowIndex) {
  3616. var classes = [];
  3617. var headerRowClassName = this.table.headerRowClassName;
  3618. if (typeof headerRowClassName === 'string') {
  3619. classes.push(headerRowClassName);
  3620. } else if (typeof headerRowClassName === 'function') {
  3621. classes.push(headerRowClassName.call(null, { rowIndex: rowIndex }));
  3622. }
  3623. return classes.join(' ');
  3624. },
  3625. getHeaderCellStyle: function getHeaderCellStyle(rowIndex, columnIndex, row, column) {
  3626. var headerCellStyle = this.table.headerCellStyle;
  3627. if (typeof headerCellStyle === 'function') {
  3628. return headerCellStyle.call(null, {
  3629. rowIndex: rowIndex,
  3630. columnIndex: columnIndex,
  3631. row: row,
  3632. column: column
  3633. });
  3634. }
  3635. return headerCellStyle;
  3636. },
  3637. getHeaderCellClass: function getHeaderCellClass(rowIndex, columnIndex, row, column) {
  3638. var classes = [column.id, column.order, column.headerAlign, column.className, column.labelClassName];
  3639. if (rowIndex === 0 && this.isCellHidden(columnIndex, row)) {
  3640. classes.push('is-hidden');
  3641. }
  3642. if (!column.children) {
  3643. classes.push('is-leaf');
  3644. }
  3645. if (column.sortable) {
  3646. classes.push('is-sortable');
  3647. }
  3648. var headerCellClassName = this.table.headerCellClassName;
  3649. if (typeof headerCellClassName === 'string') {
  3650. classes.push(headerCellClassName);
  3651. } else if (typeof headerCellClassName === 'function') {
  3652. classes.push(headerCellClassName.call(null, {
  3653. rowIndex: rowIndex,
  3654. columnIndex: columnIndex,
  3655. row: row,
  3656. column: column
  3657. }));
  3658. }
  3659. return classes.join(' ');
  3660. },
  3661. toggleAllSelection: function toggleAllSelection(event) {
  3662. event.stopPropagation();
  3663. this.store.commit('toggleAllSelection');
  3664. },
  3665. handleFilterClick: function handleFilterClick(event, column) {
  3666. event.stopPropagation();
  3667. var target = event.target;
  3668. var cell = target.tagName === 'TH' ? target : target.parentNode;
  3669. if (Object(dom_["hasClass"])(cell, 'noclick')) return;
  3670. cell = cell.querySelector('.el-table__column-filter-trigger') || cell;
  3671. var table = this.$parent;
  3672. var filterPanel = this.filterPanels[column.id];
  3673. if (filterPanel && column.filterOpened) {
  3674. filterPanel.showPopper = false;
  3675. return;
  3676. }
  3677. if (!filterPanel) {
  3678. filterPanel = new external_vue_default.a(filter_panel);
  3679. this.filterPanels[column.id] = filterPanel;
  3680. if (column.filterPlacement) {
  3681. filterPanel.placement = column.filterPlacement;
  3682. }
  3683. filterPanel.table = table;
  3684. filterPanel.cell = cell;
  3685. filterPanel.column = column;
  3686. !this.$isServer && filterPanel.$mount(document.createElement('div'));
  3687. }
  3688. setTimeout(function () {
  3689. filterPanel.showPopper = true;
  3690. }, 16);
  3691. },
  3692. handleHeaderClick: function handleHeaderClick(event, column) {
  3693. if (!column.filters && column.sortable) {
  3694. this.handleSortClick(event, column);
  3695. } else if (column.filterable && !column.sortable) {
  3696. this.handleFilterClick(event, column);
  3697. }
  3698. this.$parent.$emit('header-click', column, event);
  3699. },
  3700. handleHeaderContextMenu: function handleHeaderContextMenu(event, column) {
  3701. this.$parent.$emit('header-contextmenu', column, event);
  3702. },
  3703. handleMouseDown: function handleMouseDown(event, column) {
  3704. var _this3 = this;
  3705. if (this.$isServer) return;
  3706. if (column.children && column.children.length > 0) return;
  3707. /* istanbul ignore if */
  3708. if (this.draggingColumn && this.border) {
  3709. this.dragging = true;
  3710. this.$parent.resizeProxyVisible = true;
  3711. var table = this.$parent;
  3712. var tableEl = table.$el;
  3713. var tableLeft = tableEl.getBoundingClientRect().left;
  3714. var columnEl = this.$el.querySelector('th.' + column.id);
  3715. var columnRect = columnEl.getBoundingClientRect();
  3716. var minLeft = columnRect.left - tableLeft + 30;
  3717. Object(dom_["addClass"])(columnEl, 'noclick');
  3718. this.dragState = {
  3719. startMouseLeft: event.clientX,
  3720. startLeft: columnRect.right - tableLeft,
  3721. startColumnLeft: columnRect.left - tableLeft,
  3722. tableLeft: tableLeft
  3723. };
  3724. var resizeProxy = table.$refs.resizeProxy;
  3725. resizeProxy.style.left = this.dragState.startLeft + 'px';
  3726. document.onselectstart = function () {
  3727. return false;
  3728. };
  3729. document.ondragstart = function () {
  3730. return false;
  3731. };
  3732. var handleMouseMove = function handleMouseMove(event) {
  3733. var deltaLeft = event.clientX - _this3.dragState.startMouseLeft;
  3734. var proxyLeft = _this3.dragState.startLeft + deltaLeft;
  3735. resizeProxy.style.left = Math.max(minLeft, proxyLeft) + 'px';
  3736. };
  3737. var handleMouseUp = function handleMouseUp() {
  3738. if (_this3.dragging) {
  3739. var _dragState = _this3.dragState,
  3740. startColumnLeft = _dragState.startColumnLeft,
  3741. startLeft = _dragState.startLeft;
  3742. var finalLeft = parseInt(resizeProxy.style.left, 10);
  3743. var columnWidth = finalLeft - startColumnLeft;
  3744. column.width = column.realWidth = columnWidth;
  3745. table.$emit('header-dragend', column.width, startLeft - startColumnLeft, column, event);
  3746. _this3.store.scheduleLayout();
  3747. document.body.style.cursor = '';
  3748. _this3.dragging = false;
  3749. _this3.draggingColumn = null;
  3750. _this3.dragState = {};
  3751. table.resizeProxyVisible = false;
  3752. }
  3753. document.removeEventListener('mousemove', handleMouseMove);
  3754. document.removeEventListener('mouseup', handleMouseUp);
  3755. document.onselectstart = null;
  3756. document.ondragstart = null;
  3757. setTimeout(function () {
  3758. Object(dom_["removeClass"])(columnEl, 'noclick');
  3759. }, 0);
  3760. };
  3761. document.addEventListener('mousemove', handleMouseMove);
  3762. document.addEventListener('mouseup', handleMouseUp);
  3763. }
  3764. },
  3765. handleMouseMove: function handleMouseMove(event, column) {
  3766. if (column.children && column.children.length > 0) return;
  3767. var target = event.target;
  3768. while (target && target.tagName !== 'TH') {
  3769. target = target.parentNode;
  3770. }
  3771. if (!column || !column.resizable) return;
  3772. if (!this.dragging && this.border) {
  3773. var rect = target.getBoundingClientRect();
  3774. var bodyStyle = document.body.style;
  3775. if (rect.width > 12 && rect.right - event.pageX < 8) {
  3776. bodyStyle.cursor = 'col-resize';
  3777. if (Object(dom_["hasClass"])(target, 'is-sortable')) {
  3778. target.style.cursor = 'col-resize';
  3779. }
  3780. this.draggingColumn = column;
  3781. } else if (!this.dragging) {
  3782. bodyStyle.cursor = '';
  3783. if (Object(dom_["hasClass"])(target, 'is-sortable')) {
  3784. target.style.cursor = 'pointer';
  3785. }
  3786. this.draggingColumn = null;
  3787. }
  3788. }
  3789. },
  3790. handleMouseOut: function handleMouseOut() {
  3791. if (this.$isServer) return;
  3792. document.body.style.cursor = '';
  3793. },
  3794. toggleOrder: function toggleOrder(_ref) {
  3795. var order = _ref.order,
  3796. sortOrders = _ref.sortOrders;
  3797. if (order === '') return sortOrders[0];
  3798. var index = sortOrders.indexOf(order || null);
  3799. return sortOrders[index > sortOrders.length - 2 ? 0 : index + 1];
  3800. },
  3801. handleSortClick: function handleSortClick(event, column, givenOrder) {
  3802. event.stopPropagation();
  3803. var order = column.order === givenOrder ? null : givenOrder || this.toggleOrder(column);
  3804. var target = event.target;
  3805. while (target && target.tagName !== 'TH') {
  3806. target = target.parentNode;
  3807. }
  3808. if (target && target.tagName === 'TH') {
  3809. if (Object(dom_["hasClass"])(target, 'noclick')) {
  3810. Object(dom_["removeClass"])(target, 'noclick');
  3811. return;
  3812. }
  3813. }
  3814. if (!column.sortable) return;
  3815. var states = this.store.states;
  3816. var sortProp = states.sortProp;
  3817. var sortOrder = void 0;
  3818. var sortingColumn = states.sortingColumn;
  3819. if (sortingColumn !== column || sortingColumn === column && sortingColumn.order === null) {
  3820. if (sortingColumn) {
  3821. sortingColumn.order = null;
  3822. }
  3823. states.sortingColumn = column;
  3824. sortProp = column.property;
  3825. }
  3826. if (!order) {
  3827. sortOrder = column.order = null;
  3828. } else {
  3829. sortOrder = column.order = order;
  3830. }
  3831. states.sortProp = sortProp;
  3832. states.sortOrder = sortOrder;
  3833. this.store.commit('changeSortCondition');
  3834. }
  3835. },
  3836. data: function data() {
  3837. return {
  3838. draggingColumn: null,
  3839. dragging: false,
  3840. dragState: {}
  3841. };
  3842. }
  3843. });
  3844. // CONCATENATED MODULE: ./packages/table/src/table-footer.js
  3845. var table_footer_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; };
  3846. /* harmony default export */ var table_footer = ({
  3847. name: 'TisTableFooter',
  3848. mixins: [layout_observer],
  3849. render: function render(h) {
  3850. var _this = this;
  3851. var sums = [];
  3852. if (this.summaryMethod) {
  3853. sums = this.summaryMethod({ columns: this.columns, data: this.store.states.data });
  3854. } else {
  3855. this.columns.forEach(function (column, index) {
  3856. if (index === 0) {
  3857. sums[index] = _this.sumText;
  3858. return;
  3859. }
  3860. var values = _this.store.states.data.map(function (item) {
  3861. return Number(item[column.property]);
  3862. });
  3863. var precisions = [];
  3864. var notNumber = true;
  3865. values.forEach(function (value) {
  3866. if (!isNaN(value)) {
  3867. notNumber = false;
  3868. var decimal = ('' + value).split('.')[1];
  3869. precisions.push(decimal ? decimal.length : 0);
  3870. }
  3871. });
  3872. var precision = Math.max.apply(null, precisions);
  3873. if (!notNumber) {
  3874. sums[index] = values.reduce(function (prev, curr) {
  3875. var value = Number(curr);
  3876. if (!isNaN(value)) {
  3877. return parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
  3878. } else {
  3879. return prev;
  3880. }
  3881. }, 0);
  3882. } else {
  3883. sums[index] = '';
  3884. }
  3885. });
  3886. }
  3887. return h(
  3888. 'table',
  3889. {
  3890. 'class': 'el-table__footer',
  3891. attrs: { cellspacing: '0',
  3892. cellpadding: '0',
  3893. border: '0' }
  3894. },
  3895. [h('colgroup', [this.columns.map(function (column) {
  3896. return h('col', {
  3897. attrs: { name: column.id },
  3898. key: column.id });
  3899. }), this.hasGutter ? h('col', {
  3900. attrs: { name: 'gutter' }
  3901. }) : '']), h(
  3902. 'tbody',
  3903. { 'class': [{ 'has-gutter': this.hasGutter }] },
  3904. [h('tr', [this.columns.map(function (column, cellIndex) {
  3905. return h(
  3906. 'td',
  3907. {
  3908. key: cellIndex,
  3909. attrs: { colspan: column.colSpan,
  3910. rowspan: column.rowSpan
  3911. },
  3912. 'class': _this.getRowClasses(column, cellIndex) },
  3913. [h(
  3914. 'div',
  3915. { 'class': ['cell', column.labelClassName] },
  3916. [sums[cellIndex]]
  3917. )]
  3918. );
  3919. }), this.hasGutter ? h('th', { 'class': 'gutter' }) : ''])]
  3920. )]
  3921. );
  3922. },
  3923. props: {
  3924. fixed: String,
  3925. store: {
  3926. required: true
  3927. },
  3928. summaryMethod: Function,
  3929. sumText: String,
  3930. border: Boolean,
  3931. defaultSort: {
  3932. type: Object,
  3933. default: function _default() {
  3934. return {
  3935. prop: '',
  3936. order: ''
  3937. };
  3938. }
  3939. }
  3940. },
  3941. computed: table_footer_extends({
  3942. table: function table() {
  3943. return this.$parent;
  3944. },
  3945. hasGutter: function hasGutter() {
  3946. return !this.fixed && this.tableLayout.gutterWidth;
  3947. }
  3948. }, mapStates({
  3949. columns: 'columns',
  3950. isAllSelected: 'isAllSelected',
  3951. leftFixedLeafCount: 'fixedLeafColumnsLength',
  3952. rightFixedLeafCount: 'rightFixedLeafColumnsLength',
  3953. columnsCount: function columnsCount(states) {
  3954. return states.columns.length;
  3955. },
  3956. leftFixedCount: function leftFixedCount(states) {
  3957. return states.fixedColumns.length;
  3958. },
  3959. rightFixedCount: function rightFixedCount(states) {
  3960. return states.rightFixedColumns.length;
  3961. }
  3962. })),
  3963. methods: {
  3964. isCellHidden: function isCellHidden(index, columns, column) {
  3965. if (this.fixed === true || this.fixed === 'left') {
  3966. return index >= this.leftFixedLeafCount;
  3967. } else if (this.fixed === 'right') {
  3968. var before = 0;
  3969. for (var i = 0; i < index; i++) {
  3970. before += columns[i].colSpan;
  3971. }
  3972. return before < this.columnsCount - this.rightFixedLeafCount;
  3973. } else if (!this.fixed && column.fixed) {
  3974. // hide cell when footer instance is not fixed and column is fixed
  3975. return true;
  3976. } else {
  3977. return index < this.leftFixedCount || index >= this.columnsCount - this.rightFixedCount;
  3978. }
  3979. },
  3980. getRowClasses: function getRowClasses(column, cellIndex) {
  3981. var classes = [column.id, column.align, column.labelClassName];
  3982. if (column.className) {
  3983. classes.push(column.className);
  3984. }
  3985. if (this.isCellHidden(cellIndex, this.columns, column)) {
  3986. classes.push('is-hidden');
  3987. }
  3988. if (!column.children) {
  3989. classes.push('is-leaf');
  3990. }
  3991. return classes;
  3992. }
  3993. }
  3994. });
  3995. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/table/src/table.vue?vue&type=script&lang=js&
  3996. var tablevue_type_script_lang_js_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; };
  3997. //
  3998. //
  3999. //
  4000. //
  4001. //
  4002. //
  4003. //
  4004. //
  4005. //
  4006. //
  4007. //
  4008. //
  4009. //
  4010. //
  4011. //
  4012. //
  4013. //
  4014. //
  4015. //
  4016. //
  4017. //
  4018. //
  4019. //
  4020. //
  4021. //
  4022. //
  4023. //
  4024. //
  4025. //
  4026. //
  4027. //
  4028. //
  4029. //
  4030. //
  4031. //
  4032. //
  4033. //
  4034. //
  4035. //
  4036. //
  4037. //
  4038. //
  4039. //
  4040. //
  4041. //
  4042. //
  4043. //
  4044. //
  4045. //
  4046. //
  4047. //
  4048. //
  4049. //
  4050. //
  4051. //
  4052. //
  4053. //
  4054. //
  4055. //
  4056. //
  4057. //
  4058. //
  4059. //
  4060. //
  4061. //
  4062. //
  4063. //
  4064. //
  4065. //
  4066. //
  4067. //
  4068. //
  4069. //
  4070. //
  4071. //
  4072. //
  4073. //
  4074. //
  4075. //
  4076. //
  4077. //
  4078. //
  4079. //
  4080. //
  4081. //
  4082. //
  4083. //
  4084. //
  4085. //
  4086. //
  4087. //
  4088. //
  4089. //
  4090. //
  4091. //
  4092. //
  4093. //
  4094. //
  4095. //
  4096. //
  4097. //
  4098. //
  4099. //
  4100. //
  4101. //
  4102. //
  4103. //
  4104. //
  4105. //
  4106. //
  4107. //
  4108. //
  4109. //
  4110. //
  4111. //
  4112. //
  4113. //
  4114. //
  4115. //
  4116. //
  4117. //
  4118. //
  4119. //
  4120. //
  4121. //
  4122. //
  4123. //
  4124. //
  4125. //
  4126. //
  4127. //
  4128. //
  4129. //
  4130. //
  4131. //
  4132. //
  4133. //
  4134. //
  4135. //
  4136. //
  4137. //
  4138. //
  4139. //
  4140. //
  4141. //
  4142. //
  4143. //
  4144. //
  4145. //
  4146. //
  4147. //
  4148. //
  4149. //
  4150. //
  4151. //
  4152. //
  4153. //
  4154. //
  4155. //
  4156. //
  4157. //
  4158. //
  4159. //
  4160. //
  4161. //
  4162. //
  4163. //
  4164. //
  4165. //
  4166. //
  4167. //
  4168. //
  4169. //
  4170. //
  4171. //
  4172. //
  4173. //
  4174. //
  4175. //
  4176. //
  4177. //
  4178. //
  4179. //
  4180. //
  4181. //
  4182. //
  4183. //
  4184. //
  4185. //
  4186. //
  4187. //
  4188. //
  4189. //
  4190. //
  4191. //
  4192. //
  4193. //
  4194. //
  4195. //
  4196. //
  4197. //
  4198. //
  4199. //
  4200. //
  4201. //
  4202. //
  4203. //
  4204. //
  4205. //
  4206. //
  4207. //
  4208. //
  4209. //
  4210. //
  4211. var tableIdSeed = 1;
  4212. /* harmony default export */ var tablevue_type_script_lang_js_ = ({
  4213. name: 'TisTable',
  4214. mixins: [locale_default.a, migrating_default.a],
  4215. directives: {
  4216. Mousewheel: directives_mousewheel
  4217. },
  4218. props: {
  4219. data: {
  4220. type: Array,
  4221. default: function _default() {
  4222. return [];
  4223. }
  4224. },
  4225. size: String,
  4226. width: [String, Number],
  4227. height: [String, Number],
  4228. maxHeight: [String, Number],
  4229. fit: {
  4230. type: Boolean,
  4231. default: true
  4232. },
  4233. stripe: Boolean,
  4234. border: Boolean,
  4235. rowKey: [String, Function],
  4236. context: {},
  4237. showHeader: {
  4238. type: Boolean,
  4239. default: true
  4240. },
  4241. showSummary: Boolean,
  4242. sumText: String,
  4243. summaryMethod: Function,
  4244. rowClassName: [String, Function],
  4245. rowStyle: [Object, Function],
  4246. cellClassName: [String, Function],
  4247. cellStyle: [Object, Function],
  4248. headerRowClassName: [String, Function],
  4249. headerRowStyle: [Object, Function],
  4250. headerCellClassName: [String, Function],
  4251. headerCellStyle: [Object, Function],
  4252. highlightCurrentRow: Boolean,
  4253. currentRowKey: [String, Number],
  4254. emptyText: String,
  4255. expandRowKeys: Array,
  4256. defaultExpandAll: Boolean,
  4257. defaultSort: Object,
  4258. tooltipEffect: String,
  4259. spanMethod: Function,
  4260. selectOnIndeterminate: {
  4261. type: Boolean,
  4262. default: true
  4263. },
  4264. indent: {
  4265. type: Number,
  4266. default: 16
  4267. },
  4268. treeProps: {
  4269. type: Object,
  4270. default: function _default() {
  4271. return {
  4272. hasChildren: 'hasChildren',
  4273. children: 'children'
  4274. };
  4275. }
  4276. },
  4277. lazy: Boolean,
  4278. load: Function
  4279. },
  4280. components: {
  4281. TableHeader: table_header,
  4282. TableFooter: table_footer,
  4283. TableBody: table_body,
  4284. ElCheckbox: packages_checkbox["default"]
  4285. },
  4286. methods: {
  4287. getMigratingConfig: function getMigratingConfig() {
  4288. return {
  4289. events: {
  4290. expand: 'expand is renamed to expand-change'
  4291. }
  4292. };
  4293. },
  4294. setCurrentRow: function setCurrentRow(row) {
  4295. this.store.commit('setCurrentRow', row);
  4296. },
  4297. toggleRowSelection: function toggleRowSelection(row, selected) {
  4298. this.store.toggleRowSelection(row, selected, false);
  4299. this.store.updateAllSelected();
  4300. },
  4301. toggleRowExpansion: function toggleRowExpansion(row, expanded) {
  4302. this.store.toggleRowExpansionAdapter(row, expanded);
  4303. },
  4304. clearSelection: function clearSelection() {
  4305. this.store.clearSelection();
  4306. },
  4307. clearFilter: function clearFilter(columnKeys) {
  4308. this.store.clearFilter(columnKeys);
  4309. },
  4310. clearSort: function clearSort() {
  4311. this.store.clearSort();
  4312. },
  4313. handleMouseLeave: function handleMouseLeave() {
  4314. this.store.commit('setHoverRow', null);
  4315. if (this.hoverState) this.hoverState = null;
  4316. },
  4317. updateScrollY: function updateScrollY() {
  4318. var changed = this.layout.updateScrollY();
  4319. if (changed) {
  4320. this.layout.notifyObservers('scrollable');
  4321. this.layout.updateColumnsWidth();
  4322. }
  4323. },
  4324. handleFixedMousewheel: function handleFixedMousewheel(event, data) {
  4325. var bodyWrapper = this.bodyWrapper;
  4326. if (Math.abs(data.spinY) > 0) {
  4327. var currentScrollTop = bodyWrapper.scrollTop;
  4328. if (data.pixelY < 0 && currentScrollTop !== 0) {
  4329. event.preventDefault();
  4330. }
  4331. if (data.pixelY > 0 && bodyWrapper.scrollHeight - bodyWrapper.clientHeight > currentScrollTop) {
  4332. event.preventDefault();
  4333. }
  4334. bodyWrapper.scrollTop += Math.ceil(data.pixelY / 5);
  4335. } else {
  4336. bodyWrapper.scrollLeft += Math.ceil(data.pixelX / 5);
  4337. }
  4338. },
  4339. handleHeaderFooterMousewheel: function handleHeaderFooterMousewheel(event, data) {
  4340. var pixelX = data.pixelX,
  4341. pixelY = data.pixelY;
  4342. if (Math.abs(pixelX) >= Math.abs(pixelY)) {
  4343. this.bodyWrapper.scrollLeft += data.pixelX / 5;
  4344. }
  4345. },
  4346. // TODO 使用 CSS transform
  4347. syncPostion: Object(external_throttle_debounce_["throttle"])(20, function () {
  4348. var _bodyWrapper = this.bodyWrapper,
  4349. scrollLeft = _bodyWrapper.scrollLeft,
  4350. scrollTop = _bodyWrapper.scrollTop,
  4351. offsetWidth = _bodyWrapper.offsetWidth,
  4352. scrollWidth = _bodyWrapper.scrollWidth;
  4353. var _$refs = this.$refs,
  4354. headerWrapper = _$refs.headerWrapper,
  4355. footerWrapper = _$refs.footerWrapper,
  4356. fixedBodyWrapper = _$refs.fixedBodyWrapper,
  4357. rightFixedBodyWrapper = _$refs.rightFixedBodyWrapper;
  4358. if (headerWrapper) headerWrapper.scrollLeft = scrollLeft;
  4359. if (footerWrapper) footerWrapper.scrollLeft = scrollLeft;
  4360. if (fixedBodyWrapper) fixedBodyWrapper.scrollTop = scrollTop;
  4361. if (rightFixedBodyWrapper) rightFixedBodyWrapper.scrollTop = scrollTop;
  4362. var maxScrollLeftPosition = scrollWidth - offsetWidth - 1;
  4363. if (scrollLeft >= maxScrollLeftPosition) {
  4364. this.scrollPosition = 'right';
  4365. } else if (scrollLeft === 0) {
  4366. this.scrollPosition = 'left';
  4367. } else {
  4368. this.scrollPosition = 'middle';
  4369. }
  4370. }),
  4371. bindEvents: function bindEvents() {
  4372. this.bodyWrapper.addEventListener('scroll', this.syncPostion, { passive: true });
  4373. if (this.fit) {
  4374. Object(resize_event_["addResizeListener"])(this.$el, this.resizeListener);
  4375. }
  4376. },
  4377. unbindEvents: function unbindEvents() {
  4378. this.bodyWrapper.removeEventListener('scroll', this.syncPostion, { passive: true });
  4379. if (this.fit) {
  4380. Object(resize_event_["removeResizeListener"])(this.$el, this.resizeListener);
  4381. }
  4382. },
  4383. resizeListener: function resizeListener() {
  4384. if (!this.$ready) return;
  4385. var shouldUpdateLayout = false;
  4386. var el = this.$el;
  4387. var _resizeState = this.resizeState,
  4388. oldWidth = _resizeState.width,
  4389. oldHeight = _resizeState.height;
  4390. var width = el.offsetWidth;
  4391. if (oldWidth !== width) {
  4392. shouldUpdateLayout = true;
  4393. }
  4394. var height = el.offsetHeight;
  4395. if ((this.height || this.shouldUpdateHeight) && oldHeight !== height) {
  4396. shouldUpdateLayout = true;
  4397. }
  4398. if (shouldUpdateLayout) {
  4399. this.resizeState.width = width;
  4400. this.resizeState.height = height;
  4401. this.doLayout();
  4402. }
  4403. },
  4404. doLayout: function doLayout() {
  4405. if (this.shouldUpdateHeight) {
  4406. this.layout.updateElsHeight();
  4407. }
  4408. this.layout.updateColumnsWidth();
  4409. },
  4410. sort: function sort(prop, order) {
  4411. this.store.commit('sort', { prop: prop, order: order });
  4412. },
  4413. toggleAllSelection: function toggleAllSelection() {
  4414. this.store.commit('toggleAllSelection');
  4415. }
  4416. },
  4417. computed: tablevue_type_script_lang_js_extends({
  4418. tableSize: function tableSize() {
  4419. return this.size || (this.$ELEMENT || {}).size;
  4420. },
  4421. bodyWrapper: function bodyWrapper() {
  4422. return this.$refs.bodyWrapper;
  4423. },
  4424. shouldUpdateHeight: function shouldUpdateHeight() {
  4425. return this.height || this.maxHeight || this.fixedColumns.length > 0 || this.rightFixedColumns.length > 0;
  4426. },
  4427. bodyWidth: function bodyWidth() {
  4428. var _layout = this.layout,
  4429. bodyWidth = _layout.bodyWidth,
  4430. scrollY = _layout.scrollY,
  4431. gutterWidth = _layout.gutterWidth;
  4432. return bodyWidth ? bodyWidth - (scrollY ? gutterWidth : 0) + 'px' : '';
  4433. },
  4434. bodyHeight: function bodyHeight() {
  4435. var _layout2 = this.layout,
  4436. _layout2$headerHeight = _layout2.headerHeight,
  4437. headerHeight = _layout2$headerHeight === undefined ? 0 : _layout2$headerHeight,
  4438. bodyHeight = _layout2.bodyHeight,
  4439. _layout2$footerHeight = _layout2.footerHeight,
  4440. footerHeight = _layout2$footerHeight === undefined ? 0 : _layout2$footerHeight;
  4441. if (this.height) {
  4442. return {
  4443. height: bodyHeight ? bodyHeight + 'px' : ''
  4444. };
  4445. } else if (this.maxHeight) {
  4446. var maxHeight = Object(util["j" /* parseHeight */])(this.maxHeight);
  4447. if (typeof maxHeight === 'number') {
  4448. return {
  4449. 'max-height': maxHeight - footerHeight - (this.showHeader ? headerHeight : 0) + 'px'
  4450. };
  4451. }
  4452. }
  4453. return {};
  4454. },
  4455. fixedBodyHeight: function fixedBodyHeight() {
  4456. if (this.height) {
  4457. return {
  4458. height: this.layout.fixedBodyHeight ? this.layout.fixedBodyHeight + 'px' : ''
  4459. };
  4460. } else if (this.maxHeight) {
  4461. var maxHeight = Object(util["j" /* parseHeight */])(this.maxHeight);
  4462. if (typeof maxHeight === 'number') {
  4463. maxHeight = this.layout.scrollX ? maxHeight - this.layout.gutterWidth : maxHeight;
  4464. if (this.showHeader) {
  4465. maxHeight -= this.layout.headerHeight;
  4466. }
  4467. maxHeight -= this.layout.footerHeight;
  4468. return {
  4469. 'max-height': maxHeight + 'px'
  4470. };
  4471. }
  4472. }
  4473. return {};
  4474. },
  4475. fixedHeight: function fixedHeight() {
  4476. if (this.maxHeight) {
  4477. if (this.showSummary) {
  4478. return {
  4479. bottom: 0
  4480. };
  4481. }
  4482. return {
  4483. bottom: this.layout.scrollX && this.data.length ? this.layout.gutterWidth + 'px' : ''
  4484. };
  4485. } else {
  4486. if (this.showSummary) {
  4487. return {
  4488. height: this.layout.tableHeight ? this.layout.tableHeight + 'px' : ''
  4489. };
  4490. }
  4491. return {
  4492. height: this.layout.viewportHeight ? this.layout.viewportHeight + 'px' : ''
  4493. };
  4494. }
  4495. },
  4496. emptyBlockStyle: function emptyBlockStyle() {
  4497. if (this.data && this.data.length) return null;
  4498. var height = '100%';
  4499. if (this.layout.appendHeight) {
  4500. height = 'calc(100% - ' + this.layout.appendHeight + 'px)';
  4501. }
  4502. return {
  4503. width: this.bodyWidth,
  4504. height: height
  4505. };
  4506. }
  4507. }, mapStates({
  4508. selection: 'selection',
  4509. columns: 'columns',
  4510. tableData: 'data',
  4511. fixedColumns: 'fixedColumns',
  4512. rightFixedColumns: 'rightFixedColumns'
  4513. })),
  4514. watch: {
  4515. height: {
  4516. immediate: true,
  4517. handler: function handler(value) {
  4518. this.layout.setHeight(value);
  4519. }
  4520. },
  4521. maxHeight: {
  4522. immediate: true,
  4523. handler: function handler(value) {
  4524. this.layout.setMaxHeight(value);
  4525. }
  4526. },
  4527. currentRowKey: {
  4528. immediate: true,
  4529. handler: function handler(value) {
  4530. if (!this.rowKey) return;
  4531. this.store.setCurrentRowKey(value);
  4532. }
  4533. },
  4534. data: {
  4535. immediate: true,
  4536. handler: function handler(value) {
  4537. this.store.commit('setData', value);
  4538. }
  4539. },
  4540. expandRowKeys: {
  4541. immediate: true,
  4542. handler: function handler(newVal) {
  4543. if (newVal) {
  4544. this.store.setExpandRowKeysAdapter(newVal);
  4545. }
  4546. }
  4547. }
  4548. },
  4549. created: function created() {
  4550. var _this = this;
  4551. this.tableId = 'el-table_' + tableIdSeed++;
  4552. this.debouncedUpdateLayout = Object(external_throttle_debounce_["debounce"])(50, function () {
  4553. return _this.doLayout();
  4554. });
  4555. },
  4556. mounted: function mounted() {
  4557. var _this2 = this;
  4558. this.bindEvents();
  4559. this.store.updateColumns();
  4560. this.doLayout();
  4561. this.resizeState = {
  4562. width: this.$el.offsetWidth,
  4563. height: this.$el.offsetHeight
  4564. };
  4565. // init filters
  4566. this.store.states.columns.forEach(function (column) {
  4567. if (column.filteredValue && column.filteredValue.length) {
  4568. _this2.store.commit('filterChange', {
  4569. column: column,
  4570. values: column.filteredValue,
  4571. silent: true
  4572. });
  4573. }
  4574. });
  4575. this.$ready = true;
  4576. },
  4577. destroyed: function destroyed() {
  4578. this.unbindEvents();
  4579. },
  4580. data: function data() {
  4581. var _treeProps = this.treeProps,
  4582. _treeProps$hasChildre = _treeProps.hasChildren,
  4583. hasChildren = _treeProps$hasChildre === undefined ? 'hasChildren' : _treeProps$hasChildre,
  4584. _treeProps$children = _treeProps.children,
  4585. children = _treeProps$children === undefined ? 'children' : _treeProps$children;
  4586. this.store = createStore(this, {
  4587. rowKey: this.rowKey,
  4588. defaultExpandAll: this.defaultExpandAll,
  4589. selectOnIndeterminate: this.selectOnIndeterminate,
  4590. // TreeTable 的相关配置
  4591. indent: this.indent,
  4592. lazy: this.lazy,
  4593. lazyColumnIdentifier: hasChildren,
  4594. childrenColumnName: children
  4595. });
  4596. var layout = new table_layout({
  4597. store: this.store,
  4598. table: this,
  4599. fit: this.fit,
  4600. showHeader: this.showHeader
  4601. });
  4602. return {
  4603. layout: layout,
  4604. isHidden: false,
  4605. renderExpanded: null,
  4606. resizeProxyVisible: false,
  4607. resizeState: {
  4608. width: null,
  4609. height: null
  4610. },
  4611. // 是否拥有多级表头
  4612. isGroup: false,
  4613. scrollPosition: 'left'
  4614. };
  4615. }
  4616. });
  4617. // CONCATENATED MODULE: ./packages/table/src/table.vue?vue&type=script&lang=js&
  4618. /* harmony default export */ var src_tablevue_type_script_lang_js_ = (tablevue_type_script_lang_js_);
  4619. // CONCATENATED MODULE: ./packages/table/src/table.vue
  4620. /* normalize component */
  4621. var table_component = Object(componentNormalizer["a" /* default */])(
  4622. src_tablevue_type_script_lang_js_,
  4623. render,
  4624. staticRenderFns,
  4625. false,
  4626. null,
  4627. null,
  4628. null
  4629. )
  4630. /* hot reload */
  4631. if (false) { var table_api; }
  4632. table_component.options.__file = "packages/table/src/table.vue"
  4633. /* harmony default export */ var src_table = (table_component.exports);
  4634. // CONCATENATED MODULE: ./packages/table/index.js
  4635. /* istanbul ignore next */
  4636. src_table.install = function (Vue) {
  4637. Vue.component(src_table.name, src_table);
  4638. };
  4639. /* harmony default export */ var packages_table = __webpack_exports__["default"] = (src_table);
  4640. /***/ }),
  4641. /***/ 61:
  4642. /***/ (function(module, exports) {
  4643. module.exports = require("tis-ui/lib/utils/clickoutside");
  4644. /***/ }),
  4645. /***/ 62:
  4646. /***/ (function(module, exports) {
  4647. module.exports = require("throttle-debounce/debounce");
  4648. /***/ }),
  4649. /***/ 65:
  4650. /***/ (function(module, exports) {
  4651. module.exports = require("tis-ui/lib/utils/scrollbar-width");
  4652. /***/ }),
  4653. /***/ 66:
  4654. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4655. "use strict";
  4656. // ESM COMPAT FLAG
  4657. __webpack_require__.r(__webpack_exports__);
  4658. // EXTERNAL MODULE: external "tis-ui/lib/utils/resize-event"
  4659. var resize_event_ = __webpack_require__(44);
  4660. // EXTERNAL MODULE: external "tis-ui/lib/utils/scrollbar-width"
  4661. var scrollbar_width_ = __webpack_require__(65);
  4662. var scrollbar_width_default = /*#__PURE__*/__webpack_require__.n(scrollbar_width_);
  4663. // EXTERNAL MODULE: external "tis-ui/lib/utils/util"
  4664. var util_ = __webpack_require__(10);
  4665. // EXTERNAL MODULE: external "tis-ui/lib/utils/dom"
  4666. var dom_ = __webpack_require__(7);
  4667. // CONCATENATED MODULE: ./packages/scrollbar/src/util.js
  4668. var BAR_MAP = {
  4669. vertical: {
  4670. offset: 'offsetHeight',
  4671. scroll: 'scrollTop',
  4672. scrollSize: 'scrollHeight',
  4673. size: 'height',
  4674. key: 'vertical',
  4675. axis: 'Y',
  4676. client: 'clientY',
  4677. direction: 'top'
  4678. },
  4679. horizontal: {
  4680. offset: 'offsetWidth',
  4681. scroll: 'scrollLeft',
  4682. scrollSize: 'scrollWidth',
  4683. size: 'width',
  4684. key: 'horizontal',
  4685. axis: 'X',
  4686. client: 'clientX',
  4687. direction: 'left'
  4688. }
  4689. };
  4690. function renderThumbStyle(_ref) {
  4691. var move = _ref.move,
  4692. size = _ref.size,
  4693. bar = _ref.bar;
  4694. var style = {};
  4695. var translate = 'translate' + bar.axis + '(' + move + '%)';
  4696. style[bar.size] = size;
  4697. style.transform = translate;
  4698. style.msTransform = translate;
  4699. style.webkitTransform = translate;
  4700. return style;
  4701. };
  4702. // CONCATENATED MODULE: ./packages/scrollbar/src/bar.js
  4703. /* istanbul ignore next */
  4704. /* harmony default export */ var src_bar = ({
  4705. name: 'Bar',
  4706. props: {
  4707. vertical: Boolean,
  4708. size: String,
  4709. move: Number
  4710. },
  4711. computed: {
  4712. bar: function bar() {
  4713. return BAR_MAP[this.vertical ? 'vertical' : 'horizontal'];
  4714. },
  4715. wrap: function wrap() {
  4716. return this.$parent.wrap;
  4717. }
  4718. },
  4719. render: function render(h) {
  4720. var size = this.size,
  4721. move = this.move,
  4722. bar = this.bar;
  4723. return h(
  4724. 'div',
  4725. {
  4726. 'class': ['el-scrollbar__bar', 'is-' + bar.key],
  4727. on: {
  4728. 'mousedown': this.clickTrackHandler
  4729. }
  4730. },
  4731. [h('div', {
  4732. ref: 'thumb',
  4733. 'class': 'el-scrollbar__thumb',
  4734. on: {
  4735. 'mousedown': this.clickThumbHandler
  4736. },
  4737. style: renderThumbStyle({ size: size, move: move, bar: bar }) })]
  4738. );
  4739. },
  4740. methods: {
  4741. clickThumbHandler: function clickThumbHandler(e) {
  4742. // prevent click event of right button
  4743. if (e.ctrlKey || e.button === 2) {
  4744. return;
  4745. }
  4746. this.startDrag(e);
  4747. this[this.bar.axis] = e.currentTarget[this.bar.offset] - (e[this.bar.client] - e.currentTarget.getBoundingClientRect()[this.bar.direction]);
  4748. },
  4749. clickTrackHandler: function clickTrackHandler(e) {
  4750. var offset = Math.abs(e.target.getBoundingClientRect()[this.bar.direction] - e[this.bar.client]);
  4751. var thumbHalf = this.$refs.thumb[this.bar.offset] / 2;
  4752. var thumbPositionPercentage = (offset - thumbHalf) * 100 / this.$el[this.bar.offset];
  4753. this.wrap[this.bar.scroll] = thumbPositionPercentage * this.wrap[this.bar.scrollSize] / 100;
  4754. },
  4755. startDrag: function startDrag(e) {
  4756. e.stopImmediatePropagation();
  4757. this.cursorDown = true;
  4758. Object(dom_["on"])(document, 'mousemove', this.mouseMoveDocumentHandler);
  4759. Object(dom_["on"])(document, 'mouseup', this.mouseUpDocumentHandler);
  4760. document.onselectstart = function () {
  4761. return false;
  4762. };
  4763. },
  4764. mouseMoveDocumentHandler: function mouseMoveDocumentHandler(e) {
  4765. if (this.cursorDown === false) return;
  4766. var prevPage = this[this.bar.axis];
  4767. if (!prevPage) return;
  4768. var offset = (this.$el.getBoundingClientRect()[this.bar.direction] - e[this.bar.client]) * -1;
  4769. var thumbClickPosition = this.$refs.thumb[this.bar.offset] - prevPage;
  4770. var thumbPositionPercentage = (offset - thumbClickPosition) * 100 / this.$el[this.bar.offset];
  4771. this.wrap[this.bar.scroll] = thumbPositionPercentage * this.wrap[this.bar.scrollSize] / 100;
  4772. },
  4773. mouseUpDocumentHandler: function mouseUpDocumentHandler(e) {
  4774. this.cursorDown = false;
  4775. this[this.bar.axis] = 0;
  4776. Object(dom_["off"])(document, 'mousemove', this.mouseMoveDocumentHandler);
  4777. document.onselectstart = null;
  4778. }
  4779. },
  4780. destroyed: function destroyed() {
  4781. Object(dom_["off"])(document, 'mouseup', this.mouseUpDocumentHandler);
  4782. }
  4783. });
  4784. // CONCATENATED MODULE: ./packages/scrollbar/src/main.js
  4785. // reference https://github.com/noeldelgado/gemini-scrollbar/blob/master/index.js
  4786. /* istanbul ignore next */
  4787. /* harmony default export */ var main = ({
  4788. name: 'TisScrollbar',
  4789. components: { Bar: src_bar },
  4790. props: {
  4791. native: Boolean,
  4792. wrapStyle: {},
  4793. wrapClass: {},
  4794. viewClass: {},
  4795. viewStyle: {},
  4796. noresize: Boolean, // 如果 container 尺寸不会发生变化,最好设置它可以优化性能
  4797. tag: {
  4798. type: String,
  4799. default: 'div'
  4800. }
  4801. },
  4802. data: function data() {
  4803. return {
  4804. sizeWidth: '0',
  4805. sizeHeight: '0',
  4806. moveX: 0,
  4807. moveY: 0
  4808. };
  4809. },
  4810. computed: {
  4811. wrap: function wrap() {
  4812. return this.$refs.wrap;
  4813. }
  4814. },
  4815. render: function render(h) {
  4816. var gutter = scrollbar_width_default()();
  4817. var style = this.wrapStyle;
  4818. if (gutter) {
  4819. var gutterWith = '-' + gutter + 'px';
  4820. var gutterStyle = 'margin-bottom: ' + gutterWith + '; margin-right: ' + gutterWith + ';';
  4821. if (Array.isArray(this.wrapStyle)) {
  4822. style = Object(util_["toObject"])(this.wrapStyle);
  4823. style.marginRight = style.marginBottom = gutterWith;
  4824. } else if (typeof this.wrapStyle === 'string') {
  4825. style += gutterStyle;
  4826. } else {
  4827. style = gutterStyle;
  4828. }
  4829. }
  4830. var view = h(this.tag, {
  4831. class: ['el-scrollbar__view', this.viewClass],
  4832. style: this.viewStyle,
  4833. ref: 'resize'
  4834. }, this.$slots.default);
  4835. var wrap = h(
  4836. 'div',
  4837. {
  4838. ref: 'wrap',
  4839. style: style,
  4840. on: {
  4841. 'scroll': this.handleScroll
  4842. },
  4843. 'class': [this.wrapClass, 'el-scrollbar__wrap', gutter ? '' : 'el-scrollbar__wrap--hidden-default'] },
  4844. [[view]]
  4845. );
  4846. var nodes = void 0;
  4847. if (!this.native) {
  4848. nodes = [wrap, h(src_bar, {
  4849. attrs: {
  4850. move: this.moveX,
  4851. size: this.sizeWidth }
  4852. }), h(src_bar, {
  4853. attrs: {
  4854. vertical: true,
  4855. move: this.moveY,
  4856. size: this.sizeHeight }
  4857. })];
  4858. } else {
  4859. nodes = [h(
  4860. 'div',
  4861. {
  4862. ref: 'wrap',
  4863. 'class': [this.wrapClass, 'el-scrollbar__wrap'],
  4864. style: style },
  4865. [[view]]
  4866. )];
  4867. }
  4868. return h('div', { class: 'el-scrollbar' }, nodes);
  4869. },
  4870. methods: {
  4871. handleScroll: function handleScroll() {
  4872. var wrap = this.wrap;
  4873. this.moveY = wrap.scrollTop * 100 / wrap.clientHeight;
  4874. this.moveX = wrap.scrollLeft * 100 / wrap.clientWidth;
  4875. },
  4876. update: function update() {
  4877. var heightPercentage = void 0,
  4878. widthPercentage = void 0;
  4879. var wrap = this.wrap;
  4880. if (!wrap) return;
  4881. heightPercentage = wrap.clientHeight * 100 / wrap.scrollHeight;
  4882. widthPercentage = wrap.clientWidth * 100 / wrap.scrollWidth;
  4883. this.sizeHeight = heightPercentage < 100 ? heightPercentage + '%' : '';
  4884. this.sizeWidth = widthPercentage < 100 ? widthPercentage + '%' : '';
  4885. }
  4886. },
  4887. mounted: function mounted() {
  4888. if (this.native) return;
  4889. this.$nextTick(this.update);
  4890. !this.noresize && Object(resize_event_["addResizeListener"])(this.$refs.resize, this.update);
  4891. },
  4892. beforeDestroy: function beforeDestroy() {
  4893. if (this.native) return;
  4894. !this.noresize && Object(resize_event_["removeResizeListener"])(this.$refs.resize, this.update);
  4895. }
  4896. });
  4897. // CONCATENATED MODULE: ./packages/scrollbar/index.js
  4898. /* istanbul ignore next */
  4899. main.install = function (Vue) {
  4900. Vue.component(main.name, main);
  4901. };
  4902. /* harmony default export */ var scrollbar = __webpack_exports__["default"] = (main);
  4903. /***/ }),
  4904. /***/ 68:
  4905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4906. "use strict";
  4907. // ESM COMPAT FLAG
  4908. __webpack_require__.r(__webpack_exports__);
  4909. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/checkbox/src/checkbox.vue?vue&type=template&id=d0387074&
  4910. var render = function() {
  4911. var _vm = this
  4912. var _h = _vm.$createElement
  4913. var _c = _vm._self._c || _h
  4914. return _c(
  4915. "label",
  4916. {
  4917. staticClass: "el-checkbox",
  4918. class: [
  4919. _vm.border && _vm.checkboxSize
  4920. ? "el-checkbox--" + _vm.checkboxSize
  4921. : "",
  4922. { "is-disabled": _vm.isDisabled },
  4923. { "is-bordered": _vm.border },
  4924. { "is-checked": _vm.isChecked }
  4925. ],
  4926. attrs: { id: _vm.id }
  4927. },
  4928. [
  4929. _c(
  4930. "span",
  4931. {
  4932. staticClass: "el-checkbox__input",
  4933. class: {
  4934. "is-disabled": _vm.isDisabled,
  4935. "is-checked": _vm.isChecked,
  4936. "is-indeterminate": _vm.indeterminate,
  4937. "is-focus": _vm.focus
  4938. },
  4939. attrs: {
  4940. tabindex: _vm.indeterminate ? 0 : false,
  4941. role: _vm.indeterminate ? "checkbox" : false,
  4942. "aria-checked": _vm.indeterminate ? "mixed" : false
  4943. }
  4944. },
  4945. [
  4946. _c("span", { staticClass: "el-checkbox__inner" }),
  4947. _vm.trueLabel || _vm.falseLabel
  4948. ? _c("input", {
  4949. directives: [
  4950. {
  4951. name: "model",
  4952. rawName: "v-model",
  4953. value: _vm.model,
  4954. expression: "model"
  4955. }
  4956. ],
  4957. staticClass: "el-checkbox__original",
  4958. attrs: {
  4959. type: "checkbox",
  4960. "aria-hidden": _vm.indeterminate ? "true" : "false",
  4961. name: _vm.name,
  4962. disabled: _vm.isDisabled,
  4963. "true-value": _vm.trueLabel,
  4964. "false-value": _vm.falseLabel
  4965. },
  4966. domProps: {
  4967. checked: Array.isArray(_vm.model)
  4968. ? _vm._i(_vm.model, null) > -1
  4969. : _vm._q(_vm.model, _vm.trueLabel)
  4970. },
  4971. on: {
  4972. change: [
  4973. function($event) {
  4974. var $$a = _vm.model,
  4975. $$el = $event.target,
  4976. $$c = $$el.checked ? _vm.trueLabel : _vm.falseLabel
  4977. if (Array.isArray($$a)) {
  4978. var $$v = null,
  4979. $$i = _vm._i($$a, $$v)
  4980. if ($$el.checked) {
  4981. $$i < 0 && (_vm.model = $$a.concat([$$v]))
  4982. } else {
  4983. $$i > -1 &&
  4984. (_vm.model = $$a
  4985. .slice(0, $$i)
  4986. .concat($$a.slice($$i + 1)))
  4987. }
  4988. } else {
  4989. _vm.model = $$c
  4990. }
  4991. },
  4992. _vm.handleChange
  4993. ],
  4994. focus: function($event) {
  4995. _vm.focus = true
  4996. },
  4997. blur: function($event) {
  4998. _vm.focus = false
  4999. }
  5000. }
  5001. })
  5002. : _c("input", {
  5003. directives: [
  5004. {
  5005. name: "model",
  5006. rawName: "v-model",
  5007. value: _vm.model,
  5008. expression: "model"
  5009. }
  5010. ],
  5011. staticClass: "el-checkbox__original",
  5012. attrs: {
  5013. type: "checkbox",
  5014. "aria-hidden": _vm.indeterminate ? "true" : "false",
  5015. disabled: _vm.isDisabled,
  5016. name: _vm.name
  5017. },
  5018. domProps: {
  5019. value: _vm.label,
  5020. checked: Array.isArray(_vm.model)
  5021. ? _vm._i(_vm.model, _vm.label) > -1
  5022. : _vm.model
  5023. },
  5024. on: {
  5025. change: [
  5026. function($event) {
  5027. var $$a = _vm.model,
  5028. $$el = $event.target,
  5029. $$c = $$el.checked ? true : false
  5030. if (Array.isArray($$a)) {
  5031. var $$v = _vm.label,
  5032. $$i = _vm._i($$a, $$v)
  5033. if ($$el.checked) {
  5034. $$i < 0 && (_vm.model = $$a.concat([$$v]))
  5035. } else {
  5036. $$i > -1 &&
  5037. (_vm.model = $$a
  5038. .slice(0, $$i)
  5039. .concat($$a.slice($$i + 1)))
  5040. }
  5041. } else {
  5042. _vm.model = $$c
  5043. }
  5044. },
  5045. _vm.handleChange
  5046. ],
  5047. focus: function($event) {
  5048. _vm.focus = true
  5049. },
  5050. blur: function($event) {
  5051. _vm.focus = false
  5052. }
  5053. }
  5054. })
  5055. ]
  5056. ),
  5057. _vm.$slots.default || _vm.label
  5058. ? _c(
  5059. "span",
  5060. { staticClass: "el-checkbox__label" },
  5061. [
  5062. _vm._t("default"),
  5063. !_vm.$slots.default ? [_vm._v(_vm._s(_vm.label))] : _vm._e()
  5064. ],
  5065. 2
  5066. )
  5067. : _vm._e()
  5068. ]
  5069. )
  5070. }
  5071. var staticRenderFns = []
  5072. render._withStripped = true
  5073. // CONCATENATED MODULE: ./packages/checkbox/src/checkbox.vue?vue&type=template&id=d0387074&
  5074. // EXTERNAL MODULE: external "tis-ui/lib/mixins/emitter"
  5075. var emitter_ = __webpack_require__(13);
  5076. var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
  5077. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/checkbox/src/checkbox.vue?vue&type=script&lang=js&
  5078. //
  5079. //
  5080. //
  5081. //
  5082. //
  5083. //
  5084. //
  5085. //
  5086. //
  5087. //
  5088. //
  5089. //
  5090. //
  5091. //
  5092. //
  5093. //
  5094. //
  5095. //
  5096. //
  5097. //
  5098. //
  5099. //
  5100. //
  5101. //
  5102. //
  5103. //
  5104. //
  5105. //
  5106. //
  5107. //
  5108. //
  5109. //
  5110. //
  5111. //
  5112. //
  5113. //
  5114. //
  5115. //
  5116. //
  5117. //
  5118. //
  5119. //
  5120. //
  5121. //
  5122. //
  5123. //
  5124. //
  5125. //
  5126. //
  5127. //
  5128. //
  5129. //
  5130. //
  5131. //
  5132. //
  5133. /* harmony default export */ var checkboxvue_type_script_lang_js_ = ({
  5134. name: 'TisCheckbox',
  5135. mixins: [emitter_default.a],
  5136. inject: {
  5137. elForm: {
  5138. default: ''
  5139. },
  5140. elFormItem: {
  5141. default: ''
  5142. }
  5143. },
  5144. componentName: 'TisCheckbox',
  5145. data: function data() {
  5146. return {
  5147. selfModel: false,
  5148. focus: false,
  5149. isLimitExceeded: false
  5150. };
  5151. },
  5152. computed: {
  5153. model: {
  5154. get: function get() {
  5155. return this.isGroup ? this.store : this.value !== undefined ? this.value : this.selfModel;
  5156. },
  5157. set: function set(val) {
  5158. if (this.isGroup) {
  5159. this.isLimitExceeded = false;
  5160. this._checkboxGroup.min !== undefined && val.length < this._checkboxGroup.min && (this.isLimitExceeded = true);
  5161. this._checkboxGroup.max !== undefined && val.length > this._checkboxGroup.max && (this.isLimitExceeded = true);
  5162. this.isLimitExceeded === false && this.dispatch('TisCheckboxGroup', 'input', [val]);
  5163. } else {
  5164. this.$emit('input', val);
  5165. this.selfModel = val;
  5166. }
  5167. }
  5168. },
  5169. isChecked: function isChecked() {
  5170. if ({}.toString.call(this.model) === '[object Boolean]') {
  5171. return this.model;
  5172. } else if (Array.isArray(this.model)) {
  5173. return this.model.indexOf(this.label) > -1;
  5174. } else if (this.model !== null && this.model !== undefined) {
  5175. return this.model === this.trueLabel;
  5176. }
  5177. },
  5178. isGroup: function isGroup() {
  5179. var parent = this.$parent;
  5180. while (parent) {
  5181. if (parent.$options.componentName !== 'TisCheckboxGroup') {
  5182. parent = parent.$parent;
  5183. } else {
  5184. this._checkboxGroup = parent;
  5185. return true;
  5186. }
  5187. }
  5188. return false;
  5189. },
  5190. store: function store() {
  5191. return this._checkboxGroup ? this._checkboxGroup.value : this.value;
  5192. },
  5193. /* used to make the isDisabled judgment under max/min props */
  5194. isLimitDisabled: function isLimitDisabled() {
  5195. var _checkboxGroup = this._checkboxGroup,
  5196. max = _checkboxGroup.max,
  5197. min = _checkboxGroup.min;
  5198. return !!(max || min) && this.model.length >= max && !this.isChecked || this.model.length <= min && this.isChecked;
  5199. },
  5200. isDisabled: function isDisabled() {
  5201. return this.isGroup ? this._checkboxGroup.disabled || this.disabled || (this.elForm || {}).disabled || this.isLimitDisabled : this.disabled || (this.elForm || {}).disabled;
  5202. },
  5203. _elFormItemSize: function _elFormItemSize() {
  5204. return (this.elFormItem || {}).elFormItemSize;
  5205. },
  5206. checkboxSize: function checkboxSize() {
  5207. var temCheckboxSize = this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
  5208. return this.isGroup ? this._checkboxGroup.checkboxGroupSize || temCheckboxSize : temCheckboxSize;
  5209. }
  5210. },
  5211. props: {
  5212. value: {},
  5213. label: {},
  5214. indeterminate: Boolean,
  5215. disabled: Boolean,
  5216. checked: Boolean,
  5217. name: String,
  5218. trueLabel: [String, Number],
  5219. falseLabel: [String, Number],
  5220. id: String, /* 当indeterminate为真时,为controls提供相关连的checkbox的id,表明元素间的控制关系*/
  5221. controls: String, /* 当indeterminate为真时,为controls提供相关连的checkbox的id,表明元素间的控制关系*/
  5222. border: Boolean,
  5223. size: String
  5224. },
  5225. methods: {
  5226. addToStore: function addToStore() {
  5227. if (Array.isArray(this.model) && this.model.indexOf(this.label) === -1) {
  5228. this.model.push(this.label);
  5229. } else {
  5230. this.model = this.trueLabel || true;
  5231. }
  5232. },
  5233. handleChange: function handleChange(ev) {
  5234. var _this = this;
  5235. if (this.isLimitExceeded) return;
  5236. var value = void 0;
  5237. if (ev.target.checked) {
  5238. value = this.trueLabel === undefined ? true : this.trueLabel;
  5239. } else {
  5240. value = this.falseLabel === undefined ? false : this.falseLabel;
  5241. }
  5242. this.$emit('change', value, ev);
  5243. this.$nextTick(function () {
  5244. if (_this.isGroup) {
  5245. _this.dispatch('TisCheckboxGroup', 'change', [_this._checkboxGroup.value]);
  5246. }
  5247. });
  5248. }
  5249. },
  5250. created: function created() {
  5251. this.checked && this.addToStore();
  5252. },
  5253. mounted: function mounted() {
  5254. // 为indeterminate元素 添加aria-controls 属性
  5255. if (this.indeterminate) {
  5256. this.$el.setAttribute('aria-controls', this.controls);
  5257. }
  5258. },
  5259. watch: {
  5260. value: function value(_value) {
  5261. this.dispatch('ElFormItem', 'el.form.change', _value);
  5262. }
  5263. }
  5264. });
  5265. // CONCATENATED MODULE: ./packages/checkbox/src/checkbox.vue?vue&type=script&lang=js&
  5266. /* harmony default export */ var src_checkboxvue_type_script_lang_js_ = (checkboxvue_type_script_lang_js_);
  5267. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  5268. var componentNormalizer = __webpack_require__(2);
  5269. // CONCATENATED MODULE: ./packages/checkbox/src/checkbox.vue
  5270. /* normalize component */
  5271. var component = Object(componentNormalizer["a" /* default */])(
  5272. src_checkboxvue_type_script_lang_js_,
  5273. render,
  5274. staticRenderFns,
  5275. false,
  5276. null,
  5277. null,
  5278. null
  5279. )
  5280. /* hot reload */
  5281. if (false) { var api; }
  5282. component.options.__file = "packages/checkbox/src/checkbox.vue"
  5283. /* harmony default export */ var src_checkbox = (component.exports);
  5284. // CONCATENATED MODULE: ./packages/checkbox/index.js
  5285. /* istanbul ignore next */
  5286. src_checkbox.install = function (Vue) {
  5287. Vue.component(src_checkbox.name, src_checkbox);
  5288. };
  5289. /* harmony default export */ var packages_checkbox = __webpack_exports__["default"] = (src_checkbox);
  5290. /***/ }),
  5291. /***/ 7:
  5292. /***/ (function(module, exports) {
  5293. module.exports = require("tis-ui/lib/utils/dom");
  5294. /***/ }),
  5295. /***/ 77:
  5296. /***/ (function(module, exports) {
  5297. module.exports = require("tis-ui/lib/utils/popup");
  5298. /***/ })
  5299. /******/ });