@mozaic-ds/vue 0.22.0 → 0.23.0-beta.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 +73 -65
- package/dist/mozaic-vue.common.js +73 -65
- package/dist/mozaic-vue.common.js.map +1 -1
- package/dist/mozaic-vue.umd.js +73 -65
- 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 +71 -54
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"
|
|
@@ -23,14 +33,9 @@
|
|
|
23
33
|
class="mc-tabs__link"
|
|
24
34
|
role="tab"
|
|
25
35
|
:aria-selected="tab.active ? 'true' : 'false'"
|
|
26
|
-
:class="
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
$event.target,
|
|
30
|
-
$event,
|
|
31
|
-
Object.assign({ index: index }, tab)
|
|
32
|
-
)
|
|
33
|
-
"
|
|
36
|
+
:class="setLinkClass(tab)"
|
|
37
|
+
v-bind="tab.attrs"
|
|
38
|
+
@click="onTabClicked($event, tab, index)"
|
|
34
39
|
>
|
|
35
40
|
{{ tab.text }}
|
|
36
41
|
</component>
|
|
@@ -82,38 +87,41 @@ export default {
|
|
|
82
87
|
},
|
|
83
88
|
activeIndex: {
|
|
84
89
|
type: Number,
|
|
85
|
-
default:
|
|
90
|
+
default: null,
|
|
86
91
|
},
|
|
87
92
|
},
|
|
88
93
|
|
|
89
94
|
data() {
|
|
90
95
|
return {
|
|
91
96
|
tablist: null,
|
|
97
|
+
localActiveIndex: null,
|
|
92
98
|
};
|
|
93
99
|
},
|
|
94
100
|
|
|
95
101
|
computed: {
|
|
96
102
|
setClasses() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
},
|
|
104
|
-
];
|
|
105
|
-
|
|
106
|
-
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
|
+
};
|
|
107
109
|
},
|
|
108
110
|
},
|
|
109
111
|
|
|
110
112
|
watch: {
|
|
111
113
|
activeIndex(newValue) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
+
},
|
|
117
125
|
},
|
|
118
126
|
|
|
119
127
|
mounted: function () {
|
|
@@ -122,17 +130,16 @@ export default {
|
|
|
122
130
|
this.tablist = this.$refs.tablist;
|
|
123
131
|
|
|
124
132
|
if (this.activeIndex) {
|
|
125
|
-
|
|
126
|
-
if (tab) {
|
|
127
|
-
this.manageTabs(tab);
|
|
128
|
-
}
|
|
133
|
+
this.localActiveIndex = this.activeIndex;
|
|
129
134
|
} else {
|
|
130
|
-
const isActive = this.tabs.some(
|
|
131
|
-
|
|
135
|
+
const isActive = this.tabs.some(
|
|
136
|
+
(tab) =>
|
|
137
|
+
Object.prototype.hasOwnProperty.call(tab, 'active') &&
|
|
138
|
+
tab.active === true
|
|
132
139
|
);
|
|
140
|
+
|
|
133
141
|
if (!isActive) {
|
|
134
|
-
|
|
135
|
-
this.manageTabs(firstTab);
|
|
142
|
+
this.localActiveIndex = 0;
|
|
136
143
|
}
|
|
137
144
|
}
|
|
138
145
|
}
|
|
@@ -140,40 +147,50 @@ export default {
|
|
|
140
147
|
},
|
|
141
148
|
|
|
142
149
|
methods: {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (tab.disabled) {
|
|
151
|
-
tabClasses.push('mc-tabs__link--disabled');
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return tabClasses;
|
|
150
|
+
setLinkClass: function (tab) {
|
|
151
|
+
return {
|
|
152
|
+
'mc-tabs__link--selected': tab.active,
|
|
153
|
+
'mc-tabs__link--disabled': tab.disabled,
|
|
154
|
+
};
|
|
155
155
|
},
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
this.$emit('tab-clicked', e.target, tab);
|
|
162
|
-
}
|
|
156
|
+
setTabState(tab) {
|
|
157
|
+
this.tablist.querySelectorAll('.mc-tabs__link').forEach((el) => {
|
|
158
|
+
el.classList.remove('mc-tabs__link--selected');
|
|
159
|
+
el.setAttribute('aria-selected', 'false');
|
|
160
|
+
});
|
|
163
161
|
|
|
162
|
+
tab.classList.add('mc-tabs__link--selected');
|
|
163
|
+
tab.setAttribute('aria-selected', 'true');
|
|
164
|
+
},
|
|
165
|
+
setTabState(tab) {
|
|
164
166
|
this.tablist.querySelectorAll('.mc-tabs__link').forEach((el) => {
|
|
165
167
|
el.classList.remove('mc-tabs__link--selected');
|
|
166
168
|
el.setAttribute('aria-selected', 'false');
|
|
167
169
|
});
|
|
168
170
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
+
tab.classList.add('mc-tabs__link--selected');
|
|
172
|
+
tab.setAttribute('aria-selected', 'true');
|
|
171
173
|
},
|
|
172
174
|
getTabFromIndex: function (index) {
|
|
173
|
-
if (
|
|
175
|
+
if (
|
|
176
|
+
this.tablist &&
|
|
177
|
+
this.tablist.children[index] &&
|
|
178
|
+
this.tablist.children[index].children[0]
|
|
179
|
+
) {
|
|
174
180
|
return this.tablist.children[index].children[0];
|
|
175
181
|
}
|
|
176
182
|
},
|
|
183
|
+
onTabClicked(e, tab, index) {
|
|
184
|
+
if (tab && tab.disabled) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (typeof this.activeIndex !== 'number') {
|
|
189
|
+
this.localActiveIndex = index;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
this.$emit('tab-clicked', e.target, Object.assign({ index: index }, tab));
|
|
193
|
+
},
|
|
177
194
|
},
|
|
178
195
|
};
|
|
179
196
|
</script>
|