index-d3364b49.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { d as defineComponent, c as createVNode, L as Transition } from "./index-5e4623ce.js";
  2. import { c as createNamespace, t as truthProp, z as makeStringProp, H as HAPTICS_FEEDBACK, I as Icon, w as withInstall } from "./index-487cde8c.js";
  3. const [name, bem] = createNamespace("tag");
  4. const tagProps = {
  5. size: String,
  6. mark: Boolean,
  7. show: truthProp,
  8. type: makeStringProp("default"),
  9. color: String,
  10. plain: Boolean,
  11. round: Boolean,
  12. textColor: String,
  13. closeable: Boolean
  14. };
  15. var stdin_default = defineComponent({
  16. name,
  17. props: tagProps,
  18. emits: ["close"],
  19. setup(props, {
  20. slots,
  21. emit
  22. }) {
  23. const onClose = (event) => {
  24. event.stopPropagation();
  25. emit("close", event);
  26. };
  27. const getStyle = () => {
  28. if (props.plain) {
  29. return {
  30. color: props.textColor || props.color,
  31. borderColor: props.color
  32. };
  33. }
  34. return {
  35. color: props.textColor,
  36. background: props.color
  37. };
  38. };
  39. const renderTag = () => {
  40. var _a;
  41. const {
  42. type,
  43. mark,
  44. plain,
  45. round,
  46. size,
  47. closeable
  48. } = props;
  49. const classes = {
  50. mark,
  51. plain,
  52. round
  53. };
  54. if (size) {
  55. classes[size] = size;
  56. }
  57. const CloseIcon = closeable && createVNode(Icon, {
  58. "name": "cross",
  59. "class": [bem("close"), HAPTICS_FEEDBACK],
  60. "onClick": onClose
  61. }, null);
  62. return createVNode("span", {
  63. "style": getStyle(),
  64. "class": bem([classes, type])
  65. }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
  66. };
  67. return () => createVNode(Transition, {
  68. "name": props.closeable ? "van-fade" : void 0
  69. }, {
  70. default: () => [props.show ? renderTag() : null]
  71. });
  72. }
  73. });
  74. const Tag = withInstall(stdin_default);
  75. const index = "";
  76. export {
  77. Tag as T
  78. };