UNPKG

2.46 kBTypeScriptView Raw
1import { DecoratorFunction, Parameters, StoryApi, StoryFn } from "@storybook/addons";
2import { StoryContext } from "@storybook/csf/dist/story";
3import { ComponentType, ReactElement } from "react";
4
5export interface WrapStoryProps {
6 storyFn?: StoryFn | undefined;
7 context?: object | undefined;
8 options?: object | undefined;
9}
10
11export interface TableComponentOptionProps {
12 propDefinitions: Array<{
13 property: string;
14 propType: object | string; // TODO: info about what this object is...
15 required: boolean;
16 description: string;
17 defaultValue: any;
18 }>;
19}
20
21export interface Options {
22 text?: string | undefined;
23 header?: boolean | undefined;
24 inline?: boolean | undefined;
25 source?: boolean | undefined;
26 propTables?: Array<ComponentType<any>> | false | undefined;
27 propTablesExclude?: Array<ComponentType<any>> | undefined;
28 styles?: object | undefined;
29 components?: {
30 [key: string]: ComponentType<any>;
31 } | undefined;
32 /**
33 * @deprecated "marksyConf" option has been renamed to "components"
34 */
35 marksyConf?: object | undefined;
36 maxPropsIntoLine?: number | undefined;
37 maxPropObjectKeys?: number | undefined;
38 maxPropArrayLength?: number | undefined;
39 maxPropStringLength?: number | undefined;
40 TableComponent?: ComponentType<TableComponentOptionProps> | undefined;
41 excludedPropTypes?: string[] | undefined;
42}
43
44export function withInfo<A = unknown>(
45 story: StoryFn<A>,
46 context: StoryContext<{ component: any; storyResult: A }>,
47): ReturnType<DecoratorFunction<A>>;
48
49// Legacy, but supported
50/**
51 * @deprecated withInfo wrapper is deprecated, use the info parameter globally or on each story
52 */
53export function withInfo(
54 textOrOptions?: string | Options,
55): (storyFn: StoryFn) => (context?: object) => ReactElement<WrapStoryProps>;
56
57/**
58 * @deprecated setDefaults is deprecated. Instead, you can pass options into withInfo(options) directly, or use the info parameter.
59 */
60export function setDefaults(newDefaults: Options): Options;
61
62declare module "@storybook/addons" {
63 interface ClientStoryApi<StoryFnReturnType = unknown> {
64 storiesOf(kind: string, module: NodeModule): StoryApi<StoryFnReturnType>;
65 addParameters(parameter: Parameters & { info: Options }): StoryApi<StoryFnReturnType>;
66 addDecorator(decorator: DecoratorFunction<StoryFnReturnType>): StoryApi<StoryFnReturnType>;
67 }
68}