UNPKG

hongluan-ui

Version:
88 lines (85 loc) 2.09 kB
import { defineComponent, computed, h } from 'vue'; import '../../../utils/index.mjs'; import '../../../hooks/index.mjs'; import { iconProps } from './icon2.mjs'; import { useNamespace } from '../../../hooks/use-namespace/index.mjs'; import { generateId } from '../../../utils/rand.mjs'; const _sfc_main = defineComponent({ name: "Icon", props: iconProps, setup(props) { const { namespace } = useNamespace("icon"); const iconStyle = computed(() => { const style = {}; if (props.width) { style.width = !Number.isNaN(+props.width) ? props.width + "px" : props.width; } if (props.height) { style.height = !Number.isNaN(+props.height) ? props.height + "px" : props.height; } if (props.color) { style.color = props.color; } return style; }); return { namespace, iconStyle, iconId: "icon_" + generateId() }; }, render() { const { $slots, namespace, iconStyle, iconId, type, size, effect, fill, round, color, radius, opacity, startColor, gradient, transition, border } = this; const handleSlotsChildren = (internalSlots) => { var _a; const children = ((_a = internalSlots.default) == null ? void 0 : _a.call(internalSlots)) || []; children.forEach((c) => { if (c.shapeFlag & 4 || c.shapeFlag & 2) { c.props = Object.assign(c.props || {}, { borderWidth: border, opacity, startColor, gradient, iconId, color }); } }); return children; }; return h("i", { class: [ namespace, type ? type : "", size, effect, { "fill": fill, "round": round, "radius": radius, "transition": transition } ], style: iconStyle }, handleSlotsChildren($slots)); } }); export { _sfc_main as default }; //# sourceMappingURL=icon.mjs.map