UNPKG

2.8 kBTypeScriptView Raw
1import React from 'react';
2import { StoryId, StoryKind, Args, Parameters } from '../index';
3import { Provider } from '../modules/provider';
4import { ViewMode } from '../modules/addons';
5export type { StoryId };
6export interface Root {
7 id: StoryId;
8 depth: 0;
9 name: string;
10 refId?: string;
11 children: StoryId[];
12 isComponent: false;
13 isRoot: true;
14 isLeaf: false;
15 renderLabel?: (item: Root) => React.ReactNode;
16 startCollapsed?: boolean;
17}
18export interface Group {
19 id: StoryId;
20 depth: number;
21 name: string;
22 children: StoryId[];
23 refId?: string;
24 parent?: StoryId;
25 isComponent: boolean;
26 isRoot: false;
27 isLeaf: false;
28 renderLabel?: (item: Group) => React.ReactNode;
29 parameters?: {
30 docsOnly?: boolean;
31 viewMode?: ViewMode;
32 };
33}
34export interface Story {
35 id: StoryId;
36 depth: number;
37 parent: StoryId;
38 name: string;
39 kind: StoryKind;
40 refId?: string;
41 children?: StoryId[];
42 isComponent: boolean;
43 isRoot: false;
44 isLeaf: true;
45 renderLabel?: (item: Story) => React.ReactNode;
46 parameters?: {
47 fileName: string;
48 options: {
49 [optionName: string]: any;
50 };
51 docsOnly?: boolean;
52 viewMode?: ViewMode;
53 [parameterName: string]: any;
54 };
55 args: Args;
56 initialArgs: Args;
57}
58export interface StoryInput {
59 id: StoryId;
60 name: string;
61 refId?: string;
62 kind: StoryKind;
63 children: string[];
64 parameters: {
65 fileName: string;
66 options: {
67 [optionName: string]: any;
68 };
69 docsOnly?: boolean;
70 viewMode?: ViewMode;
71 [parameterName: string]: any;
72 };
73 isLeaf: boolean;
74 args: Args;
75 initialArgs: Args;
76}
77export interface StoriesHash {
78 [id: string]: Root | Group | Story;
79}
80export declare type StoriesList = (Group | Story)[];
81export declare type GroupsList = (Root | Group)[];
82export interface StoriesRaw {
83 [id: string]: StoryInput;
84}
85export declare type SetStoriesPayload = {
86 v: 2;
87 error?: Error;
88 globals: Args;
89 globalParameters: Parameters;
90 stories: StoriesRaw;
91 kindParameters: {
92 [kind: string]: Parameters;
93 };
94} | ({
95 v?: number;
96 stories: StoriesRaw;
97} & Record<string, never>);
98export declare const denormalizeStoryParameters: ({ globalParameters, kindParameters, stories, }: SetStoriesPayload) => StoriesRaw;
99export declare const transformStoriesRawToStoriesHash: (input: StoriesRaw, { provider }: {
100 provider: Provider;
101}) => StoriesHash;
102export declare type Item = StoriesHash[keyof StoriesHash];
103export declare function isRoot(item: Item): item is Root;
104export declare function isGroup(item: Item): item is Group;
105export declare function isStory(item: Item): item is Story;