UNPKG

@zhsz/cool-design-dv

Version:

77 lines (76 loc) 2.43 kB
import { defineComponent, inject, computed, getCurrentInstance, onBeforeUnmount, openBlock, createBlock, Transition, withCtx, unref, mergeProps, renderSlot, createCommentVNode } from "vue"; import "animate.css"; import Box from "../dv-box/index.mjs"; import { dvPageSymbols } from "../../symbols/index.mjs"; const __default__ = defineComponent({ name: "DvScreen", inheritAttrs: false }); const _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: { enter: { type: String, default: "slideInRight" }, leave: { type: String, default: "slideOutLeft" } }, setup(__props) { const props = __props; const page = inject(dvPageSymbols, null); const enterClass = computed(() => { return `animate__animated animate__${props.enter} animate__faster`; }); const leaveClass = computed(() => { return `animate__animated animate__${props.leave} animate__faster`; }); const instance = getCurrentInstance(); const active = computed(() => { if (!page) { return false; } return page.screens.value[page.screenActiveIndex.value] === (instance == null ? void 0 : instance.uid); }); function register() { if (page && (instance == null ? void 0 : instance.uid)) { page.screens.value.push(instance == null ? void 0 : instance.uid); } } function unregister() { if (page && (instance == null ? void 0 : instance.uid)) { page.screens.value = page.screens.value.filter((n) => n !== (instance == null ? void 0 : instance.uid)); } } register(); onBeforeUnmount(() => { unregister(); }); return (_ctx, _cache) => { return openBlock(), createBlock(Transition, { "enter-active-class": enterClass.value, "leave-active-class": leaveClass.value }, { default: withCtx(() => [ active.value ? (openBlock(), createBlock(unref(Box), mergeProps({ key: 0, class: "my-dv-screen", "default-width": "100%", "default-height": "100%" }, _ctx.$attrs), { default: withCtx(() => [ renderSlot(_ctx.$slots, "default") ]), _: 3 }, 16)) : createCommentVNode("", true) ]), _: 3 }, 8, ["enter-active-class", "leave-active-class"]); }; } }); export { _sfc_main as default };