ContactCard.mjs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { createVNode as _createVNode } from "vue";
  2. import { defineComponent } from "vue";
  3. import { truthProp, makeStringProp, createNamespace } from "../utils/index.mjs";
  4. import { Cell } from "../cell/index.mjs";
  5. const [name, bem, t] = createNamespace("contact-card");
  6. const contactCardProps = {
  7. tel: String,
  8. name: String,
  9. type: makeStringProp("add"),
  10. addText: String,
  11. editable: truthProp
  12. };
  13. var stdin_default = defineComponent({
  14. name,
  15. props: contactCardProps,
  16. emits: ["click"],
  17. setup(props, {
  18. emit
  19. }) {
  20. const onClick = (event) => {
  21. if (props.editable) {
  22. emit("click", event);
  23. }
  24. };
  25. const renderContent = () => {
  26. if (props.type === "add") {
  27. return props.addText || t("addContact");
  28. }
  29. return [_createVNode("div", null, [`${t("name")}\uFF1A${props.name}`]), _createVNode("div", null, [`${t("tel")}\uFF1A${props.tel}`])];
  30. };
  31. return () => _createVNode(Cell, {
  32. "center": true,
  33. "icon": props.type === "edit" ? "contact" : "add-square",
  34. "class": bem([props.type]),
  35. "border": false,
  36. "isLink": props.editable,
  37. "valueClass": bem("value"),
  38. "onClick": onClick
  39. }, {
  40. value: renderContent
  41. });
  42. }
  43. });
  44. export {
  45. stdin_default as default
  46. };