1 | import { ComponentType, ReactNode } from 'react';
|
2 | export type StoryConfig<Props> = {
|
3 | |
4 |
|
5 |
|
6 |
|
7 | sectionProp?: keyof Props;
|
8 | |
9 |
|
10 |
|
11 |
|
12 | maxExamplesPerPage?: number | ((sectionName: string) => number);
|
13 | /**
|
14 | * Specifies the total max number of examples. Default: 500
|
15 | */
|
16 | maxExamples?: number;
|
17 | /**
|
18 | * An object with keys that correspond to the component props. Each key has a
|
19 | * corresponding value array. This array contains possible values for that prop.
|
20 | */
|
21 | propValues?: Partial<Record<keyof Props | string, any[]>>;
|
22 | /**
|
23 | * Prop keys to exclude from propValues. Useful when generating propValues with code.
|
24 | */
|
25 | excludeProps?: (keyof Props)[];
|
26 | /**
|
27 | * The values returned by this function are passed to the component.
|
28 | * A function called with the prop combination for the current example. It
|
29 | * returns an object of props that will be passed into the `renderExample`
|
30 | * function as componentProps.
|
31 | */
|
32 | getComponentProps?: (props: Props & Record<string, any>) => Partial<Props>;
|
33 | |
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | getExampleProps?: (props: Props & Record<string, any>) => Record<string, any>;
|
41 | |
42 |
|
43 |
|
44 |
|
45 |
|
46 | getParameters?: (params: ExamplesPage<Props>) => {
|
47 | [key: string]: any;
|
48 | delay?: number;
|
49 | disable?: boolean;
|
50 | };
|
51 | filter?: (props: Props) => boolean;
|
52 | };
|
53 | type ExampleSection<Props> = {
|
54 | sectionName: string;
|
55 | propName: keyof Props;
|
56 | propValue: string;
|
57 | pages: ExamplesPage<Props>[];
|
58 | };
|
59 | export type ExamplesPage<Props> = {
|
60 | examples: Example<Props>[];
|
61 | index: number;
|
62 | renderExample?: (exampleProps: Example<Props>) => ReactNode;
|
63 | parameters?: Record<string, unknown>;
|
64 | };
|
65 | export type Example<Props> = {
|
66 | Component: ComponentType;
|
67 | componentProps: Partial<Props>;
|
68 | exampleProps: Record<string, any>;
|
69 | key: string;
|
70 | };
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | export declare function generateComponentExamples<Props extends Record<string, any>>(Component: ComponentType<any>, config: StoryConfig<Props>): ExampleSection<Props>[];
|
81 | export default generateComponentExamples;
|
82 |
|
\ | No newline at end of file |