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