@mozaic-ds/vue 0.22.1-beta.0 → 0.23.0-beta.0
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 +62 -66
- package/dist/mozaic-vue.common.js +62 -66
- package/dist/mozaic-vue.common.js.map +1 -1
- package/dist/mozaic-vue.umd.js +62 -66
- package/dist/mozaic-vue.umd.js.map +1 -1
- package/dist/mozaic-vue.umd.min.js +2 -2
- package/dist/mozaic-vue.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/tabs/MTab.vue +55 -48
package/package.json
CHANGED
|
@@ -13,8 +13,18 @@
|
|
|
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
|
+
active-class="mc-tabs__link--selected"
|
|
22
|
+
>
|
|
23
|
+
{{ tab.text }}
|
|
24
|
+
</component>
|
|
16
25
|
<component
|
|
17
26
|
:is="tab.href ? (tab.disabled ? 'span' : 'a') : 'button'"
|
|
27
|
+
v-else
|
|
18
28
|
:id="tab.id"
|
|
19
29
|
ref="tab"
|
|
20
30
|
:href="tab.href ? (!tab.disabled ? tab.href : null) : null"
|
|
@@ -24,6 +34,7 @@
|
|
|
24
34
|
role="tab"
|
|
25
35
|
:aria-selected="tab.active ? 'true' : 'false'"
|
|
26
36
|
:class="setLinkClass(tab)"
|
|
37
|
+
v-bind="tab.attrs"
|
|
27
38
|
@click="onTabClicked($event, tab, index)"
|
|
28
39
|
>
|
|
29
40
|
{{ tab.text }}
|
|
@@ -83,31 +94,34 @@ export default {
|
|
|
83
94
|
data() {
|
|
84
95
|
return {
|
|
85
96
|
tablist: null,
|
|
97
|
+
localActiveIndex: null,
|
|
86
98
|
};
|
|
87
99
|
},
|
|
88
100
|
|
|
89
101
|
computed: {
|
|
90
102
|
setClasses() {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
},
|
|
98
|
-
];
|
|
99
|
-
|
|
100
|
-
return classes;
|
|
103
|
+
return {
|
|
104
|
+
'mc-tabs--full': this.align === 'full',
|
|
105
|
+
'mc-tabs--full-centered': this.align === 'centered',
|
|
106
|
+
'mc-tabs--dropdown': this.type === 'dropdown',
|
|
107
|
+
'mc-tabs--no-shadow': !this.shadow,
|
|
108
|
+
};
|
|
101
109
|
},
|
|
102
110
|
},
|
|
103
111
|
|
|
104
112
|
watch: {
|
|
105
113
|
activeIndex(newValue) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
this.localActiveIndex = newValue;
|
|
115
|
+
},
|
|
116
|
+
localActiveIndex: {
|
|
117
|
+
handler: function (newValue) {
|
|
118
|
+
const selectedTab = this.getTabFromIndex(newValue);
|
|
119
|
+
if (selectedTab) {
|
|
120
|
+
this.setTabState(selectedTab);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
immediate: true,
|
|
124
|
+
},
|
|
111
125
|
},
|
|
112
126
|
|
|
113
127
|
mounted: function () {
|
|
@@ -116,17 +130,16 @@ export default {
|
|
|
116
130
|
this.tablist = this.$refs.tablist;
|
|
117
131
|
|
|
118
132
|
if (this.activeIndex) {
|
|
119
|
-
|
|
120
|
-
if (tab) {
|
|
121
|
-
this.setTabState(tab);
|
|
122
|
-
}
|
|
133
|
+
this.localActiveIndex = this.activeIndex;
|
|
123
134
|
} else {
|
|
124
|
-
const isActive = this.tabs.some(
|
|
125
|
-
|
|
135
|
+
const isActive = this.tabs.some(
|
|
136
|
+
(tab) =>
|
|
137
|
+
Object.prototype.hasOwnProperty.call(tab, 'active') &&
|
|
138
|
+
tab.active === true
|
|
126
139
|
);
|
|
140
|
+
|
|
127
141
|
if (!isActive) {
|
|
128
|
-
|
|
129
|
-
this.setTabState(firstTab);
|
|
142
|
+
this.localActiveIndex = 0;
|
|
130
143
|
}
|
|
131
144
|
}
|
|
132
145
|
}
|
|
@@ -140,35 +153,14 @@ export default {
|
|
|
140
153
|
'mc-tabs__link--disabled': tab.disabled,
|
|
141
154
|
};
|
|
142
155
|
},
|
|
143
|
-
|
|
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
|
-
|
|
156
|
+
setTabState(tab) {
|
|
165
157
|
this.tablist.querySelectorAll('.mc-tabs__link').forEach((el) => {
|
|
166
158
|
el.classList.remove('mc-tabs__link--selected');
|
|
167
159
|
el.setAttribute('aria-selected', 'false');
|
|
168
160
|
});
|
|
169
161
|
|
|
170
|
-
|
|
171
|
-
|
|
162
|
+
tab.classList.add('mc-tabs__link--selected');
|
|
163
|
+
tab.setAttribute('aria-selected', 'true');
|
|
172
164
|
},
|
|
173
165
|
setTabState(tab) {
|
|
174
166
|
this.tablist.querySelectorAll('.mc-tabs__link').forEach((el) => {
|
|
@@ -180,10 +172,25 @@ export default {
|
|
|
180
172
|
tab.setAttribute('aria-selected', 'true');
|
|
181
173
|
},
|
|
182
174
|
getTabFromIndex: function (index) {
|
|
183
|
-
if (
|
|
175
|
+
if (
|
|
176
|
+
this.tablist &&
|
|
177
|
+
this.tablist.children[index] &&
|
|
178
|
+
this.tablist.children[index].children[0]
|
|
179
|
+
) {
|
|
184
180
|
return this.tablist.children[index].children[0];
|
|
185
181
|
}
|
|
186
182
|
},
|
|
183
|
+
onTabClicked(e, tab, index) {
|
|
184
|
+
if (tab && tab.disabled) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (!this.activeIndex) {
|
|
189
|
+
this.localActiveIndex = index;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
this.$emit('tab-clicked', e.target, Object.assign({ index: index }, tab));
|
|
193
|
+
},
|
|
187
194
|
},
|
|
188
195
|
};
|
|
189
196
|
</script>
|