import { computed, CSSProperties, defineComponent } from 'vue'; import { createNamespace, isDef, truthProp } from '../utils'; import { Badge } from '../badge'; const [name, bem] = createNamespace('tab'); export default defineComponent({ name, props: { dot: Boolean, type: String, color: String, title: String, badge: [Number, String], isActive: Boolean, disabled: Boolean, scrollable: Boolean, activeColor: String, renderTitle: Function, inactiveColor: String, showZeroBadge: truthProp, }, setup(props) { const style = computed(() => { const style: CSSProperties = {}; const { type, color, disabled, isActive, activeColor, inactiveColor } = props; const isCard = type === 'card'; // card theme color if (color && isCard) { style.borderColor = color; if (!disabled) { if (isActive) { style.backgroundColor = color; } else { style.color = color; } } } const titleColor = isActive ? activeColor : inactiveColor; if (titleColor) { style.color = titleColor; } return style; }); const renderText = () => { const Text = ( {props.renderTitle ? props.renderTitle() : props.title} ); if (props.dot || (isDef(props.badge) && props.badge !== '')) { return ( {Text} ); } return Text; }; return () => ( ); }, });