@scalar/api-client
Version:
the open source API testing client
85 lines (84 loc) • 3.38 kB
JavaScript
import { defineComponent as p, computed as d, createElementBlock as s, openBlock as a, withModifiers as y, createCommentVNode as m, createBlock as x, normalizeClass as r, Fragment as g, renderList as k, createElementVNode as u, toDisplayString as w, unref as B, withCtx as C, createVNode as A } from "vue";
import z from "./RequestAuthTab.vue.js";
import N from "../../../components/data-table/DataTable.vue.js";
const O = ["onClick"], T = { class: "relative z-10 font-medium whitespace-nowrap" }, U = {
key: 0,
class: "absolute inset-x-1 bottom-[var(--scalar-border-width)] left-1/2 z-1 h-px w-full -translate-x-1/2 bg-current"
}, E = /* @__PURE__ */ p({
__name: "RequestAuthDataTable",
props: {
environment: {},
isStatic: { type: Boolean },
selectedSchemeOptions: {},
activeAuthIndex: {},
securitySchemes: { default: () => ({}) },
server: {},
eventBus: {},
meta: {}
},
setup(t, { expose: h }) {
const n = d(
() => t.selectedSchemeOptions[t.activeAuthIndex]
), v = d(() => t.selectedSchemeOptions.length > 1), b = (e) => t.eventBus.emit("auth:update:active-index", {
index: e,
meta: t.meta
}), S = (e) => t.eventBus.emit("auth:update:security-scheme", {
payload: e,
name: n.value?.id ?? ""
}), f = (e) => t.eventBus.emit("auth:update:selected-scopes", {
...e,
meta: t.meta
}), c = (e) => t.activeAuthIndex === e;
return h({
activeScheme: n
}), (e, o) => (a(), s("form", {
onSubmit: o[0] || (o[0] = y(() => {
}, ["prevent"]))
}, [
v.value ? (a(), s("div", {
key: 0,
class: r(["box-content flex flex-wrap gap-x-2.5 overflow-hidden border border-b-0 px-3", { "border-x-0": !e.isStatic }]),
"data-testid": "auth-tabs"
}, [
(a(!0), s(g, null, k(e.selectedSchemeOptions, (l, i) => (a(), s("div", {
key: l.id,
class: "relative z-1 -mb-[var(--scalar-border-width)] flex h-8"
}, [
u("button", {
class: r(["floating-bg relative cursor-pointer border-b border-transparent py-1 text-sm font-medium transition-colors", c(i) ? "text-c-1" : "text-c-3"]),
type: "button",
onClick: (I) => b(i)
}, [
u("span", T, w(l.label), 1)
], 10, O),
c(i) ? (a(), s("div", U)) : m("", !0)
]))), 128))
], 2)) : m("", !0),
n.value ? (a(), x(B(N), {
key: 1,
class: r(["flex-1", { "bg-b-1 rounded-b-lg border border-t-0": e.isStatic }]),
columns: [""],
presentational: ""
}, {
default: C(() => [
A(z, {
environment: e.environment,
isStatic: e.isStatic,
securitySchemes: e.securitySchemes,
selectedSecuritySchemas: n.value.value,
server: e.server,
"onUpdate:securityScheme": S,
"onUpdate:selectedScopes": f
}, null, 8, ["environment", "isStatic", "securitySchemes", "selectedSecuritySchemas", "server"])
]),
_: 1
}, 8, ["class"])) : (a(), s("div", {
key: 2,
class: r(["bg-b-1 text-c-3 flex min-h-16 items-center justify-center border-t px-4 text-sm", { "min-h-[calc(4rem+0.5px)] rounded-b-lg border": e.isStatic }])
}, " No authentication selected ", 2))
], 32));
}
});
export {
E as default
};