@scalar/api-client
Version:
the open source API testing client
64 lines (63 loc) • 1.92 kB
JavaScript
import { defineComponent as d, ref as p, watch as i, createElementBlock as l, createBlock as y, openBlock as s, normalizeClass as a, createElementVNode as n, withCtx as f, createTextVNode as m } from "vue";
import v from "./ResponseBodyInfo.vue.js";
const c = ["src"], k = ["src", "type"], w = ["src", "type"], B = ["data", "type"], $ = /* @__PURE__ */ d({
__name: "ResponseBodyPreview",
props: {
src: {},
type: {},
mode: {},
alpha: { type: Boolean, default: !1 }
},
setup(u) {
const r = p(!1);
return i(
() => u.src,
() => r.value = !1
), (e, o) => !r.value && e.src ? (s(), l("div", {
key: 0,
class: a(["flex justify-center overflow-auto rounded-b", { "bg-preview p-2": e.alpha }])
}, [
e.mode === "image" ? (s(), l("img", {
key: 0,
class: a(["h-full max-w-full", { rounded: e.alpha }]),
src: e.src,
onError: o[0] || (o[0] = (t) => r.value = !0)
}, null, 42, c)) : e.mode === "video" ? (s(), l("video", {
key: 1,
autoplay: "",
controls: "",
width: "100%",
onError: o[1] || (o[1] = (t) => r.value = !0)
}, [
n("source", {
src: e.src,
type: e.type
}, null, 8, k)
], 32)) : e.mode === "audio" ? (s(), l("audio", {
key: 2,
class: "my-12",
controls: "",
onError: o[2] || (o[2] = (t) => r.value = !0)
}, [
n("source", {
src: e.src,
type: e.type
}, null, 8, w)
], 32)) : (s(), l("object", {
key: 3,
class: "aspect-[4/3] w-full",
data: e.src,
type: e.type,
onError: o[3] || (o[3] = (t) => r.value = !0)
}, null, 40, B))
], 2)) : (s(), y(v, { key: 1 }, {
default: f(() => [...o[4] || (o[4] = [
m("Preview unavailable", -1)
])]),
_: 1
}));
}
});
export {
$ as default
};