UNPKG

@aplus-frontend/ui

Version:

90 lines (89 loc) 2.76 kB
import { defineComponent as h, ref as f, watch as E, unref as l, computed as n, createBlock as d, openBlock as v, withCtx as w, resolveDynamicComponent as S, mergeProps as z, renderSlot as C, createElementVNode as F, normalizeClass as I } from "vue"; import "../hooks/index.mjs"; import "../portal/index.mjs"; import "../config-provider/index.mjs"; import { useScrollLock as N } from "@vueuse/core"; import $ from "./style/index.mjs"; import { useFullScreen as B } from "../hooks/useFullScreen.mjs"; import { useNamespace as L } from "../config-provider/hooks/use-namespace.mjs"; import D from "../portal/index.vue.mjs"; const O = /* @__PURE__ */ h({ name: "FullScreen", __name: "index", props: { wrapperElementName: { default: "div" }, zIndex: { default: 2147483647 }, to: { default: "body" } }, setup(M, { expose: b }) { const { target: i, full: y, enter: _, exit: g } = B(), { b: p, bm: k, be: x } = L("full-screen"), R = $("full-screen"), t = f(!1), a = f(), c = N(document.body), u = f(); E( () => l(y), (e) => { e || (t.value = !1, a.value = void 0); } ); async function r(e, o = !1) { await s(), t.value = !0, a.value = e, e === "browser" ? _(o) : c.value = !0; } async function s(e = !1) { t.value = !1, a.value === "browser" ? await g(e) : c.value = !1, a.value = void 0; } async function m(e, o = !1) { t.value ? a.value !== e ? await r(e, o) : await s(o) : await r(e, o); } return b({ target: n(() => l(i)), portalRoot: n(() => l(u)), full: n(() => l(t)), mode: n(() => l(a)), enter: r, exit: s, toggle: m }), (e, o) => (v(), d(l(D), { to: e.to, disabled: a.value !== "window" }, { default: w(() => [ (v(), d(S(e.wrapperElementName), z({ ref_key: "target", ref: i }, e.$attrs, { class: [ l(p)(), l(p)("wrapper"), t.value && a.value === "window" ? l(k)("wrapper", "full") : null, l(R) ], style: { zIndex: t.value && a.value === "window" ? e.zIndex : "unset" } }), { default: w(() => [ C(e.$slots, "default", { full: t.value, enter: r, exit: s, toggle: m, mode: a.value, portalRoot: u.value }), F("div", { ref_key: "portalRootRef", ref: u, class: I(l(x)("wrapper", "portal-root")) }, null, 2) ]), _: 3 }, 16, ["class", "style"])) ]), _: 3 }, 8, ["to", "disabled"])); } }); export { O as default };