app模板、应用模板、组件模板、widget模板
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.

2691 lines
74 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 = 153);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 10:
  90. /***/ (function(module, exports) {
  91. module.exports = require("tis-ui/lib/utils/util");
  92. /***/ }),
  93. /***/ 13:
  94. /***/ (function(module, exports) {
  95. module.exports = require("tis-ui/lib/mixins/emitter");
  96. /***/ }),
  97. /***/ 153:
  98. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99. "use strict";
  100. // ESM COMPAT FLAG
  101. __webpack_require__.r(__webpack_exports__);
  102. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/tree/src/tree.vue?vue&type=template&id=547575a6&
  103. var render = function() {
  104. var _vm = this
  105. var _h = _vm.$createElement
  106. var _c = _vm._self._c || _h
  107. return _c(
  108. "div",
  109. {
  110. staticClass: "el-tree",
  111. class: {
  112. "el-tree--highlight-current": _vm.highlightCurrent,
  113. "is-dragging": !!_vm.dragState.draggingNode,
  114. "is-drop-not-allow": !_vm.dragState.allowDrop,
  115. "is-drop-inner": _vm.dragState.dropType === "inner"
  116. },
  117. attrs: { role: "tree" }
  118. },
  119. [
  120. _vm._l(_vm.root.childNodes, function(child) {
  121. return _c("tis-tree-node", {
  122. key: _vm.getNodeKey(child),
  123. attrs: {
  124. node: child,
  125. props: _vm.props,
  126. "render-after-expand": _vm.renderAfterExpand,
  127. "show-checkbox": _vm.showCheckbox,
  128. "render-content": _vm.renderContent
  129. },
  130. on: { "node-expand": _vm.handleNodeExpand }
  131. })
  132. }),
  133. _vm.isEmpty
  134. ? _c("div", { staticClass: "el-tree__empty-block" }, [
  135. _c("span", { staticClass: "el-tree__empty-text" }, [
  136. _vm._v(_vm._s(_vm.emptyText))
  137. ])
  138. ])
  139. : _vm._e(),
  140. _c("div", {
  141. directives: [
  142. {
  143. name: "show",
  144. rawName: "v-show",
  145. value: _vm.dragState.showDropIndicator,
  146. expression: "dragState.showDropIndicator"
  147. }
  148. ],
  149. ref: "dropIndicator",
  150. staticClass: "el-tree__drop-indicator"
  151. })
  152. ],
  153. 2
  154. )
  155. }
  156. var staticRenderFns = []
  157. render._withStripped = true
  158. // CONCATENATED MODULE: ./packages/tree/src/tree.vue?vue&type=template&id=547575a6&
  159. // EXTERNAL MODULE: external "tis-ui/lib/utils/merge"
  160. var merge_ = __webpack_require__(33);
  161. var merge_default = /*#__PURE__*/__webpack_require__.n(merge_);
  162. // CONCATENATED MODULE: ./packages/tree/src/model/util.js
  163. var NODE_KEY = '$treeNodeId';
  164. var markNodeData = function markNodeData(node, data) {
  165. if (!data || data[NODE_KEY]) return;
  166. Object.defineProperty(data, NODE_KEY, {
  167. value: node.id,
  168. enumerable: false,
  169. configurable: false,
  170. writable: false
  171. });
  172. };
  173. var util_getNodeKey = function getNodeKey(key, data) {
  174. if (!key) return data[NODE_KEY];
  175. return data[key];
  176. };
  177. var findNearestComponent = function findNearestComponent(element, componentName) {
  178. var target = element;
  179. while (target && target.tagName !== 'BODY') {
  180. if (target.__vue__ && target.__vue__.$options.name === componentName) {
  181. return target.__vue__;
  182. }
  183. target = target.parentNode;
  184. }
  185. return null;
  186. };
  187. // EXTERNAL MODULE: external "tis-ui/lib/utils/util"
  188. var util_ = __webpack_require__(10);
  189. // CONCATENATED MODULE: ./packages/tree/src/model/node.js
  190. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  191. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  192. var getChildState = function getChildState(node) {
  193. var all = true;
  194. var none = true;
  195. var allWithoutDisable = true;
  196. for (var i = 0, j = node.length; i < j; i++) {
  197. var n = node[i];
  198. if (n.checked !== true || n.indeterminate) {
  199. all = false;
  200. if (!n.disabled) {
  201. allWithoutDisable = false;
  202. }
  203. }
  204. if (n.checked !== false || n.indeterminate) {
  205. none = false;
  206. }
  207. }
  208. return { all: all, none: none, allWithoutDisable: allWithoutDisable, half: !all && !none };
  209. };
  210. var reInitChecked = function reInitChecked(node) {
  211. if (node.childNodes.length === 0) return;
  212. var _getChildState = getChildState(node.childNodes),
  213. all = _getChildState.all,
  214. none = _getChildState.none,
  215. half = _getChildState.half;
  216. if (all) {
  217. node.checked = true;
  218. node.indeterminate = false;
  219. } else if (half) {
  220. node.checked = false;
  221. node.indeterminate = true;
  222. } else if (none) {
  223. node.checked = false;
  224. node.indeterminate = false;
  225. }
  226. var parent = node.parent;
  227. if (!parent || parent.level === 0) return;
  228. if (!node.store.checkStrictly) {
  229. reInitChecked(parent);
  230. }
  231. };
  232. var getPropertyFromData = function getPropertyFromData(node, prop) {
  233. var props = node.store.props;
  234. var data = node.data || {};
  235. var config = props[prop];
  236. if (typeof config === 'function') {
  237. return config(data, node);
  238. } else if (typeof config === 'string') {
  239. return data[config];
  240. } else if (typeof config === 'undefined') {
  241. var dataProp = data[prop];
  242. return dataProp === undefined ? '' : dataProp;
  243. }
  244. };
  245. var nodeIdSeed = 0;
  246. var node_Node = function () {
  247. function Node(options) {
  248. _classCallCheck(this, Node);
  249. this.id = nodeIdSeed++;
  250. this.text = null;
  251. this.checked = false;
  252. this.indeterminate = false;
  253. this.data = null;
  254. this.expanded = false;
  255. this.parent = null;
  256. this.visible = true;
  257. this.isCurrent = false;
  258. for (var name in options) {
  259. if (options.hasOwnProperty(name)) {
  260. this[name] = options[name];
  261. }
  262. }
  263. // internal
  264. this.level = 0;
  265. this.loaded = false;
  266. this.childNodes = [];
  267. this.loading = false;
  268. if (this.parent) {
  269. this.level = this.parent.level + 1;
  270. }
  271. var store = this.store;
  272. if (!store) {
  273. throw new Error('[Node]store is required!');
  274. }
  275. store.registerNode(this);
  276. var props = store.props;
  277. if (props && typeof props.isLeaf !== 'undefined') {
  278. var isLeaf = getPropertyFromData(this, 'isLeaf');
  279. if (typeof isLeaf === 'boolean') {
  280. this.isLeafByUser = isLeaf;
  281. }
  282. }
  283. if (store.lazy !== true && this.data) {
  284. this.setData(this.data);
  285. if (store.defaultExpandAll) {
  286. this.expanded = true;
  287. }
  288. } else if (this.level > 0 && store.lazy && store.defaultExpandAll) {
  289. this.expand();
  290. }
  291. if (!Array.isArray(this.data)) {
  292. markNodeData(this, this.data);
  293. }
  294. if (!this.data) return;
  295. var defaultExpandedKeys = store.defaultExpandedKeys;
  296. var key = store.key;
  297. if (key && defaultExpandedKeys && defaultExpandedKeys.indexOf(this.key) !== -1) {
  298. this.expand(null, store.autoExpandParent);
  299. }
  300. if (key && store.currentNodeKey !== undefined && this.key === store.currentNodeKey) {
  301. store.currentNode = this;
  302. store.currentNode.isCurrent = true;
  303. }
  304. if (store.lazy) {
  305. store._initDefaultCheckedNode(this);
  306. }
  307. this.updateLeafState();
  308. }
  309. Node.prototype.setData = function setData(data) {
  310. if (!Array.isArray(data)) {
  311. markNodeData(this, data);
  312. }
  313. this.data = data;
  314. this.childNodes = [];
  315. var children = void 0;
  316. if (this.level === 0 && this.data instanceof Array) {
  317. children = this.data;
  318. } else {
  319. children = getPropertyFromData(this, 'children') || [];
  320. }
  321. for (var i = 0, j = children.length; i < j; i++) {
  322. this.insertChild({ data: children[i] });
  323. }
  324. };
  325. Node.prototype.contains = function contains(target) {
  326. var deep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  327. var walk = function walk(parent) {
  328. var children = parent.childNodes || [];
  329. var result = false;
  330. for (var i = 0, j = children.length; i < j; i++) {
  331. var child = children[i];
  332. if (child === target || deep && walk(child)) {
  333. result = true;
  334. break;
  335. }
  336. }
  337. return result;
  338. };
  339. return walk(this);
  340. };
  341. Node.prototype.remove = function remove() {
  342. var parent = this.parent;
  343. if (parent) {
  344. parent.removeChild(this);
  345. }
  346. };
  347. Node.prototype.insertChild = function insertChild(child, index, batch) {
  348. if (!child) throw new Error('insertChild error: child is required.');
  349. if (!(child instanceof Node)) {
  350. if (!batch) {
  351. var children = this.getChildren(true);
  352. if (children.indexOf(child.data) === -1) {
  353. if (typeof index === 'undefined' || index < 0) {
  354. children.push(child.data);
  355. } else {
  356. children.splice(index, 0, child.data);
  357. }
  358. }
  359. }
  360. merge_default()(child, {
  361. parent: this,
  362. store: this.store
  363. });
  364. child = new Node(child);
  365. }
  366. child.level = this.level + 1;
  367. if (typeof index === 'undefined' || index < 0) {
  368. this.childNodes.push(child);
  369. } else {
  370. this.childNodes.splice(index, 0, child);
  371. }
  372. this.updateLeafState();
  373. };
  374. Node.prototype.insertBefore = function insertBefore(child, ref) {
  375. var index = void 0;
  376. if (ref) {
  377. index = this.childNodes.indexOf(ref);
  378. }
  379. this.insertChild(child, index);
  380. };
  381. Node.prototype.insertAfter = function insertAfter(child, ref) {
  382. var index = void 0;
  383. if (ref) {
  384. index = this.childNodes.indexOf(ref);
  385. if (index !== -1) index += 1;
  386. }
  387. this.insertChild(child, index);
  388. };
  389. Node.prototype.removeChild = function removeChild(child) {
  390. var children = this.getChildren() || [];
  391. var dataIndex = children.indexOf(child.data);
  392. if (dataIndex > -1) {
  393. children.splice(dataIndex, 1);
  394. }
  395. var index = this.childNodes.indexOf(child);
  396. if (index > -1) {
  397. this.store && this.store.deregisterNode(child);
  398. child.parent = null;
  399. this.childNodes.splice(index, 1);
  400. }
  401. this.updateLeafState();
  402. };
  403. Node.prototype.removeChildByData = function removeChildByData(data) {
  404. var targetNode = null;
  405. for (var i = 0; i < this.childNodes.length; i++) {
  406. if (this.childNodes[i].data === data) {
  407. targetNode = this.childNodes[i];
  408. break;
  409. }
  410. }
  411. if (targetNode) {
  412. this.removeChild(targetNode);
  413. }
  414. };
  415. Node.prototype.expand = function expand(callback, expandParent) {
  416. var _this = this;
  417. var done = function done() {
  418. if (expandParent) {
  419. var parent = _this.parent;
  420. while (parent.level > 0) {
  421. parent.expanded = true;
  422. parent = parent.parent;
  423. }
  424. }
  425. _this.expanded = true;
  426. if (callback) callback();
  427. };
  428. if (this.shouldLoadData()) {
  429. this.loadData(function (data) {
  430. if (data instanceof Array) {
  431. if (_this.checked) {
  432. _this.setChecked(true, true);
  433. } else if (!_this.store.checkStrictly) {
  434. reInitChecked(_this);
  435. }
  436. done();
  437. }
  438. });
  439. } else {
  440. done();
  441. }
  442. };
  443. Node.prototype.doCreateChildren = function doCreateChildren(array) {
  444. var _this2 = this;
  445. var defaultProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  446. array.forEach(function (item) {
  447. _this2.insertChild(merge_default()({ data: item }, defaultProps), undefined, true);
  448. });
  449. };
  450. Node.prototype.collapse = function collapse() {
  451. this.expanded = false;
  452. };
  453. Node.prototype.shouldLoadData = function shouldLoadData() {
  454. return this.store.lazy === true && this.store.load && !this.loaded;
  455. };
  456. Node.prototype.updateLeafState = function updateLeafState() {
  457. if (this.store.lazy === true && this.loaded !== true && typeof this.isLeafByUser !== 'undefined') {
  458. this.isLeaf = this.isLeafByUser;
  459. return;
  460. }
  461. var childNodes = this.childNodes;
  462. if (!this.store.lazy || this.store.lazy === true && this.loaded === true) {
  463. this.isLeaf = !childNodes || childNodes.length === 0;
  464. return;
  465. }
  466. this.isLeaf = false;
  467. };
  468. Node.prototype.setChecked = function setChecked(value, deep, recursion, passValue) {
  469. var _this3 = this;
  470. this.indeterminate = value === 'half';
  471. this.checked = value === true;
  472. if (this.store.checkStrictly) return;
  473. if (!(this.shouldLoadData() && !this.store.checkDescendants)) {
  474. var _getChildState2 = getChildState(this.childNodes),
  475. all = _getChildState2.all,
  476. allWithoutDisable = _getChildState2.allWithoutDisable;
  477. if (!this.isLeaf && !all && allWithoutDisable) {
  478. this.checked = false;
  479. value = false;
  480. }
  481. var handleDescendants = function handleDescendants() {
  482. if (deep) {
  483. var childNodes = _this3.childNodes;
  484. for (var i = 0, j = childNodes.length; i < j; i++) {
  485. var child = childNodes[i];
  486. passValue = passValue || value !== false;
  487. var isCheck = child.disabled ? child.checked : passValue;
  488. child.setChecked(isCheck, deep, true, passValue);
  489. }
  490. var _getChildState3 = getChildState(childNodes),
  491. half = _getChildState3.half,
  492. _all = _getChildState3.all;
  493. if (!_all) {
  494. _this3.checked = _all;
  495. _this3.indeterminate = half;
  496. }
  497. }
  498. };
  499. if (this.shouldLoadData()) {
  500. // Only work on lazy load data.
  501. this.loadData(function () {
  502. handleDescendants();
  503. reInitChecked(_this3);
  504. }, {
  505. checked: value !== false
  506. });
  507. return;
  508. } else {
  509. handleDescendants();
  510. }
  511. }
  512. var parent = this.parent;
  513. if (!parent || parent.level === 0) return;
  514. if (!recursion) {
  515. reInitChecked(parent);
  516. }
  517. };
  518. Node.prototype.getChildren = function getChildren() {
  519. var forceInit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  520. // this is data
  521. if (this.level === 0) return this.data;
  522. var data = this.data;
  523. if (!data) return null;
  524. var props = this.store.props;
  525. var children = 'children';
  526. if (props) {
  527. children = props.children || 'children';
  528. }
  529. if (data[children] === undefined) {
  530. data[children] = null;
  531. }
  532. if (forceInit && !data[children]) {
  533. data[children] = [];
  534. }
  535. return data[children];
  536. };
  537. Node.prototype.updateChildren = function updateChildren() {
  538. var _this4 = this;
  539. var newData = this.getChildren() || [];
  540. var oldData = this.childNodes.map(function (node) {
  541. return node.data;
  542. });
  543. var newDataMap = {};
  544. var newNodes = [];
  545. newData.forEach(function (item, index) {
  546. var key = item[NODE_KEY];
  547. var isNodeExists = !!key && Object(util_["arrayFindIndex"])(oldData, function (data) {
  548. return data[NODE_KEY] === key;
  549. }) >= 0;
  550. if (isNodeExists) {
  551. newDataMap[key] = { index: index, data: item };
  552. } else {
  553. newNodes.push({ index: index, data: item });
  554. }
  555. });
  556. if (!this.store.lazy) {
  557. oldData.forEach(function (item) {
  558. if (!newDataMap[item[NODE_KEY]]) _this4.removeChildByData(item);
  559. });
  560. }
  561. newNodes.forEach(function (_ref) {
  562. var index = _ref.index,
  563. data = _ref.data;
  564. _this4.insertChild({ data: data }, index);
  565. });
  566. this.updateLeafState();
  567. };
  568. Node.prototype.loadData = function loadData(callback) {
  569. var _this5 = this;
  570. var defaultProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  571. if (this.store.lazy === true && this.store.load && !this.loaded && (!this.loading || Object.keys(defaultProps).length)) {
  572. this.loading = true;
  573. var resolve = function resolve(children) {
  574. _this5.loaded = true;
  575. _this5.loading = false;
  576. _this5.childNodes = [];
  577. _this5.doCreateChildren(children, defaultProps);
  578. _this5.updateLeafState();
  579. if (callback) {
  580. callback.call(_this5, children);
  581. }
  582. };
  583. this.store.load(this, resolve);
  584. } else {
  585. if (callback) {
  586. callback.call(this);
  587. }
  588. }
  589. };
  590. _createClass(Node, [{
  591. key: 'label',
  592. get: function get() {
  593. return getPropertyFromData(this, 'label');
  594. }
  595. }, {
  596. key: 'key',
  597. get: function get() {
  598. var nodeKey = this.store.key;
  599. if (this.data) return this.data[nodeKey];
  600. return null;
  601. }
  602. }, {
  603. key: 'disabled',
  604. get: function get() {
  605. return getPropertyFromData(this, 'disabled');
  606. }
  607. }, {
  608. key: 'nextSibling',
  609. get: function get() {
  610. var parent = this.parent;
  611. if (parent) {
  612. var index = parent.childNodes.indexOf(this);
  613. if (index > -1) {
  614. return parent.childNodes[index + 1];
  615. }
  616. }
  617. return null;
  618. }
  619. }, {
  620. key: 'previousSibling',
  621. get: function get() {
  622. var parent = this.parent;
  623. if (parent) {
  624. var index = parent.childNodes.indexOf(this);
  625. if (index > -1) {
  626. return index > 0 ? parent.childNodes[index - 1] : null;
  627. }
  628. }
  629. return null;
  630. }
  631. }]);
  632. return Node;
  633. }();
  634. /* harmony default export */ var model_node = (node_Node);
  635. // CONCATENATED MODULE: ./packages/tree/src/model/tree-store.js
  636. 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; };
  637. function tree_store_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  638. var tree_store_TreeStore = function () {
  639. function TreeStore(options) {
  640. var _this = this;
  641. tree_store_classCallCheck(this, TreeStore);
  642. this.currentNode = null;
  643. this.currentNodeKey = null;
  644. for (var option in options) {
  645. if (options.hasOwnProperty(option)) {
  646. this[option] = options[option];
  647. }
  648. }
  649. this.nodesMap = {};
  650. this.root = new model_node({
  651. data: this.data,
  652. store: this
  653. });
  654. if (this.lazy && this.load) {
  655. var loadFn = this.load;
  656. loadFn(this.root, function (data) {
  657. _this.root.doCreateChildren(data);
  658. _this._initDefaultCheckedNodes();
  659. });
  660. } else {
  661. this._initDefaultCheckedNodes();
  662. }
  663. }
  664. TreeStore.prototype.filter = function filter(value) {
  665. var filterNodeMethod = this.filterNodeMethod;
  666. var lazy = this.lazy;
  667. var traverse = function traverse(node) {
  668. var childNodes = node.root ? node.root.childNodes : node.childNodes;
  669. childNodes.forEach(function (child) {
  670. child.visible = filterNodeMethod.call(child, value, child.data, child);
  671. traverse(child);
  672. });
  673. if (!node.visible && childNodes.length) {
  674. var allHidden = true;
  675. allHidden = !childNodes.some(function (child) {
  676. return child.visible;
  677. });
  678. if (node.root) {
  679. node.root.visible = allHidden === false;
  680. } else {
  681. node.visible = allHidden === false;
  682. }
  683. }
  684. if (!value) return;
  685. if (node.visible && !node.isLeaf && !lazy) node.expand();
  686. };
  687. traverse(this);
  688. };
  689. TreeStore.prototype.setData = function setData(newVal) {
  690. var instanceChanged = newVal !== this.root.data;
  691. if (instanceChanged) {
  692. this.root.setData(newVal);
  693. this._initDefaultCheckedNodes();
  694. } else {
  695. this.root.updateChildren();
  696. }
  697. };
  698. TreeStore.prototype.getNode = function getNode(data) {
  699. if (data instanceof model_node) return data;
  700. var key = (typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object' ? data : util_getNodeKey(this.key, data);
  701. return this.nodesMap[key] || null;
  702. };
  703. TreeStore.prototype.insertBefore = function insertBefore(data, refData) {
  704. var refNode = this.getNode(refData);
  705. refNode.parent.insertBefore({ data: data }, refNode);
  706. };
  707. TreeStore.prototype.insertAfter = function insertAfter(data, refData) {
  708. var refNode = this.getNode(refData);
  709. refNode.parent.insertAfter({ data: data }, refNode);
  710. };
  711. TreeStore.prototype.remove = function remove(data) {
  712. var node = this.getNode(data);
  713. if (node && node.parent) {
  714. if (node === this.currentNode) {
  715. this.currentNode = null;
  716. }
  717. node.parent.removeChild(node);
  718. }
  719. };
  720. TreeStore.prototype.append = function append(data, parentData) {
  721. var parentNode = parentData ? this.getNode(parentData) : this.root;
  722. if (parentNode) {
  723. parentNode.insertChild({ data: data });
  724. }
  725. };
  726. TreeStore.prototype._initDefaultCheckedNodes = function _initDefaultCheckedNodes() {
  727. var _this2 = this;
  728. var defaultCheckedKeys = this.defaultCheckedKeys || [];
  729. var nodesMap = this.nodesMap;
  730. defaultCheckedKeys.forEach(function (checkedKey) {
  731. var node = nodesMap[checkedKey];
  732. if (node) {
  733. node.setChecked(true, !_this2.checkStrictly);
  734. }
  735. });
  736. };
  737. TreeStore.prototype._initDefaultCheckedNode = function _initDefaultCheckedNode(node) {
  738. var defaultCheckedKeys = this.defaultCheckedKeys || [];
  739. if (defaultCheckedKeys.indexOf(node.key) !== -1) {
  740. node.setChecked(true, !this.checkStrictly);
  741. }
  742. };
  743. TreeStore.prototype.setDefaultCheckedKey = function setDefaultCheckedKey(newVal) {
  744. if (newVal !== this.defaultCheckedKeys) {
  745. this.defaultCheckedKeys = newVal;
  746. this._initDefaultCheckedNodes();
  747. }
  748. };
  749. TreeStore.prototype.registerNode = function registerNode(node) {
  750. var key = this.key;
  751. if (!key || !node || !node.data) return;
  752. var nodeKey = node.key;
  753. if (nodeKey !== undefined) this.nodesMap[node.key] = node;
  754. };
  755. TreeStore.prototype.deregisterNode = function deregisterNode(node) {
  756. var _this3 = this;
  757. var key = this.key;
  758. if (!key || !node || !node.data) return;
  759. node.childNodes.forEach(function (child) {
  760. _this3.deregisterNode(child);
  761. });
  762. delete this.nodesMap[node.key];
  763. };
  764. TreeStore.prototype.getCheckedNodes = function getCheckedNodes() {
  765. var leafOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  766. var includeHalfChecked = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  767. var checkedNodes = [];
  768. var traverse = function traverse(node) {
  769. var childNodes = node.root ? node.root.childNodes : node.childNodes;
  770. childNodes.forEach(function (child) {
  771. if ((child.checked || includeHalfChecked && child.indeterminate) && (!leafOnly || leafOnly && child.isLeaf)) {
  772. checkedNodes.push(child.data);
  773. }
  774. traverse(child);
  775. });
  776. };
  777. traverse(this);
  778. return checkedNodes;
  779. };
  780. TreeStore.prototype.getCheckedKeys = function getCheckedKeys() {
  781. var _this4 = this;
  782. var leafOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  783. return this.getCheckedNodes(leafOnly).map(function (data) {
  784. return (data || {})[_this4.key];
  785. });
  786. };
  787. TreeStore.prototype.getHalfCheckedNodes = function getHalfCheckedNodes() {
  788. var nodes = [];
  789. var traverse = function traverse(node) {
  790. var childNodes = node.root ? node.root.childNodes : node.childNodes;
  791. childNodes.forEach(function (child) {
  792. if (child.indeterminate) {
  793. nodes.push(child.data);
  794. }
  795. traverse(child);
  796. });
  797. };
  798. traverse(this);
  799. return nodes;
  800. };
  801. TreeStore.prototype.getHalfCheckedKeys = function getHalfCheckedKeys() {
  802. var _this5 = this;
  803. return this.getHalfCheckedNodes().map(function (data) {
  804. return (data || {})[_this5.key];
  805. });
  806. };
  807. TreeStore.prototype._getAllNodes = function _getAllNodes() {
  808. var allNodes = [];
  809. var nodesMap = this.nodesMap;
  810. for (var nodeKey in nodesMap) {
  811. if (nodesMap.hasOwnProperty(nodeKey)) {
  812. allNodes.push(nodesMap[nodeKey]);
  813. }
  814. }
  815. return allNodes;
  816. };
  817. TreeStore.prototype.updateChildren = function updateChildren(key, data) {
  818. var node = this.nodesMap[key];
  819. if (!node) return;
  820. var childNodes = node.childNodes;
  821. for (var i = childNodes.length - 1; i >= 0; i--) {
  822. var child = childNodes[i];
  823. this.remove(child.data);
  824. }
  825. for (var _i = 0, j = data.length; _i < j; _i++) {
  826. var _child = data[_i];
  827. this.append(_child, node.data);
  828. }
  829. };
  830. TreeStore.prototype._setCheckedKeys = function _setCheckedKeys(key) {
  831. var leafOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  832. var checkedKeys = arguments[2];
  833. var allNodes = this._getAllNodes().sort(function (a, b) {
  834. return b.level - a.level;
  835. });
  836. var cache = Object.create(null);
  837. var keys = Object.keys(checkedKeys);
  838. allNodes.forEach(function (node) {
  839. return node.setChecked(false, false);
  840. });
  841. for (var i = 0, j = allNodes.length; i < j; i++) {
  842. var node = allNodes[i];
  843. var nodeKey = node.data[key].toString();
  844. var checked = keys.indexOf(nodeKey) > -1;
  845. if (!checked) {
  846. if (node.checked && !cache[nodeKey]) {
  847. node.setChecked(false, false);
  848. }
  849. continue;
  850. }
  851. var parent = node.parent;
  852. while (parent && parent.level > 0) {
  853. cache[parent.data[key]] = true;
  854. parent = parent.parent;
  855. }
  856. if (node.isLeaf || this.checkStrictly) {
  857. node.setChecked(true, false);
  858. continue;
  859. }
  860. node.setChecked(true, true);
  861. if (leafOnly) {
  862. (function () {
  863. node.setChecked(false, false);
  864. var traverse = function traverse(node) {
  865. var childNodes = node.childNodes;
  866. childNodes.forEach(function (child) {
  867. if (!child.isLeaf) {
  868. child.setChecked(false, false);
  869. }
  870. traverse(child);
  871. });
  872. };
  873. traverse(node);
  874. })();
  875. }
  876. }
  877. };
  878. TreeStore.prototype.setCheckedNodes = function setCheckedNodes(array) {
  879. var leafOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  880. var key = this.key;
  881. var checkedKeys = {};
  882. array.forEach(function (item) {
  883. checkedKeys[(item || {})[key]] = true;
  884. });
  885. this._setCheckedKeys(key, leafOnly, checkedKeys);
  886. };
  887. TreeStore.prototype.setCheckedKeys = function setCheckedKeys(keys) {
  888. var leafOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  889. this.defaultCheckedKeys = keys;
  890. var key = this.key;
  891. var checkedKeys = {};
  892. keys.forEach(function (key) {
  893. checkedKeys[key] = true;
  894. });
  895. this._setCheckedKeys(key, leafOnly, checkedKeys);
  896. };
  897. TreeStore.prototype.setDefaultExpandedKeys = function setDefaultExpandedKeys(keys) {
  898. var _this6 = this;
  899. keys = keys || [];
  900. this.defaultExpandedKeys = keys;
  901. keys.forEach(function (key) {
  902. var node = _this6.getNode(key);
  903. if (node) node.expand(null, _this6.autoExpandParent);
  904. });
  905. };
  906. TreeStore.prototype.setChecked = function setChecked(data, checked, deep) {
  907. var node = this.getNode(data);
  908. if (node) {
  909. node.setChecked(!!checked, deep);
  910. }
  911. };
  912. TreeStore.prototype.getCurrentNode = function getCurrentNode() {
  913. return this.currentNode;
  914. };
  915. TreeStore.prototype.setCurrentNode = function setCurrentNode(currentNode) {
  916. var prevCurrentNode = this.currentNode;
  917. if (prevCurrentNode) {
  918. prevCurrentNode.isCurrent = false;
  919. }
  920. this.currentNode = currentNode;
  921. this.currentNode.isCurrent = true;
  922. };
  923. TreeStore.prototype.setUserCurrentNode = function setUserCurrentNode(node) {
  924. var key = node[this.key];
  925. var currNode = this.nodesMap[key];
  926. this.setCurrentNode(currNode);
  927. };
  928. TreeStore.prototype.setCurrentNodeKey = function setCurrentNodeKey(key) {
  929. if (key === null || key === undefined) {
  930. this.currentNode && (this.currentNode.isCurrent = false);
  931. this.currentNode = null;
  932. return;
  933. }
  934. var node = this.getNode(key);
  935. if (node) {
  936. this.setCurrentNode(node);
  937. }
  938. };
  939. return TreeStore;
  940. }();
  941. /* harmony default export */ var tree_store = (tree_store_TreeStore);
  942. ;
  943. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/tree/src/tree-node.vue?vue&type=template&id=3ba3ef0e&
  944. var tree_nodevue_type_template_id_3ba3ef0e_render = function() {
  945. var this$1 = this
  946. var _vm = this
  947. var _h = _vm.$createElement
  948. var _c = _vm._self._c || _h
  949. return _c(
  950. "div",
  951. {
  952. directives: [
  953. {
  954. name: "show",
  955. rawName: "v-show",
  956. value: _vm.node.visible,
  957. expression: "node.visible"
  958. }
  959. ],
  960. ref: "node",
  961. staticClass: "el-tree-node",
  962. class: {
  963. "is-expanded": _vm.expanded,
  964. "is-current": _vm.node.isCurrent,
  965. "is-hidden": !_vm.node.visible,
  966. "is-focusable": !_vm.node.disabled,
  967. "is-checked": !_vm.node.disabled && _vm.node.checked
  968. },
  969. attrs: {
  970. role: "treeitem",
  971. tabindex: "-1",
  972. "aria-expanded": _vm.expanded,
  973. "aria-disabled": _vm.node.disabled,
  974. "aria-checked": _vm.node.checked,
  975. draggable: _vm.tree.draggable
  976. },
  977. on: {
  978. click: function($event) {
  979. $event.stopPropagation()
  980. return _vm.handleClick($event)
  981. },
  982. contextmenu: function($event) {
  983. return this$1.handleContextMenu($event)
  984. },
  985. dragstart: function($event) {
  986. $event.stopPropagation()
  987. return _vm.handleDragStart($event)
  988. },
  989. dragover: function($event) {
  990. $event.stopPropagation()
  991. return _vm.handleDragOver($event)
  992. },
  993. dragend: function($event) {
  994. $event.stopPropagation()
  995. return _vm.handleDragEnd($event)
  996. },
  997. drop: function($event) {
  998. $event.stopPropagation()
  999. return _vm.handleDrop($event)
  1000. }
  1001. }
  1002. },
  1003. [
  1004. _c(
  1005. "div",
  1006. {
  1007. staticClass: "el-tree-node__content",
  1008. style: {
  1009. "padding-left": (_vm.node.level - 1) * _vm.tree.indent + "px"
  1010. }
  1011. },
  1012. [
  1013. _c("span", {
  1014. class: [
  1015. {
  1016. "is-leaf": _vm.node.isLeaf,
  1017. expanded: !_vm.node.isLeaf && _vm.expanded
  1018. },
  1019. "el-tree-node__expand-icon",
  1020. _vm.tree.iconClass ? _vm.tree.iconClass : "el-icon-caret-right"
  1021. ],
  1022. on: {
  1023. click: function($event) {
  1024. $event.stopPropagation()
  1025. return _vm.handleExpandIconClick($event)
  1026. }
  1027. }
  1028. }),
  1029. _vm.showCheckbox
  1030. ? _c("tis-checkbox", {
  1031. attrs: {
  1032. indeterminate: _vm.node.indeterminate,
  1033. disabled: !!_vm.node.disabled
  1034. },
  1035. on: { change: _vm.handleCheckChange },
  1036. nativeOn: {
  1037. click: function($event) {
  1038. $event.stopPropagation()
  1039. }
  1040. },
  1041. model: {
  1042. value: _vm.node.checked,
  1043. callback: function($$v) {
  1044. _vm.$set(_vm.node, "checked", $$v)
  1045. },
  1046. expression: "node.checked"
  1047. }
  1048. })
  1049. : _vm._e(),
  1050. _vm.node.loading
  1051. ? _c("span", {
  1052. staticClass: "el-tree-node__loading-icon el-icon-loading"
  1053. })
  1054. : _vm._e(),
  1055. _c("node-content", { attrs: { node: _vm.node } })
  1056. ],
  1057. 1
  1058. ),
  1059. _c("tis-collapse-transition", [
  1060. !_vm.renderAfterExpand || _vm.childNodeRendered
  1061. ? _c(
  1062. "div",
  1063. {
  1064. directives: [
  1065. {
  1066. name: "show",
  1067. rawName: "v-show",
  1068. value: _vm.expanded,
  1069. expression: "expanded"
  1070. }
  1071. ],
  1072. staticClass: "el-tree-node__children",
  1073. attrs: { role: "group", "aria-expanded": _vm.expanded }
  1074. },
  1075. _vm._l(_vm.node.childNodes, function(child) {
  1076. return _c("tis-tree-node", {
  1077. key: _vm.getNodeKey(child),
  1078. attrs: {
  1079. "render-content": _vm.renderContent,
  1080. "render-after-expand": _vm.renderAfterExpand,
  1081. "show-checkbox": _vm.showCheckbox,
  1082. node: child
  1083. },
  1084. on: { "node-expand": _vm.handleChildNodeExpand }
  1085. })
  1086. }),
  1087. 1
  1088. )
  1089. : _vm._e()
  1090. ])
  1091. ],
  1092. 1
  1093. )
  1094. }
  1095. var tree_nodevue_type_template_id_3ba3ef0e_staticRenderFns = []
  1096. tree_nodevue_type_template_id_3ba3ef0e_render._withStripped = true
  1097. // CONCATENATED MODULE: ./packages/tree/src/tree-node.vue?vue&type=template&id=3ba3ef0e&
  1098. // EXTERNAL MODULE: external "tis-ui/lib/transitions/collapse-transition"
  1099. var collapse_transition_ = __webpack_require__(98);
  1100. var collapse_transition_default = /*#__PURE__*/__webpack_require__.n(collapse_transition_);
  1101. // EXTERNAL MODULE: ./packages/checkbox/index.js + 5 modules
  1102. var packages_checkbox = __webpack_require__(68);
  1103. // EXTERNAL MODULE: external "tis-ui/lib/mixins/emitter"
  1104. var emitter_ = __webpack_require__(13);
  1105. var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
  1106. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/tree/src/tree-node.vue?vue&type=script&lang=js&
  1107. //
  1108. //
  1109. //
  1110. //
  1111. //
  1112. //
  1113. //
  1114. //
  1115. //
  1116. //
  1117. //
  1118. //
  1119. //
  1120. //
  1121. //
  1122. //
  1123. //
  1124. //
  1125. //
  1126. //
  1127. //
  1128. //
  1129. //
  1130. //
  1131. //
  1132. //
  1133. //
  1134. //
  1135. //
  1136. //
  1137. //
  1138. //
  1139. //
  1140. //
  1141. //
  1142. //
  1143. //
  1144. //
  1145. //
  1146. //
  1147. //
  1148. //
  1149. //
  1150. //
  1151. //
  1152. //
  1153. //
  1154. //
  1155. //
  1156. //
  1157. //
  1158. //
  1159. //
  1160. //
  1161. //
  1162. //
  1163. //
  1164. //
  1165. //
  1166. //
  1167. //
  1168. //
  1169. //
  1170. //
  1171. //
  1172. //
  1173. //
  1174. //
  1175. //
  1176. //
  1177. //
  1178. //
  1179. //
  1180. /* harmony default export */ var tree_nodevue_type_script_lang_js_ = ({
  1181. name: 'TisTreeNode',
  1182. componentName: 'TisTreeNode',
  1183. mixins: [emitter_default.a],
  1184. props: {
  1185. node: {
  1186. default: function _default() {
  1187. return {};
  1188. }
  1189. },
  1190. props: {},
  1191. renderContent: Function,
  1192. renderAfterExpand: {
  1193. type: Boolean,
  1194. default: true
  1195. },
  1196. showCheckbox: {
  1197. type: Boolean,
  1198. default: false
  1199. }
  1200. },
  1201. components: {
  1202. TisCollapseTransition: collapse_transition_default.a,
  1203. TisCheckbox: packages_checkbox["default"],
  1204. NodeContent: {
  1205. props: {
  1206. node: {
  1207. required: true
  1208. }
  1209. },
  1210. render: function render(h) {
  1211. var parent = this.$parent;
  1212. var tree = parent.tree;
  1213. var node = this.node;
  1214. var data = node.data,
  1215. store = node.store;
  1216. return parent.renderContent ? parent.renderContent.call(parent._renderProxy, h, { _self: tree.$vnode.context, node: node, data: data, store: store }) : tree.$scopedSlots.default ? tree.$scopedSlots.default({ node: node, data: data }) : h(
  1217. 'span',
  1218. { 'class': 'el-tree-node__label' },
  1219. [node.label]
  1220. );
  1221. }
  1222. }
  1223. },
  1224. data: function data() {
  1225. return {
  1226. tree: null,
  1227. expanded: false,
  1228. childNodeRendered: false,
  1229. oldChecked: null,
  1230. oldIndeterminate: null
  1231. };
  1232. },
  1233. watch: {
  1234. 'node.indeterminate': function nodeIndeterminate(val) {
  1235. this.handleSelectChange(this.node.checked, val);
  1236. },
  1237. 'node.checked': function nodeChecked(val) {
  1238. this.handleSelectChange(val, this.node.indeterminate);
  1239. },
  1240. 'node.expanded': function nodeExpanded(val) {
  1241. var _this = this;
  1242. this.$nextTick(function () {
  1243. return _this.expanded = val;
  1244. });
  1245. if (val) {
  1246. this.childNodeRendered = true;
  1247. }
  1248. }
  1249. },
  1250. methods: {
  1251. getNodeKey: function getNodeKey(node) {
  1252. return util_getNodeKey(this.tree.nodeKey, node.data);
  1253. },
  1254. handleSelectChange: function handleSelectChange(checked, indeterminate) {
  1255. if (this.oldChecked !== checked && this.oldIndeterminate !== indeterminate) {
  1256. this.tree.$emit('check-change', this.node.data, checked, indeterminate);
  1257. }
  1258. this.oldChecked = checked;
  1259. this.indeterminate = indeterminate;
  1260. },
  1261. handleClick: function handleClick() {
  1262. var store = this.tree.store;
  1263. store.setCurrentNode(this.node);
  1264. this.tree.$emit('current-change', store.currentNode ? store.currentNode.data : null, store.currentNode);
  1265. this.tree.currentNode = this;
  1266. if (this.tree.expandOnClickNode) {
  1267. this.handleExpandIconClick();
  1268. }
  1269. if (this.tree.checkOnClickNode && !this.node.disabled) {
  1270. this.handleCheckChange(null, {
  1271. target: { checked: !this.node.checked }
  1272. });
  1273. }
  1274. this.tree.$emit('node-click', this.node.data, this.node, this);
  1275. },
  1276. handleContextMenu: function handleContextMenu(event) {
  1277. if (this.tree._events['node-contextmenu'] && this.tree._events['node-contextmenu'].length > 0) {
  1278. event.stopPropagation();
  1279. event.preventDefault();
  1280. }
  1281. this.tree.$emit('node-contextmenu', event, this.node.data, this.node, this);
  1282. },
  1283. handleExpandIconClick: function handleExpandIconClick() {
  1284. if (this.node.isLeaf) return;
  1285. if (this.expanded) {
  1286. this.tree.$emit('node-collapse', this.node.data, this.node, this);
  1287. this.node.collapse();
  1288. } else {
  1289. this.node.expand();
  1290. this.$emit('node-expand', this.node.data, this.node, this);
  1291. }
  1292. },
  1293. handleCheckChange: function handleCheckChange(value, ev) {
  1294. var _this2 = this;
  1295. this.node.setChecked(ev.target.checked, !this.tree.checkStrictly);
  1296. this.$nextTick(function () {
  1297. var store = _this2.tree.store;
  1298. _this2.tree.$emit('check', _this2.node.data, {
  1299. checkedNodes: store.getCheckedNodes(),
  1300. checkedKeys: store.getCheckedKeys(),
  1301. halfCheckedNodes: store.getHalfCheckedNodes(),
  1302. halfCheckedKeys: store.getHalfCheckedKeys()
  1303. });
  1304. });
  1305. },
  1306. handleChildNodeExpand: function handleChildNodeExpand(nodeData, node, instance) {
  1307. this.broadcast('ElTreeNode', 'tree-node-expand', node);
  1308. this.tree.$emit('node-expand', nodeData, node, instance);
  1309. },
  1310. handleDragStart: function handleDragStart(event) {
  1311. if (!this.tree.draggable) return;
  1312. this.tree.$emit('tree-node-drag-start', event, this);
  1313. },
  1314. handleDragOver: function handleDragOver(event) {
  1315. if (!this.tree.draggable) return;
  1316. this.tree.$emit('tree-node-drag-over', event, this);
  1317. event.preventDefault();
  1318. },
  1319. handleDrop: function handleDrop(event) {
  1320. event.preventDefault();
  1321. },
  1322. handleDragEnd: function handleDragEnd(event) {
  1323. if (!this.tree.draggable) return;
  1324. this.tree.$emit('tree-node-drag-end', event, this);
  1325. }
  1326. },
  1327. created: function created() {
  1328. var _this3 = this;
  1329. var parent = this.$parent;
  1330. if (parent.isTree) {
  1331. this.tree = parent;
  1332. } else {
  1333. this.tree = parent.tree;
  1334. }
  1335. var tree = this.tree;
  1336. if (!tree) {
  1337. console.warn('Can not find node\'s tree.');
  1338. }
  1339. var props = tree.props || {};
  1340. var childrenKey = props['children'] || 'children';
  1341. this.$watch('node.data.' + childrenKey, function () {
  1342. _this3.node.updateChildren();
  1343. });
  1344. if (this.node.expanded) {
  1345. this.expanded = true;
  1346. this.childNodeRendered = true;
  1347. }
  1348. if (this.tree.accordion) {
  1349. this.$on('tree-node-expand', function (node) {
  1350. if (_this3.node !== node) {
  1351. _this3.node.collapse();
  1352. }
  1353. });
  1354. }
  1355. }
  1356. });
  1357. // CONCATENATED MODULE: ./packages/tree/src/tree-node.vue?vue&type=script&lang=js&
  1358. /* harmony default export */ var src_tree_nodevue_type_script_lang_js_ = (tree_nodevue_type_script_lang_js_);
  1359. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  1360. var componentNormalizer = __webpack_require__(2);
  1361. // CONCATENATED MODULE: ./packages/tree/src/tree-node.vue
  1362. /* normalize component */
  1363. var component = Object(componentNormalizer["a" /* default */])(
  1364. src_tree_nodevue_type_script_lang_js_,
  1365. tree_nodevue_type_template_id_3ba3ef0e_render,
  1366. tree_nodevue_type_template_id_3ba3ef0e_staticRenderFns,
  1367. false,
  1368. null,
  1369. null,
  1370. null
  1371. )
  1372. /* hot reload */
  1373. if (false) { var api; }
  1374. component.options.__file = "packages/tree/src/tree-node.vue"
  1375. /* harmony default export */ var tree_node = (component.exports);
  1376. // EXTERNAL MODULE: external "tis-ui/lib/locale"
  1377. var locale_ = __webpack_require__(72);
  1378. // EXTERNAL MODULE: external "tis-ui/lib/utils/dom"
  1379. var dom_ = __webpack_require__(7);
  1380. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/tree/src/tree.vue?vue&type=script&lang=js&
  1381. //
  1382. //
  1383. //
  1384. //
  1385. //
  1386. //
  1387. //
  1388. //
  1389. //
  1390. //
  1391. //
  1392. //
  1393. //
  1394. //
  1395. //
  1396. //
  1397. //
  1398. //
  1399. //
  1400. //
  1401. //
  1402. //
  1403. //
  1404. //
  1405. //
  1406. //
  1407. //
  1408. //
  1409. //
  1410. //
  1411. //
  1412. //
  1413. /* harmony default export */ var treevue_type_script_lang_js_ = ({
  1414. name: 'TisTree',
  1415. mixins: [emitter_default.a],
  1416. components: {
  1417. TisTreeNode: tree_node
  1418. },
  1419. data: function data() {
  1420. return {
  1421. store: null,
  1422. root: null,
  1423. currentNode: null,
  1424. treeItems: null,
  1425. checkboxItems: [],
  1426. dragState: {
  1427. showDropIndicator: false,
  1428. draggingNode: null,
  1429. dropNode: null,
  1430. allowDrop: true
  1431. }
  1432. };
  1433. },
  1434. props: {
  1435. data: {
  1436. type: Array
  1437. },
  1438. emptyText: {
  1439. type: String,
  1440. default: function _default() {
  1441. return Object(locale_["t"])('el.tree.emptyText');
  1442. }
  1443. },
  1444. renderAfterExpand: {
  1445. type: Boolean,
  1446. default: true
  1447. },
  1448. nodeKey: String,
  1449. checkStrictly: Boolean,
  1450. defaultExpandAll: Boolean,
  1451. expandOnClickNode: {
  1452. type: Boolean,
  1453. default: true
  1454. },
  1455. checkOnClickNode: Boolean,
  1456. checkDescendants: {
  1457. type: Boolean,
  1458. default: false
  1459. },
  1460. autoExpandParent: {
  1461. type: Boolean,
  1462. default: true
  1463. },
  1464. defaultCheckedKeys: Array,
  1465. defaultExpandedKeys: Array,
  1466. currentNodeKey: [String, Number],
  1467. renderContent: Function,
  1468. showCheckbox: {
  1469. type: Boolean,
  1470. default: false
  1471. },
  1472. draggable: {
  1473. type: Boolean,
  1474. default: false
  1475. },
  1476. allowDrag: Function,
  1477. allowDrop: Function,
  1478. props: {
  1479. default: function _default() {
  1480. return {
  1481. children: 'children',
  1482. label: 'label',
  1483. disabled: 'disabled'
  1484. };
  1485. }
  1486. },
  1487. lazy: {
  1488. type: Boolean,
  1489. default: false
  1490. },
  1491. highlightCurrent: Boolean,
  1492. load: Function,
  1493. filterNodeMethod: Function,
  1494. accordion: Boolean,
  1495. indent: {
  1496. type: Number,
  1497. default: 18
  1498. },
  1499. iconClass: String
  1500. },
  1501. computed: {
  1502. children: {
  1503. set: function set(value) {
  1504. this.data = value;
  1505. },
  1506. get: function get() {
  1507. return this.data;
  1508. }
  1509. },
  1510. treeItemArray: function treeItemArray() {
  1511. return Array.prototype.slice.call(this.treeItems);
  1512. },
  1513. isEmpty: function isEmpty() {
  1514. var childNodes = this.root.childNodes;
  1515. return !childNodes || childNodes.length === 0 || childNodes.every(function (_ref) {
  1516. var visible = _ref.visible;
  1517. return !visible;
  1518. });
  1519. }
  1520. },
  1521. watch: {
  1522. defaultCheckedKeys: function defaultCheckedKeys(newVal) {
  1523. this.store.setDefaultCheckedKey(newVal);
  1524. },
  1525. defaultExpandedKeys: function defaultExpandedKeys(newVal) {
  1526. this.store.defaultExpandedKeys = newVal;
  1527. this.store.setDefaultExpandedKeys(newVal);
  1528. },
  1529. data: function data(newVal) {
  1530. this.store.setData(newVal);
  1531. },
  1532. checkboxItems: function checkboxItems(val) {
  1533. Array.prototype.forEach.call(val, function (checkbox) {
  1534. checkbox.setAttribute('tabindex', -1);
  1535. });
  1536. },
  1537. checkStrictly: function checkStrictly(newVal) {
  1538. this.store.checkStrictly = newVal;
  1539. }
  1540. },
  1541. methods: {
  1542. filter: function filter(value) {
  1543. if (!this.filterNodeMethod) throw new Error('[Tree] filterNodeMethod is required when filter');
  1544. this.store.filter(value);
  1545. },
  1546. getNodeKey: function getNodeKey(node) {
  1547. return util_getNodeKey(this.nodeKey, node.data);
  1548. },
  1549. getNodePath: function getNodePath(data) {
  1550. if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in getNodePath');
  1551. var node = this.store.getNode(data);
  1552. if (!node) return [];
  1553. var path = [node.data];
  1554. var parent = node.parent;
  1555. while (parent && parent !== this.root) {
  1556. path.push(parent.data);
  1557. parent = parent.parent;
  1558. }
  1559. return path.reverse();
  1560. },
  1561. getCheckedNodes: function getCheckedNodes(leafOnly, includeHalfChecked) {
  1562. return this.store.getCheckedNodes(leafOnly, includeHalfChecked);
  1563. },
  1564. getCheckedKeys: function getCheckedKeys(leafOnly) {
  1565. return this.store.getCheckedKeys(leafOnly);
  1566. },
  1567. getCurrentNode: function getCurrentNode() {
  1568. var currentNode = this.store.getCurrentNode();
  1569. return currentNode ? currentNode.data : null;
  1570. },
  1571. getCurrentKey: function getCurrentKey() {
  1572. if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in getCurrentKey');
  1573. var currentNode = this.getCurrentNode();
  1574. return currentNode ? currentNode[this.nodeKey] : null;
  1575. },
  1576. setCheckedNodes: function setCheckedNodes(nodes, leafOnly) {
  1577. if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in setCheckedNodes');
  1578. this.store.setCheckedNodes(nodes, leafOnly);
  1579. },
  1580. setCheckedKeys: function setCheckedKeys(keys, leafOnly) {
  1581. if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in setCheckedKeys');
  1582. this.store.setCheckedKeys(keys, leafOnly);
  1583. },
  1584. setChecked: function setChecked(data, checked, deep) {
  1585. this.store.setChecked(data, checked, deep);
  1586. },
  1587. getHalfCheckedNodes: function getHalfCheckedNodes() {
  1588. return this.store.getHalfCheckedNodes();
  1589. },
  1590. getHalfCheckedKeys: function getHalfCheckedKeys() {
  1591. return this.store.getHalfCheckedKeys();
  1592. },
  1593. setCurrentNode: function setCurrentNode(node) {
  1594. if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in setCurrentNode');
  1595. this.store.setUserCurrentNode(node);
  1596. },
  1597. setCurrentKey: function setCurrentKey(key) {
  1598. if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in setCurrentKey');
  1599. this.store.setCurrentNodeKey(key);
  1600. },
  1601. getNode: function getNode(data) {
  1602. return this.store.getNode(data);
  1603. },
  1604. remove: function remove(data) {
  1605. this.store.remove(data);
  1606. },
  1607. append: function append(data, parentNode) {
  1608. this.store.append(data, parentNode);
  1609. },
  1610. insertBefore: function insertBefore(data, refNode) {
  1611. this.store.insertBefore(data, refNode);
  1612. },
  1613. insertAfter: function insertAfter(data, refNode) {
  1614. this.store.insertAfter(data, refNode);
  1615. },
  1616. handleNodeExpand: function handleNodeExpand(nodeData, node, instance) {
  1617. this.broadcast('ElTreeNode', 'tree-node-expand', node);
  1618. this.$emit('node-expand', nodeData, node, instance);
  1619. },
  1620. updateKeyChildren: function updateKeyChildren(key, data) {
  1621. if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in updateKeyChild');
  1622. this.store.updateChildren(key, data);
  1623. },
  1624. initTabIndex: function initTabIndex() {
  1625. this.treeItems = this.$el.querySelectorAll('.is-focusable[role=treeitem]');
  1626. this.checkboxItems = this.$el.querySelectorAll('input[type=checkbox]');
  1627. var checkedItem = this.$el.querySelectorAll('.is-checked[role=treeitem]');
  1628. if (checkedItem.length) {
  1629. checkedItem[0].setAttribute('tabindex', 0);
  1630. return;
  1631. }
  1632. this.treeItems[0] && this.treeItems[0].setAttribute('tabindex', 0);
  1633. },
  1634. handleKeydown: function handleKeydown(ev) {
  1635. var currentItem = ev.target;
  1636. if (currentItem.className.indexOf('el-tree-node') === -1) return;
  1637. var keyCode = ev.keyCode;
  1638. this.treeItems = this.$el.querySelectorAll('.is-focusable[role=treeitem]');
  1639. var currentIndex = this.treeItemArray.indexOf(currentItem);
  1640. var nextIndex = void 0;
  1641. if ([38, 40].indexOf(keyCode) > -1) {
  1642. // up、down
  1643. ev.preventDefault();
  1644. if (keyCode === 38) {
  1645. // up
  1646. nextIndex = currentIndex !== 0 ? currentIndex - 1 : 0;
  1647. } else {
  1648. nextIndex = currentIndex < this.treeItemArray.length - 1 ? currentIndex + 1 : 0;
  1649. }
  1650. this.treeItemArray[nextIndex].focus(); // 选中
  1651. }
  1652. if ([37, 39].indexOf(keyCode) > -1) {
  1653. // left、right 展开
  1654. ev.preventDefault();
  1655. currentItem.click(); // 选中
  1656. }
  1657. var hasInput = currentItem.querySelector('[type="checkbox"]');
  1658. if ([13, 32].indexOf(keyCode) > -1 && hasInput) {
  1659. // space enter选中checkbox
  1660. ev.preventDefault();
  1661. hasInput.click();
  1662. }
  1663. }
  1664. },
  1665. created: function created() {
  1666. var _this = this;
  1667. this.isTree = true;
  1668. this.store = new tree_store({
  1669. key: this.nodeKey,
  1670. data: this.data,
  1671. lazy: this.lazy,
  1672. props: this.props,
  1673. load: this.load,
  1674. currentNodeKey: this.currentNodeKey,
  1675. checkStrictly: this.checkStrictly,
  1676. checkDescendants: this.checkDescendants,
  1677. defaultCheckedKeys: this.defaultCheckedKeys,
  1678. defaultExpandedKeys: this.defaultExpandedKeys,
  1679. autoExpandParent: this.autoExpandParent,
  1680. defaultExpandAll: this.defaultExpandAll,
  1681. filterNodeMethod: this.filterNodeMethod
  1682. });
  1683. this.root = this.store.root;
  1684. var dragState = this.dragState;
  1685. this.$on('tree-node-drag-start', function (event, treeNode) {
  1686. if (typeof _this.allowDrag === 'function' && !_this.allowDrag(treeNode.node)) {
  1687. event.preventDefault();
  1688. return false;
  1689. }
  1690. event.dataTransfer.effectAllowed = 'move';
  1691. // wrap in try catch to address IE's error when first param is 'text/plain'
  1692. try {
  1693. // setData is required for draggable to work in FireFox
  1694. // the content has to be '' so dragging a node out of the tree won't open a new tab in FireFox
  1695. event.dataTransfer.setData('text/plain', '');
  1696. } catch (e) {}
  1697. dragState.draggingNode = treeNode;
  1698. _this.$emit('node-drag-start', treeNode.node, event);
  1699. });
  1700. this.$on('tree-node-drag-over', function (event, treeNode) {
  1701. var dropNode = findNearestComponent(event.target, 'ElTreeNode');
  1702. var oldDropNode = dragState.dropNode;
  1703. if (oldDropNode && oldDropNode !== dropNode) {
  1704. Object(dom_["removeClass"])(oldDropNode.$el, 'is-drop-inner');
  1705. }
  1706. var draggingNode = dragState.draggingNode;
  1707. if (!draggingNode || !dropNode) return;
  1708. var dropPrev = true;
  1709. var dropInner = true;
  1710. var dropNext = true;
  1711. var userAllowDropInner = true;
  1712. if (typeof _this.allowDrop === 'function') {
  1713. dropPrev = _this.allowDrop(draggingNode.node, dropNode.node, 'prev');
  1714. userAllowDropInner = dropInner = _this.allowDrop(draggingNode.node, dropNode.node, 'inner');
  1715. dropNext = _this.allowDrop(draggingNode.node, dropNode.node, 'next');
  1716. }
  1717. event.dataTransfer.dropEffect = dropInner ? 'move' : 'none';
  1718. if ((dropPrev || dropInner || dropNext) && oldDropNode !== dropNode) {
  1719. if (oldDropNode) {
  1720. _this.$emit('node-drag-leave', draggingNode.node, oldDropNode.node, event);
  1721. }
  1722. _this.$emit('node-drag-enter', draggingNode.node, dropNode.node, event);
  1723. }
  1724. if (dropPrev || dropInner || dropNext) {
  1725. dragState.dropNode = dropNode;
  1726. }
  1727. if (dropNode.node.nextSibling === draggingNode.node) {
  1728. dropNext = false;
  1729. }
  1730. if (dropNode.node.previousSibling === draggingNode.node) {
  1731. dropPrev = false;
  1732. }
  1733. if (dropNode.node.contains(draggingNode.node, false)) {
  1734. dropInner = false;
  1735. }
  1736. if (draggingNode.node === dropNode.node || draggingNode.node.contains(dropNode.node)) {
  1737. dropPrev = false;
  1738. dropInner = false;
  1739. dropNext = false;
  1740. }
  1741. var targetPosition = dropNode.$el.getBoundingClientRect();
  1742. var treePosition = _this.$el.getBoundingClientRect();
  1743. var dropType = void 0;
  1744. var prevPercent = dropPrev ? dropInner ? 0.25 : dropNext ? 0.45 : 1 : -1;
  1745. var nextPercent = dropNext ? dropInner ? 0.75 : dropPrev ? 0.55 : 0 : 1;
  1746. var indicatorTop = -9999;
  1747. var distance = event.clientY - targetPosition.top;
  1748. if (distance < targetPosition.height * prevPercent) {
  1749. dropType = 'before';
  1750. } else if (distance > targetPosition.height * nextPercent) {
  1751. dropType = 'after';
  1752. } else if (dropInner) {
  1753. dropType = 'inner';
  1754. } else {
  1755. dropType = 'none';
  1756. }
  1757. var iconPosition = dropNode.$el.querySelector('.el-tree-node__expand-icon').getBoundingClientRect();
  1758. var dropIndicator = _this.$refs.dropIndicator;
  1759. if (dropType === 'before') {
  1760. indicatorTop = iconPosition.top - treePosition.top;
  1761. } else if (dropType === 'after') {
  1762. indicatorTop = iconPosition.bottom - treePosition.top;
  1763. }
  1764. dropIndicator.style.top = indicatorTop + 'px';
  1765. dropIndicator.style.left = iconPosition.right - treePosition.left + 'px';
  1766. if (dropType === 'inner') {
  1767. Object(dom_["addClass"])(dropNode.$el, 'is-drop-inner');
  1768. } else {
  1769. Object(dom_["removeClass"])(dropNode.$el, 'is-drop-inner');
  1770. }
  1771. dragState.showDropIndicator = dropType === 'before' || dropType === 'after';
  1772. dragState.allowDrop = dragState.showDropIndicator || userAllowDropInner;
  1773. dragState.dropType = dropType;
  1774. _this.$emit('node-drag-over', draggingNode.node, dropNode.node, event);
  1775. });
  1776. this.$on('tree-node-drag-end', function (event) {
  1777. var draggingNode = dragState.draggingNode,
  1778. dropType = dragState.dropType,
  1779. dropNode = dragState.dropNode;
  1780. event.preventDefault();
  1781. event.dataTransfer.dropEffect = 'move';
  1782. if (draggingNode && dropNode) {
  1783. var draggingNodeCopy = { data: draggingNode.node.data };
  1784. if (dropType !== 'none') {
  1785. draggingNode.node.remove();
  1786. }
  1787. if (dropType === 'before') {
  1788. dropNode.node.parent.insertBefore(draggingNodeCopy, dropNode.node);
  1789. } else if (dropType === 'after') {
  1790. dropNode.node.parent.insertAfter(draggingNodeCopy, dropNode.node);
  1791. } else if (dropType === 'inner') {
  1792. dropNode.node.insertChild(draggingNodeCopy);
  1793. }
  1794. if (dropType !== 'none') {
  1795. _this.store.registerNode(draggingNodeCopy);
  1796. }
  1797. Object(dom_["removeClass"])(dropNode.$el, 'is-drop-inner');
  1798. _this.$emit('node-drag-end', draggingNode.node, dropNode.node, dropType, event);
  1799. if (dropType !== 'none') {
  1800. _this.$emit('node-drop', draggingNode.node, dropNode.node, dropType, event);
  1801. }
  1802. }
  1803. if (draggingNode && !dropNode) {
  1804. _this.$emit('node-drag-end', draggingNode.node, null, dropType, event);
  1805. }
  1806. dragState.showDropIndicator = false;
  1807. dragState.draggingNode = null;
  1808. dragState.dropNode = null;
  1809. dragState.allowDrop = true;
  1810. });
  1811. },
  1812. mounted: function mounted() {
  1813. this.initTabIndex();
  1814. this.$el.addEventListener('keydown', this.handleKeydown);
  1815. },
  1816. updated: function updated() {
  1817. this.treeItems = this.$el.querySelectorAll('[role=treeitem]');
  1818. this.checkboxItems = this.$el.querySelectorAll('input[type=checkbox]');
  1819. }
  1820. });
  1821. // CONCATENATED MODULE: ./packages/tree/src/tree.vue?vue&type=script&lang=js&
  1822. /* harmony default export */ var src_treevue_type_script_lang_js_ = (treevue_type_script_lang_js_);
  1823. // CONCATENATED MODULE: ./packages/tree/src/tree.vue
  1824. /* normalize component */
  1825. var tree_component = Object(componentNormalizer["a" /* default */])(
  1826. src_treevue_type_script_lang_js_,
  1827. render,
  1828. staticRenderFns,
  1829. false,
  1830. null,
  1831. null,
  1832. null
  1833. )
  1834. /* hot reload */
  1835. if (false) { var tree_api; }
  1836. tree_component.options.__file = "packages/tree/src/tree.vue"
  1837. /* harmony default export */ var tree = (tree_component.exports);
  1838. // CONCATENATED MODULE: ./packages/tree/index.js
  1839. /* istanbul ignore next */
  1840. tree.install = function (Vue) {
  1841. Vue.component(tree.name, tree);
  1842. };
  1843. /* harmony default export */ var packages_tree = __webpack_exports__["default"] = (tree);
  1844. /***/ }),
  1845. /***/ 2:
  1846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1847. "use strict";
  1848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
  1849. /* globals __VUE_SSR_CONTEXT__ */
  1850. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  1851. // This module is a runtime utility for cleaner component module output and will
  1852. // be included in the final webpack user bundle.
  1853. function normalizeComponent (
  1854. scriptExports,
  1855. render,
  1856. staticRenderFns,
  1857. functionalTemplate,
  1858. injectStyles,
  1859. scopeId,
  1860. moduleIdentifier, /* server only */
  1861. shadowMode /* vue-cli only */
  1862. ) {
  1863. // Vue.extend constructor export interop
  1864. var options = typeof scriptExports === 'function'
  1865. ? scriptExports.options
  1866. : scriptExports
  1867. // render functions
  1868. if (render) {
  1869. options.render = render
  1870. options.staticRenderFns = staticRenderFns
  1871. options._compiled = true
  1872. }
  1873. // functional template
  1874. if (functionalTemplate) {
  1875. options.functional = true
  1876. }
  1877. // scopedId
  1878. if (scopeId) {
  1879. options._scopeId = 'data-v-' + scopeId
  1880. }
  1881. var hook
  1882. if (moduleIdentifier) { // server build
  1883. hook = function (context) {
  1884. // 2.3 injection
  1885. context =
  1886. context || // cached call
  1887. (this.$vnode && this.$vnode.ssrContext) || // stateful
  1888. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  1889. // 2.2 with runInNewContext: true
  1890. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  1891. context = __VUE_SSR_CONTEXT__
  1892. }
  1893. // inject component styles
  1894. if (injectStyles) {
  1895. injectStyles.call(this, context)
  1896. }
  1897. // register component module identifier for async chunk inferrence
  1898. if (context && context._registeredComponents) {
  1899. context._registeredComponents.add(moduleIdentifier)
  1900. }
  1901. }
  1902. // used by ssr in case component is cached and beforeCreate
  1903. // never gets called
  1904. options._ssrRegister = hook
  1905. } else if (injectStyles) {
  1906. hook = shadowMode
  1907. ? function () {
  1908. injectStyles.call(
  1909. this,
  1910. (options.functional ? this.parent : this).$root.$options.shadowRoot
  1911. )
  1912. }
  1913. : injectStyles
  1914. }
  1915. if (hook) {
  1916. if (options.functional) {
  1917. // for template-only hot-reload because in that case the render fn doesn't
  1918. // go through the normalizer
  1919. options._injectStyles = hook
  1920. // register for functional component in vue file
  1921. var originalRender = options.render
  1922. options.render = function renderWithStyleInjection (h, context) {
  1923. hook.call(context)
  1924. return originalRender(h, context)
  1925. }
  1926. } else {
  1927. // inject component registration as beforeCreate hook
  1928. var existing = options.beforeCreate
  1929. options.beforeCreate = existing
  1930. ? [].concat(existing, hook)
  1931. : [hook]
  1932. }
  1933. }
  1934. return {
  1935. exports: scriptExports,
  1936. options: options
  1937. }
  1938. }
  1939. /***/ }),
  1940. /***/ 33:
  1941. /***/ (function(module, exports) {
  1942. module.exports = require("tis-ui/lib/utils/merge");
  1943. /***/ }),
  1944. /***/ 68:
  1945. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1946. "use strict";
  1947. // ESM COMPAT FLAG
  1948. __webpack_require__.r(__webpack_exports__);
  1949. // 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&
  1950. var render = function() {
  1951. var _vm = this
  1952. var _h = _vm.$createElement
  1953. var _c = _vm._self._c || _h
  1954. return _c(
  1955. "label",
  1956. {
  1957. staticClass: "el-checkbox",
  1958. class: [
  1959. _vm.border && _vm.checkboxSize
  1960. ? "el-checkbox--" + _vm.checkboxSize
  1961. : "",
  1962. { "is-disabled": _vm.isDisabled },
  1963. { "is-bordered": _vm.border },
  1964. { "is-checked": _vm.isChecked }
  1965. ],
  1966. attrs: { id: _vm.id }
  1967. },
  1968. [
  1969. _c(
  1970. "span",
  1971. {
  1972. staticClass: "el-checkbox__input",
  1973. class: {
  1974. "is-disabled": _vm.isDisabled,
  1975. "is-checked": _vm.isChecked,
  1976. "is-indeterminate": _vm.indeterminate,
  1977. "is-focus": _vm.focus
  1978. },
  1979. attrs: {
  1980. tabindex: _vm.indeterminate ? 0 : false,
  1981. role: _vm.indeterminate ? "checkbox" : false,
  1982. "aria-checked": _vm.indeterminate ? "mixed" : false
  1983. }
  1984. },
  1985. [
  1986. _c("span", { staticClass: "el-checkbox__inner" }),
  1987. _vm.trueLabel || _vm.falseLabel
  1988. ? _c("input", {
  1989. directives: [
  1990. {
  1991. name: "model",
  1992. rawName: "v-model",
  1993. value: _vm.model,
  1994. expression: "model"
  1995. }
  1996. ],
  1997. staticClass: "el-checkbox__original",
  1998. attrs: {
  1999. type: "checkbox",
  2000. "aria-hidden": _vm.indeterminate ? "true" : "false",
  2001. name: _vm.name,
  2002. disabled: _vm.isDisabled,
  2003. "true-value": _vm.trueLabel,
  2004. "false-value": _vm.falseLabel
  2005. },
  2006. domProps: {
  2007. checked: Array.isArray(_vm.model)
  2008. ? _vm._i(_vm.model, null) > -1
  2009. : _vm._q(_vm.model, _vm.trueLabel)
  2010. },
  2011. on: {
  2012. change: [
  2013. function($event) {
  2014. var $$a = _vm.model,
  2015. $$el = $event.target,
  2016. $$c = $$el.checked ? _vm.trueLabel : _vm.falseLabel
  2017. if (Array.isArray($$a)) {
  2018. var $$v = null,
  2019. $$i = _vm._i($$a, $$v)
  2020. if ($$el.checked) {
  2021. $$i < 0 && (_vm.model = $$a.concat([$$v]))
  2022. } else {
  2023. $$i > -1 &&
  2024. (_vm.model = $$a
  2025. .slice(0, $$i)
  2026. .concat($$a.slice($$i + 1)))
  2027. }
  2028. } else {
  2029. _vm.model = $$c
  2030. }
  2031. },
  2032. _vm.handleChange
  2033. ],
  2034. focus: function($event) {
  2035. _vm.focus = true
  2036. },
  2037. blur: function($event) {
  2038. _vm.focus = false
  2039. }
  2040. }
  2041. })
  2042. : _c("input", {
  2043. directives: [
  2044. {
  2045. name: "model",
  2046. rawName: "v-model",
  2047. value: _vm.model,
  2048. expression: "model"
  2049. }
  2050. ],
  2051. staticClass: "el-checkbox__original",
  2052. attrs: {
  2053. type: "checkbox",
  2054. "aria-hidden": _vm.indeterminate ? "true" : "false",
  2055. disabled: _vm.isDisabled,
  2056. name: _vm.name
  2057. },
  2058. domProps: {
  2059. value: _vm.label,
  2060. checked: Array.isArray(_vm.model)
  2061. ? _vm._i(_vm.model, _vm.label) > -1
  2062. : _vm.model
  2063. },
  2064. on: {
  2065. change: [
  2066. function($event) {
  2067. var $$a = _vm.model,
  2068. $$el = $event.target,
  2069. $$c = $$el.checked ? true : false
  2070. if (Array.isArray($$a)) {
  2071. var $$v = _vm.label,
  2072. $$i = _vm._i($$a, $$v)
  2073. if ($$el.checked) {
  2074. $$i < 0 && (_vm.model = $$a.concat([$$v]))
  2075. } else {
  2076. $$i > -1 &&
  2077. (_vm.model = $$a
  2078. .slice(0, $$i)
  2079. .concat($$a.slice($$i + 1)))
  2080. }
  2081. } else {
  2082. _vm.model = $$c
  2083. }
  2084. },
  2085. _vm.handleChange
  2086. ],
  2087. focus: function($event) {
  2088. _vm.focus = true
  2089. },
  2090. blur: function($event) {
  2091. _vm.focus = false
  2092. }
  2093. }
  2094. })
  2095. ]
  2096. ),
  2097. _vm.$slots.default || _vm.label
  2098. ? _c(
  2099. "span",
  2100. { staticClass: "el-checkbox__label" },
  2101. [
  2102. _vm._t("default"),
  2103. !_vm.$slots.default ? [_vm._v(_vm._s(_vm.label))] : _vm._e()
  2104. ],
  2105. 2
  2106. )
  2107. : _vm._e()
  2108. ]
  2109. )
  2110. }
  2111. var staticRenderFns = []
  2112. render._withStripped = true
  2113. // CONCATENATED MODULE: ./packages/checkbox/src/checkbox.vue?vue&type=template&id=d0387074&
  2114. // EXTERNAL MODULE: external "tis-ui/lib/mixins/emitter"
  2115. var emitter_ = __webpack_require__(13);
  2116. var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
  2117. // 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&
  2118. //
  2119. //
  2120. //
  2121. //
  2122. //
  2123. //
  2124. //
  2125. //
  2126. //
  2127. //
  2128. //
  2129. //
  2130. //
  2131. //
  2132. //
  2133. //
  2134. //
  2135. //
  2136. //
  2137. //
  2138. //
  2139. //
  2140. //
  2141. //
  2142. //
  2143. //
  2144. //
  2145. //
  2146. //
  2147. //
  2148. //
  2149. //
  2150. //
  2151. //
  2152. //
  2153. //
  2154. //
  2155. //
  2156. //
  2157. //
  2158. //
  2159. //
  2160. //
  2161. //
  2162. //
  2163. //
  2164. //
  2165. //
  2166. //
  2167. //
  2168. //
  2169. //
  2170. //
  2171. //
  2172. //
  2173. /* harmony default export */ var checkboxvue_type_script_lang_js_ = ({
  2174. name: 'TisCheckbox',
  2175. mixins: [emitter_default.a],
  2176. inject: {
  2177. elForm: {
  2178. default: ''
  2179. },
  2180. elFormItem: {
  2181. default: ''
  2182. }
  2183. },
  2184. componentName: 'TisCheckbox',
  2185. data: function data() {
  2186. return {
  2187. selfModel: false,
  2188. focus: false,
  2189. isLimitExceeded: false
  2190. };
  2191. },
  2192. computed: {
  2193. model: {
  2194. get: function get() {
  2195. return this.isGroup ? this.store : this.value !== undefined ? this.value : this.selfModel;
  2196. },
  2197. set: function set(val) {
  2198. if (this.isGroup) {
  2199. this.isLimitExceeded = false;
  2200. this._checkboxGroup.min !== undefined && val.length < this._checkboxGroup.min && (this.isLimitExceeded = true);
  2201. this._checkboxGroup.max !== undefined && val.length > this._checkboxGroup.max && (this.isLimitExceeded = true);
  2202. this.isLimitExceeded === false && this.dispatch('TisCheckboxGroup', 'input', [val]);
  2203. } else {
  2204. this.$emit('input', val);
  2205. this.selfModel = val;
  2206. }
  2207. }
  2208. },
  2209. isChecked: function isChecked() {
  2210. if ({}.toString.call(this.model) === '[object Boolean]') {
  2211. return this.model;
  2212. } else if (Array.isArray(this.model)) {
  2213. return this.model.indexOf(this.label) > -1;
  2214. } else if (this.model !== null && this.model !== undefined) {
  2215. return this.model === this.trueLabel;
  2216. }
  2217. },
  2218. isGroup: function isGroup() {
  2219. var parent = this.$parent;
  2220. while (parent) {
  2221. if (parent.$options.componentName !== 'TisCheckboxGroup') {
  2222. parent = parent.$parent;
  2223. } else {
  2224. this._checkboxGroup = parent;
  2225. return true;
  2226. }
  2227. }
  2228. return false;
  2229. },
  2230. store: function store() {
  2231. return this._checkboxGroup ? this._checkboxGroup.value : this.value;
  2232. },
  2233. /* used to make the isDisabled judgment under max/min props */
  2234. isLimitDisabled: function isLimitDisabled() {
  2235. var _checkboxGroup = this._checkboxGroup,
  2236. max = _checkboxGroup.max,
  2237. min = _checkboxGroup.min;
  2238. return !!(max || min) && this.model.length >= max && !this.isChecked || this.model.length <= min && this.isChecked;
  2239. },
  2240. isDisabled: function isDisabled() {
  2241. return this.isGroup ? this._checkboxGroup.disabled || this.disabled || (this.elForm || {}).disabled || this.isLimitDisabled : this.disabled || (this.elForm || {}).disabled;
  2242. },
  2243. _elFormItemSize: function _elFormItemSize() {
  2244. return (this.elFormItem || {}).elFormItemSize;
  2245. },
  2246. checkboxSize: function checkboxSize() {
  2247. var temCheckboxSize = this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
  2248. return this.isGroup ? this._checkboxGroup.checkboxGroupSize || temCheckboxSize : temCheckboxSize;
  2249. }
  2250. },
  2251. props: {
  2252. value: {},
  2253. label: {},
  2254. indeterminate: Boolean,
  2255. disabled: Boolean,
  2256. checked: Boolean,
  2257. name: String,
  2258. trueLabel: [String, Number],
  2259. falseLabel: [String, Number],
  2260. id: String, /* 当indeterminate为真时,为controls提供相关连的checkbox的id,表明元素间的控制关系*/
  2261. controls: String, /* 当indeterminate为真时,为controls提供相关连的checkbox的id,表明元素间的控制关系*/
  2262. border: Boolean,
  2263. size: String
  2264. },
  2265. methods: {
  2266. addToStore: function addToStore() {
  2267. if (Array.isArray(this.model) && this.model.indexOf(this.label) === -1) {
  2268. this.model.push(this.label);
  2269. } else {
  2270. this.model = this.trueLabel || true;
  2271. }
  2272. },
  2273. handleChange: function handleChange(ev) {
  2274. var _this = this;
  2275. if (this.isLimitExceeded) return;
  2276. var value = void 0;
  2277. if (ev.target.checked) {
  2278. value = this.trueLabel === undefined ? true : this.trueLabel;
  2279. } else {
  2280. value = this.falseLabel === undefined ? false : this.falseLabel;
  2281. }
  2282. this.$emit('change', value, ev);
  2283. this.$nextTick(function () {
  2284. if (_this.isGroup) {
  2285. _this.dispatch('TisCheckboxGroup', 'change', [_this._checkboxGroup.value]);
  2286. }
  2287. });
  2288. }
  2289. },
  2290. created: function created() {
  2291. this.checked && this.addToStore();
  2292. },
  2293. mounted: function mounted() {
  2294. // 为indeterminate元素 添加aria-controls 属性
  2295. if (this.indeterminate) {
  2296. this.$el.setAttribute('aria-controls', this.controls);
  2297. }
  2298. },
  2299. watch: {
  2300. value: function value(_value) {
  2301. this.dispatch('ElFormItem', 'el.form.change', _value);
  2302. }
  2303. }
  2304. });
  2305. // CONCATENATED MODULE: ./packages/checkbox/src/checkbox.vue?vue&type=script&lang=js&
  2306. /* harmony default export */ var src_checkboxvue_type_script_lang_js_ = (checkboxvue_type_script_lang_js_);
  2307. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  2308. var componentNormalizer = __webpack_require__(2);
  2309. // CONCATENATED MODULE: ./packages/checkbox/src/checkbox.vue
  2310. /* normalize component */
  2311. var component = Object(componentNormalizer["a" /* default */])(
  2312. src_checkboxvue_type_script_lang_js_,
  2313. render,
  2314. staticRenderFns,
  2315. false,
  2316. null,
  2317. null,
  2318. null
  2319. )
  2320. /* hot reload */
  2321. if (false) { var api; }
  2322. component.options.__file = "packages/checkbox/src/checkbox.vue"
  2323. /* harmony default export */ var src_checkbox = (component.exports);
  2324. // CONCATENATED MODULE: ./packages/checkbox/index.js
  2325. /* istanbul ignore next */
  2326. src_checkbox.install = function (Vue) {
  2327. Vue.component(src_checkbox.name, src_checkbox);
  2328. };
  2329. /* harmony default export */ var packages_checkbox = __webpack_exports__["default"] = (src_checkbox);
  2330. /***/ }),
  2331. /***/ 7:
  2332. /***/ (function(module, exports) {
  2333. module.exports = require("tis-ui/lib/utils/dom");
  2334. /***/ }),
  2335. /***/ 72:
  2336. /***/ (function(module, exports) {
  2337. module.exports = require("tis-ui/lib/locale");
  2338. /***/ }),
  2339. /***/ 98:
  2340. /***/ (function(module, exports) {
  2341. module.exports = require("tis-ui/lib/transitions/collapse-transition");
  2342. /***/ })
  2343. /******/ });