@scalar/api-client
Version:
the open source API testing client
40 lines • 1.54 kB
TypeScript
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
import { createSidebarState } from '@scalar/sidebar';
import type { WorkspaceStore } from '@scalar/workspace-store/client';
import type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation';
import { type ComputedRef, type Ref } from 'vue';
export type UseAppSidebarReturn = {
handleSelectItem: (id: string) => void;
state: ReturnType<typeof createSidebarState<TraversedEntry>>;
getEntryByLocation: (location: {
document: string;
path?: string;
method?: HttpMethod;
example?: string;
}) => TraversedEntry | undefined;
};
/**
* useSidebarState - Custom hook to manage the sidebar state and navigation logic in the Scalar API client
*
* This composable manages the sidebar structure, synchronizes selection state
* with the current route, and provides a handler for selecting sidebar items.
*
* Example usage:
*
* const { handleSelectItem, sidebarState } = useSidebarState({
* workspaceStore,
* workspaceSlug,
* documentSlug,
* path,
* method,
* exampleName,
* })
*/
export declare const useAppSidebar: ({ workspaceStore, documentSlug, path, method, exampleName, }: {
workspaceStore: Ref<WorkspaceStore | null>;
documentSlug: ComputedRef<string | undefined>;
path: ComputedRef<string | undefined>;
method: ComputedRef<HttpMethod | undefined>;
exampleName: ComputedRef<string | undefined>;
}) => UseAppSidebarReturn;
//# sourceMappingURL=use-app-sidebar.d.ts.map