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