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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _PanelContent = require('./PanelContent');
var _PanelContent2 = _interopRequireDefault(_PanelContent);
var _propsUtil = require('../../_util/props-util');
var _vnode = require('../../_util/vnode');
var _commonProps = require('./commonProps');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
exports['default'] = {
name: 'Panel',
props: (0, _propsUtil.initDefaultProps)(_commonProps.panelProps, {
showArrow: true,
isActive: false,
destroyInactivePanel: false,
headerClass: '',
forceRender: false
}),
methods: {
handleItemClick: function handleItemClick() {
this.$emit('itemClick');
},
handleKeyPress: function handleKeyPress(e) {
if (e.key === 'Enter' || e.keyCode === 13 || e.which === 13) {
this.handleItemClick();
}
}
},
render: function render() {
var _headerCls, _itemCls;
var h = arguments[0];
var _$props = this.$props,
prefixCls = _$props.prefixCls,
headerClass = _$props.headerClass,
isActive = _$props.isActive,
showArrow = _$props.showArrow,
destroyInactivePanel = _$props.destroyInactivePanel,
disabled = _$props.disabled,
openAnimation = _$props.openAnimation,
accordion = _$props.accordion,
forceRender = _$props.forceRender,
expandIcon = _$props.expandIcon;
var $slots = this.$slots;
var transitionProps = {
props: (0, _extends3['default'])({
appear: true,
css: false
}),
on: (0, _extends3['default'])({}, openAnimation)
};
var headerCls = (_headerCls = {}, (0, _defineProperty3['default'])(_headerCls, prefixCls + '-header', true), (0, _defineProperty3['default'])(_headerCls, headerClass, headerClass), _headerCls);
var header = (0, _propsUtil.getComponentFromProp)(this, 'header');
var itemCls = (_itemCls = {}, (0, _defineProperty3['default'])(_itemCls, prefixCls + '-item', true), (0, _defineProperty3['default'])(_itemCls, prefixCls + '-item-active', isActive), (0, _defineProperty3['default'])(_itemCls, prefixCls + '-item-disabled', disabled), _itemCls);
var icon = null;
if (showArrow && typeof expandIcon === 'function') {
icon = (0, _vnode.cloneElement)(expandIcon(this.$props));
}
return h(
'div',
{ 'class': itemCls, attrs: { role: 'tablist' }
},
[h(
'div',
{
'class': headerCls,
on: {
'click': this.handleItemClick.bind(this),
'keypress': this.handleKeyPress
},
attrs: {
role: accordion ? 'tab' : 'button',
tabIndex: disabled ? -1 : 0,
'aria-expanded': isActive
}
},
[showArrow && (icon || h('i', { 'class': 'arrow' })), header]
), h(
'transition',
transitionProps,
[h(
_PanelContent2['default'],
{
directives: [{
name: 'show',
value: isActive
}],
attrs: {
prefixCls: prefixCls,
isActive: isActive,
destroyInactivePanel: destroyInactivePanel,
forceRender: forceRender,
role: accordion ? 'tabpanel' : null
}
},
[$slots['default']]
)]
)]
);
}
};