@mozaic-ds/vue 0.22.1-beta.0 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mozaic-vue.adeo.umd.js +49 -60
- package/dist/mozaic-vue.common.js +49 -60
- package/dist/mozaic-vue.common.js.map +1 -1
- package/dist/mozaic-vue.umd.js +49 -60
- package/dist/mozaic-vue.umd.js.map +1 -1
- package/dist/mozaic-vue.umd.min.js +1 -1
- package/dist/mozaic-vue.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/tabs/MTab.vue +55 -55
package/package.json
CHANGED
|
@@ -13,8 +13,20 @@
|
|
|
13
13
|
class="mc-tabs__item"
|
|
14
14
|
role="presentation"
|
|
15
15
|
>
|
|
16
|
+
<component
|
|
17
|
+
:is="`${tab.router}`"
|
|
18
|
+
v-if="tab.router"
|
|
19
|
+
v-bind="tab.attrs"
|
|
20
|
+
:to="tab.to"
|
|
21
|
+
class="mc-tabs__link"
|
|
22
|
+
:class="setLinkClass(tab)"
|
|
23
|
+
active-class="mc-tabs__link--selected"
|
|
24
|
+
>
|
|
25
|
+
{{ tab.text }}
|
|
26
|
+
</component>
|
|
16
27
|
<component
|
|
17
28
|
:is="tab.href ? (tab.disabled ? 'span' : 'a') : 'button'"
|
|
29
|
+
v-else
|
|
18
30
|
:id="tab.id"
|
|
19
31
|
ref="tab"
|
|
20
32
|
:href="tab.href ? (!tab.disabled ? tab.href : null) : null"
|
|
@@ -24,6 +36,7 @@
|
|
|
24
36
|
role="tab"
|
|
25
37
|
:aria-selected="tab.active ? 'true' : 'false'"
|
|
26
38
|
:class="setLinkClass(tab)"
|
|
39
|
+
v-bind="tab.attrs"
|
|
27
40
|
@click="onTabClicked($event, tab, index)"
|
|
28
41
|
>
|
|
29
42
|
{{ tab.text }}
|
|
@@ -76,38 +89,41 @@ export default {
|
|
|
76
89
|
},
|
|
77
90
|
activeIndex: {
|
|
78
91
|
type: Number,
|
|
79
|
-
default:
|
|
92
|
+
default: null,
|
|
80
93
|
},
|
|
81
94
|
},
|
|
82
95
|
|
|
83
96
|
data() {
|
|
84
97
|
return {
|
|
85
98
|
tablist: null,
|
|
99
|
+
localActiveIndex: null,
|
|
86
100
|
};
|
|
87
101
|
},
|
|
88
102
|
|
|
89
103
|
computed: {
|
|
90
104
|
setClasses() {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
},
|
|
98
|
-
];
|
|
99
|
-
|
|
100
|
-
return classes;
|
|
105
|
+
return {
|
|
106
|
+
'mc-tabs--full': this.align === 'full',
|
|
107
|
+
'mc-tabs--full-centered': this.align === 'centered',
|
|
108
|
+
'mc-tabs--dropdown': this.type === 'dropdown',
|
|
109
|
+
'mc-tabs--no-shadow': !this.shadow,
|
|
110
|
+
};
|
|
101
111
|
},
|
|
102
112
|
},
|
|
103
113
|
|
|
104
114
|
watch: {
|
|
105
115
|
activeIndex(newValue) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
116
|
+
this.localActiveIndex = newValue;
|
|
117
|
+
},
|
|
118
|
+
localActiveIndex: {
|
|
119
|
+
handler: function (newValue) {
|
|
120
|
+
const selectedTab = this.getTabFromIndex(newValue);
|
|
121
|
+
if (selectedTab) {
|
|
122
|
+
this.setTabState(selectedTab);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
immediate: true,
|
|
126
|
+
},
|
|
111
127
|
},
|
|
112
128
|
|
|
113
129
|
mounted: function () {
|
|
@@ -116,17 +132,16 @@ export default {
|
|
|
116
132
|
this.tablist = this.$refs.tablist;
|
|
117
133
|
|
|
118
134
|
if (this.activeIndex) {
|
|
119
|
-
|
|
120
|
-
if (tab) {
|
|
121
|
-
this.setTabState(tab);
|
|
122
|
-
}
|
|
135
|
+
this.localActiveIndex = this.activeIndex;
|
|
123
136
|
} else {
|
|
124
|
-
const isActive = this.tabs.some(
|
|
125
|
-
|
|
137
|
+
const isActive = this.tabs.some(
|
|
138
|
+
(tab) =>
|
|
139
|
+
Object.prototype.hasOwnProperty.call(tab, 'active') &&
|
|
140
|
+
tab.active === true
|
|
126
141
|
);
|
|
142
|
+
|
|
127
143
|
if (!isActive) {
|
|
128
|
-
|
|
129
|
-
this.setTabState(firstTab);
|
|
144
|
+
this.localActiveIndex = 0;
|
|
130
145
|
}
|
|
131
146
|
}
|
|
132
147
|
}
|
|
@@ -140,36 +155,6 @@ export default {
|
|
|
140
155
|
'mc-tabs__link--disabled': tab.disabled,
|
|
141
156
|
};
|
|
142
157
|
},
|
|
143
|
-
onTabClicked(e, tab, index) {
|
|
144
|
-
if (tab && tab.disabled) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
let selectedTab = this.getTabFromIndex(index);
|
|
149
|
-
|
|
150
|
-
if (this.activeIndex) {
|
|
151
|
-
selectedTab = this.getTabFromIndex(this.activeIndex);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
this.setTabState(selectedTab);
|
|
155
|
-
this.$emit('tab-clicked', e.target, Object.assign({ index: index }, tab));
|
|
156
|
-
},
|
|
157
|
-
manageTabs: function (el, e, tab) {
|
|
158
|
-
if (tab && tab.disabled) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
if (e) {
|
|
162
|
-
this.$emit('tab-clicked', e.target, tab);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
this.tablist.querySelectorAll('.mc-tabs__link').forEach((el) => {
|
|
166
|
-
el.classList.remove('mc-tabs__link--selected');
|
|
167
|
-
el.setAttribute('aria-selected', 'false');
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
el.classList.add('mc-tabs__link--selected');
|
|
171
|
-
el.setAttribute('aria-selected', 'true');
|
|
172
|
-
},
|
|
173
158
|
setTabState(tab) {
|
|
174
159
|
this.tablist.querySelectorAll('.mc-tabs__link').forEach((el) => {
|
|
175
160
|
el.classList.remove('mc-tabs__link--selected');
|
|
@@ -180,10 +165,25 @@ export default {
|
|
|
180
165
|
tab.setAttribute('aria-selected', 'true');
|
|
181
166
|
},
|
|
182
167
|
getTabFromIndex: function (index) {
|
|
183
|
-
if (
|
|
168
|
+
if (
|
|
169
|
+
this.tablist &&
|
|
170
|
+
this.tablist.children[index] &&
|
|
171
|
+
this.tablist.children[index].children[0]
|
|
172
|
+
) {
|
|
184
173
|
return this.tablist.children[index].children[0];
|
|
185
174
|
}
|
|
186
175
|
},
|
|
176
|
+
onTabClicked(e, tab, index) {
|
|
177
|
+
if (tab && tab.disabled) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (typeof this.activeIndex !== 'number') {
|
|
182
|
+
this.localActiveIndex = index;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
this.$emit('tab-clicked', e.target, Object.assign({ index: index }, tab));
|
|
186
|
+
},
|
|
187
187
|
},
|
|
188
188
|
};
|
|
189
189
|
</script>
|