@scalar/api-reference
Version:
Generate beautiful API references from OpenAPI documents
53 lines (52 loc) • 1.86 kB
JavaScript
import { defineComponent as u, useId as m, createElementBlock as f, openBlock as h, normalizeProps as b, guardReactiveProps as y, unref as e, createElementVNode as t, renderSlot as g, createVNode as a, withModifiers as _, withCtx as s, createTextVNode as C } from "vue";
import { useBindCx as v, ScalarButton as k } from "@scalar/components";
import { ScalarIconHash as x } from "@scalar/icons";
import { useClipboard as S } from "@scalar/use-hooks/useClipboard";
import { useNavState as B } from "../../hooks/useNavState.js";
import N from "../ScreenReader.vue.js";
const w = ["id"], I = { class: "relative" }, T = /* @__PURE__ */ u({
__name: "Anchor",
props: {
id: {}
},
setup(i) {
const r = m(), { cx: n } = v(), { copyToClipboard: l } = S(), { getHashedUrl: d } = B(), p = () => {
l(d(i.id));
};
return (c, o) => (h(), f("span", b(y(e(n)("group/heading word-break-all relative"))), [
t("span", {
id: e(r),
class: "contents"
}, [
g(c.$slots, "default")
], 8, w),
t("span", I, [
o[1] || (o[1] = t("span", null, "", -1)),
a(e(k), {
"aria-describedby": e(r),
class: "absolute top-1/2 left-0 inline-block h-fit -translate-y-1/2 px-1.5 py-1 opacity-0 group-hover/heading:opacity-100 group-has-focus-visible/heading:opacity-100",
variant: "ghost",
onClick: _(p, ["stop"])
}, {
default: s(() => [
a(e(x), {
"aria-hidden": "true",
class: "size-4.5"
}),
a(N, null, {
default: s(() => o[0] || (o[0] = [
C("Copy link")
])),
_: 1,
__: [0]
})
]),
_: 1
}, 8, ["aria-describedby"])
])
], 16));
}
});
export {
T as default
};