hongluan-ui
Version:
Hongluan Component Library for Vue 3
92 lines (87 loc) • 2.15 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
require('../../../utils/index.js');
require('../../../hooks/index.js');
var icon = require('./icon2.js');
var index = require('../../../hooks/use-namespace/index.js');
var rand = require('../../../utils/rand.js');
const _sfc_main = vue.defineComponent({
name: "Icon",
props: icon.iconProps,
setup(props) {
const { namespace } = index.useNamespace("icon");
const iconStyle = vue.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_" + rand.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 vue.h("i", {
class: [
namespace,
type ? type : "",
size,
effect,
{
"fill": fill,
"round": round,
"radius": radius,
"transition": transition
}
],
style: iconStyle
}, handleSlotsChildren($slots));
}
});
exports["default"] = _sfc_main;
//# sourceMappingURL=icon.js.map