UNPKG

1.85 kBTypeScriptView Raw
1import { ReactElement } from 'react';
2import { RenderData } from '@storybook/router';
3import { ModuleFn } from '../index';
4import { Options } from '../store';
5export declare type ViewMode = 'story' | 'info' | 'settings' | 'page' | undefined | string;
6export declare enum types {
7 TAB = "tab",
8 PANEL = "panel",
9 TOOL = "tool",
10 PREVIEW = "preview",
11 NOTES_ELEMENT = "notes-element"
12}
13export declare type Types = types | string;
14export interface RenderOptions {
15 active: boolean;
16 key: string;
17}
18export interface RouteOptions {
19 storyId: string;
20 viewMode: ViewMode;
21 location: RenderData['location'];
22 path: string;
23}
24export interface MatchOptions {
25 storyId: string;
26 viewMode: ViewMode;
27 location: RenderData['location'];
28 path: string;
29}
30export interface Addon {
31 title: string;
32 type?: Types;
33 id?: string;
34 route?: (routeOptions: RouteOptions) => string;
35 match?: (matchOptions: MatchOptions) => boolean;
36 render: (renderOptions: RenderOptions) => ReactElement<any>;
37 paramKey?: string;
38 disabled?: boolean;
39 hidden?: boolean;
40}
41export interface Collection<T = Addon> {
42 [key: string]: T;
43}
44declare type Panels = Collection<Addon>;
45declare type StateMerger<S> = (input: S) => S;
46export interface SubAPI {
47 getElements: <T>(type: Types) => Collection<T>;
48 getPanels: () => Panels;
49 getStoryPanels: () => Panels;
50 getSelectedPanel: () => string;
51 setSelectedPanel: (panelName: string) => void;
52 setAddonState<S>(addonId: string, newStateOrMerger: S | StateMerger<S>, options?: Options): Promise<S>;
53 getAddonState<S>(addonId: string): S;
54}
55export declare function ensurePanel(panels: Panels, selectedPanel?: string, currentPanel?: string): string;
56export declare const init: ModuleFn;
57export {};