@scalar/api-client
Version:
the open source API testing client
87 lines (86 loc) • 2.98 kB
JavaScript
import { defineComponent as B, computed as f, createBlock as p, openBlock as u, unref as t, withCtx as n, createVNode as d, createElementBlock as D, createTextVNode as s, toDisplayString as m, Fragment as F, renderList as k } from "vue";
import U from "./RequestTableRow.vue.js";
import C from "../../../components/data-table/DataTable.vue.js";
import P from "../../../components/data-table/DataTableRow.vue.js";
import c from "../../../components/data-table/DataTableHeader.vue.js";
const V = /* @__PURE__ */ B({
__name: "RequestTable",
props: {
data: {},
isReadOnly: { type: Boolean },
hasCheckboxDisabled: { type: Boolean },
invalidParams: {},
label: {},
showUploadButton: { type: Boolean },
showAddRowPlaceholder: { type: Boolean, default: !0 },
environment: {}
},
emits: ["addRow", "updateRow", "deleteRow", "uploadFile", "removeFile"],
setup(a, { emit: b }) {
const l = b, w = (e) => {
l("uploadFile", e);
}, h = f(() => a.showUploadButton ? ["36px", "", "", "auto"] : ["36px", "", ""]), R = f(() => {
if (!a.showAddRowPlaceholder)
return a.data;
const e = a.data.at(-1);
return !e || e.name !== "" || e.value !== "" ? [...a.data, { name: "", value: "", isDisabled: !0 }] : a.data;
}), v = ({
index: e,
payload: r
}) => {
if (e >= a.data.length) {
l("addRow", r);
return;
}
l("updateRow", e, r);
};
return (e, r) => (u(), p(t(C), {
class: "group/table flex-1",
columns: h.value
}, {
default: n(() => [
d(t(P), { class: "sr-only !block" }, {
default: n(() => [
d(t(c), null, {
default: n(() => [
s(m(e.label) + " Enabled", 1)
]),
_: 1
}),
d(t(c), null, {
default: n(() => [
s(m(e.label) + " Key", 1)
]),
_: 1
}),
d(t(c), null, {
default: n(() => [
s(m(e.label) + " Value", 1)
]),
_: 1
})
]),
_: 1
}),
(u(!0), D(F, null, k(R.value, (y, o) => (u(), p(U, {
key: o,
data: y,
environment: e.environment,
hasCheckboxDisabled: e.hasCheckboxDisabled,
invalidParams: e.invalidParams,
isReadOnly: e.isReadOnly,
label: e.label,
showUploadButton: e.showUploadButton,
onDeleteRow: (i) => l("deleteRow", o),
onRemoveFile: (i) => l("removeFile", o),
onUpdateRow: (i) => v({ index: o, payload: i }),
onUploadFile: () => w(o)
}, null, 8, ["data", "environment", "hasCheckboxDisabled", "invalidParams", "isReadOnly", "label", "showUploadButton", "onDeleteRow", "onRemoveFile", "onUpdateRow", "onUploadFile"]))), 128))
]),
_: 1
}, 8, ["columns"]));
}
});
export {
V as default
};