@scalar/api-client
Version:
the open source API testing client
134 lines (133 loc) • 3.13 kB
JavaScript
import { useModal as y } from "@scalar/components";
import { ScalarIconArrowSquareIn as P, ScalarIconPackage as _, ScalarIconFolder as A, ScalarIconArrowUpRight as R, ScalarIconPuzzlePiece as b, ScalarIconBracketsCurly as q, ScalarIconCookie as L, ScalarIconSlidersHorizontal as $ } from "@scalar/icons";
import d from "fuse.js";
import { ref as p, shallowRef as x, computed as o, toValue as a } from "vue";
import z from "../components/CommandPaletteExample.vue.js";
import E from "../components/CommandPaletteImport.vue.js";
import F from "../components/CommandPaletteImportCurl.vue.js";
import O from "../components/CommandPaletteOpenApiDocument.vue.js";
import U from "../components/CommandPaletteRequest.vue.js";
import f from "../components/CommandPaletteTag.vue.js";
const W = (m = T, l = Q) => {
const c = y(), n = p(""), i = x(null), s = p(null), v = o(() => c.open), C = o(
() => new d(a(m), {
keys: ["name"],
threshold: 0.2
})
), g = o(
() => new d(a(l), {
keys: ["name"],
threshold: 0.2
})
), S = o(() => {
const e = n.value.toLowerCase().trim();
return (e ? C.value.search(e).map((t) => t.item) : a(m)).filter((t) => !t.hidden);
}), h = o(() => {
const e = n.value.toLowerCase().trim();
return e ? g.value.search(e).map((r) => r.item) : a(l);
}), w = (e, ...r) => {
e && (i.value = a(m).find((t) => t.id === e) ?? null, s.value = r[0] ?? null), c.show();
}, I = () => {
c.hide(), u();
}, k = (e) => {
n.value = e;
}, u = () => {
n.value = "", i.value = null, s.value = null;
};
return {
isOpen: v,
activeCommand: i,
activeCommandProps: s,
filterQuery: n,
filteredCommands: o(() => [
{
label: "",
commands: S.value
},
{
label: "Pages",
commands: h.value
}
]),
open: w,
close: I,
setFilterQuery: k,
reset: u
};
}, Q = [
{
type: "route",
id: "environment",
name: "Environment",
icon: q,
to: {
name: "workspace.environment"
}
},
{
type: "route",
id: "cookies",
name: "Cookies",
icon: L,
to: {
name: "workspace.cookies"
}
},
{
type: "route",
id: "settings",
name: "Settings",
icon: $,
to: {
name: "workspace.settings"
}
}
], T = [
{
id: "import-from-openapi-swagger-postman-curl",
name: "Import from OpenAPI/Swagger/Postman/cURL",
component: E,
icon: P
},
{
id: "create-openapi-document",
name: "Create OpenAPI Document",
component: O,
icon: _
},
{
id: "add-tag",
name: "Add Tag",
component: f,
icon: A
},
{
id: "create-request",
name: "Create Request",
component: U,
icon: R
},
{
id: "add-example",
name: "Add Example",
component: z,
icon: b
},
{
id: "import-curl-command",
name: "Import cURL Command",
hidden: !0,
component: F
},
{
id: "edit-tag",
name: "Edit Tag",
hidden: !0,
component: f
}
];
export {
T as baseClientActions,
Q as baseRoutes,
W as useCommandPaletteState
};