diff --git a/src-next/cell/index.js b/src-next/cell/index.js index 4f4eb4964..83703384a 100644 --- a/src-next/cell/index.js +++ b/src-next/cell/index.js @@ -1,6 +1,6 @@ // Utils import { createNamespace, isDef } from '../utils'; -import { routeProps } from '../utils/router'; +import { route, routeProps } from '../utils/router'; import { cellProps } from './shared'; // Components @@ -15,102 +15,103 @@ export default createComponent({ }, setup(props, { slots, emit }) { - const { icon, size, title, label, value, isLink } = props; - const showTitle = slots.title || isDef(title); - - function Label() { - const showLabel = slots.label || isDef(label); - - if (showLabel) { - return ( -
- {slots.label ? slots.label() : label} -
- ); - } - } - - function Title() { - if (showTitle) { - return ( -
- {slots.title ? slots.title() : {title}} - {Label()} -
- ); - } - } - - function Value() { - const showValue = slots.default || isDef(value); - - if (showValue) { - return ( -
- {slots.default ? slots.default() : {value}} -
- ); - } - } - - function LeftIcon() { - if (slots.icon) { - return slots.icon(); - } - - if (icon) { - return ( - - ); - } - } - - function RightIcon() { - const rightIconSlot = slots['right-icon']; - - if (rightIconSlot) { - return rightIconSlot(); - } - - if (isLink) { - const { arrowDirection } = props; - - return ( - - ); - } - } - - function onClick(event) { - emit('click', event); - // TODO - // functionalRoute(ctx); - } - - const clickable = isLink || props.clickable; - - const classes = { - clickable, - center: props.center, - required: props.required, - borderless: !props.border, - }; - - if (size) { - classes[size] = size; - } - return function () { + const { icon, size, title, label, value, isLink } = props; + const showTitle = slots.title || isDef(title); + + function Label() { + const showLabel = slots.label || isDef(label); + + if (showLabel) { + return ( +
+ {slots.label ? slots.label() : label} +
+ ); + } + } + + function Title() { + if (showTitle) { + return ( +
+ {slots.title ? slots.title() : {title}} + {Label()} +
+ ); + } + } + + function Value() { + const showValue = slots.default || isDef(value); + + if (showValue) { + return ( +
+ {slots.default ? slots.default() : {value}} +
+ ); + } + } + + function LeftIcon() { + if (slots.icon) { + return slots.icon(); + } + + if (icon) { + return ( + + ); + } + } + + function RightIcon() { + const rightIconSlot = slots['right-icon']; + + if (rightIconSlot) { + return rightIconSlot(); + } + + if (isLink) { + const { arrowDirection } = props; + + return ( + + ); + } + } + + const onClick = (event) => { + emit('click', event); + route(this.$router, this); + }; + + const clickable = isLink || props.clickable; + + const classes = { + clickable, + center: props.center, + required: props.required, + borderless: !props.border, + }; + + if (size) { + classes[size] = size; + } + return (