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
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _extends from 'babel-runtime/helpers/extends';
import PanelContent from './PanelContent';
import { initDefaultProps, getComponentFromProp } from '../../_util/props-util';
import { cloneElement } from '../../_util/vnode';
import { panelProps } from './commonProps';
export default {
name: 'Panel',
props: initDefaultProps(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: _extends({
appear: true,
css: false
}),
on: _extends({}, openAnimation)
};
var headerCls = (_headerCls = {}, _defineProperty(_headerCls, prefixCls + '-header', true), _defineProperty(_headerCls, headerClass, headerClass), _headerCls);
var header = getComponentFromProp(this, 'header');
var itemCls = (_itemCls = {}, _defineProperty(_itemCls, prefixCls + '-item', true), _defineProperty(_itemCls, prefixCls + '-item-active', isActive), _defineProperty(_itemCls, prefixCls + '-item-disabled', disabled), _itemCls);
var icon = null;
if (showArrow && typeof expandIcon === 'function') {
icon = 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(
PanelContent,
{
directives: [{
name: 'show',
value: isActive
}],
attrs: {
prefixCls: prefixCls,
isActive: isActive,
destroyInactivePanel: destroyInactivePanel,
forceRender: forceRender,
role: accordion ? 'tabpanel' : null
}
},
[$slots['default']]
)]
)]
);
}
};