UNPKG

1.57 kBTypeScriptView Raw
1import { ReactElement } from 'react';
2import { Channel } from '@storybook/channels';
3import { API } from '@storybook/api';
4import { RenderData as RouterData } from '@storybook/router';
5import { ThemeVars } from '@storybook/theming';
6import { Types } from './types';
7export { Channel };
8export interface RenderOptions {
9 active?: boolean;
10 key?: string;
11}
12export interface Addon {
13 title: (() => string) | string;
14 type?: Types;
15 id?: string;
16 route?: (routeOptions: RouterData) => string;
17 match?: (matchOptions: RouterData) => boolean;
18 render: (renderOptions: RenderOptions) => ReactElement<any>;
19 paramKey?: string;
20 disabled?: boolean;
21 hidden?: boolean;
22}
23export declare type Loader = (api: API) => void;
24export interface Collection {
25 [key: string]: Addon;
26}
27export interface Config {
28 theme?: ThemeVars;
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: Types) => 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;