@scalar/api-client
Version:
the open source API testing client
50 lines (49 loc) • 1.83 kB
JavaScript
import { defineComponent as m, useId as v, createElementBlock as c, createCommentVNode as p, openBlock as t, Fragment as g, renderList as h, normalizeClass as y, createElementVNode as k, createBlock as b, unref as a, toDisplayString as $ } from "vue";
import C from "./ServerVariablesSelect.vue.js";
import V from "./ServerVariablesTextbox.vue.js";
const B = ["for"], F = /* @__PURE__ */ m({
__name: "ServerVariablesForm",
props: {
variables: {},
values: {},
controls: {},
layout: { default: "client" }
},
emits: ["update:variable"],
setup(n, { emit: d }) {
const f = d, o = v();
function s(e, u) {
f("update:variable", e, u);
}
const i = (e) => (n.values?.[e] ?? n.variables?.[e]?.default ?? "").toString();
return (e, u) => e.variables && Object.keys(e.variables ?? {}).length ? (t(!0), c(g, { key: 0 }, h(Object.keys(e.variables), (r) => (t(), c("div", {
key: r,
class: y([
"group/label flex h-8 w-full",
e.layout === "reference" && "items-center border-x border-b last:rounded-b-lg"
])
}, [
k("label", {
class: "flex items-center py-2 pl-3 group-has-[input]/label:mr-0 after:content-[':']",
for: `${a(o)}-${r}`
}, $(r), 9, B),
e.variables?.[r]?.enum?.length ? (t(), b(C, {
key: 0,
id: `${a(o)}-${r}`,
controls: e.controls,
enum: e.variables[r]?.enum?.map((l) => `${l}`) ?? [],
value: i(r),
onChange: (l) => s(r, l)
}, null, 8, ["id", "controls", "enum", "value", "onChange"])) : (t(), b(V, {
key: 1,
id: `${a(o)}-${r}`,
controls: e.controls,
value: i(r),
onChange: (l) => s(r, l)
}, null, 8, ["id", "controls", "value", "onChange"]))
], 2))), 128)) : p("", !0);
}
});
export {
F as default
};