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