UNPKG

@scalar/api-client

Version:

the open source API testing client

64 lines (63 loc) 2.71 kB
import { defineComponent as h, computed as c, createBlock as i, openBlock as a, unref as m, withCtx as u, createElementVNode as d, createElementBlock as t, createCommentVNode as s, toDisplayString as o } from "vue"; import { ScalarPopover as p, ScalarMarkdown as f } from "@scalar/components"; import { ScalarIconWarning as v, ScalarIconInfo as k } from "@scalar/icons"; import { validateParameter as y } from "../helpers/validate-parameter.js"; const g = ["aria-label", "role"], b = { class: "w-content text-xxs text-c-1 grid min-w-48 gap-1.5 rounded px-1.5 pt-2 pb-1.5 leading-none" }, I = { key: 0, class: "text-error-1" }, w = { key: 1, class: "schema text-c-2 flex items-center" }, S = { key: 0 }, _ = { key: 1 }, x = { key: 2 }, B = { key: 3 }, C = { key: 4 }, T = /* @__PURE__ */ h({ __name: "RequestTableTooltip", props: { schema: {}, value: {}, description: {} }, setup(l) { const r = c(() => y(l.schema, l.value)), n = c(() => r.value.ok === !1); return (e, M) => (a(), i(m(p), { offset: 4, placement: "left", teleport: "" }, { popover: u(() => [ d("div", b, [ r.value.ok === !1 ? (a(), t("div", I, o(r.value.message), 1)) : e.schema && ("type" in e.schema || "format" in e.schema || "minimum" in e.schema || "maximum" in e.schema || "default" in e.schema) ? (a(), t("div", w, [ "type" in e.schema ? (a(), t("span", S, o(e.schema.type), 1)) : s("", !0), "format" in e.schema ? (a(), t("span", _, o(e.schema.format), 1)) : s("", !0), "minimum" in e.schema ? (a(), t("span", x, "min: " + o(e.schema.minimum), 1)) : s("", !0), "maximum" in e.schema ? (a(), t("span", B, "max: " + o(e.schema.maximum), 1)) : s("", !0), "default" in e.schema ? (a(), t("span", C, "default: " + o(e.schema.default), 1)) : s("", !0) ])) : s("", !0), e.description && !n.value ? (a(), i(m(f), { key: 2, class: "max-w-[16rem]", value: e.description }, null, 8, ["value"])) : s("", !0) ]) ]), default: u(() => [ d("button", { "aria-label": n.value ? "Input is invalid" : "More Information", class: "text-c-2 hover:text-c-1 hover:bg-b-2 rounded p-1", role: n.value ? "alert" : "none", type: "button" }, [ n.value ? (a(), i(m(v), { key: 0, class: "text-orange size-3.5 brightness-90 hover:brightness-75" })) : (a(), i(m(k), { key: 1, class: "text-c-2 hover:text-c-1 size-3.5" })) ], 8, g) ]), _: 1 })); } }); export { T as default };