import { use, isDef } from '../utils'; import { cellProps } from './shared'; import { emit, inherit, unifySlots } from '../utils/functional'; import { routeProps, functionalRoute } from '../mixins/router-link'; import Icon from '../icon'; const [sfc, bem] = use('cell'); export default sfc({ functional: true, props: { ...cellProps, ...routeProps, size: String, clickable: Boolean, arrowDirection: String }, render(h, context) { const slots = unifySlots(context); const { props } = context; const { icon, size, title, label, value, isLink, arrowDirection } = props; const showTitle = slots.title || isDef(title); const showValue = slots.default || isDef(value); const Title = showTitle && (
{slots.title ? slots.title() : {title}} {label &&
{label}
}
); const Value = showValue && (
{slots.default ? slots.default() : {value}}
); const LeftIcon = slots.icon ? slots.icon() : icon && ; const RightIcon = slots['right-icon'] ? slots['right-icon']() : isLink && ( ); const onClick = event => { emit(context, 'click', event); functionalRoute(context); }; return (
{LeftIcon} {Title} {Value} {RightIcon} {slots.extra && slots.extra()}
); } });