@scalar/api-client
Version:
the open source API testing client
90 lines (89 loc) • 3.65 kB
JavaScript
import { defineComponent as h, createBlock as n, openBlock as a, unref as t, withCtx as o, createVNode as r, createSlots as g, createCommentVNode as _, createElementVNode as s, normalizeStyle as v, createElementBlock as x, Fragment as y, renderList as k, toDisplayString as l, normalizeClass as C } from "vue";
import { Menu as S, MenuButton as b, MenuItems as B, MenuItem as H } from "@headlessui/vue";
import { ScalarFloating as M, ScalarIcon as z, ScalarFloatingBackdrop as I } from "@scalar/components";
import { httpStatusCodes as w } from "@scalar/oas-utils/helpers";
import { formatMs as F } from "../../../../libs/formatters.js";
import { getStatusCodeColor as N } from "./httpStatusCodeColors.js";
import V from "../../../../components/HttpMethod/HttpMethod.vue.js";
const E = { class: "min-w-0" }, q = { class: "text-c-1 min-w-0 truncate" }, O = /* @__PURE__ */ h({
__name: "AddressBarHistory",
props: {
target: {},
history: {}
},
emits: ["selectHistoryItem"],
setup(A, { emit: m }) {
const u = m;
return (i, c) => (a(), n(t(S), { as: "div" }, {
default: o(({ open: p }) => [
r(t(M), {
offset: 0,
resize: "",
target: i.target
}, g({
default: o(() => [
i.history.length ? (a(), n(t(b), {
key: 0,
class: "address-bar-history-button z-context-plus text-c-3 focus:text-c-1 relative mr-1 rounded-lg p-1.5"
}, {
default: o(() => [
r(t(z), {
icon: "History",
size: "sm",
thickness: "2.25"
}),
c[0] || (c[0] = s("span", { class: "sr-only" }, "Request History", -1))
]),
_: 1
})) : _("", !0)
]),
_: 2
}, [
p ? {
name: "floating",
fn: o(({ width: f }) => [
r(t(B), {
class: "custom-scroll grid max-h-[inherit] grid-cols-[44px_1fr_repeat(3,auto)] items-center border-t p-0.75",
static: "",
style: v({ width: f })
}, {
default: o(() => [
(a(!0), x(y, null, k(i.history, (e, d) => (a(), n(t(H), {
key: e.id,
as: "button",
class: "font-code ui-active:*:bg-b-2 text-c-2 contents text-sm font-medium *:flex *:h-8 *:cursor-pointer *:items-center *:rounded-none *:px-1.5 *:first:rounded-l *:last:rounded-r",
value: d,
onClick: (D) => u("selectHistoryItem", { index: d })
}, {
default: o(() => [
r(t(V), {
class: "text-[11px]",
method: e.method
}, null, 8, ["method"]),
s("div", E, [
s("div", q, l(e.path), 1)
]),
s("div", null, l(t(F)(e.duration)), 1),
s("div", {
class: C([t(N)(e.status).color])
}, l(e.status), 3),
s("div", null, l(t(w)[e.status]?.name), 1)
]),
_: 2
}, 1032, ["value", "onClick"]))), 128))
]),
_: 1
}, 8, ["style"]),
r(t(I), { class: "-top-(--scalar-address-bar-height) rounded-lg" })
]),
key: "0"
} : void 0
]), 1032, ["target"])
]),
_: 1
}));
}
});
export {
O as default
};