index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import _mergeJSXProps from "@vue/babel-helper-vue-jsx-merge-props";
  2. // Utils
  3. import { createNamespace } from '../utils';
  4. import { emit, inherit } from '../utils/functional'; // Components
  5. import Cell from '../cell'; // Types
  6. var _createNamespace = createNamespace('contact-card'),
  7. createComponent = _createNamespace[0],
  8. bem = _createNamespace[1],
  9. t = _createNamespace[2];
  10. function ContactCard(h, props, slots, ctx) {
  11. var type = props.type,
  12. editable = props.editable;
  13. function onClick(event) {
  14. if (editable) {
  15. emit(ctx, 'click', event);
  16. }
  17. }
  18. function Content() {
  19. if (type === 'add') {
  20. return props.addText || t('addText');
  21. }
  22. return [h("div", [t('name') + "\uFF1A" + props.name]), h("div", [t('tel') + "\uFF1A" + props.tel])];
  23. }
  24. return h(Cell, _mergeJSXProps([{
  25. "attrs": {
  26. "center": true,
  27. "border": false,
  28. "isLink": editable,
  29. "valueClass": bem('value'),
  30. "icon": type === 'edit' ? 'contact' : 'add-square'
  31. },
  32. "class": bem([type]),
  33. "on": {
  34. "click": onClick
  35. }
  36. }, inherit(ctx)]), [Content()]);
  37. }
  38. ContactCard.props = {
  39. tel: String,
  40. name: String,
  41. addText: String,
  42. editable: {
  43. type: Boolean,
  44. default: true
  45. },
  46. type: {
  47. type: String,
  48. default: 'add'
  49. }
  50. };
  51. export default createComponent(ContactCard);