UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

52 lines (51 loc) 1.94 kB
import { defineComponent, computed, createElementBlock, createCommentVNode, openBlock, createVNode, unref, withCtx, createElementVNode, toDisplayString } from "vue"; import { ScalarListbox } from "@scalar/components"; import { ScalarIconCaretUpDown } from "@scalar/icons"; const _hoisted_1 = { key: 0, class: "document-selector -mb-1 p-3 pb-0" }; const _hoisted_2 = { class: "group/dropdown-label hover:bg-b-2 text-c-2 flex h-8 w-full cursor-pointer items-center rounded border px-2 py-1.75", type: "button" }; const _hoisted_3 = { class: "text-c-1 overflow-hidden text-base text-ellipsis" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "DocumentSelector", props: { options: {}, modelValue: {} }, emits: ["update:modelValue"], setup(__props, { emit: __emit }) { const props = __props; const emit = __emit; const formattedOptions = computed( () => props.options.map((o) => ({ id: o.id, label: o.label })) ); const selected = computed( () => formattedOptions.value.find((o) => o.id === props.modelValue) ); return (_ctx, _cache) => { return __props.options.length > 1 ? (openBlock(), createElementBlock("div", _hoisted_1, [ createVNode(unref(ScalarListbox), { modelValue: selected.value, options: formattedOptions.value, resize: "", "onUpdate:modelValue": _cache[0] || (_cache[0] = (e) => emit("update:modelValue", e.id)) }, { default: withCtx(() => [ createElementVNode("button", _hoisted_2, [ createVNode(unref(ScalarIconCaretUpDown), { class: "mr-1 size-4 text-current" }), createElementVNode("span", _hoisted_3, toDisplayString(selected.value?.label || "Select API"), 1) ]) ]), _: 1 }, 8, ["modelValue", "options"]) ])) : createCommentVNode("", true); }; } }); export { _sfc_main as default };