index.js 1.6 KB

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