UNPKG

@scalar/api-client

Version:

the open source API testing client

56 lines (55 loc) 1.76 kB
import { defineComponent as m, ref as f, toRef as c, createElementBlock as l, openBlock as i, createCommentVNode as y, createElementVNode as e, unref as a, createVNode as b } from "vue"; import { ScalarIcon as v } from "@scalar/components"; import { prettyPrintJson as C } from "@scalar/oas-utils/helpers"; import { useCodeMirror as g } from "@scalar/use-codemirror"; import { useClipboard as _ } from "@scalar/use-hooks/useClipboard"; const k = { class: "body-raw grid min-h-0 overflow-hidden p-px outline-none has-[:focus-visible]:outline" }, w = { key: 0, class: "scalar-code-copy" }, R = { class: "body-raw-scroller relative overflow-auto overscroll-contain", tabindex: "0" }, E = /* @__PURE__ */ m({ __name: "ResponseBodyRaw", props: { content: {}, language: {} }, setup(d) { const r = d, n = f(null), { copyToClipboard: u } = _(), { codeMirror: p } = g({ codeMirrorRef: n, readOnly: !0, lineNumbers: !0, content: c(() => C(r.content)), language: c(() => r.language), forceFoldGutter: !0 }), s = () => { var t; return ((t = p.value) == null ? void 0 : t.state.doc.toString()) || ""; }; return (t, o) => (i(), l("div", k, [ s() ? (i(), l("div", w, [ e("button", { class: "copy-button", type: "button", onClick: o[0] || (o[0] = (x) => a(u)(s())) }, [ o[1] || (o[1] = e("span", { class: "sr-only" }, "Copy content", -1)), b(a(v), { icon: "Clipboard", size: "md" }) ]) ])) : y("", !0), e("div", R, [ e("div", { ref_key: "codeMirrorRef", ref: n }, null, 512) ]) ])); } }); export { E as default };