UNPKG

@scalar/api-client

Version:

the open source API testing client

49 lines (48 loc) 1.94 kB
import { defineComponent as i, computed as s, createElementBlock as l, createCommentVNode as m, openBlock as u, createVNode as d, createTextVNode as f, unref as g } from "vue"; import { ScalarIcon as h } from "@scalar/components"; import { makeUrlAbsolute as p } from "@scalar/oas-utils/helpers"; const k = ["href"], L = /* @__PURE__ */ i({ __name: "OpenApiClientButton", props: { buttonSource: {}, source: { default: "api-reference" }, isDevelopment: { type: Boolean }, integration: {}, url: {} }, setup(t) { const c = s(() => { const n = t.url ?? (typeof window < "u" ? window.location.href : void 0); if (!n) return; const o = p(n); if (!o?.length) return; const e = new URL( t.isDevelopment ? "http://localhost:5065" : "https://client.scalar.com" ); if (e.searchParams.set("url", o), t.integration !== null && e.searchParams.set("integration", t.integration ?? "vue"), e.searchParams.set("utm_source", "api-reference"), e.searchParams.set("utm_medium", "button"), e.searchParams.set("utm_campaign", t.buttonSource), t.source === "gitbook") { e.searchParams.set("utm_source", "gitbook"); const r = document.querySelector("img.dark\\:block[alt='Logo']"), a = document.querySelector("img.dark\\:hidden[alt='Logo']"); r && r instanceof HTMLImageElement && e.searchParams.set("dark_logo", encodeURIComponent(r.src)), a && a instanceof HTMLImageElement && e.searchParams.set("light_logo", encodeURIComponent(a.src)); } return e.toString(); }); return (n, o) => c.value ? (u(), l("a", { key: 0, class: "open-api-client-button", href: c.value, target: "_blank" }, [ d(g(h), { icon: "ExternalLink", size: "xs", thickness: "2.5" }), o[0] || (o[0] = f(" Open API Client ")) ], 8, k)) : m("", !0); } }); export { L as default };