UNPKG

comic-plus

Version:

<p align="center"> <img width="200px" src="./logo.png"/> </p>

107 lines (106 loc) 4.09 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const vue = require("vue"); const core = require("@vueuse/core"); const vue$1 = require("@floating-ui/vue"); const config = require("../../../utils/config.js"); const tools = require("../../../utils/tools.js"); const client = require("../../../utils/client.js"); const _hoisted_1 = { class: "floatCard__content" }; const _hoisted_2 = { class: "floatCard__time" }; const _sfc_main = /* @__PURE__ */ vue.defineComponent({ __name: "float-card", props: { data: Object, trigger: Object, cardWidth: Number }, setup(__props) { const props = __props; const zIndex = vue.ref(0); const recordData = vue.ref(props.data); const containerRef = vue.ref(); const virtualEl = vue.ref(); const triggerRef = vue.computed(() => { return props.trigger; }); const extractor = (event) => [event.clientX, event.clientY]; const { x, y } = core.useMouse({ target: triggerRef, touch: false, type: extractor }); const { floatingStyles } = vue$1.useFloating(virtualEl, containerRef, { placement: "right-end", middleware: [vue$1.offset(10), vue$1.flip(), vue$1.shift({ padding: 10 })] }); const updateVirtualEl = () => { client.raf(() => { virtualEl.value = { getBoundingClientRect() { return { width: 0, height: 0, x: x.value, y: y.value, left: x.value, right: x.value, top: y.value, bottom: y.value }; } }; }); }; vue.watch([x, y], updateVirtualEl); vue.watch( () => props.data, (val) => { if (val) { if (zIndex.value === 0) { zIndex.value = config.getNextZIndex(); } recordData.value = val; updateVirtualEl(); } else { zIndex.value = 0; } } ); return (_ctx, _cache) => { return vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [ vue.createVNode(vue.Transition, { name: "cu-fade" }, { default: vue.withCtx(() => [ vue.withDirectives(vue.createElementVNode("div", { class: "cu-calendar--floatCard", ref_key: "containerRef", ref: containerRef, style: vue.normalizeStyle({ ...vue.unref(floatingStyles), zIndex: zIndex.value, "max-width": __props.cardWidth ? __props.cardWidth + "px" : void 0 }) }, [ vue.renderSlot(_ctx.$slots, "default", { data: recordData.value }, () => [ recordData.value ? (vue.openBlock(), vue.createElementBlock("div", { key: 0, class: "floatCard__container", style: vue.normalizeStyle({ "--card-color": recordData.value.color }) }, [ vue.createElementVNode("div", _hoisted_1, vue.toDisplayString(recordData.value.content), 1), vue.createElementVNode("div", _hoisted_2, [ vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(tools.formatDate)(recordData.value.startDate, "MM-dd")), 1), recordData.value.endDate.getTime() > recordData.value.startDate.getTime() ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [ _cache[0] || (_cache[0] = vue.createElementVNode("span", null, "~", -1)), vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(tools.formatDate)(recordData.value.endDate, "MM-dd")), 1) ], 64)) : vue.createCommentVNode("", true) ]) ], 4)) : vue.createCommentVNode("", true) ]) ], 4), [ [vue.vShow, !!__props.data] ]) ]), _: 3 }) ]); }; } }); exports.default = _sfc_main;