UNPKG

@scalar/api-client

Version:

the open source API testing client

89 lines (88 loc) 3.2 kB
import { defineComponent as c, computed as s, createBlock as i, openBlock as m, unref as n, withCtx as l, createVNode as d, 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 { getParameterExample as A } from "../helpers/get-parameter-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__ */ c({ __name: "RequestParams", props: { parameters: {}, exampleKey: {}, title: {}, label: {}, invalidParams: {}, globalRoute: {}, showAddRowPlaceholder: { type: Boolean, default: !0 }, environment: {} }, emits: ["add", "update", "delete", "deleteAll"], setup(o, { emit: v }) { const r = v, w = s( () => o.parameters.map((e) => { const t = A(e, o.exampleKey); return { name: e.name, value: t?.value ?? "", globalRoute: o.globalRoute, schema: C(e), isRequired: e.required, isDisabled: t?.["x-disabled"] ?? !1 }; }) ), R = s(() => o.parameters.length > 1); return (e, t) => (m(), i(n(q), { class: "group/params", itemCount: e.parameters.length }, { title: l(() => [ u(f(e.title), 1) ]), actions: l(() => [ p("div", K, [ R.value ? (m(), i(n(y), { key: 0, content: "Clear optional parameters", placement: "left" }, { default: l(() => [ d(n(P), { class: "pr-0.75 pl-1 transition-none", size: "sm", variant: "ghost", onClick: t[0] || (t[0] = h((a) => r("deleteAll"), ["stop"])) }, { default: l(() => [ t[4] || (t[4] = u(" Clear ", -1)), p("span", k, "All " + f(e.title), 1) ]), _: 1 }) ]), _: 1 })) : g("", !0) ]) ]), default: l(() => [ d(x, { class: "flex-1", columns: ["32px", "", ""], data: w.value, environment: e.environment, exampleKey: e.exampleKey, globalRoute: e.globalRoute, invalidParams: e.invalidParams, label: e.label, showAddRowPlaceholder: e.showAddRowPlaceholder, onAddRow: t[1] || (t[1] = (a) => r("add", a)), onDeleteRow: t[2] || (t[2] = (a) => r("delete", { index: a })), onUpdateRow: t[3] || (t[3] = (a, b) => r("update", { index: a, payload: b })) }, null, 8, ["data", "environment", "exampleKey", "globalRoute", "invalidParams", "label", "showAddRowPlaceholder"]) ]), _: 1 }, 8, ["itemCount"])); } }); export { E as default };