import { use } from '../utils'; import { emit, inherit } from '../utils/functional'; import Icon from '../icon'; import Cell from '../cell'; import Radio from '../radio'; // Types import { CreateElement, RenderContext } from 'vue/types'; import { DefaultSlots } from '../utils/use/sfc'; export type AddressItemData = { id: string | number; tel: string | number; name: string; address: string; }; export type AddressItemProps = { data: AddressItemData; disabled?: boolean; switchable?: boolean; }; export type AddressItemEvents = { onEdit(): void; onSelect(): void; }; const [sfc, bem] = use('address-item'); function AddressItem( h: CreateElement, props: AddressItemProps, slots: DefaultSlots, ctx: RenderContext ) { const { disabled, switchable } = props; function onSelect() { if (switchable) { emit(ctx, 'select'); } } const renderRightIcon = () => ( { event.stopPropagation(); emit(ctx, 'edit'); }} /> ); const renderContent = () => { const { data } = props; const Info = [
{`${data.name},${data.tel}`}
,
{data.address}
]; return switchable && !disabled ? ( {Info} ) : ( Info ); }; return ( ); } AddressItem.props = { data: Object, disabled: Boolean, switchable: Boolean }; export default sfc(AddressItem);