@scalar/api-client
Version:
the open source API testing client
90 lines (89 loc) • 3.25 kB
JavaScript
import { defineComponent as b, computed as s, createBlock as i, openBlock as d, unref as r, withCtx as a, createVNode as m, createElementVNode as p, createCommentVNode as g, withModifiers as h, createTextVNode as u, toDisplayString as f } from "vue";
import { ScalarTooltip as y, ScalarButton as P } from "@scalar/components";
import { getExample as A } from "../../operation-block/helpers/get-example.js";
import { getParameterSchema as C } from "../helpers/get-parameter-schema.js";
import x from "./RequestTable.vue.js";
import q from "../../../components/layout/CollapsibleSection.vue.js";
const K = { class: "text-c-2 request-meta-buttons flex whitespace-nowrap opacity-0 group-hover/params:opacity-100 has-[:focus-visible]:opacity-100" }, k = { class: "sr-only" }, E = /* @__PURE__ */ b({
__name: "RequestParams",
props: {
parameters: {},
exampleKey: {},
title: {},
label: {},
invalidParams: {},
globalRoute: {},
showAddRowPlaceholder: { type: Boolean, default: !0 },
environment: {}
},
emits: ["add", "update", "delete", "deleteAll"],
setup(l, { emit: v }) {
const n = v, c = s(
() => l.parameters.map((e) => {
const t = A(e, l.exampleKey, void 0);
return {
name: e.name,
value: t?.value ?? "",
description: e.description,
globalRoute: l.globalRoute,
schema: C(e),
isRequired: e.required,
isDisabled: t?.["x-disabled"] ?? !1
};
})
), w = s(() => l.parameters.length > 1);
return (e, t) => (d(), i(r(q), {
class: "group/params",
itemCount: e.parameters.length
}, {
title: a(() => [
u(f(e.title), 1)
]),
actions: a(() => [
p("div", K, [
w.value ? (d(), i(r(y), {
key: 0,
content: "Clear optional parameters",
placement: "left"
}, {
default: a(() => [
m(r(P), {
class: "pr-0.75 pl-1 transition-none",
size: "sm",
variant: "ghost",
onClick: t[0] || (t[0] = h((o) => n("deleteAll"), ["stop"]))
}, {
default: a(() => [
t[4] || (t[4] = u(" Clear ", -1)),
p("span", k, "All " + f(e.title), 1)
]),
_: 1
})
]),
_: 1
})) : g("", !0)
])
]),
default: a(() => [
m(x, {
class: "flex-1",
columns: ["32px", "", ""],
data: c.value,
environment: e.environment,
exampleKey: e.exampleKey,
globalRoute: e.globalRoute,
invalidParams: e.invalidParams,
label: e.label,
showAddRowPlaceholder: e.showAddRowPlaceholder,
onAddRow: t[1] || (t[1] = (o) => n("add", o)),
onDeleteRow: t[2] || (t[2] = (o) => n("delete", { index: o })),
onUpdateRow: t[3] || (t[3] = (o, R) => n("update", { index: o, payload: R }))
}, null, 8, ["data", "environment", "exampleKey", "globalRoute", "invalidParams", "label", "showAddRowPlaceholder"])
]),
_: 1
}, 8, ["itemCount"]));
}
});
export {
E as default
};