1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import _mergeJSXProps from 'babel-helper-vue-jsx-merge-props';
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import warning from 'warning';
import PropTypes from '../../_util/vue-types';
import BaseMixin from '../../_util/BaseMixin';
import { getOptionProps, getComponentFromProp } from '../../_util/props-util';
import { isVertical } from './utils';
function noop() {}
export default {
name: 'TabBarTabsNode',
mixins: [BaseMixin],
props: {
activeKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
panels: PropTypes.any.def([]),
prefixCls: PropTypes.string.def(''),
tabBarGutter: PropTypes.any.def(null),
onTabClick: PropTypes.func,
saveRef: PropTypes.func.def(noop),
getRef: PropTypes.func.def(noop),
tabBarPosition: PropTypes.string
},
render: function render() {
var _this = this;
var h = arguments[0];
var _$props = this.$props,
children = _$props.panels,
activeKey = _$props.activeKey,
prefixCls = _$props.prefixCls,
tabBarGutter = _$props.tabBarGutter,
saveRef = _$props.saveRef,
tabBarPosition = _$props.tabBarPosition;
var rst = [];
children.forEach(function (child, index) {
if (!child) {
return;
}
var props = getOptionProps(child);
var key = child.key;
var cls = activeKey === key ? prefixCls + '-tab-active' : '';
cls += ' ' + prefixCls + '-tab';
var events = { on: {} };
var disabled = props.disabled || props.disabled === '';
if (disabled) {
cls += ' ' + prefixCls + '-tab-disabled';
} else {
events.on.click = function () {
_this.__emit('tabClick', key);
};
}
var directives = [];
if (activeKey === key) {
directives.push({
name: 'ant-ref',
value: saveRef('activeTab')
});
}
var tab = getComponentFromProp(child, 'tab');
var gutter = tabBarGutter && index === children.length - 1 ? 0 : tabBarGutter;
gutter = typeof gutter === 'number' ? gutter + 'px' : gutter;
var style = _defineProperty({}, isVertical(tabBarPosition) ? 'marginBottom' : 'marginRight', gutter);
warning(tab !== undefined, 'There must be `tab` property or slot on children of Tabs.');
rst.push(h(
'div',
_mergeJSXProps([{
attrs: {
role: 'tab',
'aria-disabled': disabled ? 'true' : 'false',
'aria-selected': activeKey === key ? 'true' : 'false'
}
}, events, {
'class': cls,
key: key,
style: style
}, { directives: directives }]),
[tab]
));
});
return h(
'div',
{
directives: [{
name: 'ant-ref',
value: this.saveRef('navTabsContainer')
}]
},
[rst]
);
}
};