@scalar/api-reference
Version:
Generate beautiful API references from OpenAPI documents
74 lines (73 loc) • 2.36 kB
JavaScript
import { defineComponent as b, mergeModels as y, useModel as V, computed as l, createBlock as g, createElementBlock as S, openBlock as p, unref as t, withCtx as a, createVNode as r, normalizeClass as m, createElementVNode as f, createTextVNode as C, toDisplayString as v } from "vue";
import { cva as k, ScalarListbox as w, ScalarButton as T } from "@scalar/components";
import { ScalarIconCaretDown as _ } from "@scalar/icons";
import B from "../../../components/ScreenReader.vue.js";
const D = /* @__PURE__ */ b({
__name: "ContentTypeSelect",
props: /* @__PURE__ */ y({
content: {}
}, {
modelValue: { required: !0 },
modelModifiers: {}
}),
emits: ["update:modelValue"],
setup(s) {
const o = V(s, "modelValue"), d = l(() => Object.keys(s.content ?? {})), u = l({
get: () => c.value.find((e) => e.id === o.value),
set: (e) => {
e && (o.value = e.id);
}
}), c = l(() => d.value.map((e) => ({
id: e,
label: e
}))), i = k({
base: "font-normal text-c-2 bg-b-2 py-0.75 flex cursor-pointer items-center gap-1 rounded-full text-xs",
variants: {
dropdown: {
true: "border hover:text-c-1 pl-2 pr-1.5",
false: "px-2"
}
}
});
return (e, n) => d.value.length > 1 ? (p(), g(t(w), {
key: 0,
modelValue: u.value,
"onUpdate:modelValue": n[0] || (n[0] = (x) => u.value = x),
options: c.value,
placement: "bottom-end"
}, {
default: a(() => [
r(t(T), {
class: m(["h-fit", t(i)({ dropdown: !0 })]),
variant: "ghost"
}, {
default: a(() => [
r(B, null, {
default: a(() => n[1] || (n[1] = [
C("Selected Content Type:")
])),
_: 1,
__: [1]
}),
f("span", null, v(o.value), 1),
r(t(_), {
class: "ui-open:rotate-180 size-2.75 transition-transform duration-100",
weight: "bold"
})
]),
_: 1
}, 8, ["class"])
]),
_: 1
}, 8, ["modelValue", "options"])) : (p(), S("div", {
key: 1,
class: m(["selected-content-type", t(i)({ dropdown: !1 })]),
tabindex: "0"
}, [
f("span", null, v(o.value), 1)
], 2));
}
});
export {
D as default
};