UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

71 lines (70 loc) 2.4 kB
import { defineComponent as y, createElementBlock as l, openBlock as p, Fragment as i, createCommentVNode as u, createElementVNode as e, unref as o, createVNode as c, toDisplayString as n, renderList as b } from "vue"; import { ScalarIcon as x } from "@scalar/components"; import { useClipboard as v } from "@scalar/use-hooks/useClipboard"; import { formatExample as r } from "./helpers/format-example.js"; const f = { key: 0, class: "property-example" }, g = { class: "property-example-value-list" }, h = { key: 1, class: "property-example" }, k = { type: "button", class: "property-example-label" }, C = { class: "property-example-value-list" }, _ = ["onClick"], z = /* @__PURE__ */ y({ __name: "SchemaPropertyExamples", props: { examples: {}, example: {} }, setup(E) { const { copyToClipboard: m } = v(); return (t, s) => (p(), l(i, null, [ t.example ? (p(), l("div", f, [ s[1] || (s[1] = e("button", { type: "button", class: "property-example-label" }, [ e("span", null, "Example") ], -1)), e("div", g, [ e("button", { type: "button", class: "property-example-value group", onClick: s[0] || (s[0] = (a) => o(m)(String(o(r)(t.example)))) }, [ e("span", null, n(o(r)(t.example)), 1), c(o(x), { icon: "Clipboard", size: "xs", class: "group-hover:text-c-1 text-c-3 ml-auto min-h-3 min-w-3" }) ]) ]) ])) : u("", !0), t.examples && typeof t.examples == "object" && Object.keys(t.examples).length > 0 ? (p(), l("div", h, [ e("button", k, [ e("span", null, n(Object.keys(t.examples).length === 1 ? "Example" : "Examples"), 1) ]), e("div", C, [ (p(!0), l(i, null, b(t.examples, (a, d) => (p(), l("button", { type: "button", key: d, class: "property-example-value group", onClick: (S) => o(m)(String(o(r)(a))) }, [ e("span", null, n(o(r)(a)), 1), c(o(x), { icon: "Clipboard", size: "xs", class: "text-c-3 group-hover:text-c-1 ml-auto min-h-3 min-w-3" }) ], 8, _))), 128)) ]) ])) : u("", !0) ], 64)); } }); export { z as default };