UNPKG

@scalar/api-client

Version:

the open source API testing client

81 lines (80 loc) 2.55 kB
import { defineComponent as p, ref as m, createBlock as v, openBlock as b, withCtx as l, createVNode as r, createTextVNode as _, unref as u } from "vue"; import { ScalarButton as k } from "@scalar/components"; import { LibraryIcon as C } from "@scalar/icons/library"; import { useToasts as V } from "@scalar/use-toasts"; import x from "../IconSelector.vue.js"; import { useActiveEntities as N } from "../../store/active-entities.js"; import B from "./CommandActionForm.vue.js"; import S from "./CommandActionInput.vue.js"; import { useWorkspace as $ } from "../../store/store.js"; const D = /* @__PURE__ */ p({ __name: "CommandPaletteCollection", emits: ["close", "back"], setup(w, { emit: c }) { const n = c, { activeWorkspace: i } = N(), { collectionMutators: d } = $(), o = m(""), a = m("interface-content-folder"), { toast: s } = V(), f = () => { if (!o.value) { s("Please enter a name before creating a collection.", "error"); return; } if (!i.value?.uid) { s("No active workspace found.", "error"); return; } d.add( { openapi: "3.1.0", info: { title: o.value, version: "0.0.1" }, "x-scalar-icon": a.value }, i.value?.uid ), n("close"); }; return (I, e) => (b(), v(B, { disabled: !o.value.trim(), onSubmit: f }, { options: l(() => [ r(x, { modelValue: a.value, "onUpdate:modelValue": e[2] || (e[2] = (t) => a.value = t), placement: "bottom-start" }, { default: l(() => [ r(u(k), { class: "aspect-square h-auto px-0", variant: "outlined" }, { default: l(() => [ r(u(C), { class: "text-c-2 size-4 stroke-[1.75]", src: a.value }, null, 8, ["src"]) ]), _: 1 }) ]), _: 1 }, 8, ["modelValue"]) ]), submit: l(() => [...e[3] || (e[3] = [ _(" Create Collection ", -1) ])]), default: l(() => [ r(S, { modelValue: o.value, "onUpdate:modelValue": e[0] || (e[0] = (t) => o.value = t), label: "Collection Name", placeholder: "Collection Name", onOnDelete: e[1] || (e[1] = (t) => n("back", t)) }, null, 8, ["modelValue"]) ]), _: 1 }, 8, ["disabled"])); } }); export { D as default };