UNPKG

@graphql-hive/laboratory

Version:

67 lines (66 loc) 2.22 kB
import { LaboratoryEnv } from './env'; import { LaboratoryHistoryRequest } from './history'; import { LaboratoryOperation } from './operations'; import { LaboratoryPreflight } from './preflight'; import { LaboratoryTest } from './tests'; export interface LaboratoryTabOperation { id: string; type: "operation"; data: Pick<LaboratoryOperation, "id" | "name">; readOnly?: boolean; } export interface LaboratoryTabHistory { id: string; type: "history"; data: Pick<LaboratoryHistoryRequest, "id">; readOnly?: boolean; } export interface LaboratoryTabPreflight { id: string; type: "preflight"; data: LaboratoryPreflight; readOnly?: boolean; } export interface LaboratoryTabEnv { id: string; type: "env"; data: LaboratoryEnv; readOnly?: boolean; } export interface LaboratoryTabTest { id: string; type: "test"; data: Pick<LaboratoryTest, "id" | "name">; readOnly?: boolean; } export interface LaboratoryTabSettings { id: string; type: "settings"; data: unknown; readOnly?: boolean; } export interface LaboratoryTabCustom { id: string; type: string; data: unknown; readOnly?: boolean; } export type LaboratoryTabData = Pick<LaboratoryOperation, "id" | "name"> | Pick<LaboratoryHistoryRequest, "id"> | LaboratoryPreflight | LaboratoryEnv; export type LaboratoryTab = LaboratoryTabOperation | LaboratoryTabPreflight | LaboratoryTabEnv | LaboratoryTabHistory | LaboratoryTabSettings | LaboratoryTabTest | LaboratoryTabCustom; export interface LaboratoryTabsState { tabs: LaboratoryTab[]; } export interface LaboratoryTabsActions { activeTab: LaboratoryTab | null; setActiveTab: (tab: LaboratoryTab) => void; setTabs: (tabs: LaboratoryTab[]) => void; addTab: (tab: Omit<LaboratoryTab, "id">) => LaboratoryTab; updateTab: (id: string, data: LaboratoryTabData) => void; deleteTab: (tabId: string) => void; } export declare const useTabs: (props: { defaultTabs?: LaboratoryTab[] | null; defaultActiveTabId?: string | null; onTabsChange?: (tabs: LaboratoryTab[]) => void; onActiveTabIdChange?: (tabId: string | null) => void; }) => LaboratoryTabsState & LaboratoryTabsActions;