ActionBarIcon.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. actionBarIconProps: () => actionBarIconProps,
  21. default: () => stdin_default
  22. });
  23. module.exports = __toCommonJS(stdin_exports);
  24. var import_vue = require("vue");
  25. var import_vue2 = require("vue");
  26. var import_utils = require("../utils");
  27. var import_ActionBar = require("../action-bar/ActionBar");
  28. var import_use = require("@vant/use");
  29. var import_use_route = require("../composables/use-route");
  30. var import_icon = require("../icon");
  31. var import_badge = require("../badge");
  32. const [name, bem] = (0, import_utils.createNamespace)("action-bar-icon");
  33. const actionBarIconProps = (0, import_utils.extend)({}, import_use_route.routeProps, {
  34. dot: Boolean,
  35. text: String,
  36. icon: String,
  37. color: String,
  38. badge: import_utils.numericProp,
  39. iconClass: import_utils.unknownProp,
  40. badgeProps: Object,
  41. iconPrefix: String
  42. });
  43. var stdin_default = (0, import_vue2.defineComponent)({
  44. name,
  45. props: actionBarIconProps,
  46. setup(props, {
  47. slots
  48. }) {
  49. const route = (0, import_use_route.useRoute)();
  50. (0, import_use.useParent)(import_ActionBar.ACTION_BAR_KEY);
  51. const renderIcon = () => {
  52. const {
  53. dot,
  54. badge,
  55. icon,
  56. color,
  57. iconClass,
  58. badgeProps,
  59. iconPrefix
  60. } = props;
  61. if (slots.icon) {
  62. return (0, import_vue.createVNode)(import_badge.Badge, (0, import_vue.mergeProps)({
  63. "dot": dot,
  64. "class": bem("icon"),
  65. "content": badge
  66. }, badgeProps), {
  67. default: slots.icon
  68. });
  69. }
  70. return (0, import_vue.createVNode)(import_icon.Icon, {
  71. "tag": "div",
  72. "dot": dot,
  73. "name": icon,
  74. "badge": badge,
  75. "color": color,
  76. "class": [bem("icon"), iconClass],
  77. "badgeProps": badgeProps,
  78. "classPrefix": iconPrefix
  79. }, null);
  80. };
  81. return () => (0, import_vue.createVNode)("div", {
  82. "role": "button",
  83. "class": bem(),
  84. "tabindex": 0,
  85. "onClick": route
  86. }, [renderIcon(), slots.default ? slots.default() : props.text]);
  87. }
  88. });