UNPKG

5.67 kBTypeScriptView Raw
1import { Component, FunctionComponent, ReactElement, ReactNode } from 'react';
2import { RouterData } from '@storybook/router';
3import { Listener } from '@storybook/channels';
4import Store, { Options } from './store';
5import type { StoriesHash, Story, Root, Group } from './lib/stories';
6import { isGroup, isRoot, isStory } from './lib/stories';
7import * as provider from './modules/provider';
8import * as addons from './modules/addons';
9import * as channel from './modules/channel';
10import * as notifications from './modules/notifications';
11import * as settings from './modules/settings';
12import * as releaseNotes from './modules/release-notes';
13import * as stories from './modules/stories';
14import * as refs from './modules/refs';
15import * as layout from './modules/layout';
16import * as shortcuts from './modules/shortcuts';
17import * as url from './modules/url';
18import * as version from './modules/versions';
19import * as globals from './modules/globals';
20declare const ActiveTabs: {
21 SIDEBAR: "sidebar";
22 CANVAS: "canvas";
23 ADDONS: "addons";
24};
25export { default as merge } from './lib/merge';
26export type { Options as StoreOptions, Listener as ChannelListener };
27export { ActiveTabs };
28export declare type ModuleArgs = RouterData & ProviderData & {
29 mode?: 'production' | 'development';
30 state: State;
31 fullAPI: API;
32 store: Store;
33};
34export declare type State = layout.SubState & stories.SubState & refs.SubState & notifications.SubState & version.SubState & url.SubState & shortcuts.SubState & releaseNotes.SubState & settings.SubState & globals.SubState & RouterData & Other;
35export declare type API = addons.SubAPI & channel.SubAPI & provider.SubAPI & stories.SubAPI & refs.SubAPI & globals.SubAPI & layout.SubAPI & notifications.SubAPI & shortcuts.SubAPI & releaseNotes.SubAPI & settings.SubAPI & version.SubAPI & url.SubAPI & Other;
36interface Other {
37 [key: string]: any;
38}
39export interface Combo {
40 api: API;
41 state: State;
42}
43interface ProviderData {
44 provider: provider.Provider;
45}
46export declare type ManagerProviderProps = RouterData & ProviderData & {
47 docsMode: boolean;
48 children: ReactNode | ((props: Combo) => ReactNode);
49};
50export declare type StoryId = string;
51export declare type StoryKind = string;
52export interface Args {
53 [key: string]: any;
54}
55export interface ArgType {
56 name?: string;
57 description?: string;
58 defaultValue?: any;
59 [key: string]: any;
60}
61export interface ArgTypes {
62 [key: string]: ArgType;
63}
64export interface Parameters {
65 [key: string]: any;
66}
67export declare const combineParameters: (...parameterSets: Parameters[]) => any;
68export declare type ModuleFn = (m: ModuleArgs) => Module;
69interface Module {
70 init?: () => void;
71 api?: unknown;
72 state?: unknown;
73}
74declare class ManagerProvider extends Component<ManagerProviderProps, State> {
75 api: API;
76 modules: Module[];
77 static displayName: string;
78 constructor(props: ManagerProviderProps);
79 static getDerivedStateFromProps: (props: ManagerProviderProps, state: State) => {
80 location: Partial<Location>;
81 path: string;
82 refId: string;
83 viewMode: string;
84 storyId: string;
85 layout: layout.Layout;
86 ui: layout.UI;
87 selectedPanel: string;
88 theme: import("@storybook/theming").ThemeVars;
89 storiesHash: StoriesHash;
90 storiesConfigured: boolean;
91 storiesFailed?: Error;
92 refs: Record<string, refs.ComposedRef>;
93 notifications: notifications.Notification[];
94 versions: version.Versions & version.UnknownEntries;
95 lastVersionCheck: number;
96 dismissedVersionNotification: string;
97 customQueryParams: url.QueryParams;
98 shortcuts: shortcuts.Shortcuts;
99 releaseNotesViewed: string[];
100 settings: settings.Settings;
101 globals?: import("@storybook/csf").Globals;
102 globalTypes?: import("@storybook/csf").GlobalTypes;
103 navigate: (to: string | number, options?: import("@storybook/router/dist/ts3.9/router").NavigateOptions) => void;
104 singleStory?: boolean;
105 };
106 shouldComponentUpdate(nextProps: ManagerProviderProps, nextState: State): boolean;
107 initModules: () => void;
108 render(): JSX.Element;
109}
110interface ManagerConsumerProps<P = unknown> {
111 filter?: (combo: Combo) => P;
112 children: FunctionComponent<P> | ReactNode;
113}
114declare function ManagerConsumer<P = Combo>({ filter, children, }: ManagerConsumerProps<P>): ReactElement;
115export declare function useStorybookState(): State;
116export declare function useStorybookApi(): API;
117export type { StoriesHash, Story, Root, Group };
118export { ManagerConsumer as Consumer, ManagerProvider as Provider, isGroup, isRoot, isStory };
119export interface EventMap {
120 [eventId: string]: Listener;
121}
122export declare const useChannel: (eventMap: EventMap, deps?: any[]) => (type: string, ...args: any[]) => void;
123export declare function useStoryPrepared(storyId?: StoryId): boolean;
124export declare function useParameter<S>(parameterKey: string, defaultValue?: S): S;
125declare type StateMerger<S> = (input: S) => S;
126export declare function useSharedState<S>(stateId: string, defaultState?: S): [S, (newStateOrMerger: S | StateMerger<S>, options?: Options) => void];
127export declare function useAddonState<S>(addonId: string, defaultState?: S): [S, (newStateOrMerger: S | StateMerger<S>, options?: Options) => void];
128export declare function useArgs(): [Args, (newArgs: Args) => void, (argNames?: string[]) => void];
129export declare function useGlobals(): [Args, (newGlobals: Args) => void];
130export declare function useGlobalTypes(): ArgTypes;
131export declare function useArgTypes(): ArgTypes;