Icon.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. iconProps: () => iconProps
  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_badge = require("../badge");
  28. var import_ConfigProvider = require("../config-provider/ConfigProvider");
  29. const [name, bem] = (0, import_utils.createNamespace)("icon");
  30. const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
  31. const iconProps = {
  32. dot: Boolean,
  33. tag: (0, import_utils.makeStringProp)("i"),
  34. name: String,
  35. size: import_utils.numericProp,
  36. badge: import_utils.numericProp,
  37. color: String,
  38. badgeProps: Object,
  39. classPrefix: String
  40. };
  41. var stdin_default = (0, import_vue2.defineComponent)({
  42. name,
  43. props: iconProps,
  44. setup(props, {
  45. slots
  46. }) {
  47. const config = (0, import_vue2.inject)(import_ConfigProvider.CONFIG_PROVIDER_KEY, null);
  48. const classPrefix = (0, import_vue2.computed)(() => props.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem());
  49. return () => {
  50. const {
  51. tag,
  52. dot,
  53. name: name2,
  54. size,
  55. badge,
  56. color
  57. } = props;
  58. const isImageIcon = isImage(name2);
  59. return (0, import_vue.createVNode)(import_badge.Badge, (0, import_vue.mergeProps)({
  60. "dot": dot,
  61. "tag": tag,
  62. "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
  63. "style": {
  64. color,
  65. fontSize: (0, import_utils.addUnit)(size)
  66. },
  67. "content": badge
  68. }, props.badgeProps), {
  69. default: () => {
  70. var _a;
  71. return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && (0, import_vue.createVNode)("img", {
  72. "class": bem("image"),
  73. "src": name2
  74. }, null)];
  75. }
  76. });
  77. };
  78. }
  79. });