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.

930 lines
28 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 = 520);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 10:
  90. /***/ (function(module, exports) {
  91. module.exports = require("tis-ui/lib/utils/util");
  92. /***/ }),
  93. /***/ 2:
  94. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95. "use strict";
  96. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
  97. /* globals __VUE_SSR_CONTEXT__ */
  98. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  99. // This module is a runtime utility for cleaner component module output and will
  100. // be included in the final webpack user bundle.
  101. function normalizeComponent (
  102. scriptExports,
  103. render,
  104. staticRenderFns,
  105. functionalTemplate,
  106. injectStyles,
  107. scopeId,
  108. moduleIdentifier, /* server only */
  109. shadowMode /* vue-cli only */
  110. ) {
  111. // Vue.extend constructor export interop
  112. var options = typeof scriptExports === 'function'
  113. ? scriptExports.options
  114. : scriptExports
  115. // render functions
  116. if (render) {
  117. options.render = render
  118. options.staticRenderFns = staticRenderFns
  119. options._compiled = true
  120. }
  121. // functional template
  122. if (functionalTemplate) {
  123. options.functional = true
  124. }
  125. // scopedId
  126. if (scopeId) {
  127. options._scopeId = 'data-v-' + scopeId
  128. }
  129. var hook
  130. if (moduleIdentifier) { // server build
  131. hook = function (context) {
  132. // 2.3 injection
  133. context =
  134. context || // cached call
  135. (this.$vnode && this.$vnode.ssrContext) || // stateful
  136. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  137. // 2.2 with runInNewContext: true
  138. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  139. context = __VUE_SSR_CONTEXT__
  140. }
  141. // inject component styles
  142. if (injectStyles) {
  143. injectStyles.call(this, context)
  144. }
  145. // register component module identifier for async chunk inferrence
  146. if (context && context._registeredComponents) {
  147. context._registeredComponents.add(moduleIdentifier)
  148. }
  149. }
  150. // used by ssr in case component is cached and beforeCreate
  151. // never gets called
  152. options._ssrRegister = hook
  153. } else if (injectStyles) {
  154. hook = shadowMode
  155. ? function () {
  156. injectStyles.call(
  157. this,
  158. (options.functional ? this.parent : this).$root.$options.shadowRoot
  159. )
  160. }
  161. : injectStyles
  162. }
  163. if (hook) {
  164. if (options.functional) {
  165. // for template-only hot-reload because in that case the render fn doesn't
  166. // go through the normalizer
  167. options._injectStyles = hook
  168. // register for functional component in vue file
  169. var originalRender = options.render
  170. options.render = function renderWithStyleInjection (h, context) {
  171. hook.call(context)
  172. return originalRender(h, context)
  173. }
  174. } else {
  175. // inject component registration as beforeCreate hook
  176. var existing = options.beforeCreate
  177. options.beforeCreate = existing
  178. ? [].concat(existing, hook)
  179. : [hook]
  180. }
  181. }
  182. return {
  183. exports: scriptExports,
  184. options: options
  185. }
  186. }
  187. /***/ }),
  188. /***/ 44:
  189. /***/ (function(module, exports) {
  190. module.exports = require("tis-ui/lib/utils/resize-event");
  191. /***/ }),
  192. /***/ 520:
  193. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  194. "use strict";
  195. // ESM COMPAT FLAG
  196. __webpack_require__.r(__webpack_exports__);
  197. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/tabs/src/tab-bar.vue?vue&type=template&id=2031f33a&
  198. var render = function() {
  199. var _vm = this
  200. var _h = _vm.$createElement
  201. var _c = _vm._self._c || _h
  202. return _c("div", {
  203. staticClass: "el-tabs__active-bar",
  204. class: "is-" + _vm.rootTabs.tabPosition,
  205. style: _vm.barStyle
  206. })
  207. }
  208. var staticRenderFns = []
  209. render._withStripped = true
  210. // CONCATENATED MODULE: ./packages/tabs/src/tab-bar.vue?vue&type=template&id=2031f33a&
  211. // EXTERNAL MODULE: external "tis-ui/lib/utils/util"
  212. var util_ = __webpack_require__(10);
  213. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/tabs/src/tab-bar.vue?vue&type=script&lang=js&
  214. //
  215. //
  216. //
  217. /* harmony default export */ var tab_barvue_type_script_lang_js_ = ({
  218. name: 'TabBar',
  219. props: {
  220. tabs: Array
  221. },
  222. inject: ['rootTabs'],
  223. computed: {
  224. barStyle: {
  225. get: function get() {
  226. var _this = this;
  227. var style = {};
  228. var offset = 0;
  229. var tabSize = 0;
  230. var sizeName = ['top', 'bottom'].indexOf(this.rootTabs.tabPosition) !== -1 ? 'width' : 'height';
  231. var sizeDir = sizeName === 'width' ? 'x' : 'y';
  232. var firstUpperCase = function firstUpperCase(str) {
  233. return str.toLowerCase().replace(/( |^)[a-z]/g, function (L) {
  234. return L.toUpperCase();
  235. });
  236. };
  237. this.tabs.every(function (tab, index) {
  238. var $el = Object(util_["arrayFind"])(_this.$parent.$refs.tabs || [], function (t) {
  239. return t.id.replace('tab-', '') === tab.paneName;
  240. });
  241. if (!$el) {
  242. return false;
  243. }
  244. if (!tab.active) {
  245. offset += $el['client' + firstUpperCase(sizeName)];
  246. return true;
  247. } else {
  248. tabSize = $el['client' + firstUpperCase(sizeName)];
  249. var tabStyles = window.getComputedStyle($el);
  250. if (sizeName === 'width' && _this.tabs.length > 1) {
  251. tabSize -= parseFloat(tabStyles.paddingLeft) + parseFloat(tabStyles.paddingRight);
  252. }
  253. if (sizeName === 'width') {
  254. offset += parseFloat(tabStyles.paddingLeft);
  255. }
  256. return false;
  257. }
  258. });
  259. var transform = 'translate' + firstUpperCase(sizeDir) + '(' + offset + 'px)';
  260. style[sizeName] = tabSize + 'px';
  261. style.transform = transform;
  262. style.msTransform = transform;
  263. style.webkitTransform = transform;
  264. return style;
  265. }
  266. }
  267. }
  268. });
  269. // CONCATENATED MODULE: ./packages/tabs/src/tab-bar.vue?vue&type=script&lang=js&
  270. /* harmony default export */ var src_tab_barvue_type_script_lang_js_ = (tab_barvue_type_script_lang_js_);
  271. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  272. var componentNormalizer = __webpack_require__(2);
  273. // CONCATENATED MODULE: ./packages/tabs/src/tab-bar.vue
  274. /* normalize component */
  275. var component = Object(componentNormalizer["a" /* default */])(
  276. src_tab_barvue_type_script_lang_js_,
  277. render,
  278. staticRenderFns,
  279. false,
  280. null,
  281. null,
  282. null
  283. )
  284. /* hot reload */
  285. if (false) { var api; }
  286. component.options.__file = "packages/tabs/src/tab-bar.vue"
  287. /* harmony default export */ var tab_bar = (component.exports);
  288. // EXTERNAL MODULE: external "tis-ui/lib/utils/resize-event"
  289. var resize_event_ = __webpack_require__(44);
  290. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/tabs/src/tab-nav.vue?vue&type=script&lang=js&
  291. function noop() {}
  292. var tab_navvue_type_script_lang_js_firstUpperCase = function firstUpperCase(str) {
  293. return str.toLowerCase().replace(/( |^)[a-z]/g, function (L) {
  294. return L.toUpperCase();
  295. });
  296. };
  297. /* harmony default export */ var tab_navvue_type_script_lang_js_ = ({
  298. name: 'TabNav',
  299. components: {
  300. TabBar: tab_bar
  301. },
  302. inject: ['rootTabs'],
  303. props: {
  304. panes: Array,
  305. currentName: String,
  306. editable: Boolean,
  307. onTabClick: {
  308. type: Function,
  309. default: noop
  310. },
  311. onTabRemove: {
  312. type: Function,
  313. default: noop
  314. },
  315. type: String,
  316. stretch: Boolean
  317. },
  318. data: function data() {
  319. return {
  320. scrollable: false,
  321. navOffset: 0,
  322. isFocus: false,
  323. focusable: true
  324. };
  325. },
  326. computed: {
  327. navStyle: function navStyle() {
  328. var dir = ['top', 'bottom'].indexOf(this.rootTabs.tabPosition) !== -1 ? 'X' : 'Y';
  329. return {
  330. transform: 'translate' + dir + '(-' + this.navOffset + 'px)'
  331. };
  332. },
  333. sizeName: function sizeName() {
  334. return ['top', 'bottom'].indexOf(this.rootTabs.tabPosition) !== -1 ? 'width' : 'height';
  335. }
  336. },
  337. methods: {
  338. scrollPrev: function scrollPrev() {
  339. var containerSize = this.$refs.navScroll['offset' + tab_navvue_type_script_lang_js_firstUpperCase(this.sizeName)];
  340. var currentOffset = this.navOffset;
  341. if (!currentOffset) return;
  342. var newOffset = currentOffset > containerSize ? currentOffset - containerSize : 0;
  343. this.navOffset = newOffset;
  344. },
  345. scrollNext: function scrollNext() {
  346. var navSize = this.$refs.nav['offset' + tab_navvue_type_script_lang_js_firstUpperCase(this.sizeName)];
  347. var containerSize = this.$refs.navScroll['offset' + tab_navvue_type_script_lang_js_firstUpperCase(this.sizeName)];
  348. var currentOffset = this.navOffset;
  349. if (navSize - currentOffset <= containerSize) return;
  350. var newOffset = navSize - currentOffset > containerSize * 2 ? currentOffset + containerSize : navSize - containerSize;
  351. this.navOffset = newOffset;
  352. },
  353. scrollToActiveTab: function scrollToActiveTab() {
  354. if (!this.scrollable) return;
  355. var nav = this.$refs.nav;
  356. var activeTab = this.$el.querySelector('.is-active');
  357. if (!activeTab) return;
  358. var navScroll = this.$refs.navScroll;
  359. var isHorizontal = ['top', 'bottom'].indexOf(this.rootTabs.tabPosition) !== -1;
  360. var activeTabBounding = activeTab.getBoundingClientRect();
  361. var navScrollBounding = navScroll.getBoundingClientRect();
  362. var maxOffset = isHorizontal ? nav.offsetWidth - navScrollBounding.width : nav.offsetHeight - navScrollBounding.height;
  363. var currentOffset = this.navOffset;
  364. var newOffset = currentOffset;
  365. if (isHorizontal) {
  366. if (activeTabBounding.left < navScrollBounding.left) {
  367. newOffset = currentOffset - (navScrollBounding.left - activeTabBounding.left);
  368. }
  369. if (activeTabBounding.right > navScrollBounding.right) {
  370. newOffset = currentOffset + activeTabBounding.right - navScrollBounding.right;
  371. }
  372. } else {
  373. if (activeTabBounding.top < navScrollBounding.top) {
  374. newOffset = currentOffset - (navScrollBounding.top - activeTabBounding.top);
  375. }
  376. if (activeTabBounding.bottom > navScrollBounding.bottom) {
  377. newOffset = currentOffset + (activeTabBounding.bottom - navScrollBounding.bottom);
  378. }
  379. }
  380. newOffset = Math.max(newOffset, 0);
  381. this.navOffset = Math.min(newOffset, maxOffset);
  382. },
  383. update: function update() {
  384. if (!this.$refs.nav) return;
  385. var sizeName = this.sizeName;
  386. var navSize = this.$refs.nav['offset' + tab_navvue_type_script_lang_js_firstUpperCase(sizeName)];
  387. var containerSize = this.$refs.navScroll['offset' + tab_navvue_type_script_lang_js_firstUpperCase(sizeName)];
  388. var currentOffset = this.navOffset;
  389. if (containerSize < navSize) {
  390. var _currentOffset = this.navOffset;
  391. this.scrollable = this.scrollable || {};
  392. this.scrollable.prev = _currentOffset;
  393. this.scrollable.next = _currentOffset + containerSize < navSize;
  394. if (navSize - _currentOffset < containerSize) {
  395. this.navOffset = navSize - containerSize;
  396. }
  397. } else {
  398. this.scrollable = false;
  399. if (currentOffset > 0) {
  400. this.navOffset = 0;
  401. }
  402. }
  403. },
  404. changeTab: function changeTab(e) {
  405. var keyCode = e.keyCode;
  406. var nextIndex = void 0;
  407. var currentIndex = void 0,
  408. tabList = void 0;
  409. if ([37, 38, 39, 40].indexOf(keyCode) !== -1) {
  410. // 左右上下键更换tab
  411. tabList = e.currentTarget.querySelectorAll('[role=tab]');
  412. currentIndex = Array.prototype.indexOf.call(tabList, e.target);
  413. } else {
  414. return;
  415. }
  416. if (keyCode === 37 || keyCode === 38) {
  417. // left
  418. if (currentIndex === 0) {
  419. // first
  420. nextIndex = tabList.length - 1;
  421. } else {
  422. nextIndex = currentIndex - 1;
  423. }
  424. } else {
  425. // right
  426. if (currentIndex < tabList.length - 1) {
  427. // not last
  428. nextIndex = currentIndex + 1;
  429. } else {
  430. nextIndex = 0;
  431. }
  432. }
  433. tabList[nextIndex].focus(); // 改变焦点元素
  434. tabList[nextIndex].click(); // 选中下一个tab
  435. this.setFocus();
  436. },
  437. setFocus: function setFocus() {
  438. if (this.focusable) {
  439. this.isFocus = true;
  440. }
  441. },
  442. removeFocus: function removeFocus() {
  443. this.isFocus = false;
  444. },
  445. visibilityChangeHandler: function visibilityChangeHandler() {
  446. var _this = this;
  447. var visibility = document.visibilityState;
  448. if (visibility === 'hidden') {
  449. this.focusable = false;
  450. } else if (visibility === 'visible') {
  451. setTimeout(function () {
  452. _this.focusable = true;
  453. }, 50);
  454. }
  455. },
  456. windowBlurHandler: function windowBlurHandler() {
  457. this.focusable = false;
  458. },
  459. windowFocusHandler: function windowFocusHandler() {
  460. var _this2 = this;
  461. setTimeout(function () {
  462. _this2.focusable = true;
  463. }, 50);
  464. }
  465. },
  466. updated: function updated() {
  467. this.update();
  468. },
  469. render: function render(h) {
  470. var _this3 = this;
  471. var type = this.type,
  472. panes = this.panes,
  473. editable = this.editable,
  474. stretch = this.stretch,
  475. onTabClick = this.onTabClick,
  476. onTabRemove = this.onTabRemove,
  477. navStyle = this.navStyle,
  478. scrollable = this.scrollable,
  479. scrollNext = this.scrollNext,
  480. scrollPrev = this.scrollPrev,
  481. changeTab = this.changeTab,
  482. setFocus = this.setFocus,
  483. removeFocus = this.removeFocus;
  484. var scrollBtn = scrollable ? [h(
  485. 'span',
  486. { 'class': ['el-tabs__nav-prev', scrollable.prev ? '' : 'is-disabled'], on: {
  487. 'click': scrollPrev
  488. }
  489. },
  490. [h('i', { 'class': 'el-icon-arrow-left' })]
  491. ), h(
  492. 'span',
  493. { 'class': ['el-tabs__nav-next', scrollable.next ? '' : 'is-disabled'], on: {
  494. 'click': scrollNext
  495. }
  496. },
  497. [h('i', { 'class': 'el-icon-arrow-right' })]
  498. )] : null;
  499. var tabs = this._l(panes, function (pane, index) {
  500. var _ref;
  501. var tabName = pane.name || pane.index || index;
  502. var closable = pane.isClosable || editable;
  503. pane.index = '' + index;
  504. var btnClose = closable ? h('span', { 'class': 'el-icon-close', on: {
  505. 'click': function click(ev) {
  506. onTabRemove(pane, ev);
  507. }
  508. }
  509. }) : null;
  510. var tabLabelContent = pane.$slots.label || pane.label;
  511. var tabindex = pane.active ? 0 : -1;
  512. return h(
  513. 'div',
  514. {
  515. 'class': (_ref = {
  516. 'el-tabs__item': true
  517. }, _ref['is-' + _this3.rootTabs.tabPosition] = true, _ref['is-active'] = pane.active, _ref['is-disabled'] = pane.disabled, _ref['is-closable'] = closable, _ref['is-focus'] = _this3.isFocus, _ref),
  518. attrs: { id: 'tab-' + tabName,
  519. 'aria-controls': 'pane-' + tabName,
  520. role: 'tab',
  521. 'aria-selected': pane.active,
  522. tabindex: tabindex
  523. },
  524. key: 'tab-' + tabName, ref: 'tabs', refInFor: true,
  525. on: {
  526. 'focus': function focus() {
  527. setFocus();
  528. },
  529. 'blur': function blur() {
  530. removeFocus();
  531. },
  532. 'click': function click(ev) {
  533. removeFocus();onTabClick(pane, tabName, ev);
  534. },
  535. 'keydown': function keydown(ev) {
  536. if (closable && (ev.keyCode === 46 || ev.keyCode === 8)) {
  537. onTabRemove(pane, ev);
  538. }
  539. }
  540. }
  541. },
  542. [tabLabelContent, btnClose]
  543. );
  544. });
  545. return h(
  546. 'div',
  547. { 'class': ['el-tabs__nav-wrap', scrollable ? 'is-scrollable' : '', 'is-' + this.rootTabs.tabPosition] },
  548. [scrollBtn, h(
  549. 'div',
  550. { 'class': ['el-tabs__nav-scroll'], ref: 'navScroll' },
  551. [h(
  552. 'div',
  553. {
  554. 'class': ['el-tabs__nav', 'is-' + this.rootTabs.tabPosition, stretch && ['top', 'bottom'].indexOf(this.rootTabs.tabPosition) !== -1 ? 'is-stretch' : ''],
  555. ref: 'nav',
  556. style: navStyle,
  557. attrs: { role: 'tablist'
  558. },
  559. on: {
  560. 'keydown': changeTab
  561. }
  562. },
  563. [!type ? h('tab-bar', {
  564. attrs: { tabs: panes }
  565. }) : null, tabs]
  566. )]
  567. )]
  568. );
  569. },
  570. mounted: function mounted() {
  571. var _this4 = this;
  572. Object(resize_event_["addResizeListener"])(this.$el, this.update);
  573. document.addEventListener('visibilitychange', this.visibilityChangeHandler);
  574. window.addEventListener('blur', this.windowBlurHandler);
  575. window.addEventListener('focus', this.windowFocusHandler);
  576. setTimeout(function () {
  577. _this4.scrollToActiveTab();
  578. }, 0);
  579. },
  580. beforeDestroy: function beforeDestroy() {
  581. if (this.$el && this.update) Object(resize_event_["removeResizeListener"])(this.$el, this.update);
  582. document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
  583. window.removeEventListener('blur', this.windowBlurHandler);
  584. window.removeEventListener('focus', this.windowFocusHandler);
  585. }
  586. });
  587. // CONCATENATED MODULE: ./packages/tabs/src/tab-nav.vue?vue&type=script&lang=js&
  588. /* harmony default export */ var src_tab_navvue_type_script_lang_js_ = (tab_navvue_type_script_lang_js_);
  589. // CONCATENATED MODULE: ./packages/tabs/src/tab-nav.vue
  590. var tab_nav_render, tab_nav_staticRenderFns
  591. /* normalize component */
  592. var tab_nav_component = Object(componentNormalizer["a" /* default */])(
  593. src_tab_navvue_type_script_lang_js_,
  594. tab_nav_render,
  595. tab_nav_staticRenderFns,
  596. false,
  597. null,
  598. null,
  599. null
  600. )
  601. /* hot reload */
  602. if (false) { var tab_nav_api; }
  603. tab_nav_component.options.__file = "packages/tabs/src/tab-nav.vue"
  604. /* harmony default export */ var tab_nav = (tab_nav_component.exports);
  605. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/tabs/src/tabs.vue?vue&type=script&lang=js&
  606. /* harmony default export */ var tabsvue_type_script_lang_js_ = ({
  607. name: 'TisTabs',
  608. components: {
  609. TabNav: tab_nav
  610. },
  611. props: {
  612. type: String,
  613. activeName: String,
  614. closable: Boolean,
  615. addable: Boolean,
  616. value: {},
  617. editable: Boolean,
  618. tabPosition: {
  619. type: String,
  620. default: 'top'
  621. },
  622. beforeLeave: Function,
  623. stretch: Boolean
  624. },
  625. provide: function provide() {
  626. return {
  627. rootTabs: this
  628. };
  629. },
  630. data: function data() {
  631. return {
  632. currentName: this.value || this.activeName,
  633. panes: []
  634. };
  635. },
  636. watch: {
  637. activeName: function activeName(value) {
  638. this.setCurrentName(value);
  639. },
  640. value: function value(_value) {
  641. this.setCurrentName(_value);
  642. },
  643. currentName: function currentName(value) {
  644. var _this = this;
  645. if (this.$refs.nav) {
  646. this.$nextTick(function () {
  647. _this.$refs.nav.$nextTick(function (_) {
  648. _this.$refs.nav.scrollToActiveTab();
  649. });
  650. });
  651. }
  652. }
  653. },
  654. methods: {
  655. calcPaneInstances: function calcPaneInstances() {
  656. var _this2 = this;
  657. var isForceUpdate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  658. if (this.$slots.default) {
  659. var paneSlots = this.$slots.default.filter(function (vnode) {
  660. return vnode.tag && vnode.componentOptions && vnode.componentOptions.Ctor.options.name === 'TisTabPane';
  661. });
  662. // update indeed
  663. var panes = paneSlots.map(function (_ref) {
  664. var componentInstance = _ref.componentInstance;
  665. return componentInstance;
  666. });
  667. var panesChanged = !(panes.length === this.panes.length && panes.every(function (pane, index) {
  668. return pane === _this2.panes[index];
  669. }));
  670. if (isForceUpdate || panesChanged) {
  671. this.panes = panes;
  672. }
  673. } else if (this.panes.length !== 0) {
  674. this.panes = [];
  675. }
  676. },
  677. handleTabClick: function handleTabClick(tab, tabName, event) {
  678. if (tab.disabled) return;
  679. this.setCurrentName(tabName);
  680. this.$emit('tab-click', tab, event);
  681. },
  682. handleTabRemove: function handleTabRemove(pane, ev) {
  683. if (pane.disabled) return;
  684. ev.stopPropagation();
  685. this.$emit('edit', pane.name, 'remove');
  686. this.$emit('tab-remove', pane.name);
  687. },
  688. handleTabAdd: function handleTabAdd() {
  689. this.$emit('edit', null, 'add');
  690. this.$emit('tab-add');
  691. },
  692. setCurrentName: function setCurrentName(value) {
  693. var _this3 = this;
  694. var changeCurrentName = function changeCurrentName() {
  695. _this3.currentName = value;
  696. _this3.$emit('input', value);
  697. };
  698. if (this.currentName !== value && this.beforeLeave) {
  699. var before = this.beforeLeave(value, this.currentName);
  700. if (before && before.then) {
  701. before.then(function () {
  702. changeCurrentName();
  703. _this3.$refs.nav && _this3.$refs.nav.removeFocus();
  704. }, function () {
  705. // https://github.com/ElemeFE/element/pull/14816
  706. // ignore promise rejection in `before-leave` hook
  707. });
  708. } else if (before !== false) {
  709. changeCurrentName();
  710. }
  711. } else {
  712. changeCurrentName();
  713. }
  714. }
  715. },
  716. render: function render(h) {
  717. var _ref2;
  718. var type = this.type,
  719. handleTabClick = this.handleTabClick,
  720. handleTabRemove = this.handleTabRemove,
  721. handleTabAdd = this.handleTabAdd,
  722. currentName = this.currentName,
  723. panes = this.panes,
  724. editable = this.editable,
  725. addable = this.addable,
  726. tabPosition = this.tabPosition,
  727. stretch = this.stretch;
  728. var newButton = editable || addable ? h(
  729. 'span',
  730. {
  731. 'class': 'el-tabs__new-tab',
  732. on: {
  733. 'click': handleTabAdd,
  734. 'keydown': function keydown(ev) {
  735. if (ev.keyCode === 13) {
  736. handleTabAdd();
  737. }
  738. }
  739. },
  740. attrs: {
  741. tabindex: '0'
  742. }
  743. },
  744. [h('i', { 'class': 'el-icon-plus' })]
  745. ) : null;
  746. var navData = {
  747. props: {
  748. currentName: currentName,
  749. onTabClick: handleTabClick,
  750. onTabRemove: handleTabRemove,
  751. editable: editable,
  752. type: type,
  753. panes: panes,
  754. stretch: stretch
  755. },
  756. ref: 'nav'
  757. };
  758. var header = h(
  759. 'div',
  760. { 'class': ['el-tabs__header', 'is-' + tabPosition] },
  761. [newButton, h('tab-nav', navData)]
  762. );
  763. var panels = h(
  764. 'div',
  765. { 'class': 'el-tabs__content' },
  766. [this.$slots.default]
  767. );
  768. return h(
  769. 'div',
  770. { 'class': (_ref2 = {
  771. 'el-tabs': true,
  772. 'el-tabs--card': type === 'card'
  773. }, _ref2['el-tabs--' + tabPosition] = true, _ref2['el-tabs--border-card'] = type === 'border-card', _ref2) },
  774. [tabPosition !== 'bottom' ? [header, panels] : [panels, header]]
  775. );
  776. },
  777. created: function created() {
  778. if (!this.currentName) {
  779. this.setCurrentName('0');
  780. }
  781. this.$on('tab-nav-update', this.calcPaneInstances.bind(null, true));
  782. },
  783. mounted: function mounted() {
  784. this.calcPaneInstances();
  785. },
  786. updated: function updated() {
  787. this.calcPaneInstances();
  788. }
  789. });
  790. // CONCATENATED MODULE: ./packages/tabs/src/tabs.vue?vue&type=script&lang=js&
  791. /* harmony default export */ var src_tabsvue_type_script_lang_js_ = (tabsvue_type_script_lang_js_);
  792. // CONCATENATED MODULE: ./packages/tabs/src/tabs.vue
  793. var tabs_render, tabs_staticRenderFns
  794. /* normalize component */
  795. var tabs_component = Object(componentNormalizer["a" /* default */])(
  796. src_tabsvue_type_script_lang_js_,
  797. tabs_render,
  798. tabs_staticRenderFns,
  799. false,
  800. null,
  801. null,
  802. null
  803. )
  804. /* hot reload */
  805. if (false) { var tabs_api; }
  806. tabs_component.options.__file = "packages/tabs/src/tabs.vue"
  807. /* harmony default export */ var tabs = (tabs_component.exports);
  808. // CONCATENATED MODULE: ./packages/tabs/index.js
  809. /* istanbul ignore next */
  810. tabs.install = function (Vue) {
  811. Vue.component(tabs.name, tabs);
  812. };
  813. /* harmony default export */ var packages_tabs = __webpack_exports__["default"] = (tabs);
  814. /***/ })
  815. /******/ });