@scalar/api-client
Version:
the open source API testing client
91 lines (90 loc) • 3.29 kB
JavaScript
import { defineComponent as C, ref as N, computed as m, toRef as w, createBlock as n, openBlock as o, createSlots as T, withCtx as d, createElementBlock as $, createCommentVNode as r, createElementVNode as g, toDisplayString as _, unref as a, createTextVNode as x, createVNode as E } from "vue";
import P from "../../../components/ViewLayout/ViewLayoutCollapse.vue.js";
import { useResponseBody as S } from "../../../hooks/useResponseBody.js";
import U from "./ResponseBodyDownload.vue.js";
import j from "./ResponseBodyInfo.vue.js";
import D from "./ResponseBodyPreview.vue.js";
import F from "./ResponseBodyRaw.vue.js";
import I from "./ResponseBodyToggle.vue.js";
import { getMediaTypeConfig as M } from "../consts/mediaTypes.js";
const q = {
key: 0,
class: "bg-b-1 flex max-h-[calc(100%-32px)] flex-col overflow-hidden"
}, z = { class: "box-content flex min-h-8 items-center justify-between border-y px-3" }, A = { class: "text-xxs font-code leading-3" }, Y = /* @__PURE__ */ C({
__name: "ResponseBody",
props: {
title: {},
layout: {},
data: {},
headers: {}
},
setup(k) {
const c = k, s = N(!0), p = m(
() => {
var t;
return !!((t = e.value) != null && t.raw && e.value.preview);
}
), B = m(() => s.value || !p.value), R = m(() => !s.value || !p.value), { mimeType: i, attachmentFilename: V, dataUrl: l } = S({
data: w(c, "data"),
headers: w(c, "headers")
}), e = m(() => M(i.value.essence));
return (t, u) => (o(), n(P, {
class: "max-h-content overflow-y-hidden",
layout: t.layout
}, T({
title: d(() => [
x(_(t.title), 1)
]),
default: d(() => {
var f, v, y, h;
return [
t.data ? (o(), $("div", q, [
g("div", z, [
g("span", A, _(a(i).essence), 1),
p.value ? (o(), n(I, {
key: 0,
modelValue: s.value,
"onUpdate:modelValue": u[0] || (u[0] = (b) => s.value = b)
}, null, 8, ["modelValue"])) : r("", !0)
]),
(f = e.value) != null && f.raw && R.value ? (o(), n(F, {
key: a(l),
content: t.data,
language: e.value.language
}, null, 8, ["content", "language"])) : r("", !0),
(v = e.value) != null && v.preview && B.value ? (o(), n(D, {
key: a(l),
alpha: e.value.alpha,
mode: e.value.preview,
src: a(l),
type: a(i).essence
}, null, 8, ["alpha", "mode", "src", "type"])) : r("", !0),
!((y = e.value) != null && y.raw) && !((h = e.value) != null && h.preview) ? (o(), n(j, { key: 2 }, {
default: d(() => u[1] || (u[1] = [
x(" Binary file ")
])),
_: 1,
__: [1]
})) : r("", !0)
])) : r("", !0)
];
}),
_: 2
}, [
t.data && a(l) ? {
name: "actions",
fn: d(() => [
E(U, {
filename: a(V),
href: a(l),
type: a(i).essence
}, null, 8, ["filename", "href", "type"])
]),
key: "0"
} : void 0
]), 1032, ["layout"]));
}
});
export {
Y as default
};