UNPKG

2.96 kBTypeScriptView Raw
1/// <reference types="node" />
2import { HooksContext } from './hooks';
3import { Addon } from './index';
4export declare enum types {
5 TAB = "tab",
6 PANEL = "panel",
7 TOOL = "tool",
8 PREVIEW = "preview",
9 NOTES_ELEMENT = "notes-element"
10}
11export declare type Types = types | string;
12export declare function isSupportedType(type: Types): boolean;
13export interface Parameters {
14 fileName?: string;
15 options?: OptionsParameter;
16 [key: string]: any;
17}
18export interface StoryContext {
19 id: string;
20 name: string;
21 kind: string;
22 [key: string]: any;
23 parameters: Parameters;
24 hooks?: HooksContext;
25}
26export interface WrapperSettings {
27 options: OptionsParameter;
28 parameters: {
29 [key: string]: any;
30 };
31}
32export interface OptionsParameter extends Object {
33 storySort?: any;
34 hierarchyRootSeparator?: string;
35 hierarchySeparator?: RegExp;
36 showRoots?: boolean;
37 theme?: {
38 base: string;
39 brandTitle?: string;
40 };
41 [key: string]: any;
42}
43export declare type StoryGetter = (context: StoryContext) => any;
44export declare type StoryFn<ReturnType = unknown> = (p?: StoryContext) => ReturnType;
45export declare type StoryWrapper = (getStory: StoryGetter, context: StoryContext, settings: WrapperSettings) => any;
46export declare type MakeDecoratorResult = (...args: any) => any;
47export interface AddStoryArgs<StoryFnReturnType = unknown> {
48 id: string;
49 kind: string;
50 name: string;
51 storyFn: StoryFn<StoryFnReturnType>;
52 parameters: Parameters;
53}
54export interface ClientApiAddon<StoryFnReturnType = unknown> extends Addon {
55 apply: (a: StoryApi<StoryFnReturnType>, b: any[]) => any;
56}
57export interface ClientApiAddons<StoryFnReturnType> {
58 [key: string]: ClientApiAddon<StoryFnReturnType>;
59}
60export declare type ClientApiReturnFn<StoryFnReturnType> = (...args: any[]) => StoryApi<StoryFnReturnType>;
61export interface StoryApi<StoryFnReturnType = unknown> {
62 kind: string;
63 add: (storyName: string, storyFn: StoryFn<StoryFnReturnType>, parameters?: Parameters) => StoryApi<StoryFnReturnType>;
64 addDecorator: (decorator: DecoratorFunction<StoryFnReturnType>) => StoryApi<StoryFnReturnType>;
65 addParameters: (parameters: Parameters) => StoryApi<StoryFnReturnType>;
66 [k: string]: string | ClientApiReturnFn<StoryFnReturnType>;
67}
68export declare type DecoratorFunction<StoryFnReturnType = unknown> = (fn: StoryFn<StoryFnReturnType>, c: StoryContext) => ReturnType<StoryFn<StoryFnReturnType>>;
69export interface ClientStoryApi<StoryFnReturnType = unknown> {
70 storiesOf(kind: string, module: NodeModule): StoryApi<StoryFnReturnType>;
71 addDecorator(decorator: DecoratorFunction<StoryFnReturnType>): StoryApi<StoryFnReturnType>;
72 addParameters(parameter: Parameters): StoryApi<StoryFnReturnType>;
73}
74declare type LoadFn = () => any;
75declare type RequireContext = any;
76export declare type Loadable = RequireContext | [RequireContext] | LoadFn;
77export {};