UNPKG

2.69 kBJavaScriptView Raw
1var __defProp = Object.defineProperty;
2var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3var __getOwnPropNames = Object.getOwnPropertyNames;
4var __hasOwnProp = Object.prototype.hasOwnProperty;
5var __export = (target, all) => {
6 for (var name2 in all)
7 __defProp(target, name2, { get: all[name2], enumerable: true });
8};
9var __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};
17var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18var stdin_exports = {};
19__export(stdin_exports, {
20 default: () => stdin_default,
21 iconProps: () => iconProps
22});
23module.exports = __toCommonJS(stdin_exports);
24var import_vue = require("vue");
25var import_utils = require("../utils");
26var import_badge = require("../badge");
27var import_ConfigProvider = require("../config-provider/ConfigProvider");
28const [name, bem] = (0, import_utils.createNamespace)("icon");
29const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
30const iconProps = {
31 dot: Boolean,
32 tag: (0, import_utils.makeStringProp)("i"),
33 name: String,
34 size: import_utils.numericProp,
35 badge: import_utils.numericProp,
36 color: String,
37 badgeProps: Object,
38 classPrefix: String
39};
40var stdin_default = (0, import_vue.defineComponent)({
41 name,
42 props: iconProps,
43 setup(props, {
44 slots
45 }) {
46 const config = (0, import_vue.inject)(import_ConfigProvider.CONFIG_PROVIDER_KEY, null);
47 const classPrefix = (0, import_vue.computed)(() => props.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem());
48 return () => {
49 const {
50 tag,
51 dot,
52 name: name2,
53 size,
54 badge,
55 color
56 } = props;
57 const isImageIcon = isImage(name2);
58 return (0, import_vue.createVNode)(import_badge.Badge, (0, import_vue.mergeProps)({
59 "dot": dot,
60 "tag": tag,
61 "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
62 "style": {
63 color,
64 fontSize: (0, import_utils.addUnit)(size)
65 },
66 "content": badge
67 }, props.badgeProps), {
68 default: () => {
69 var _a;
70 return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && (0, import_vue.createVNode)("img", {
71 "class": bem("image"),
72 "src": name2
73 }, null)];
74 }
75 });
76 };
77 }
78});