UNPKG

3.73 kBJavaScriptView Raw
1;(function(){
2(function (global, factory) {
3 if (typeof define === "function" && define.amd) {
4 define(['exports', '../tab-bar', '../_style/global.css', './style/index.css'], factory);
5 } else if (typeof exports !== "undefined") {
6 factory(exports, require('../tab-bar'), require('../_style/global.css'), require('./style/index.css'));
7 } else {
8 var mod = {
9 exports: {}
10 };
11 factory(mod.exports, global.tabBar, global.global, global.index);
12 global.index = mod.exports;
13 }
14})(this, function (exports, _tabBar) {
15 'use strict';
16
17 Object.defineProperty(exports, "__esModule", {
18 value: true
19 });
20
21 var _tabBar2 = _interopRequireDefault(_tabBar);
22
23 function _interopRequireDefault(obj) {
24 return obj && obj.__esModule ? obj : {
25 default: obj
26 };
27 }
28
29 function _defineProperty(obj, key, value) {
30 if (key in obj) {
31 Object.defineProperty(obj, key, {
32 value: value,
33 enumerable: true,
34 configurable: true,
35 writable: true
36 });
37 } else {
38 obj[key] = value;
39 }
40
41 return obj;
42 }
43
44 exports.default = {
45 name: 'md-tabs',
46
47 components: _defineProperty({}, _tabBar2.default.name, _tabBar2.default),
48
49 props: {
50 value: String,
51 hasInk: {
52 type: Boolean,
53 default: true
54 },
55 inkLength: {
56 type: Number,
57 default: 80
58 },
59 immediate: Boolean
60 },
61
62 data: function data() {
63 return {
64 currentName: this.value,
65 prevIndex: 0,
66 panes: []
67 };
68 },
69
70
71 watch: {
72 value: function value(val) {
73 if (val !== this.currentName) {
74 this.currentName = val;
75 }
76 }
77 },
78
79 computed: {
80 menus: function menus() {
81 return this.panes.map(function (pane) {
82 return {
83 name: pane.name,
84 label: pane.label,
85 disabled: pane.disabled
86 };
87 });
88 },
89 currentIndex: function currentIndex() {
90 for (var i = 0, len = this.menus.length; i < len; i++) {
91 if (this.menus[i].name === this.currentName) {
92 return i;
93 }
94 }
95 return 0;
96 }
97 },
98
99 provide: function provide() {
100 return {
101 rootTabs: this
102 };
103 },
104 mounted: function mounted() {
105 if (!this.currentName && this.menus.length) {
106 this.currentName = this.menus[0].name;
107 }
108 },
109
110
111 methods: {
112 $_handleTabClick: function $_handleTabClick(tab, index, prevIndex) {
113 this.currentName = tab.name;
114 this.prevIndex = prevIndex;
115 this.$emit('input', tab.name);
116 this.$emit('change', tab);
117 },
118 $_addPane: function $_addPane(pane) {
119 if (this.panes.indexOf(pane) === -1) {
120 this.panes.push(pane);
121 }
122 },
123 $_removePane: function $_removePane(pane) {
124 var index = this.panes.indexOf(pane);
125 if (index >= 0) {
126 this.panes.splice(index, 1);
127 }
128 },
129 reflowTabBar: function reflowTabBar() {
130 this.$refs.tabBar.reflow();
131 }
132 }
133 };
134});
135})()
136if (module.exports.__esModule) module.exports = module.exports.default
137var __vue__options__ = (typeof module.exports === "function"? module.exports.options: module.exports)
138__vue__options__.render = function render () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"md-tabs"},[_c('md-tab-bar',{ref:"tabBar",attrs:{"items":_vm.menus,"value":_vm.currentName,"has-ink":_vm.hasInk,"ink-length":_vm.inkLength,"immediate":_vm.immediate},on:{"change":_vm.$_handleTabClick}}),_vm._v(" "),_c('div',{staticClass:"md-tabs-content"},[_vm._t("default")],2)],1)}
139__vue__options__.staticRenderFns = []