UNPKG

1.68 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}
27interface ToolbarConfig {
28 hidden?: boolean;
29}
30export interface Config {
31 theme?: ThemeVars;
32 toolbar?: {
33 [id: string]: ToolbarConfig;
34 };
35 [key: string]: any;
36}
37export declare class AddonStore {
38 constructor();
39 private loaders;
40 private elements;
41 private config;
42 private channel;
43 private promise;
44 private resolve;
45 getChannel: () => Channel;
46 ready: () => Promise<Channel>;
47 hasChannel: () => boolean;
48 setChannel: (channel: Channel) => void;
49 getElements: (type: Types) => Collection;
50 addPanel: (name: string, options: Addon) => void;
51 add: (name: string, addon: Addon) => void;
52 setConfig: (value: Config) => void;
53 getConfig: () => Config;
54 register: (name: string, registerCallback: (api: API) => void) => void;
55 loadAddons: (api: any) => void;
56}
57export declare const addons: AddonStore;