UNPKG

@scalar/api-client

Version:

the open source API testing client

135 lines (134 loc) 5.08 kB
import { defineComponent as I, computed as d, createBlock as i, openBlock as l, unref as t, withCtx as a, createVNode as n, createElementBlock as k, createCommentVNode as u, createTextVNode as m, resolveDynamicComponent as s, Fragment as D, createElementVNode as b, normalizeClass as f, toDisplayString as $ } from "vue"; import { ScalarContextMenu as B, ScalarFloating as N, ScalarDropdownMenu as O, ScalarDropdownButton as p, ScalarHotkey as v, ScalarDropdownDivider as U, ScalarTooltip as V } from "@scalar/components"; import { isMacOS as q } from "@scalar/helpers/general/is-mac-os"; import { ScalarIconPlusSquare as F, ScalarIconLinkSimple as M, ScalarIconXSquare as E, ScalarIconTabs as L, ScalarIconFolderSimple as P, ScalarIconArrowUpRight as R, ScalarIconX as X } from "@scalar/icons"; const K = /* @__PURE__ */ I({ __name: "DesktopTab", props: { hotkey: {}, active: { type: Boolean }, isSingleTab: { type: Boolean, default: !1 }, tab: {} }, emits: ["click", "close", "newTab", "copyUrl", "closeOtherTabs"], setup(g, { emit: y }) { const r = y, S = { request: R, document: P }, T = d(() => q() ? "⌘" : "^"), C = d( () => g.hotkey ? `${T.value} ${g.hotkey}` : "" ), w = (o) => { o.stopPropagation(), r("close"); }; return (o, e) => (l(), i(t(B), { triggerClass: `overflow-hidden w-full flex-1 select-none ` }, { trigger: a(() => [ (l(), i(s(o.isSingleTab ? "div" : t(V)), { content: C.value, placement: "bottom" }, { default: a(() => [ b("div", { class: f(["app-no-drag-region", [ o.isSingleTab ? "nav-single-tab" : "nav-item", { "nav-item__active": o.active && !o.isSingleTab } ]]), onClick: e[0] || (e[0] = (c) => !o.isSingleTab && r("click")) }, [ b("div", { class: f([ "flex items-center justify-center gap-1.5", o.isSingleTab ? "custom-scroll h-full w-full whitespace-nowrap" : "nav-item-icon-copy flex-1" ]) }, [ o.tab.icon && S[o.tab.icon] ? (l(), i(s(S[o.tab.icon]), { key: 0 })) : u("", !0), b("span", { class: f([ o.isSingleTab ? "" : "custom-scroll nav-item-copy", "text-sm" ]) }, $(o.tab.title), 3) ], 2), o.isSingleTab ? u("", !0) : (l(), k("button", { key: 0, class: "nav-item-close", type: "button", onClick: w }, [ (l(), i(s(t(X)))) ])) ], 2) ]), _: 1 }, 8, ["content"])) ]), content: a(() => [ n(t(N), { placement: "right-start" }, { floating: a(() => [ n(t(O), { class: "scalar-app scalar-client" }, { default: a(() => [ n(t(p), { class: "flex items-center gap-1.5", onClick: e[1] || (e[1] = (c) => r("newTab")) }, { default: a(() => [ (l(), i(s(t(F)))), e[5] || (e[5] = m(" New Tab ", -1)), n(t(v), { class: "bg-b-2 ml-auto", hotkey: "T" }) ]), _: 1 }), n(t(p), { class: "flex items-center gap-1.5", onClick: e[2] || (e[2] = (c) => r("copyUrl")) }, { default: a(() => [ (l(), i(s(t(M)))), e[6] || (e[6] = m(" Copy URL ", -1)) ]), _: 1 }), o.isSingleTab ? u("", !0) : (l(), k(D, { key: 0 }, [ n(t(U)), n(t(p), { class: "flex items-center gap-1.5", onClick: e[3] || (e[3] = (c) => r("close")) }, { default: a(() => [ (l(), i(s(t(E)))), e[7] || (e[7] = m(" Close Tab ", -1)), n(t(v), { class: "bg-b-2 ml-auto", hotkey: "W" }) ]), _: 1 }), n(t(p), { class: "flex items-center gap-1.5", onClick: e[4] || (e[4] = (c) => r("closeOtherTabs")) }, { default: a(() => [ (l(), i(s(t(L)))), e[8] || (e[8] = m(" Close Other Tabs ", -1)) ]), _: 1 }) ], 64)) ]), _: 1 }) ]), _: 1 }) ]), _: 1 })); } }); export { K as default };