/**
* @file Santd collapse panel file
* @author mayihui@baidu.com
**/
import {classCreator} from '../core/util';
import Icon from '../icon';
const prefixCls = classCreator('collapse')();
import Base from 'santd/base';
import {IPanelProps} from './interface';
class PanelContent extends Base {
static template = `
`;
};
export default class Panel extends Base {
initData(): IPanelProps {
return {
showArrow: true,
isActive: false,
destroyInactivePanel: false,
headerClass: '',
forceRender: false
};
}
static computed = {
classes(this: Panel) {
let classArr = [];
this.data.get('isActive') && classArr.push(`${prefixCls}-item-active`);
this.data.get('disabled') && classArr.push(`${prefixCls}-item-disabled`);
!this.data.get('showArrow') && classArr.push(`${prefixCls}-no-arrow`);
return classArr;
}
}
inited() {
this.data.set('hasExpandIcon', !!this.sourceSlots.named[this.data.get('expandIcon')]);
}
attached() {
this.dispatch('santd_panel_add', this);
}
static components = {
's-panelcontent': PanelContent,
's-icon': Icon
}
handleItemClick() {
if (this.data.get('disabled')) {
return;
}
this.dispatch('santd_panel_click', this.data.get('panelKey'));
}
handleKeyPress(e: KeyboardEvent) {
if (e.key === 'Enter' || e.keyCode === 13 || e.which === 13) {
this.handleItemClick();
}
}
static template = `
`;
}