UNPKG

@scalar/api-client

Version:

the open source API testing client

96 lines (95 loc) 3.89 kB
import { defineComponent as g, createBlock as c, openBlock as l, unref as t, withCtx as s, createVNode as r, createSlots as h, createCommentVNode as v, createElementVNode as n, normalizeStyle as x, createElementBlock as y, Fragment as k, renderList as C, toDisplayString as i, normalizeClass as _ } from "vue"; import { Menu as S, MenuButton as b, MenuItems as B, MenuItem as M } from "@headlessui/vue"; import { ScalarFloating as z, ScalarIcon as H, ScalarFloatingBackdrop as w } from "@scalar/components"; import { httpStatusCodes as F } from "@scalar/oas-utils/helpers"; import { formatMs as I } from "../../../../libs/formatters.js"; import N from "../../../components/layout/ValueEmitter.vue.js"; import { getStatusCodeColor as V } from "./httpStatusCodeColors.js"; import $ from "../../../../components/HttpMethod/HttpMethod.vue.js"; const E = { class: "min-w-0" }, q = { class: "text-c-1 min-w-0 truncate" }, P = /* @__PURE__ */ g({ __name: "AddressBarHistory", props: { target: {}, history: {} }, emits: ["select:history:item", "update:open"], setup(u, { emit: p }) { const m = p; return (A, e) => (l(), c(t(S), { as: "div" }, { default: s(({ open: f }) => [ r(N, { value: f, onChange: e[0] || (e[0] = (a) => m("update:open", a)), onUnmount: e[1] || (e[1] = (a) => m("update:open", !1)) }, null, 8, ["value"]), r(t(z), { offset: 0, resize: "", target: u.target }, h({ default: s(() => [ u.history.length ? (l(), c(t(b), { key: 0, class: "address-bar-history-button text-c-3 focus:text-c-1 relative mr-1 rounded-lg p-1.5" }, { default: s(() => [ r(t(H), { icon: "History", size: "sm", thickness: "2.25" }), e[2] || (e[2] = n("span", { class: "sr-only" }, "Request History", -1)) ]), _: 1 })) : v("", !0) ]), _: 2 }, [ f ? { name: "floating", fn: s(({ width: a }) => [ r(t(B), { class: "custom-scroll grid max-h-[inherit] grid-cols-[44px_1fr_repeat(3,auto)] items-center p-0.75", static: "", style: x({ width: a }) }, { default: s(() => [ (l(!0), y(k, null, C(u.history, (o, d) => (l(), c(t(M), { key: d, 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) => m("select:history:item", { index: d }) }, { default: s(() => [ r(t($), { class: "text-[11px]", method: o.method }, null, 8, ["method"]), n("div", E, [ n("div", q, i(o.path), 1) ]), n("div", null, i(t(I)(o.duration)), 1), n("div", { class: _([t(V)(o.status).color]) }, i(o.status), 3), n("div", null, i(t(F)[o.status]?.name), 1) ]), _: 2 }, 1032, ["value", "onClick"]))), 128)) ]), _: 1 }, 8, ["style"]), r(t(w), { class: "inset-x-px rounded-none rounded-b-lg" }) ]), key: "0" } : void 0 ]), 1032, ["target"]) ]), _: 1 })); } }); export { P as default };