UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

52 lines (51 loc) 2.12 kB
import { defineComponent, useId, createElementBlock, openBlock, normalizeProps, guardReactiveProps, unref, createElementVNode, renderSlot, createVNode, withModifiers, withCtx, createTextVNode } from "vue"; import { useBindCx, ScalarButton } from "@scalar/components"; import { ScalarIconHash } from "@scalar/icons"; import ScreenReader from "../ScreenReader.vue.js"; const _hoisted_1 = ["id"]; const _hoisted_2 = { class: "relative" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "Anchor", emits: ["copyAnchorUrl"], setup(__props, { emit: __emit }) { const emit = __emit; const labelId = useId(); const { cx } = useBindCx(); return (_ctx, _cache) => { return openBlock(), createElementBlock("span", normalizeProps(guardReactiveProps(unref(cx)("group/heading word-break-all relative"))), [ createElementVNode("span", { id: unref(labelId), class: "contents" }, [ renderSlot(_ctx.$slots, "default") ], 8, _hoisted_1), createElementVNode("span", _hoisted_2, [ _cache[2] || (_cache[2] = createElementVNode("span", null, "​", -1)), createVNode(unref(ScalarButton), { "aria-describedby": unref(labelId), 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: _cache[0] || (_cache[0] = withModifiers(() => emit("copyAnchorUrl"), ["stop"])) }, { default: withCtx(() => [ createVNode(unref(ScalarIconHash), { "aria-hidden": "true", class: "size-4.5" }), createVNode(ScreenReader, null, { default: withCtx(() => [..._cache[1] || (_cache[1] = [ createTextVNode("Copy link", -1) ])]), _: 1 }) ]), _: 1 }, 8, ["aria-describedby"]) ]) ], 16); }; } }); export { _sfc_main as default };