ActionBarIcon.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. var __defProp = Object.defineProperty;
  2. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  3. var __getOwnPropNames = Object.getOwnPropertyNames;
  4. var __hasOwnProp = Object.prototype.hasOwnProperty;
  5. var __export = (target, all) => {
  6. for (var name2 in all)
  7. __defProp(target, name2, { get: all[name2], enumerable: true });
  8. };
  9. var __copyProps = (to, from, except, desc) => {
  10. if (from && typeof from === "object" || typeof from === "function") {
  11. for (let key of __getOwnPropNames(from))
  12. if (!__hasOwnProp.call(to, key) && key !== except)
  13. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  14. }
  15. return to;
  16. };
  17. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  18. var stdin_exports = {};
  19. __export(stdin_exports, {
  20. default: () => stdin_default
  21. });
  22. module.exports = __toCommonJS(stdin_exports);
  23. var import_vue = require("vue");
  24. var import_vue2 = require("vue");
  25. var import_utils = require("../utils");
  26. var import_ActionBar = require("../action-bar/ActionBar");
  27. var import_use = require("@vant/use");
  28. var import_use_route = require("../composables/use-route");
  29. var import_icon = require("../icon");
  30. var import_badge = require("../badge");
  31. const [name, bem] = (0, import_utils.createNamespace)("action-bar-icon");
  32. const actionBarIconProps = (0, import_utils.extend)({}, import_use_route.routeProps, {
  33. dot: Boolean,
  34. text: String,
  35. icon: String,
  36. color: String,
  37. badge: import_utils.numericProp,
  38. iconClass: import_utils.unknownProp,
  39. badgeProps: Object,
  40. iconPrefix: String
  41. });
  42. var stdin_default = (0, import_vue2.defineComponent)({
  43. name,
  44. props: actionBarIconProps,
  45. setup(props, {
  46. slots
  47. }) {
  48. const route = (0, import_use_route.useRoute)();
  49. (0, import_use.useParent)(import_ActionBar.ACTION_BAR_KEY);
  50. const renderIcon = () => {
  51. const {
  52. dot,
  53. badge,
  54. icon,
  55. color,
  56. iconClass,
  57. badgeProps,
  58. iconPrefix
  59. } = props;
  60. if (slots.icon) {
  61. return (0, import_vue.createVNode)(import_badge.Badge, (0, import_vue.mergeProps)({
  62. "dot": dot,
  63. "class": bem("icon"),
  64. "content": badge
  65. }, badgeProps), {
  66. default: slots.icon
  67. });
  68. }
  69. return (0, import_vue.createVNode)(import_icon.Icon, {
  70. "tag": "div",
  71. "dot": dot,
  72. "name": icon,
  73. "badge": badge,
  74. "color": color,
  75. "class": [bem("icon"), iconClass],
  76. "badgeProps": badgeProps,
  77. "classPrefix": iconPrefix
  78. }, null);
  79. };
  80. return () => (0, import_vue.createVNode)("div", {
  81. "role": "button",
  82. "class": bem(),
  83. "tabindex": 0,
  84. "onClick": route
  85. }, [renderIcon(), slots.default ? slots.default() : props.text]);
  86. }
  87. });