@scalar/api-client
Version:
the open source API testing client
59 lines (58 loc) • 2.42 kB
JavaScript
import { defineComponent as f, ref as v, useId as h, watch as w, nextTick as y, onBeforeMount as _, onMounted as k, onBeforeUnmount as C, withDirectives as E, createElementBlock as T, openBlock as x, createElementVNode as r, unref as a, createVNode as d, withCtx as K, vShow as F } from "vue";
import { addScalarClassesToHeadless as M, ScalarTeleportRoot as B } from "@scalar/components";
import { useFocusTrap as P } from "@vueuse/integrations/useFocusTrap";
import { RouterView as S } from "vue-router";
import { useActiveEntities as b } from "../../store/active-entities.js";
import { useWorkspace as A } from "../../store/store.js";
import { handleHotKeyDown as D } from "../../libs/hot-keys.js";
const V = { class: "scalar scalar-app" }, $ = { class: "scalar-container" }, g = ["id"], q = /* @__PURE__ */ f({
__name: "ApiClientModal",
setup(H) {
const { activeWorkspace: m } = b(), { modalState: o, events: n } = A(), l = v(null), s = h(), { activate: u, deactivate: p } = P(l, {
allowOutsideClick: !0,
fallbackFocus: `#${s}`
}), c = (e) => {
var t;
return D(e, n.hotKeys, (t = m.value) == null ? void 0 : t.hotKeyConfig);
};
w(
() => o.open,
(e) => {
e ? (window.addEventListener("keydown", c), document.documentElement.style.overflow = "hidden", u({ checkCanFocusTrap: () => y() })) : (window.removeEventListener("keydown", c), document.documentElement.style.removeProperty("overflow"), p());
}
), _(() => M());
const i = (e) => (e == null ? void 0 : e.closeModal) && o.open && o.hide();
return k(() => n.hotKeys.on(i)), C(() => {
document.documentElement.style.removeProperty("overflow"), n.hotKeys.off(i);
}), (e, t) => E((x(), T("div", V, [
r("div", $, [
r("div", {
id: a(s),
ref_key: "client",
ref: l,
"aria-label": "API Client",
"aria-modal": "true",
class: "scalar-app-layout scalar-client",
role: "dialog",
tabindex: "-1"
}, [
d(a(B), null, {
default: K(() => [
d(a(S), { key: "$route.fullPath" })
]),
_: 1
})
], 8, g),
r("div", {
class: "scalar-app-exit",
onClick: t[0] || (t[0] = (I) => a(o).hide())
})
])
], 512)), [
[F, a(o).open]
]);
}
});
export {
q as default
};