1 |
|
2 | import { HooksContext } from './hooks';
|
3 | import { Addon } from './index';
|
4 | export declare enum types {
|
5 | TAB = "tab",
|
6 | PANEL = "panel",
|
7 | TOOL = "tool",
|
8 | TOOLEXTRA = "toolextra",
|
9 | PREVIEW = "preview",
|
10 | NOTES_ELEMENT = "notes-element"
|
11 | }
|
12 | export declare type Types = types | string;
|
13 | export declare function isSupportedType(type: Types): boolean;
|
14 | export declare type StoryId = string;
|
15 | export declare type StoryKind = string;
|
16 | export declare type StoryName = string;
|
17 | export declare type ViewMode = 'story' | 'docs';
|
18 | export interface Parameters {
|
19 | fileName?: string;
|
20 | options?: OptionsParameter;
|
21 |
|
22 | layout?: 'centered' | 'fullscreen' | 'padded' | 'none';
|
23 | docsOnly?: boolean;
|
24 | [key: string]: any;
|
25 | }
|
26 | export interface Args {
|
27 | [key: string]: any;
|
28 | }
|
29 | export interface ArgType {
|
30 | name?: string;
|
31 | description?: string;
|
32 | defaultValue?: any;
|
33 | [key: string]: any;
|
34 | }
|
35 | export interface ArgTypes {
|
36 | [key: string]: ArgType;
|
37 | }
|
38 | export interface StoryIdentifier {
|
39 | id: StoryId;
|
40 | kind: StoryKind;
|
41 | name: StoryName;
|
42 | }
|
43 | export declare type StoryContext = StoryIdentifier & {
|
44 | [key: string]: any;
|
45 | parameters: Parameters;
|
46 | args: Args;
|
47 | argTypes: ArgTypes;
|
48 | globals: Args;
|
49 | hooks?: HooksContext;
|
50 | viewMode?: ViewMode;
|
51 | };
|
52 | export interface WrapperSettings {
|
53 | options: OptionsParameter;
|
54 | parameters: {
|
55 | [key: string]: any;
|
56 | };
|
57 | }
|
58 | export declare type Comparator<T> = ((a: T, b: T) => boolean) | ((a: T, b: T) => number);
|
59 | export declare type StorySortMethod = 'configure' | 'alphabetical';
|
60 | export interface StorySortObjectParameter {
|
61 | method?: StorySortMethod;
|
62 | order?: any[];
|
63 | locales?: string;
|
64 | }
|
65 | export declare type StorySortComparator = Comparator<[StoryId, any, Parameters, Parameters]>;
|
66 | export declare type StorySortParameter = StorySortComparator | StorySortObjectParameter;
|
67 | export interface OptionsParameter extends Object {
|
68 | storySort?: StorySortParameter;
|
69 | theme?: {
|
70 | base: string;
|
71 | brandTitle?: string;
|
72 | };
|
73 | [key: string]: any;
|
74 | }
|
75 | export declare type StoryGetter = (context: StoryContext) => any;
|
76 | export declare type LegacyStoryFn<ReturnType = unknown> = (p?: StoryContext) => ReturnType;
|
77 | export declare type ArgsStoryFn<ReturnType = unknown> = (a?: Args, p?: StoryContext) => ReturnType;
|
78 | export declare type StoryFn<ReturnType = unknown> = LegacyStoryFn<ReturnType> | ArgsStoryFn<ReturnType>;
|
79 | export declare type StoryWrapper = (getStory: StoryGetter, context: StoryContext, settings: WrapperSettings) => any;
|
80 | export declare type MakeDecoratorResult = (...args: any) => any;
|
81 | export interface AddStoryArgs<StoryFnReturnType = unknown> {
|
82 | id: StoryId;
|
83 | kind: StoryKind;
|
84 | name: StoryName;
|
85 | storyFn: StoryFn<StoryFnReturnType>;
|
86 | parameters: Parameters;
|
87 | }
|
88 | export interface ClientApiAddon<StoryFnReturnType = unknown> extends Addon {
|
89 | apply: (a: StoryApi<StoryFnReturnType>, b: any[]) => any;
|
90 | }
|
91 | export interface ClientApiAddons<StoryFnReturnType> {
|
92 | [key: string]: ClientApiAddon<StoryFnReturnType>;
|
93 | }
|
94 | export declare type ClientApiReturnFn<StoryFnReturnType> = (...args: any[]) => StoryApi<StoryFnReturnType>;
|
95 | export interface StoryApi<StoryFnReturnType = unknown> {
|
96 | kind: StoryKind;
|
97 | add: (storyName: StoryName, storyFn: StoryFn<StoryFnReturnType>, parameters?: Parameters) => StoryApi<StoryFnReturnType>;
|
98 | addDecorator: (decorator: DecoratorFunction<StoryFnReturnType>) => StoryApi<StoryFnReturnType>;
|
99 | addLoader: (decorator: LoaderFunction) => StoryApi<StoryFnReturnType>;
|
100 | addParameters: (parameters: Parameters) => StoryApi<StoryFnReturnType>;
|
101 | [k: string]: string | ClientApiReturnFn<StoryFnReturnType>;
|
102 | }
|
103 | export declare type DecoratorFunction<StoryFnReturnType = unknown> = (fn: StoryFn<StoryFnReturnType>, c: StoryContext) => ReturnType<StoryFn<StoryFnReturnType>>;
|
104 | export declare type LoaderFunction = (c: StoryContext) => Promise<Record<string, any>>;
|
105 | export declare type DecorateStoryFunction<StoryFnReturnType = unknown> = (storyFn: StoryFn<StoryFnReturnType>, decorators: DecoratorFunction<StoryFnReturnType>[]) => StoryFn<StoryFnReturnType>;
|
106 | export interface ClientStoryApi<StoryFnReturnType = unknown> {
|
107 | storiesOf(kind: StoryKind, module: NodeModule): StoryApi<StoryFnReturnType>;
|
108 | addDecorator(decorator: DecoratorFunction<StoryFnReturnType>): StoryApi<StoryFnReturnType>;
|
109 | addParameters(parameter: Parameters): StoryApi<StoryFnReturnType>;
|
110 | }
|
111 | declare type LoadFn = () => any;
|
112 | declare type RequireContext = any;
|
113 | export declare type Loadable = RequireContext | [RequireContext] | LoadFn;
|
114 | export declare type BaseDecorators<StoryFnReturnType> = Array<(story: () => StoryFnReturnType, context: StoryContext) => StoryFnReturnType>;
|
115 | export interface BaseAnnotations<Args, StoryFnReturnType> {
|
116 | |
117 |
|
118 |
|
119 |
|
120 | args?: Partial<Args>;
|
121 | |
122 |
|
123 |
|
124 |
|
125 | argTypes?: ArgTypes;
|
126 | |
127 |
|
128 |
|
129 |
|
130 | parameters?: Parameters;
|
131 | |
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 | decorators?: BaseDecorators<StoryFnReturnType>;
|
138 | }
|
139 | export interface Annotations<Args, StoryFnReturnType> extends BaseAnnotations<Args, StoryFnReturnType> {
|
140 | |
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 | includeStories?: string[] | RegExp;
|
149 | |
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 | excludeStories?: string[] | RegExp;
|
158 | }
|
159 | export interface BaseMeta<ComponentType> {
|
160 | |
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 | title: string;
|
174 | |
175 |
|
176 |
|
177 |
|
178 |
|
179 | component?: ComponentType;
|
180 | |
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 | subcomponents?: Record<string, ComponentType>;
|
196 | }
|
197 | export interface BaseStory<Args, StoryFnReturnType> {
|
198 | (args: Args, context: StoryContext): StoryFnReturnType;
|
199 | |
200 |
|
201 |
|
202 | storyName?: string;
|
203 | }
|
204 | export {};
|