UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

81 lines (80 loc) 3.3 kB
import { defineComponent, createElementBlock, openBlock, Fragment, createCommentVNode, createElementVNode, unref, createVNode, toDisplayString, renderList } from "vue"; import { ScalarIcon } from "@scalar/components"; import { useClipboard } from "@scalar/use-hooks/useClipboard"; import { formatExample } from "./helpers/format-example.js"; const _hoisted_1 = { key: 0, class: "property-example" }; const _hoisted_2 = { class: "property-example-value-list" }; const _hoisted_3 = { key: 1, class: "property-example" }; const _hoisted_4 = { class: "property-example-label", type: "button" }; const _hoisted_5 = { class: "property-example-value-list" }; const _hoisted_6 = ["onClick"]; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "SchemaPropertyExamples", props: { examples: {}, example: {} }, setup(__props) { const { copyToClipboard } = useClipboard(); return (_ctx, _cache) => { return openBlock(), createElementBlock(Fragment, null, [ __props.example ? (openBlock(), createElementBlock("div", _hoisted_1, [ _cache[1] || (_cache[1] = createElementVNode("button", { class: "property-example-label", type: "button" }, [ createElementVNode("span", null, "Example") ], -1)), createElementVNode("div", _hoisted_2, [ createElementVNode("button", { class: "property-example-value group", type: "button", onClick: _cache[0] || (_cache[0] = ($event) => unref(copyToClipboard)(unref(formatExample)(__props.example))) }, [ createElementVNode("span", null, toDisplayString(unref(formatExample)(__props.example)), 1), createVNode(unref(ScalarIcon), { class: "group-hover:text-c-1 text-c-3 ml-auto min-h-3 min-w-3", icon: "Clipboard", size: "xs" }) ]) ]) ])) : createCommentVNode("", true), __props.examples && typeof __props.examples === "object" && Object.keys(__props.examples).length > 0 ? (openBlock(), createElementBlock("div", _hoisted_3, [ createElementVNode("button", _hoisted_4, [ createElementVNode("span", null, toDisplayString(Object.keys(__props.examples).length === 1 ? "Example" : "Examples"), 1) ]), createElementVNode("div", _hoisted_5, [ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.examples, (ex, key) => { return openBlock(), createElementBlock("button", { key, class: "property-example-value group", type: "button", onClick: ($event) => unref(copyToClipboard)(unref(formatExample)(ex)) }, [ createElementVNode("span", null, toDisplayString(unref(formatExample)(ex)), 1), createVNode(unref(ScalarIcon), { class: "text-c-3 group-hover:text-c-1 ml-auto min-h-3 min-w-3", icon: "Clipboard", size: "xs" }) ], 8, _hoisted_6); }), 128)) ]) ])) : createCommentVNode("", true) ], 64); }; } }); export { _sfc_main as default };