import * as React from 'react'; import classNames from 'classnames'; import { DescriptionsItemProps } from './index'; interface ColProps { child: React.ReactElement; bordered: boolean; colon: boolean; type?: 'label' | 'content'; layout?: 'horizontal' | 'vertical'; } const Col: React.SFC = props => { const { child, bordered, colon, type, layout } = props; const { prefixCls, label, className, children, span = 1 } = child.props; const labelProps: any = { className: classNames(`${prefixCls}-item-label`, { [`${prefixCls}-item-colon`]: colon, [`${prefixCls}-item-no-label`]: !label, }), key: 'label', }; if (layout === 'vertical') { labelProps.colSpan = span * 2 - 1; } if (bordered) { if (type === 'label') { return {label}; } return ( {children} ); } if (layout === 'vertical') { if (type === 'content') { return ( {children} ); } return ( {label} ); } return ( {label} {children} ); }; export default Col;