comic-plus
Version:
<p align="center"> <img width="200px" src="./logo.png"/> </p>
60 lines (59 loc) • 2.24 kB
JavaScript
import { defineComponent, getCurrentInstance, inject, computed, reactive, onUnmounted, openBlock, createElementBlock, normalizeClass, normalizeStyle, unref, renderSlot, createElementVNode, createBlock, resolveDynamicComponent, createCommentVNode } from "vue";
import { bulletProps } from "./bullet.props.mjs";
import { PISTOL_PROVIDE } from "./type.mjs";
import "../../../utils/config.mjs";
import { isVueComponent } from "../../../utils/typescript.mjs";
import "@vueuse/core";
const _hoisted_1 = { class: "cu-bullet-content" };
const _sfc_main = /* @__PURE__ */ defineComponent({
...{
name: "CuBullet"
},
__name: "bullet",
props: bulletProps,
setup(__props) {
const props = __props;
const instance = getCurrentInstance();
const { addBullet, removeBullet, itemHandleClick, bullets, pistolStyle, props: injectProps } = inject(PISTOL_PROVIDE);
const getInstanceIdx = computed(() => {
return Object.keys(bullets).indexOf(instance.uid.toString());
});
const bulletInstance = reactive({
sign: props.sign,
uid: instance.uid,
style: {}
});
addBullet(bulletInstance);
function bulletClick() {
if (props.disabled) return;
itemHandleClick(props.sign);
}
onUnmounted(() => {
removeBullet(instance.uid);
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock("li", {
class: normalizeClass(["cu-bullet", { "is-disabled": _ctx.disabled }]),
style: normalizeStyle([
bulletInstance.style,
unref(pistolStyle),
{ "--cu-pistol-delay": (unref(injectProps).iteration ? getInstanceIdx.value * (50 + (unref(injectProps).dept ?? 0)) : 0) + "ms" },
{ "--pistol-custom-color": _ctx.color ?? unref(injectProps).color }
]),
onClick: bulletClick
}, [
renderSlot(_ctx.$slots, "default", {}, () => [
createElementVNode("div", _hoisted_1, [
unref(isVueComponent)(_ctx.icon) ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.icon), {
key: 0,
class: "cu-bullet__icon"
})) : createCommentVNode("", true)
])
])
], 6);
};
}
});
export {
_sfc_main as default
};