diff --git a/src/contact-card/index.js b/src/contact-card/index.js new file mode 100644 index 000000000..73e77add5 --- /dev/null +++ b/src/contact-card/index.js @@ -0,0 +1,55 @@ +import { createNamespace } from '../utils'; +import Cell from '../cell'; + +const [createComponent, bem, t] = createNamespace('contact-card'); + +export default createComponent({ + props: { + tel: String, + name: String, + addText: String, + editable: { + type: Boolean, + default: true, + }, + type: { + type: String, + default: 'add', + }, + }, + + emits: ['click'], + + setup(props, { emit }) { + function onClick(event) { + if (props.editable) { + emit('click', event); + } + } + + function Content() { + if (props.type === 'add') { + return props.addText || t('addText'); + } + + return [ +
{`${t('name')}:${props.name}`}
, +
{`${t('tel')}:${props.tel}`}
, + ]; + } + + return () => ( + + {Content()} + + ); + }, +}); diff --git a/src/contact-list/index.js b/src/contact-list/index.js new file mode 100644 index 000000000..7dcf1a929 --- /dev/null +++ b/src/contact-list/index.js @@ -0,0 +1,111 @@ +// Utils +import { createNamespace } from '../utils'; +import { RED } from '../utils/constant'; + +// Components +import Tag from '../tag'; +import Icon from '../icon'; +import Cell from '../cell'; +import Radio from '../radio'; +import Button from '../button'; +import RadioGroup from '../radio-group'; + +const [createComponent, bem, t] = createNamespace('contact-list'); + +export default createComponent({ + props: { + list: Array, + addText: String, + modelValue: null, + defaultTagText: String, + }, + + emits: ['add', 'edit', 'select', 'update:modelValue'], + + setup(props, { emit }) { + return () => { + const List = + props.list && + props.list.map((item, index) => { + function onClick() { + emit('update:modelValue', item.id); + emit('select', item, index); + } + + function RightIcon() { + return ( + + ); + } + + function LeftIcon() { + return ( + { + event.stopPropagation(); + emit('edit', item, index); + }} + /> + ); + } + + function Content() { + const nodes = [`${item.name},${item.tel}`]; + + if (item.isDefault && props.defaultTagText) { + nodes.push( + + {props.defaultTagText} + + ); + } + + return nodes; + } + + return ( + + ); + }); + + return ( +
+ + {List} + +
+
+
+ ); + }; + }, +});