|
1 | 1 | /*!
|
2 | 2 | * vue-nav-tabs v0.5.6
|
3 |
| - * (c) 2017-present cristij <joracristi@gmail.com> |
| 3 | + * (c) 2018-present cristij <joracristi@gmail.com> |
4 | 4 | * Released under the MIT License.
|
5 | 5 | */
|
6 | 6 | 'use strict';
|
7 | 7 |
|
8 | 8 | Object.defineProperty(exports, '__esModule', { value: true });
|
9 | 9 |
|
| 10 | +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } |
| 11 | + |
| 12 | +var _mergeJSXProps = _interopDefault(require('babel-helper-vue-jsx-merge-props')); |
| 13 | + |
10 | 14 | var VueTabs = {
|
11 | 15 | name: 'vue-tabs',
|
12 | 16 | props: {
|
@@ -142,6 +146,13 @@ var VueTabs = {
|
142 | 146 | );
|
143 | 147 |
|
144 | 148 | if (tab.$slots.title) return tab.$slots.title;
|
| 149 | + if (tab.$scopedSlots.title) return tab.$scopedSlots.title({ |
| 150 | + active: active, |
| 151 | + title: title, |
| 152 | + position: position, |
| 153 | + icon: tab.icon, |
| 154 | + data: tab.tabData |
| 155 | + }); |
145 | 156 | return simpleTitle;
|
146 | 157 | },
|
147 | 158 | renderIcon: function renderIcon(index) {
|
@@ -183,35 +194,49 @@ var VueTabs = {
|
183 | 194 | var active = _this.activeTabIndex === index;
|
184 | 195 | return h(
|
185 | 196 | 'li',
|
186 |
| - { |
| 197 | + _mergeJSXProps([{ |
187 | 198 | attrs: { name: 'tab',
|
188 | 199 | id: 't-' + tabId,
|
189 | 200 | 'aria-selected': active,
|
190 | 201 | 'aria-controls': 'p-' + tabId,
|
191 | 202 | role: 'tab' },
|
192 |
| - on: { |
193 |
| - 'click': function click() { |
194 |
| - return !tab.disabled && _this.navigateToTab(index, route); |
195 |
| - } |
196 |
| - }, |
197 | 203 |
|
198 | 204 | 'class': ['tab', { active: active }, { disabled: tab.disabled }],
|
199 |
| - key: title }, |
| 205 | + key: title }, { |
| 206 | + on: { |
| 207 | + 'click': function click($event) { |
| 208 | + for (var _len = arguments.length, attrs = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
| 209 | + attrs[_key - 1] = arguments[_key]; |
| 210 | + } |
| 211 | + |
| 212 | + (function () { |
| 213 | + return !tab.disabled && _this.navigateToTab(index, route); |
| 214 | + }).apply(undefined, [$event].concat(attrs)); |
| 215 | + } |
| 216 | + } |
| 217 | + }]), |
200 | 218 | [_this.textPosition === 'top' && _this.renderTabTitle(index, _this.textPosition), h(
|
201 | 219 | 'a',
|
202 |
| - { |
| 220 | + _mergeJSXProps([{ |
203 | 221 | attrs: { href: '#',
|
204 | 222 |
|
205 | 223 | role: 'tab' },
|
206 |
| - on: { |
207 |
| - 'click': function click(e) { |
208 |
| - e.preventDefault(); |
209 |
| - return false; |
210 |
| - } |
211 |
| - }, |
212 | 224 |
|
213 | 225 | style: active ? _this.activeTabStyle : _this.tabStyles(tab),
|
214 |
| - 'class': [{ 'active_tab': active }, 'tabs__link'] }, |
| 226 | + 'class': [{ 'active_tab': active }, 'tabs__link'] }, { |
| 227 | + on: { |
| 228 | + 'click': function click($event) { |
| 229 | + for (var _len2 = arguments.length, attrs = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { |
| 230 | + attrs[_key2 - 1] = arguments[_key2]; |
| 231 | + } |
| 232 | + |
| 233 | + (function (e) { |
| 234 | + e.preventDefault(); |
| 235 | + return false; |
| 236 | + }).apply(undefined, [$event].concat(attrs)); |
| 237 | + } |
| 238 | + } |
| 239 | + }]), |
215 | 240 | [_this.textPosition !== 'center' && !tab.$slots.title && _this.renderIcon(index), _this.textPosition === 'center' && _this.renderTabTitle(index, _this.textPosition)]
|
216 | 241 | ), _this.textPosition === 'bottom' && _this.renderTabTitle(index, _this.textPosition)]
|
217 | 242 | );
|
@@ -276,6 +301,10 @@ var VTab = {
|
276 | 301 | type: String,
|
277 | 302 | default: ''
|
278 | 303 | },
|
| 304 | + tabData: { |
| 305 | + type: Object, |
| 306 | + default: null |
| 307 | + }, |
279 | 308 | /***
|
280 | 309 | * Function to execute before tab switch. Return value must be boolean
|
281 | 310 | * If the return result is false, tab switch is restricted
|
|
0 commit comments