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 StoryContextUpdate = Partial<StoryContext>;
|
44 | export declare type StoryContext = StoryIdentifier & {
|
45 | [key: string]: any;
|
46 | parameters: Parameters;
|
47 | args: Args;
|
48 | argTypes: ArgTypes;
|
49 | globals: Args;
|
50 | hooks?: HooksContext;
|
51 | viewMode?: ViewMode;
|
52 | originalStoryFn?: ArgsStoryFn;
|
53 | };
|
54 | export interface WrapperSettings {
|
55 | options: OptionsParameter;
|
56 | parameters: {
|
57 | [key: string]: any;
|
58 | };
|
59 | }
|
60 | export declare type Comparator<T> = ((a: T, b: T) => boolean) | ((a: T, b: T) => number);
|
61 | export declare type StorySortMethod = 'configure' | 'alphabetical';
|
62 | export interface StorySortObjectParameter {
|
63 | method?: StorySortMethod;
|
64 | order?: any[];
|
65 | locales?: string;
|
66 | includeNames?: boolean;
|
67 | }
|
68 | export declare type StorySortComparator = Comparator<[StoryId, any, Parameters, Parameters]>;
|
69 | export declare type StorySortParameter = StorySortComparator | StorySortObjectParameter;
|
70 | export interface OptionsParameter extends Object {
|
71 | storySort?: StorySortParameter;
|
72 | theme?: {
|
73 | base: string;
|
74 | brandTitle?: string;
|
75 | };
|
76 | [key: string]: any;
|
77 | }
|
78 | export declare type StoryGetter = (context: StoryContext) => any;
|
79 | export declare type PartialStoryFn<ReturnType = unknown> = (p?: StoryContextUpdate) => ReturnType;
|
80 | export declare type LegacyStoryFn<ReturnType = unknown> = (p?: StoryContext) => ReturnType;
|
81 | export declare type ArgsStoryFn<ReturnType = unknown> = (a?: Args, p?: StoryContext) => ReturnType;
|
82 | export declare type StoryFn<ReturnType = unknown> = LegacyStoryFn<ReturnType> | ArgsStoryFn<ReturnType>;
|
83 | export declare type StoryWrapper = (getStory: StoryGetter, context: StoryContext, settings: WrapperSettings) => any;
|
84 | export declare type MakeDecoratorResult = (...args: any) => any;
|
85 | export interface AddStoryArgs<StoryFnReturnType = unknown> {
|
86 | id: StoryId;
|
87 | kind: StoryKind;
|
88 | name: StoryName;
|
89 | storyFn: StoryFn<StoryFnReturnType>;
|
90 | parameters: Parameters;
|
91 | }
|
92 | export interface ClientApiAddon<StoryFnReturnType = unknown> extends Addon {
|
93 | apply: (a: StoryApi<StoryFnReturnType>, b: any[]) => any;
|
94 | }
|
95 | export interface ClientApiAddons<StoryFnReturnType> {
|
96 | [key: string]: ClientApiAddon<StoryFnReturnType>;
|
97 | }
|
98 | export declare type ClientApiReturnFn<StoryFnReturnType> = (...args: any[]) => StoryApi<StoryFnReturnType>;
|
99 | export interface StoryApi<StoryFnReturnType = unknown> {
|
100 | kind: StoryKind;
|
101 | add: (storyName: StoryName, storyFn: StoryFn<StoryFnReturnType>, parameters?: Parameters) => StoryApi<StoryFnReturnType>;
|
102 | addDecorator: (decorator: DecoratorFunction<StoryFnReturnType>) => StoryApi<StoryFnReturnType>;
|
103 | addLoader: (decorator: LoaderFunction) => StoryApi<StoryFnReturnType>;
|
104 | addParameters: (parameters: Parameters) => StoryApi<StoryFnReturnType>;
|
105 | [k: string]: string | ClientApiReturnFn<StoryFnReturnType>;
|
106 | }
|
107 | export declare type DecoratorFunction<StoryFnReturnType = unknown> = (fn: PartialStoryFn<StoryFnReturnType>, c: StoryContext) => ReturnType<LegacyStoryFn<StoryFnReturnType>>;
|
108 | export declare type LoaderFunction = (c: StoryContext) => Promise<Record<string, any>>;
|
109 | export declare type DecorateStoryFunction<StoryFnReturnType = unknown> = (storyFn: LegacyStoryFn<StoryFnReturnType>, decorators: DecoratorFunction<StoryFnReturnType>[]) => LegacyStoryFn<StoryFnReturnType>;
|
110 | export interface ClientStoryApi<StoryFnReturnType = unknown> {
|
111 | storiesOf(kind: StoryKind, module: NodeModule): StoryApi<StoryFnReturnType>;
|
112 | addDecorator(decorator: DecoratorFunction<StoryFnReturnType>): StoryApi<StoryFnReturnType>;
|
113 | addParameters(parameter: Parameters): StoryApi<StoryFnReturnType>;
|
114 | }
|
115 | declare type LoadFn = () => any;
|
116 | declare type RequireContext = any;
|
117 | export declare type Loadable = RequireContext | [RequireContext] | LoadFn;
|
118 | export declare type BaseDecorators<StoryFnReturnType> = Array<(story: () => StoryFnReturnType, context: StoryContext) => StoryFnReturnType>;
|
119 | export interface BaseAnnotations<Args, StoryFnReturnType> {
|
120 | |
121 |
|
122 |
|
123 |
|
124 | args?: Partial<Args>;
|
125 | |
126 |
|
127 |
|
128 |
|
129 | argTypes?: ArgTypes;
|
130 | |
131 |
|
132 |
|
133 |
|
134 | parameters?: Parameters;
|
135 | |
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 | decorators?: BaseDecorators<StoryFnReturnType>;
|
142 | }
|
143 | export interface Annotations<Args, StoryFnReturnType> extends BaseAnnotations<Args, StoryFnReturnType> {
|
144 | |
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 | includeStories?: string[] | RegExp;
|
153 | |
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 | excludeStories?: string[] | RegExp;
|
162 | }
|
163 | export interface BaseMeta<ComponentType> {
|
164 | |
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 | title: string;
|
178 | |
179 |
|
180 |
|
181 |
|
182 |
|
183 | component?: ComponentType;
|
184 | |
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 | subcomponents?: Record<string, ComponentType>;
|
200 | }
|
201 | export interface BaseStory<Args, StoryFnReturnType> {
|
202 | (args: Args, context: StoryContext): StoryFnReturnType;
|
203 | |
204 |
|
205 |
|
206 | storyName?: string;
|
207 | }
|
208 | export {};
|