import { SetupContext, VNode } from 'vue'; import { getOptionProps } from '../_util/props-util'; interface ColProps { child: VNode; bordered: boolean; colon: boolean; type?: 'label' | 'content'; layout?: 'horizontal' | 'vertical'; colKey?: string } const Col = (_props: ColProps, { attrs }: SetupContext) => { const { child = {} as VNode, bordered, colon, type, layout, colKey: key } = attrs as unknown as ColProps; const { prefixCls, span = 1 } = getOptionProps(child); const { children = {} as any, props = {} } = child; const label = props.label || (children.label && children.label()); const defaultSlot = children.default && children.default(); const labelProps: any = { class: [ `${prefixCls}-item-label`, { [`${prefixCls}-item-colon`]: colon, [`${prefixCls}-item-no-label`]: !label, }, ], key: `${key}-label`, }; if (layout === 'vertical') { labelProps.colspan = span * 2 - 1; } if (bordered) { if (type === 'label') { return {label}; } return ( {defaultSlot} ); } if (layout === 'vertical') { if (type === 'content') { return ( {defaultSlot} ); } return ( {label} ); } return ( {label} {defaultSlot} ); }; export default Col;