UNPKG

@scalar/api-client

Version:

the open source API testing client

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