/** * @file 组件 card * @author chenkai13 */ import './style/index.less'; import * as I from './interface'; import Base from 'santd/base'; import {classCreator} from '../core/util'; import LoadingBlock from './LoadingBlock'; import Tabs from '../tabs'; import Meta from './Meta'; import Grid from './Grid'; const prefix = classCreator('card')(); export default class Card extends Base { static template = `
{{title}}
`; static components = { 's-loadingblock': LoadingBlock, 's-tabs': Tabs, 's-tabpane': Tabs.TabPane }; static computed = { cls(this: Card) { let loading = this.data.get('loading'); let bordered = this.data.get('bordered'); let type = this.data.get('type'); let tabList = this.data.get('tabList'); let isContainGrid = this.data.get('isContainGrid'); let hoverable = !!this.data.get('hoverable'); let size = this.data.get('size'); let classArr = [prefix]; loading && classArr.push(`${prefix}-loading`); bordered && classArr.push(`${prefix}-bordered`); hoverable && classArr.push(`${prefix}-hoverable`); isContainGrid && classArr.push(`${prefix}-contain-grid`); tabList && tabList.length && classArr.push(`${prefix}-contain-tabs`); !!type && classArr.push(`${prefix}-type-${type}`); !!size && classArr.push(`${prefix}-${size}`); return classArr; } }; static Meta: Meta; static Grid: Grid; initData(): I.State { return { bordered: true, }; } inited(): void { let hasExtra = !!this.sourceSlots.named.extra; let showHeader = this.data.get('title') || this.data.get('tabList') || hasExtra; this.data.set('showHeader', showHeader); this.data.set('hasExtra', hasExtra); } onTabChange(key: string): void { this.fire('tabChange', key); } }