import { createNamespace } from '../utils'; import { RED } from '../utils/constant'; import { emit, inherit } from '../utils/functional'; import Icon from '../icon'; import Cell from '../cell'; import Tag from '../tag'; import Button from '../button'; import Radio from '../radio'; import RadioGroup from '../radio-group'; // Types import { CreateElement, RenderContext, VNode } from 'vue/types'; import { DefaultSlots } from '../utils/types'; export type ContactListItem = { id: string | number; tel: string | number; name: string; isDefault: boolean; }; export type ContactListProps = { value?: any; list?: ContactListItem[]; addText?: string; defaultTagText?: string; }; const [createComponent, bem, t] = createNamespace('contact-list'); function ContactList( h: CreateElement, props: ContactListProps, slots: DefaultSlots, ctx: RenderContext ) { const List = props.list && props.list.map((item, index) => { function onClick() { emit(ctx, 'input', item.id); emit(ctx, 'select', item, index); } function RightIcon() { return ( ); } function LeftIcon() { return ( { event.stopPropagation(); emit(ctx, 'edit', item, index); }} /> ); } function Content() { const nodes = ([`${item.name},${item.tel}`] as unknown[]) as VNode[]; if (item.isDefault && props.defaultTagText) { nodes.push( {props.defaultTagText} ); } return nodes; } return ( ); }); return (
{List}
); } ContactList.props = { value: null as any, list: Array, addText: String, defaultTagText: String }; export default createComponent(ContactList);