UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

104 lines (103 loc) 4.17 kB
import { defineComponent, mergeModels, useModel, computed, createBlock, openBlock, withCtx, createVNode, createElementVNode, unref, createTextVNode } from "vue"; import { ScalarFormSection, ScalarCodeBlock, ScalarFormField } from "@scalar/components"; import { prettyPrintJson } from "@scalar/oas-utils/helpers"; import _sfc_main$3 from "./ApiReferenceToolbarConfigLayout.vue.js"; import _sfc_main$4 from "./ApiReferenceToolbarConfigLayoutOptions.vue.js"; import _sfc_main$2 from "./ApiReferenceToolbarConfigTheme.vue.js"; import _sfc_main$1 from "./ApiReferenceToolbarPopover.vue.js"; const _hoisted_1 = { class: "flex flex-col gap-4" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "ApiReferenceToolbarConfig", props: /* @__PURE__ */ mergeModels({ configuration: {} }, { "overrides": {}, "overridesModifiers": {} }), emits: ["update:overrides"], setup(__props) { const overrides = useModel(__props, "overrides"); const snippet = computed(() => { return prettyPrintJson({ ...overrides.value, // Make sure the overrides are first ...__props.configuration, ...overrides.value // But also that they override the configuration }); }); const theme = computed({ get: () => overrides.value?.theme ?? __props.configuration?.theme ?? "default", set: (t) => overrides.value = { ...overrides.value, theme: t } }); const layout = computed({ get: () => overrides.value?.layout ?? __props.configuration?.layout ?? "modern", set: (l) => overrides.value = { ...overrides.value, layout: l } }); return (_ctx, _cache) => { return openBlock(), createBlock(_sfc_main$1, { class: "w-120" }, { label: withCtx(() => [..._cache[3] || (_cache[3] = [ createTextVNode("Configure", -1) ])]), default: withCtx(() => [ createVNode(unref(ScalarFormSection), null, { label: withCtx(() => [..._cache[4] || (_cache[4] = [ createTextVNode("Scalar Configuration", -1) ])]), default: withCtx(() => [ createVNode(unref(ScalarCodeBlock), { class: "bg-b-1.5 max-h-40 rounded border text-sm", content: snippet.value, lang: "json" }, null, 8, ["content"]) ]), _: 1 }), createElementVNode("div", _hoisted_1, [ createVNode(unref(ScalarFormField), null, { label: withCtx(() => [..._cache[5] || (_cache[5] = [ createTextVNode("Theme", -1) ])]), default: withCtx(() => [ createVNode(_sfc_main$2, { modelValue: theme.value, "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => theme.value = $event) }, null, 8, ["modelValue"]) ]), _: 1 }), createVNode(unref(ScalarFormField), null, { label: withCtx(() => [..._cache[6] || (_cache[6] = [ createTextVNode("Layout", -1) ])]), default: withCtx(() => [ createVNode(_sfc_main$3, { modelValue: layout.value, "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => layout.value = $event) }, null, 8, ["modelValue"]) ]), _: 1 }), createVNode(unref(ScalarFormField), { is: "div" }, { label: withCtx(() => [..._cache[7] || (_cache[7] = [ createTextVNode("Layout Options", -1) ])]), default: withCtx(() => [ createVNode(_sfc_main$4, { modelValue: overrides.value, "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => overrides.value = $event), configuration: __props.configuration }, null, 8, ["modelValue", "configuration"]) ]), _: 1 }) ]) ]), _: 1 }); }; } }); export { _sfc_main as default };