UNPKG

1.47 kBTypeScriptView Raw
1import { ReactElement } from 'react';
2import { Channel } from '@storybook/channels';
3import { API } from '@storybook/api';
4import { Types } from './types';
5export interface RenderOptions {
6 active: boolean;
7 key: string;
8}
9export interface RouteOptions {
10 storyId: string;
11}
12export interface MatchOptions {
13 viewMode: string;
14}
15export interface Addon {
16 title: string;
17 type?: Types;
18 id?: string;
19 route?: (routeOptions: RouteOptions) => string;
20 match?: (matchOptions: MatchOptions) => boolean;
21 render: (renderOptions: RenderOptions) => ReactElement<any>;
22 paramKey?: string;
23}
24export declare type Loader = (api: API) => void;
25export interface Collection {
26 [key: string]: Addon;
27}
28interface Config {
29 [key: string]: any;
30}
31export declare class AddonStore {
32 constructor();
33 private loaders;
34 private elements;
35 private config;
36 private channel;
37 private promise;
38 private resolve;
39 getChannel: () => Channel;
40 ready: () => Promise<Channel>;
41 hasChannel: () => boolean;
42 setChannel: (channel: Channel) => void;
43 getElements: (type: string) => Collection;
44 addPanel: (name: string, options: Addon) => void;
45 add: (name: string, addon: Addon) => void;
46 setConfig: (value: Config) => void;
47 getConfig: () => Config;
48 register: (name: string, registerCallback: (api: API) => void) => void;
49 loadAddons: (api: any) => void;
50}
51export declare const addons: AddonStore;
52export {};