UNPKG

@scalar/api-client

Version:

the open source API testing client

130 lines (129 loc) 5.08 kB
import { defineComponent as A, mergeModels as k, computed as p, capitalize as D, useModel as f, createBlock as S, openBlock as m, unref as o, createSlots as P, withCtx as n, createVNode as l, createTextVNode as u, toDisplayString as $, createElementVNode as i, normalizeClass as z, createElementBlock as E, createCommentVNode as w } from "vue"; import { ScalarSidebarItem as M, ScalarButton as y } from "@scalar/components"; import { ScalarIconGlobe as N } from "@scalar/icons"; import V from "../../../../assets/rabbit.ascii.js"; import q from "../../../../assets/rabbitjump.ascii.js"; import W from "../../../../components/ScalarAsciiArt.vue.js"; import { dragHandleFactory as G } from "../../../helpers/drag-handle-factory.js"; import R from "../../../components/sidebar/Sidebar.vue.js"; const j = { key: 0, class: "empty-sidebar-item-content overflow-hidden px-2.5 py-2.5" }, x = { class: "rabbit-ascii relative m-auto mt-2 h-[68px] w-[60px]" }, H = { class: "gap-1.5 p-2" }, Y = /* @__PURE__ */ A({ __name: "AppSidebar", props: /* @__PURE__ */ k({ layout: {}, sidebarState: {}, isWorkspaceOpen: { type: Boolean }, activeWorkspace: {}, workspaces: {}, eventBus: {}, store: {} }, { isSidebarOpen: { type: Boolean, required: !0 }, isSidebarOpenModifiers: {}, sidebarWidth: { required: !0, default: 288 }, sidebarWidthModifiers: {} }), emits: /* @__PURE__ */ k(["open:commandPalette", "click:workspace", "selectItem", "select:workspace", "create:workspace"], ["update:isSidebarOpen", "update:sidebarWidth"]), setup(r, { emit: O }) { const s = O, B = p(() => D(r.activeWorkspace.name)), c = f(r, "isSidebarOpen"), b = f(r, "sidebarWidth"), d = p(() => r.sidebarState.items.value.length <= 1), v = p( () => G({ store: r.store, sidebarState: r.sidebarState }) ), g = (a, e) => v.value.handleDragEnd(a, e), C = (a, e) => v.value.isDroppable(a, e); return (a, e) => (m(), S(o(R), { isDroppable: C, isSidebarOpen: c.value, "onUpdate:isSidebarOpen": e[3] || (e[3] = (t) => c.value = t), sidebarWidth: b.value, "onUpdate:sidebarWidth": e[4] || (e[4] = (t) => b.value = t), activeWorkspace: a.activeWorkspace, documents: Object.values(a.store.workspace.documents), eventBus: a.eventBus, layout: a.layout, sidebarState: a.sidebarState, workspaces: a.workspaces, onCreateWorkspace: e[5] || (e[5] = (t) => s("create:workspace")), "onSelect:workspace": e[6] || (e[6] = (t) => s("select:workspace", t)), onSelectItem: e[7] || (e[7] = (t) => s("selectItem", t)), onReorder: e[8] || (e[8] = (t, I) => g(t, I)) }, P({ workspaceButton: n(() => [ l(o(M), { is: "button", active: a.isWorkspaceOpen, icon: o(N), onClick: e[0] || (e[0] = (t) => s("click:workspace")) }, { default: n(() => [ u($(B.value), 1) ]), _: 1 }, 8, ["active", "icon"]) ]), _: 2 }, [ a.layout !== "modal" ? { name: "footer", fn: n(() => [ i("div", { class: z({ "empty-sidebar-item border-t": d.value }) }, [ d.value ? (m(), E("div", j, [ i("div", x, [ l(W, { art: o(V), class: "rabbitsit font-bold" }, null, 8, ["art"]), l(W, { art: o(q), class: "rabbitjump absolute top-0 left-0 font-bold" }, null, 8, ["art"]) ]), e[9] || (e[9] = i("div", { class: "mt-2 mb-2 text-center text-sm text-balance" }, [ i("b", { class: "font-medium" }, "Let's Get Started"), i("p", { class: "mt-2 leading-3" }, " Create request, folder, collection or import from OpenAPI/Postman ") ], -1)) ])) : w("", !0), i("div", H, [ d.value ? (m(), S(o(y), { key: 0, class: "w-full", size: "sm", onClick: e[1] || (e[1] = (t) => s("open:commandPalette", "import")) }, { default: n(() => [...e[10] || (e[10] = [ u(" Import Collection ", -1) ])]), _: 1 })) : w("", !0), l(o(y), { class: "w-full", hotkey: "K", size: "sm", variant: "outlined", onClick: e[2] || (e[2] = (t) => s("open:commandPalette")) }, { default: n(() => [...e[11] || (e[11] = [ u(" Add Item ", -1) ])]), _: 1 }) ]) ], 2) ]), key: "0" } : void 0 ]), 1032, ["isSidebarOpen", "sidebarWidth", "activeWorkspace", "documents", "eventBus", "layout", "sidebarState", "workspaces"])); } }); export { Y as default };