@storybook/react-native 7.6.9-alpha.0 → 7.6.10-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/V6.d.ts +12 -7
- package/dist/View-0aedc31a.d.ts +58 -0
- package/dist/index.d-cff8c6fa.d.ts +198 -0
- package/dist/index.d.ts +3 -6
- package/dist/preview.d.ts +1 -1
- package/package.json +15 -15
- package/dist/View-63944515.d.ts +0 -111
- package/dist/index.d-c716d0d7.d.ts +0 -638
package/dist/V6.d.ts
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
export { D as Decorator, L as Loadable, e as Loader, M as Meta, g as Preview, P as PreviewError, a as RenderStoryFunction, R as RequireContext, f as StoryContext, c as StoryFn, S as StoryFnReactReturnType, d as StoryObj } from './View-63944515.js';
|
|
2
|
+
import { P as Params } from './View-0aedc31a.js';
|
|
4
3
|
import { ClientApi } from '@storybook/preview-api';
|
|
5
|
-
import {
|
|
6
|
-
export { a as ArgTypes, A as Args, P as Parameters, R as RenderContext, S as StrictArgs } from './index.d-c716d0d7.js';
|
|
4
|
+
import { L as LoaderFunction, A as Addon_StoryApi } from './index.d-cff8c6fa.js';
|
|
7
5
|
import { ReactNode } from 'react';
|
|
6
|
+
import { ReactRenderer } from '@storybook/react';
|
|
8
7
|
export { Theme, darkTheme, theme } from '@storybook/react-native-theming';
|
|
9
8
|
import '@storybook/csf';
|
|
10
9
|
import '@storybook/preview-web';
|
|
11
|
-
import 'type-fest';
|
|
12
10
|
import '@storybook/channels';
|
|
13
11
|
|
|
12
|
+
interface RequireContext {
|
|
13
|
+
keys: () => string[];
|
|
14
|
+
(id: string): any;
|
|
15
|
+
resolve(id: string): string;
|
|
16
|
+
}
|
|
17
|
+
type Loadable = RequireContext | RequireContext[] | LoaderFunction;
|
|
18
|
+
|
|
14
19
|
declare const configure: (loadable: any, m: {
|
|
15
20
|
hot?: {
|
|
16
21
|
accept?: () => void;
|
|
17
22
|
};
|
|
18
23
|
}) => void;
|
|
19
24
|
|
|
20
|
-
type C = ClientApi<
|
|
25
|
+
type C = ClientApi<ReactRenderer>;
|
|
21
26
|
declare const addDecorator: C['addDecorator'];
|
|
22
27
|
declare const addParameters: C['addParameters'];
|
|
23
28
|
declare const addArgsEnhancer: C['addArgsEnhancer'];
|
|
@@ -26,4 +31,4 @@ declare const raw: C['raw'];
|
|
|
26
31
|
declare const storiesOf: (kind: string, m: any) => Addon_StoryApi<ReactNode>;
|
|
27
32
|
declare const getStorybookUI: (params?: Partial<Params>) => () => react_jsx_runtime.JSX.Element;
|
|
28
33
|
|
|
29
|
-
export {
|
|
34
|
+
export { Loadable, RequireContext, addArgTypesEnhancer, addArgsEnhancer, addDecorator, addParameters, configure, getStorybookUI, raw, storiesOf };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { StoryContext } from '@storybook/csf';
|
|
3
|
+
import { PreviewWithSelection } from '@storybook/preview-web';
|
|
4
|
+
import { Theme } from '@storybook/react-native-theming';
|
|
5
|
+
import { S as StoryIndex } from './index.d-cff8c6fa.js';
|
|
6
|
+
import { ReactRenderer } from '@storybook/react';
|
|
7
|
+
import { Channel } from '@storybook/channels';
|
|
8
|
+
|
|
9
|
+
type StoryKind = string;
|
|
10
|
+
type StoryName = string;
|
|
11
|
+
type InitialSelection = `${StoryKind}--${StoryName}` | {
|
|
12
|
+
/**
|
|
13
|
+
* Kind is the default export name or the storiesOf("name") name
|
|
14
|
+
*/
|
|
15
|
+
kind: StoryKind;
|
|
16
|
+
/**
|
|
17
|
+
* Name is the named export or the .add("name") name
|
|
18
|
+
*/
|
|
19
|
+
name: StoryName;
|
|
20
|
+
};
|
|
21
|
+
type DeepPartial<T> = T extends object ? {
|
|
22
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
23
|
+
} : T;
|
|
24
|
+
type Params = {
|
|
25
|
+
onDeviceUI?: boolean;
|
|
26
|
+
enableWebsockets?: boolean;
|
|
27
|
+
query?: string;
|
|
28
|
+
host?: string;
|
|
29
|
+
port?: number;
|
|
30
|
+
secured?: boolean;
|
|
31
|
+
initialSelection?: InitialSelection;
|
|
32
|
+
shouldPersistSelection?: boolean;
|
|
33
|
+
tabOpen?: number;
|
|
34
|
+
isUIHidden?: boolean;
|
|
35
|
+
isSplitPanelVisible?: boolean;
|
|
36
|
+
shouldDisableKeyboardAvoidingView?: boolean;
|
|
37
|
+
keyboardAvoidingViewVerticalOffset?: number;
|
|
38
|
+
theme: DeepPartial<Theme>;
|
|
39
|
+
};
|
|
40
|
+
declare class View {
|
|
41
|
+
_storyIndex: StoryIndex;
|
|
42
|
+
_setStory: (story: StoryContext<ReactRenderer>) => void;
|
|
43
|
+
_forceRerender: () => void;
|
|
44
|
+
_ready: boolean;
|
|
45
|
+
_preview: PreviewWithSelection<ReactRenderer>;
|
|
46
|
+
_asyncStorageStoryId: string;
|
|
47
|
+
_webUrl: string;
|
|
48
|
+
_channel: Channel;
|
|
49
|
+
constructor(preview: PreviewWithSelection<ReactRenderer>, channel: Channel);
|
|
50
|
+
_getInitialStory: ({ initialSelection, shouldPersistSelection, }?: Partial<Params>) => Promise<{
|
|
51
|
+
storySpecifier: string;
|
|
52
|
+
viewMode: string;
|
|
53
|
+
}>;
|
|
54
|
+
_getServerChannel: (params?: Partial<Params>) => Channel;
|
|
55
|
+
getStorybookUI: (params?: Partial<Params>) => () => react_jsx_runtime.JSX.Element;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { Params as P, View as V };
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface SymbolConstructor {
|
|
3
|
+
readonly observable: symbol;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface SBBaseType {
|
|
8
|
+
required?: boolean;
|
|
9
|
+
raw?: string;
|
|
10
|
+
}
|
|
11
|
+
type SBScalarType = SBBaseType & {
|
|
12
|
+
name: 'boolean' | 'string' | 'number' | 'function' | 'symbol';
|
|
13
|
+
};
|
|
14
|
+
type SBArrayType = SBBaseType & {
|
|
15
|
+
name: 'array';
|
|
16
|
+
value: SBType;
|
|
17
|
+
};
|
|
18
|
+
type SBObjectType = SBBaseType & {
|
|
19
|
+
name: 'object';
|
|
20
|
+
value: Record<string, SBType>;
|
|
21
|
+
};
|
|
22
|
+
type SBEnumType = SBBaseType & {
|
|
23
|
+
name: 'enum';
|
|
24
|
+
value: (string | number)[];
|
|
25
|
+
};
|
|
26
|
+
type SBIntersectionType = SBBaseType & {
|
|
27
|
+
name: 'intersection';
|
|
28
|
+
value: SBType[];
|
|
29
|
+
};
|
|
30
|
+
type SBUnionType = SBBaseType & {
|
|
31
|
+
name: 'union';
|
|
32
|
+
value: SBType[];
|
|
33
|
+
};
|
|
34
|
+
type SBOtherType = SBBaseType & {
|
|
35
|
+
name: 'other';
|
|
36
|
+
value: string;
|
|
37
|
+
};
|
|
38
|
+
type SBType = SBScalarType | SBEnumType | SBArrayType | SBObjectType | SBIntersectionType | SBUnionType | SBOtherType;
|
|
39
|
+
|
|
40
|
+
type StoryId = string;
|
|
41
|
+
type ComponentId = string;
|
|
42
|
+
type ComponentTitle = string;
|
|
43
|
+
type StoryName = string;
|
|
44
|
+
/** @deprecated */
|
|
45
|
+
type StoryKind = ComponentTitle;
|
|
46
|
+
type Tag = string;
|
|
47
|
+
interface StoryIdentifier {
|
|
48
|
+
componentId: ComponentId;
|
|
49
|
+
title: ComponentTitle;
|
|
50
|
+
/** @deprecated */
|
|
51
|
+
kind: ComponentTitle;
|
|
52
|
+
id: StoryId;
|
|
53
|
+
name: StoryName;
|
|
54
|
+
/** @deprecated */
|
|
55
|
+
story: StoryName;
|
|
56
|
+
tags: Tag[];
|
|
57
|
+
}
|
|
58
|
+
interface Parameters {
|
|
59
|
+
[name: string]: any;
|
|
60
|
+
}
|
|
61
|
+
type ConditionalTest = {
|
|
62
|
+
truthy?: boolean;
|
|
63
|
+
} | {
|
|
64
|
+
exists: boolean;
|
|
65
|
+
} | {
|
|
66
|
+
eq: any;
|
|
67
|
+
} | {
|
|
68
|
+
neq: any;
|
|
69
|
+
};
|
|
70
|
+
type ConditionalValue = {
|
|
71
|
+
arg: string;
|
|
72
|
+
} | {
|
|
73
|
+
global: string;
|
|
74
|
+
};
|
|
75
|
+
type Conditional = ConditionalValue & ConditionalTest;
|
|
76
|
+
interface InputType {
|
|
77
|
+
name?: string;
|
|
78
|
+
description?: string;
|
|
79
|
+
defaultValue?: any;
|
|
80
|
+
type?: SBType | SBScalarType['name'];
|
|
81
|
+
if?: Conditional;
|
|
82
|
+
[key: string]: any;
|
|
83
|
+
}
|
|
84
|
+
interface StrictInputType extends InputType {
|
|
85
|
+
name: string;
|
|
86
|
+
type?: SBType;
|
|
87
|
+
}
|
|
88
|
+
interface Args {
|
|
89
|
+
[name: string]: any;
|
|
90
|
+
}
|
|
91
|
+
type StrictArgTypes<TArgs = Args> = {
|
|
92
|
+
[name in keyof TArgs]: StrictInputType;
|
|
93
|
+
};
|
|
94
|
+
interface Globals {
|
|
95
|
+
[name: string]: any;
|
|
96
|
+
}
|
|
97
|
+
type Renderer = {
|
|
98
|
+
/** What is the type of the `component` annotation in this renderer? */
|
|
99
|
+
component: unknown;
|
|
100
|
+
/** What does the story function return in this renderer? */
|
|
101
|
+
storyResult: unknown;
|
|
102
|
+
/** What type of element does this renderer render to? */
|
|
103
|
+
canvasElement: unknown;
|
|
104
|
+
T?: unknown;
|
|
105
|
+
};
|
|
106
|
+
interface StoryContextForEnhancers<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryIdentifier {
|
|
107
|
+
component?: (TRenderer & {
|
|
108
|
+
T: any;
|
|
109
|
+
})['component'];
|
|
110
|
+
subcomponents?: Record<string, (TRenderer & {
|
|
111
|
+
T: any;
|
|
112
|
+
})['component']>;
|
|
113
|
+
parameters: Parameters;
|
|
114
|
+
initialArgs: TArgs;
|
|
115
|
+
argTypes: StrictArgTypes<TArgs>;
|
|
116
|
+
}
|
|
117
|
+
interface StoryContextUpdate<TArgs = Args> {
|
|
118
|
+
args?: TArgs;
|
|
119
|
+
globals?: Globals;
|
|
120
|
+
[key: string]: any;
|
|
121
|
+
}
|
|
122
|
+
type ViewMode$1 = 'story' | 'docs';
|
|
123
|
+
interface StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryContextForEnhancers<TRenderer, TArgs>, Required<StoryContextUpdate<TArgs>> {
|
|
124
|
+
hooks: unknown;
|
|
125
|
+
viewMode: ViewMode$1;
|
|
126
|
+
originalStoryFn: StoryFn<TRenderer>;
|
|
127
|
+
}
|
|
128
|
+
type LoaderFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContextForLoaders<TRenderer, TArgs>) => Promise<Record<string, any> | void> | Record<string, any> | void;
|
|
129
|
+
interface StoryContext<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryContextForLoaders<TRenderer, TArgs> {
|
|
130
|
+
loaded: Record<string, any>;
|
|
131
|
+
abortSignal: AbortSignal;
|
|
132
|
+
canvasElement: TRenderer['canvasElement'];
|
|
133
|
+
}
|
|
134
|
+
type PartialStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (update?: StoryContextUpdate<Partial<TArgs>>) => TRenderer['storyResult'];
|
|
135
|
+
type LegacyStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
|
|
136
|
+
type ArgsStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (args: TArgs, context: StoryContext<TRenderer, TArgs>) => (TRenderer & {
|
|
137
|
+
T: TArgs;
|
|
138
|
+
})['storyResult'];
|
|
139
|
+
type StoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = LegacyStoryFn<TRenderer, TArgs> | ArgsStoryFn<TRenderer, TArgs>;
|
|
140
|
+
type DecoratorFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (fn: PartialStoryFn<TRenderer, TArgs>, c: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
|
|
141
|
+
interface StoriesSpecifier {
|
|
142
|
+
/**
|
|
143
|
+
* When auto-titling, what to prefix all generated titles with (default: '')
|
|
144
|
+
*/
|
|
145
|
+
titlePrefix?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Where to start looking for story files
|
|
148
|
+
*/
|
|
149
|
+
directory: string;
|
|
150
|
+
/**
|
|
151
|
+
* What does the filename of a story file look like?
|
|
152
|
+
* (a glob, relative to directory, no leading `./`)
|
|
153
|
+
* If unset, we use `** / *.@(mdx|stories.@(mdx|js|jsx|mjs|ts|tsx))` (no spaces)
|
|
154
|
+
*/
|
|
155
|
+
files?: string;
|
|
156
|
+
}
|
|
157
|
+
type NormalizedStoriesSpecifier = Required<StoriesSpecifier> & {
|
|
158
|
+
importPathMatcher: RegExp;
|
|
159
|
+
};
|
|
160
|
+
interface BaseIndexEntry {
|
|
161
|
+
id: StoryId;
|
|
162
|
+
name: StoryName;
|
|
163
|
+
title: ComponentTitle;
|
|
164
|
+
tags?: Tag[];
|
|
165
|
+
importPath: Path;
|
|
166
|
+
}
|
|
167
|
+
type StoryIndexEntry = BaseIndexEntry & {
|
|
168
|
+
type: 'story';
|
|
169
|
+
};
|
|
170
|
+
type DocsIndexEntry = BaseIndexEntry & {
|
|
171
|
+
storiesImports: Path[];
|
|
172
|
+
type: 'docs';
|
|
173
|
+
};
|
|
174
|
+
type IndexEntry = StoryIndexEntry | DocsIndexEntry;
|
|
175
|
+
interface StoryIndex {
|
|
176
|
+
v: number;
|
|
177
|
+
entries: Record<StoryId, IndexEntry>;
|
|
178
|
+
}
|
|
179
|
+
type Addon_ReturnTypeFramework<ReturnType> = {
|
|
180
|
+
component: any;
|
|
181
|
+
storyResult: ReturnType;
|
|
182
|
+
canvasElement: any;
|
|
183
|
+
};
|
|
184
|
+
type Addon_StoryFn<ReturnType = unknown> = StoryFn<Addon_ReturnTypeFramework<ReturnType>>;
|
|
185
|
+
type Addon_DecoratorFunction<StoryFnReturnType = unknown> = DecoratorFunction<Addon_ReturnTypeFramework<StoryFnReturnType>>;
|
|
186
|
+
type Addon_LoaderFunction = LoaderFunction<Addon_ReturnTypeFramework<unknown>>;
|
|
187
|
+
type Addon_ClientApiReturnFn<StoryFnReturnType = unknown> = (...args: any[]) => Addon_StoryApi<StoryFnReturnType>;
|
|
188
|
+
interface Addon_StoryApi<StoryFnReturnType = unknown> {
|
|
189
|
+
kind: StoryKind;
|
|
190
|
+
add: (storyName: StoryName, storyFn: Addon_StoryFn<StoryFnReturnType>, parameters?: Parameters) => Addon_StoryApi<StoryFnReturnType>;
|
|
191
|
+
addDecorator: (decorator: Addon_DecoratorFunction<StoryFnReturnType>) => Addon_StoryApi<StoryFnReturnType>;
|
|
192
|
+
addLoader: (decorator: Addon_LoaderFunction) => Addon_StoryApi<StoryFnReturnType>;
|
|
193
|
+
addParameters: (parameters: Parameters) => Addon_StoryApi<StoryFnReturnType>;
|
|
194
|
+
[k: string]: string | Addon_ClientApiReturnFn<StoryFnReturnType>;
|
|
195
|
+
}
|
|
196
|
+
type Path = string;
|
|
197
|
+
|
|
198
|
+
export { Addon_StoryApi as A, LoaderFunction as L, NormalizedStoriesSpecifier as N, Renderer as R, StoryIndex as S, StoryContextForEnhancers as a, Args as b, StrictArgTypes as c };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { V as View } from './View-63944515.js';
|
|
2
|
-
export { D as Decorator, L as Loadable, e as Loader, M as Meta, g as Preview, P as PreviewError, b as ReactNativeRenderer, a as RenderStoryFunction, R as RequireContext, f as StoryContext, c as StoryFn, S as StoryFnReactReturnType, d as StoryObj } from './View-63944515.js';
|
|
3
1
|
export { Theme, darkTheme, theme } from '@storybook/react-native-theming';
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { V as View } from './View-0aedc31a.js';
|
|
3
|
+
import { N as NormalizedStoriesSpecifier } from './index.d-cff8c6fa.js';
|
|
6
4
|
import 'react/jsx-runtime';
|
|
7
5
|
import '@storybook/csf';
|
|
8
6
|
import '@storybook/preview-web';
|
|
9
|
-
import 'react';
|
|
10
|
-
import 'type-fest';
|
|
7
|
+
import '@storybook/react';
|
|
11
8
|
import '@storybook/channels';
|
|
12
9
|
|
|
13
10
|
declare function start({ annotations, storyEntries, }: {
|
package/dist/preview.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _storybook_docs_tools from '@storybook/docs-tools';
|
|
2
|
-
import {
|
|
2
|
+
import { R as Renderer, a as StoryContextForEnhancers, b as Args, c as StrictArgTypes } from './index.d-cff8c6fa.js';
|
|
3
3
|
|
|
4
4
|
declare const _default: {
|
|
5
5
|
argTypesEnhancers: (<TRenderer extends Renderer>(context: StoryContextForEnhancers<TRenderer, Args>) => StrictArgTypes<Args>)[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.10-alpha.0",
|
|
4
4
|
"description": "A better way to develop React Native Components for your app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -51,20 +51,20 @@
|
|
|
51
51
|
"preset": "react-native"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@storybook/channel-websocket": "^7.6.
|
|
55
|
-
"@storybook/channels": "^7.6.
|
|
56
|
-
"@storybook/client-logger": "^7.6.
|
|
57
|
-
"@storybook/core-client": "^7.6.
|
|
58
|
-
"@storybook/core-common": "^7.6.
|
|
59
|
-
"@storybook/core-events": "^7.6.
|
|
54
|
+
"@storybook/channel-websocket": "^7.6.10",
|
|
55
|
+
"@storybook/channels": "^7.6.10",
|
|
56
|
+
"@storybook/client-logger": "^7.6.10",
|
|
57
|
+
"@storybook/core-client": "^7.6.10",
|
|
58
|
+
"@storybook/core-common": "^7.6.10",
|
|
59
|
+
"@storybook/core-events": "^7.6.10",
|
|
60
60
|
"@storybook/csf": "^0.1.1",
|
|
61
|
-
"@storybook/docs-tools": "^7.6.
|
|
61
|
+
"@storybook/docs-tools": "^7.6.10",
|
|
62
62
|
"@storybook/global": "^5.0.0",
|
|
63
|
-
"@storybook/manager-api": "^7.6.
|
|
64
|
-
"@storybook/preview-api": "^7.6.
|
|
65
|
-
"@storybook/preview-web": "^7.6.
|
|
66
|
-
"@storybook/react": "^7.6.
|
|
67
|
-
"@storybook/react-native-theming": "^7.6.
|
|
63
|
+
"@storybook/manager-api": "^7.6.10",
|
|
64
|
+
"@storybook/preview-api": "^7.6.10",
|
|
65
|
+
"@storybook/preview-web": "^7.6.10",
|
|
66
|
+
"@storybook/react": "^7.6.10",
|
|
67
|
+
"@storybook/react-native-theming": "^7.6.10-alpha.0",
|
|
68
68
|
"chokidar": "^3.5.1",
|
|
69
69
|
"commander": "^8.2.0",
|
|
70
70
|
"deepmerge": "^4.3.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"util": "^0.12.4"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@storybook/types": "^7.6.
|
|
78
|
+
"@storybook/types": "^7.6.10",
|
|
79
79
|
"@types/jest": "^29.4.3",
|
|
80
80
|
"@types/react": "~18.2.14",
|
|
81
81
|
"babel-jest": "^29.4.3",
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"publishConfig": {
|
|
99
99
|
"access": "public"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "d48243ffb345570962154e0bdf610e3699202bed"
|
|
102
102
|
}
|
package/dist/View-63944515.d.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { Renderer, StoryContext as StoryContext$2 } from '@storybook/csf';
|
|
3
|
-
import { PreviewWithSelection } from '@storybook/preview-web';
|
|
4
|
-
import { Theme } from '@storybook/react-native-theming';
|
|
5
|
-
import { L as LoaderFunction, R as RenderContext, A as Args, C as ComponentAnnotations, c as AnnotatedStoryFn, d as ArgsStoryFn, e as ArgsFromMeta, f as StoryAnnotations, S as StrictArgs, D as DecoratorFunction, g as StoryContext$1, h as ProjectAnnotations, i as StoryIndex } from './index.d-c716d0d7.js';
|
|
6
|
-
import { ComponentType, ComponentProps } from 'react';
|
|
7
|
-
import { Simplify, SetOptional } from 'type-fest';
|
|
8
|
-
import { Channel } from '@storybook/channels';
|
|
9
|
-
|
|
10
|
-
interface PreviewError {
|
|
11
|
-
message?: string;
|
|
12
|
-
stack?: string;
|
|
13
|
-
}
|
|
14
|
-
interface RequireContext {
|
|
15
|
-
keys: () => string[];
|
|
16
|
-
(id: string): any;
|
|
17
|
-
resolve(id: string): string;
|
|
18
|
-
}
|
|
19
|
-
type Loadable = RequireContext | RequireContext[] | LoaderFunction;
|
|
20
|
-
|
|
21
|
-
type RenderStoryFunction = (context: RenderContext) => void;
|
|
22
|
-
type StoryFnReactReturnType = JSX.Element;
|
|
23
|
-
interface ReactNativeRenderer extends Renderer {
|
|
24
|
-
component: ComponentType<any>;
|
|
25
|
-
storyResult: StoryFnReactReturnType;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Metadata to configure the stories for a component.
|
|
30
|
-
*
|
|
31
|
-
* @see [Default export](https://storybook.js.org/docs/formats/component-story-format/#default-export)
|
|
32
|
-
*/
|
|
33
|
-
type Meta<TCmpOrArgs = Args> = [TCmpOrArgs] extends [ComponentType<any>] ? ComponentAnnotations<ReactNativeRenderer, ComponentProps<TCmpOrArgs>> : ComponentAnnotations<ReactNativeRenderer, TCmpOrArgs>;
|
|
34
|
-
/**
|
|
35
|
-
* Story function that represents a CSFv2 component example.
|
|
36
|
-
*
|
|
37
|
-
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
|
|
38
|
-
*/
|
|
39
|
-
type StoryFn<TCmpOrArgs = Args> = [TCmpOrArgs] extends [ComponentType<any>] ? AnnotatedStoryFn<ReactNativeRenderer, ComponentProps<TCmpOrArgs>> : AnnotatedStoryFn<ReactNativeRenderer, TCmpOrArgs>;
|
|
40
|
-
/**
|
|
41
|
-
* Story object that represents a CSFv3 component example.
|
|
42
|
-
*
|
|
43
|
-
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
|
|
44
|
-
*/
|
|
45
|
-
type StoryObj<TMetaOrCmpOrArgs = Args> = [TMetaOrCmpOrArgs] extends [
|
|
46
|
-
{
|
|
47
|
-
render?: ArgsStoryFn<ReactNativeRenderer, any>;
|
|
48
|
-
component?: infer Component;
|
|
49
|
-
args?: infer DefaultArgs;
|
|
50
|
-
}
|
|
51
|
-
] ? Simplify<(Component extends ComponentType<any> ? ComponentProps<Component> : unknown) & ArgsFromMeta<ReactNativeRenderer, TMetaOrCmpOrArgs>> extends infer TArgs ? StoryAnnotations<ReactNativeRenderer, AddMocks<TArgs, DefaultArgs>, SetOptional<TArgs, keyof TArgs & keyof DefaultArgs>> : never : TMetaOrCmpOrArgs extends ComponentType<any> ? StoryAnnotations<ReactNativeRenderer, ComponentProps<TMetaOrCmpOrArgs>> : StoryAnnotations<ReactNativeRenderer, TMetaOrCmpOrArgs>;
|
|
52
|
-
type AddMocks<TArgs, DefaultArgs> = Simplify<{
|
|
53
|
-
[T in keyof TArgs]: T extends keyof DefaultArgs ? DefaultArgs[T] extends (...args: any) => any & {
|
|
54
|
-
mock: {};
|
|
55
|
-
} ? DefaultArgs[T] : TArgs[T] : TArgs[T];
|
|
56
|
-
}>;
|
|
57
|
-
type Decorator<TArgs = StrictArgs> = DecoratorFunction<ReactNativeRenderer, TArgs>;
|
|
58
|
-
type Loader<TArgs = StrictArgs> = LoaderFunction<ReactNativeRenderer, TArgs>;
|
|
59
|
-
type StoryContext<TArgs = StrictArgs> = StoryContext$1<ReactNativeRenderer, TArgs>;
|
|
60
|
-
type Preview = ProjectAnnotations<ReactNativeRenderer>;
|
|
61
|
-
|
|
62
|
-
type StoryKind = string;
|
|
63
|
-
type StoryName = string;
|
|
64
|
-
type InitialSelection = `${StoryKind}--${StoryName}` | {
|
|
65
|
-
/**
|
|
66
|
-
* Kind is the default export name or the storiesOf("name") name
|
|
67
|
-
*/
|
|
68
|
-
kind: StoryKind;
|
|
69
|
-
/**
|
|
70
|
-
* Name is the named export or the .add("name") name
|
|
71
|
-
*/
|
|
72
|
-
name: StoryName;
|
|
73
|
-
};
|
|
74
|
-
type DeepPartial<T> = T extends object ? {
|
|
75
|
-
[P in keyof T]?: DeepPartial<T[P]>;
|
|
76
|
-
} : T;
|
|
77
|
-
type Params = {
|
|
78
|
-
onDeviceUI?: boolean;
|
|
79
|
-
enableWebsockets?: boolean;
|
|
80
|
-
query?: string;
|
|
81
|
-
host?: string;
|
|
82
|
-
port?: number;
|
|
83
|
-
secured?: boolean;
|
|
84
|
-
initialSelection?: InitialSelection;
|
|
85
|
-
shouldPersistSelection?: boolean;
|
|
86
|
-
tabOpen?: number;
|
|
87
|
-
isUIHidden?: boolean;
|
|
88
|
-
isSplitPanelVisible?: boolean;
|
|
89
|
-
shouldDisableKeyboardAvoidingView?: boolean;
|
|
90
|
-
keyboardAvoidingViewVerticalOffset?: number;
|
|
91
|
-
theme: DeepPartial<Theme>;
|
|
92
|
-
};
|
|
93
|
-
declare class View {
|
|
94
|
-
_storyIndex: StoryIndex;
|
|
95
|
-
_setStory: (story: StoryContext$2<ReactNativeRenderer>) => void;
|
|
96
|
-
_forceRerender: () => void;
|
|
97
|
-
_ready: boolean;
|
|
98
|
-
_preview: PreviewWithSelection<ReactNativeRenderer>;
|
|
99
|
-
_asyncStorageStoryId: string;
|
|
100
|
-
_webUrl: string;
|
|
101
|
-
_channel: Channel;
|
|
102
|
-
constructor(preview: PreviewWithSelection<ReactNativeRenderer>, channel: Channel);
|
|
103
|
-
_getInitialStory: ({ initialSelection, shouldPersistSelection, }?: Partial<Params>) => Promise<{
|
|
104
|
-
storySpecifier: string;
|
|
105
|
-
viewMode: string;
|
|
106
|
-
}>;
|
|
107
|
-
_getServerChannel: (params?: Partial<Params>) => Channel;
|
|
108
|
-
getStorybookUI: (params?: Partial<Params>) => () => react_jsx_runtime.JSX.Element;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export { Decorator as D, Loadable as L, Meta as M, PreviewError as P, RequireContext as R, StoryFnReactReturnType as S, View as V, RenderStoryFunction as a, ReactNativeRenderer as b, StoryFn as c, StoryObj as d, Loader as e, StoryContext as f, Preview as g, Params as h };
|
|
@@ -1,638 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
interface SymbolConstructor {
|
|
3
|
-
readonly observable: symbol;
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
@see Simplify
|
|
9
|
-
*/
|
|
10
|
-
interface SimplifyOptions {
|
|
11
|
-
/**
|
|
12
|
-
Do the simplification recursively.
|
|
13
|
-
|
|
14
|
-
@default false
|
|
15
|
-
*/
|
|
16
|
-
deep?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Flatten a type without worrying about the result.
|
|
20
|
-
type Flatten<
|
|
21
|
-
AnyType,
|
|
22
|
-
Options extends SimplifyOptions = {},
|
|
23
|
-
> = Options['deep'] extends true
|
|
24
|
-
? {[KeyType in keyof AnyType]: Simplify<AnyType[KeyType], Options>}
|
|
25
|
-
: {[KeyType in keyof AnyType]: AnyType[KeyType]};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
29
|
-
|
|
30
|
-
@example
|
|
31
|
-
```
|
|
32
|
-
import type {Simplify} from 'type-fest';
|
|
33
|
-
|
|
34
|
-
type PositionProps = {
|
|
35
|
-
top: number;
|
|
36
|
-
left: number;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
type SizeProps = {
|
|
40
|
-
width: number;
|
|
41
|
-
height: number;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
45
|
-
type Props = Simplify<PositionProps & SizeProps>;
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
49
|
-
|
|
50
|
-
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
51
|
-
|
|
52
|
-
@example
|
|
53
|
-
```
|
|
54
|
-
import type {Simplify} from 'type-fest';
|
|
55
|
-
|
|
56
|
-
interface SomeInterface {
|
|
57
|
-
foo: number;
|
|
58
|
-
bar?: string;
|
|
59
|
-
baz: number | undefined;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
type SomeType = {
|
|
63
|
-
foo: number;
|
|
64
|
-
bar?: string;
|
|
65
|
-
baz: number | undefined;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
69
|
-
const someType: SomeType = literal;
|
|
70
|
-
const someInterface: SomeInterface = literal;
|
|
71
|
-
|
|
72
|
-
function fn(object: Record<string, unknown>): void {}
|
|
73
|
-
|
|
74
|
-
fn(literal); // Good: literal object type is sealed
|
|
75
|
-
fn(someType); // Good: type is sealed
|
|
76
|
-
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
77
|
-
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
81
|
-
|
|
82
|
-
@category Object
|
|
83
|
-
*/
|
|
84
|
-
type Simplify<
|
|
85
|
-
AnyType,
|
|
86
|
-
Options extends SimplifyOptions = {},
|
|
87
|
-
> = Flatten<AnyType> extends AnyType
|
|
88
|
-
? Flatten<AnyType, Options>
|
|
89
|
-
: AnyType;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
Remove any index signatures from the given object type, so that only explicitly defined properties remain.
|
|
93
|
-
|
|
94
|
-
Use-cases:
|
|
95
|
-
- Remove overly permissive signatures from third-party types.
|
|
96
|
-
|
|
97
|
-
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
98
|
-
|
|
99
|
-
It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
|
|
100
|
-
|
|
101
|
-
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
102
|
-
|
|
103
|
-
```
|
|
104
|
-
const indexed: Record<string, unknown> = {}; // Allowed
|
|
105
|
-
|
|
106
|
-
const keyed: Record<'foo', unknown> = {}; // Error
|
|
107
|
-
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
|
111
|
-
|
|
112
|
-
```
|
|
113
|
-
type Indexed = {} extends Record<string, unknown>
|
|
114
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
115
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
116
|
-
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
117
|
-
|
|
118
|
-
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
119
|
-
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
120
|
-
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
121
|
-
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
import type {RemoveIndexSignature} from 'type-fest';
|
|
128
|
-
|
|
129
|
-
type RemoveIndexSignature<ObjectType> = {
|
|
130
|
-
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
131
|
-
]: ObjectType[KeyType]; // ...to its original value, i.e. `RemoveIndexSignature<Foo> == Foo`.
|
|
132
|
-
};
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
136
|
-
|
|
137
|
-
```
|
|
138
|
-
import type {RemoveIndexSignature} from 'type-fest';
|
|
139
|
-
|
|
140
|
-
type RemoveIndexSignature<ObjectType> = {
|
|
141
|
-
[KeyType in keyof ObjectType
|
|
142
|
-
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
143
|
-
as {} extends Record<KeyType, unknown>
|
|
144
|
-
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
145
|
-
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
146
|
-
]: ObjectType[KeyType];
|
|
147
|
-
};
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
|
|
151
|
-
|
|
152
|
-
```
|
|
153
|
-
import type {RemoveIndexSignature} from 'type-fest';
|
|
154
|
-
|
|
155
|
-
type RemoveIndexSignature<ObjectType> = {
|
|
156
|
-
[KeyType in keyof ObjectType
|
|
157
|
-
as {} extends Record<KeyType, unknown>
|
|
158
|
-
? never // => Remove this `KeyType`.
|
|
159
|
-
: KeyType // => Keep this `KeyType` as it is.
|
|
160
|
-
]: ObjectType[KeyType];
|
|
161
|
-
};
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
@example
|
|
165
|
-
```
|
|
166
|
-
import type {RemoveIndexSignature} from 'type-fest';
|
|
167
|
-
|
|
168
|
-
interface Example {
|
|
169
|
-
// These index signatures will be removed.
|
|
170
|
-
[x: string]: any
|
|
171
|
-
[x: number]: any
|
|
172
|
-
[x: symbol]: any
|
|
173
|
-
[x: `head-${string}`]: string
|
|
174
|
-
[x: `${string}-tail`]: string
|
|
175
|
-
[x: `head-${string}-tail`]: string
|
|
176
|
-
[x: `${bigint}`]: string
|
|
177
|
-
[x: `embedded-${number}`]: string
|
|
178
|
-
|
|
179
|
-
// These explicitly defined keys will remain.
|
|
180
|
-
foo: 'bar';
|
|
181
|
-
qux?: 'baz';
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
type ExampleWithoutIndexSignatures = RemoveIndexSignature<Example>;
|
|
185
|
-
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
@category Object
|
|
189
|
-
*/
|
|
190
|
-
type RemoveIndexSignature<ObjectType> = {
|
|
191
|
-
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|
192
|
-
? never
|
|
193
|
-
: KeyType]: ObjectType[KeyType];
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
198
|
-
|
|
199
|
-
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
|
|
200
|
-
|
|
201
|
-
@example
|
|
202
|
-
```
|
|
203
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
204
|
-
|
|
205
|
-
type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
|
|
206
|
-
|
|
207
|
-
type Intersection = UnionToIntersection<Union>;
|
|
208
|
-
//=> {the(): void; great(arg: string): void; escape: boolean};
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
A more applicable example which could make its way into your library code follows.
|
|
212
|
-
|
|
213
|
-
@example
|
|
214
|
-
```
|
|
215
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
216
|
-
|
|
217
|
-
class CommandOne {
|
|
218
|
-
commands: {
|
|
219
|
-
a1: () => undefined,
|
|
220
|
-
b1: () => undefined,
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
class CommandTwo {
|
|
225
|
-
commands: {
|
|
226
|
-
a2: (argA: string) => undefined,
|
|
227
|
-
b2: (argB: string) => undefined,
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
|
|
232
|
-
type Union = typeof union;
|
|
233
|
-
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
234
|
-
|
|
235
|
-
type Intersection = UnionToIntersection<Union>;
|
|
236
|
-
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
@category Type
|
|
240
|
-
*/
|
|
241
|
-
type UnionToIntersection<Union> = (
|
|
242
|
-
// `extends unknown` is always going to be the case and is used to convert the
|
|
243
|
-
// `Union` into a [distributive conditional
|
|
244
|
-
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
245
|
-
Union extends unknown
|
|
246
|
-
// The union type is used as the only argument to a function since the union
|
|
247
|
-
// of function arguments is an intersection.
|
|
248
|
-
? (distributedUnion: Union) => void
|
|
249
|
-
// This won't happen.
|
|
250
|
-
: never
|
|
251
|
-
// Infer the `Intersection` type since TypeScript represents the positional
|
|
252
|
-
// arguments of unions of functions as an intersection of the union.
|
|
253
|
-
) extends ((mergedIntersection: infer Intersection) => void)
|
|
254
|
-
? Intersection
|
|
255
|
-
: never;
|
|
256
|
-
|
|
257
|
-
interface SBBaseType {
|
|
258
|
-
required?: boolean;
|
|
259
|
-
raw?: string;
|
|
260
|
-
}
|
|
261
|
-
type SBScalarType = SBBaseType & {
|
|
262
|
-
name: 'boolean' | 'string' | 'number' | 'function' | 'symbol';
|
|
263
|
-
};
|
|
264
|
-
type SBArrayType = SBBaseType & {
|
|
265
|
-
name: 'array';
|
|
266
|
-
value: SBType;
|
|
267
|
-
};
|
|
268
|
-
type SBObjectType = SBBaseType & {
|
|
269
|
-
name: 'object';
|
|
270
|
-
value: Record<string, SBType>;
|
|
271
|
-
};
|
|
272
|
-
type SBEnumType = SBBaseType & {
|
|
273
|
-
name: 'enum';
|
|
274
|
-
value: (string | number)[];
|
|
275
|
-
};
|
|
276
|
-
type SBIntersectionType = SBBaseType & {
|
|
277
|
-
name: 'intersection';
|
|
278
|
-
value: SBType[];
|
|
279
|
-
};
|
|
280
|
-
type SBUnionType = SBBaseType & {
|
|
281
|
-
name: 'union';
|
|
282
|
-
value: SBType[];
|
|
283
|
-
};
|
|
284
|
-
type SBOtherType = SBBaseType & {
|
|
285
|
-
name: 'other';
|
|
286
|
-
value: string;
|
|
287
|
-
};
|
|
288
|
-
type SBType = SBScalarType | SBEnumType | SBArrayType | SBObjectType | SBIntersectionType | SBUnionType | SBOtherType;
|
|
289
|
-
|
|
290
|
-
type StoryId = string;
|
|
291
|
-
type ComponentId = string;
|
|
292
|
-
type ComponentTitle = string;
|
|
293
|
-
type StoryName = string;
|
|
294
|
-
/** @deprecated */
|
|
295
|
-
type StoryKind = ComponentTitle;
|
|
296
|
-
type Tag = string;
|
|
297
|
-
interface StoryIdentifier {
|
|
298
|
-
componentId: ComponentId;
|
|
299
|
-
title: ComponentTitle;
|
|
300
|
-
/** @deprecated */
|
|
301
|
-
kind: ComponentTitle;
|
|
302
|
-
id: StoryId;
|
|
303
|
-
name: StoryName;
|
|
304
|
-
/** @deprecated */
|
|
305
|
-
story: StoryName;
|
|
306
|
-
tags: Tag[];
|
|
307
|
-
}
|
|
308
|
-
interface Parameters {
|
|
309
|
-
[name: string]: any;
|
|
310
|
-
}
|
|
311
|
-
type ConditionalTest = {
|
|
312
|
-
truthy?: boolean;
|
|
313
|
-
} | {
|
|
314
|
-
exists: boolean;
|
|
315
|
-
} | {
|
|
316
|
-
eq: any;
|
|
317
|
-
} | {
|
|
318
|
-
neq: any;
|
|
319
|
-
};
|
|
320
|
-
type ConditionalValue = {
|
|
321
|
-
arg: string;
|
|
322
|
-
} | {
|
|
323
|
-
global: string;
|
|
324
|
-
};
|
|
325
|
-
type Conditional = ConditionalValue & ConditionalTest;
|
|
326
|
-
interface InputType {
|
|
327
|
-
name?: string;
|
|
328
|
-
description?: string;
|
|
329
|
-
defaultValue?: any;
|
|
330
|
-
type?: SBType | SBScalarType['name'];
|
|
331
|
-
if?: Conditional;
|
|
332
|
-
[key: string]: any;
|
|
333
|
-
}
|
|
334
|
-
interface StrictInputType extends InputType {
|
|
335
|
-
name: string;
|
|
336
|
-
type?: SBType;
|
|
337
|
-
}
|
|
338
|
-
interface Args {
|
|
339
|
-
[name: string]: any;
|
|
340
|
-
}
|
|
341
|
-
interface StrictArgs {
|
|
342
|
-
[name: string]: unknown;
|
|
343
|
-
}
|
|
344
|
-
type ArgTypes<TArgs = Args> = {
|
|
345
|
-
[name in keyof TArgs]: InputType;
|
|
346
|
-
};
|
|
347
|
-
type StrictArgTypes<TArgs = Args> = {
|
|
348
|
-
[name in keyof TArgs]: StrictInputType;
|
|
349
|
-
};
|
|
350
|
-
interface Globals {
|
|
351
|
-
[name: string]: any;
|
|
352
|
-
}
|
|
353
|
-
interface GlobalTypes {
|
|
354
|
-
[name: string]: InputType;
|
|
355
|
-
}
|
|
356
|
-
type Renderer = {
|
|
357
|
-
/** What is the type of the `component` annotation in this renderer? */
|
|
358
|
-
component: unknown;
|
|
359
|
-
/** What does the story function return in this renderer? */
|
|
360
|
-
storyResult: unknown;
|
|
361
|
-
/** What type of element does this renderer render to? */
|
|
362
|
-
canvasElement: unknown;
|
|
363
|
-
T?: unknown;
|
|
364
|
-
};
|
|
365
|
-
interface StoryContextForEnhancers<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryIdentifier {
|
|
366
|
-
component?: (TRenderer & {
|
|
367
|
-
T: any;
|
|
368
|
-
})['component'];
|
|
369
|
-
subcomponents?: Record<string, (TRenderer & {
|
|
370
|
-
T: any;
|
|
371
|
-
})['component']>;
|
|
372
|
-
parameters: Parameters;
|
|
373
|
-
initialArgs: TArgs;
|
|
374
|
-
argTypes: StrictArgTypes<TArgs>;
|
|
375
|
-
}
|
|
376
|
-
type ArgsEnhancer<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContextForEnhancers<TRenderer, TArgs>) => TArgs;
|
|
377
|
-
type ArgTypesEnhancer<TRenderer extends Renderer = Renderer, TArgs = Args> = ((context: StoryContextForEnhancers<TRenderer, TArgs>) => StrictArgTypes<TArgs>) & {
|
|
378
|
-
secondPass?: boolean;
|
|
379
|
-
};
|
|
380
|
-
interface StoryContextUpdate<TArgs = Args> {
|
|
381
|
-
args?: TArgs;
|
|
382
|
-
globals?: Globals;
|
|
383
|
-
[key: string]: any;
|
|
384
|
-
}
|
|
385
|
-
type ViewMode$1 = 'story' | 'docs';
|
|
386
|
-
interface StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryContextForEnhancers<TRenderer, TArgs>, Required<StoryContextUpdate<TArgs>> {
|
|
387
|
-
hooks: unknown;
|
|
388
|
-
viewMode: ViewMode$1;
|
|
389
|
-
originalStoryFn: StoryFn<TRenderer>;
|
|
390
|
-
}
|
|
391
|
-
type LoaderFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContextForLoaders<TRenderer, TArgs>) => Promise<Record<string, any> | void> | Record<string, any> | void;
|
|
392
|
-
interface StoryContext<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryContextForLoaders<TRenderer, TArgs> {
|
|
393
|
-
loaded: Record<string, any>;
|
|
394
|
-
abortSignal: AbortSignal;
|
|
395
|
-
canvasElement: TRenderer['canvasElement'];
|
|
396
|
-
}
|
|
397
|
-
type StepLabel = string;
|
|
398
|
-
type StepFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (label: StepLabel, play: PlayFunction<TRenderer, TArgs>) => Promise<void> | void;
|
|
399
|
-
type PlayFunctionContext<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryContext<TRenderer, TArgs> & {
|
|
400
|
-
step: StepFunction<TRenderer, TArgs>;
|
|
401
|
-
};
|
|
402
|
-
type PlayFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: PlayFunctionContext<TRenderer, TArgs>) => Promise<void> | void;
|
|
403
|
-
type PartialStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (update?: StoryContextUpdate<Partial<TArgs>>) => TRenderer['storyResult'];
|
|
404
|
-
type LegacyStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
|
|
405
|
-
type ArgsStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (args: TArgs, context: StoryContext<TRenderer, TArgs>) => (TRenderer & {
|
|
406
|
-
T: TArgs;
|
|
407
|
-
})['storyResult'];
|
|
408
|
-
type StoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = LegacyStoryFn<TRenderer, TArgs> | ArgsStoryFn<TRenderer, TArgs>;
|
|
409
|
-
type DecoratorFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (fn: PartialStoryFn<TRenderer, TArgs>, c: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
|
|
410
|
-
type DecoratorApplicator<TRenderer extends Renderer = Renderer, TArgs = Args> = (storyFn: LegacyStoryFn<TRenderer, TArgs>, decorators: DecoratorFunction<TRenderer, TArgs>[]) => LegacyStoryFn<TRenderer, TArgs>;
|
|
411
|
-
type StepRunner<TRenderer extends Renderer = Renderer, TArgs = Args> = (label: StepLabel, play: PlayFunction<TRenderer, TArgs>, context: PlayFunctionContext<TRenderer, TArgs>) => Promise<void>;
|
|
412
|
-
type BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> = {
|
|
413
|
-
/**
|
|
414
|
-
* Wrapper components or Storybook decorators that wrap a story.
|
|
415
|
-
*
|
|
416
|
-
* Decorators defined in Meta will be applied to every story variation.
|
|
417
|
-
* @see [Decorators](https://storybook.js.org/docs/addons/introduction/#1-decorators)
|
|
418
|
-
*/
|
|
419
|
-
decorators?: DecoratorFunction<TRenderer, Simplify<TArgs>>[] | DecoratorFunction<TRenderer, Simplify<TArgs>>;
|
|
420
|
-
/**
|
|
421
|
-
* Custom metadata for a story.
|
|
422
|
-
* @see [Parameters](https://storybook.js.org/docs/basics/writing-stories/#parameters)
|
|
423
|
-
*/
|
|
424
|
-
parameters?: Parameters;
|
|
425
|
-
/**
|
|
426
|
-
* Dynamic data that are provided (and possibly updated by) Storybook and its addons.
|
|
427
|
-
* @see [Arg story inputs](https://storybook.js.org/docs/react/api/csf#args-story-inputs)
|
|
428
|
-
*/
|
|
429
|
-
args?: Partial<TArgs>;
|
|
430
|
-
/**
|
|
431
|
-
* ArgTypes encode basic metadata for args, such as `name`, `description`, `defaultValue` for an arg. These get automatically filled in by Storybook Docs.
|
|
432
|
-
* @see [Control annotations](https://github.com/storybookjs/storybook/blob/91e9dee33faa8eff0b342a366845de7100415367/addons/controls/README.md#control-annotations)
|
|
433
|
-
*/
|
|
434
|
-
argTypes?: Partial<ArgTypes<TArgs>>;
|
|
435
|
-
/**
|
|
436
|
-
* Asynchronous functions which provide data for a story.
|
|
437
|
-
* @see [Loaders](https://storybook.js.org/docs/react/writing-stories/loaders)
|
|
438
|
-
*/
|
|
439
|
-
loaders?: LoaderFunction<TRenderer, TArgs>[] | LoaderFunction<TRenderer, TArgs>;
|
|
440
|
-
/**
|
|
441
|
-
* Define a custom render function for the story(ies). If not passed, a default render function by the renderer will be used.
|
|
442
|
-
*/
|
|
443
|
-
render?: ArgsStoryFn<TRenderer, TArgs>;
|
|
444
|
-
};
|
|
445
|
-
type ProjectAnnotations$1<TRenderer extends Renderer = Renderer, TArgs = Args> = BaseAnnotations<TRenderer, TArgs> & {
|
|
446
|
-
argsEnhancers?: ArgsEnhancer<TRenderer, Args>[];
|
|
447
|
-
argTypesEnhancers?: ArgTypesEnhancer<TRenderer, Args>[];
|
|
448
|
-
globals?: Globals;
|
|
449
|
-
globalTypes?: GlobalTypes;
|
|
450
|
-
applyDecorators?: DecoratorApplicator<TRenderer, Args>;
|
|
451
|
-
runStep?: StepRunner<TRenderer, TArgs>;
|
|
452
|
-
};
|
|
453
|
-
type StoryDescriptor$1 = string[] | RegExp;
|
|
454
|
-
interface ComponentAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> extends BaseAnnotations<TRenderer, TArgs> {
|
|
455
|
-
/**
|
|
456
|
-
* Title of the component which will be presented in the navigation. **Should be unique.**
|
|
457
|
-
*
|
|
458
|
-
* Components can be organized in a nested structure using "/" as a separator.
|
|
459
|
-
*
|
|
460
|
-
* Since CSF 3.0 this property is optional -- it can be inferred from the filesystem path
|
|
461
|
-
*
|
|
462
|
-
* @example
|
|
463
|
-
* export default {
|
|
464
|
-
* ...
|
|
465
|
-
* title: 'Design System/Atoms/Button'
|
|
466
|
-
* }
|
|
467
|
-
*
|
|
468
|
-
* @see [Story Hierarchy](https://storybook.js.org/docs/basics/writing-stories/#story-hierarchy)
|
|
469
|
-
*/
|
|
470
|
-
title?: ComponentTitle;
|
|
471
|
-
/**
|
|
472
|
-
* Id of the component (prefix of the story id) which is used for URLs.
|
|
473
|
-
*
|
|
474
|
-
* By default is inferred from sanitizing the title
|
|
475
|
-
*
|
|
476
|
-
* @see [Story Hierarchy](https://storybook.js.org/docs/basics/writing-stories/#story-hierarchy)
|
|
477
|
-
*/
|
|
478
|
-
id?: ComponentId;
|
|
479
|
-
/**
|
|
480
|
-
* Used to only include certain named exports as stories. Useful when you want to have non-story exports such as mock data or ignore a few stories.
|
|
481
|
-
* @example
|
|
482
|
-
* includeStories: ['SimpleStory', 'ComplexStory']
|
|
483
|
-
* includeStories: /.*Story$/
|
|
484
|
-
*
|
|
485
|
-
* @see [Non-story exports](https://storybook.js.org/docs/formats/component-story-format/#non-story-exports)
|
|
486
|
-
*/
|
|
487
|
-
includeStories?: StoryDescriptor$1;
|
|
488
|
-
/**
|
|
489
|
-
* Used to exclude certain named exports. Useful when you want to have non-story exports such as mock data or ignore a few stories.
|
|
490
|
-
* @example
|
|
491
|
-
* excludeStories: ['simpleData', 'complexData']
|
|
492
|
-
* excludeStories: /.*Data$/
|
|
493
|
-
*
|
|
494
|
-
* @see [Non-story exports](https://storybook.js.org/docs/formats/component-story-format/#non-story-exports)
|
|
495
|
-
*/
|
|
496
|
-
excludeStories?: StoryDescriptor$1;
|
|
497
|
-
/**
|
|
498
|
-
* The primary component for your story.
|
|
499
|
-
*
|
|
500
|
-
* Used by addons for automatic prop table generation and display of other component metadata.
|
|
501
|
-
*/
|
|
502
|
-
component?: (TRenderer & {
|
|
503
|
-
T: Record<string, unknown> extends Required<TArgs> ? any : TArgs;
|
|
504
|
-
})['component'];
|
|
505
|
-
/**
|
|
506
|
-
* Auxiliary subcomponents that are part of the stories.
|
|
507
|
-
*
|
|
508
|
-
* Used by addons for automatic prop table generation and display of other component metadata.
|
|
509
|
-
*
|
|
510
|
-
* @example
|
|
511
|
-
* import { Button, ButtonGroup } from './components';
|
|
512
|
-
*
|
|
513
|
-
* export default {
|
|
514
|
-
* ...
|
|
515
|
-
* subcomponents: { Button, ButtonGroup }
|
|
516
|
-
* }
|
|
517
|
-
*
|
|
518
|
-
* By defining them each component will have its tab in the args table.
|
|
519
|
-
*/
|
|
520
|
-
subcomponents?: Record<string, TRenderer['component']>;
|
|
521
|
-
/**
|
|
522
|
-
* Function that is executed after the story is rendered.
|
|
523
|
-
*/
|
|
524
|
-
play?: PlayFunction<TRenderer, TArgs>;
|
|
525
|
-
/**
|
|
526
|
-
* Named tags for a story, used to filter stories in different contexts.
|
|
527
|
-
*/
|
|
528
|
-
tags?: Tag[];
|
|
529
|
-
}
|
|
530
|
-
type StoryAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args, TRequiredArgs = Partial<TArgs>> = BaseAnnotations<TRenderer, TArgs> & {
|
|
531
|
-
/**
|
|
532
|
-
* Override the display name in the UI (CSF v3)
|
|
533
|
-
*/
|
|
534
|
-
name?: StoryName;
|
|
535
|
-
/**
|
|
536
|
-
* Override the display name in the UI (CSF v2)
|
|
537
|
-
*/
|
|
538
|
-
storyName?: StoryName;
|
|
539
|
-
/**
|
|
540
|
-
* Function that is executed after the story is rendered.
|
|
541
|
-
*/
|
|
542
|
-
play?: PlayFunction<TRenderer, TArgs>;
|
|
543
|
-
/**
|
|
544
|
-
* Named tags for a story, used to filter stories in different contexts.
|
|
545
|
-
*/
|
|
546
|
-
tags?: Tag[];
|
|
547
|
-
/** @deprecated */
|
|
548
|
-
story?: Omit<StoryAnnotations<TRenderer, TArgs>, 'story'>;
|
|
549
|
-
} & ({} extends TRequiredArgs ? {
|
|
550
|
-
args?: TRequiredArgs;
|
|
551
|
-
} : {
|
|
552
|
-
args: TRequiredArgs;
|
|
553
|
-
});
|
|
554
|
-
type AnnotatedStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = ArgsStoryFn<TRenderer, TArgs> & StoryAnnotations<TRenderer, TArgs>;
|
|
555
|
-
type ArgsFromMeta<TRenderer extends Renderer, Meta> = Meta extends {
|
|
556
|
-
render?: ArgsStoryFn<TRenderer, infer RArgs>;
|
|
557
|
-
loaders?: (infer Loaders)[] | infer Loaders;
|
|
558
|
-
decorators?: (infer Decorators)[] | infer Decorators;
|
|
559
|
-
} ? Simplify<RemoveIndexSignature<RArgs & DecoratorsArgs<TRenderer, Decorators> & LoaderArgs<TRenderer, Loaders>>> : unknown;
|
|
560
|
-
type DecoratorsArgs<TRenderer extends Renderer, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
|
|
561
|
-
type LoaderArgs<TRenderer extends Renderer, Loaders> = UnionToIntersection<Loaders extends LoaderFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
|
|
562
|
-
interface StoriesSpecifier {
|
|
563
|
-
/**
|
|
564
|
-
* When auto-titling, what to prefix all generated titles with (default: '')
|
|
565
|
-
*/
|
|
566
|
-
titlePrefix?: string;
|
|
567
|
-
/**
|
|
568
|
-
* Where to start looking for story files
|
|
569
|
-
*/
|
|
570
|
-
directory: string;
|
|
571
|
-
/**
|
|
572
|
-
* What does the filename of a story file look like?
|
|
573
|
-
* (a glob, relative to directory, no leading `./`)
|
|
574
|
-
* If unset, we use `** / *.@(mdx|stories.@(mdx|js|jsx|mjs|ts|tsx))` (no spaces)
|
|
575
|
-
*/
|
|
576
|
-
files?: string;
|
|
577
|
-
}
|
|
578
|
-
type NormalizedStoriesSpecifier = Required<StoriesSpecifier> & {
|
|
579
|
-
importPathMatcher: RegExp;
|
|
580
|
-
};
|
|
581
|
-
interface BaseIndexEntry {
|
|
582
|
-
id: StoryId;
|
|
583
|
-
name: StoryName;
|
|
584
|
-
title: ComponentTitle;
|
|
585
|
-
tags?: Tag[];
|
|
586
|
-
importPath: Path;
|
|
587
|
-
}
|
|
588
|
-
type StoryIndexEntry = BaseIndexEntry & {
|
|
589
|
-
type: 'story';
|
|
590
|
-
};
|
|
591
|
-
type DocsIndexEntry = BaseIndexEntry & {
|
|
592
|
-
storiesImports: Path[];
|
|
593
|
-
type: 'docs';
|
|
594
|
-
};
|
|
595
|
-
type IndexEntry = StoryIndexEntry | DocsIndexEntry;
|
|
596
|
-
interface StoryIndex {
|
|
597
|
-
v: number;
|
|
598
|
-
entries: Record<StoryId, IndexEntry>;
|
|
599
|
-
}
|
|
600
|
-
type Addon_ReturnTypeFramework<ReturnType> = {
|
|
601
|
-
component: any;
|
|
602
|
-
storyResult: ReturnType;
|
|
603
|
-
canvasElement: any;
|
|
604
|
-
};
|
|
605
|
-
type Addon_StoryFn<ReturnType = unknown> = StoryFn<Addon_ReturnTypeFramework<ReturnType>>;
|
|
606
|
-
type Addon_DecoratorFunction<StoryFnReturnType = unknown> = DecoratorFunction<Addon_ReturnTypeFramework<StoryFnReturnType>>;
|
|
607
|
-
type Addon_LoaderFunction = LoaderFunction<Addon_ReturnTypeFramework<unknown>>;
|
|
608
|
-
type Addon_ClientApiReturnFn<StoryFnReturnType = unknown> = (...args: any[]) => Addon_StoryApi<StoryFnReturnType>;
|
|
609
|
-
interface Addon_StoryApi<StoryFnReturnType = unknown> {
|
|
610
|
-
kind: StoryKind;
|
|
611
|
-
add: (storyName: StoryName, storyFn: Addon_StoryFn<StoryFnReturnType>, parameters?: Parameters) => Addon_StoryApi<StoryFnReturnType>;
|
|
612
|
-
addDecorator: (decorator: Addon_DecoratorFunction<StoryFnReturnType>) => Addon_StoryApi<StoryFnReturnType>;
|
|
613
|
-
addLoader: (decorator: Addon_LoaderFunction) => Addon_StoryApi<StoryFnReturnType>;
|
|
614
|
-
addParameters: (parameters: Parameters) => Addon_StoryApi<StoryFnReturnType>;
|
|
615
|
-
[k: string]: string | Addon_ClientApiReturnFn<StoryFnReturnType>;
|
|
616
|
-
}
|
|
617
|
-
type Path = string;
|
|
618
|
-
type MaybePromise<T> = Promise<T> | T;
|
|
619
|
-
type TeardownRenderToCanvas = () => MaybePromise<void>;
|
|
620
|
-
type RenderToCanvas<TRenderer extends Renderer> = (context: RenderContext<TRenderer>, element: TRenderer['canvasElement']) => MaybePromise<void | TeardownRenderToCanvas>;
|
|
621
|
-
type ProjectAnnotations<TRenderer extends Renderer> = ProjectAnnotations$1<TRenderer> & {
|
|
622
|
-
renderToCanvas?: RenderToCanvas<TRenderer>;
|
|
623
|
-
renderToDOM?: RenderToCanvas<TRenderer>;
|
|
624
|
-
};
|
|
625
|
-
declare type RenderContext<TRenderer extends Renderer = Renderer> = StoryIdentifier & {
|
|
626
|
-
showMain: () => void;
|
|
627
|
-
showError: (error: {
|
|
628
|
-
title: string;
|
|
629
|
-
description: string;
|
|
630
|
-
}) => void;
|
|
631
|
-
showException: (err: Error) => void;
|
|
632
|
-
forceRemount: boolean;
|
|
633
|
-
storyContext: StoryContext<TRenderer>;
|
|
634
|
-
storyFn: PartialStoryFn<TRenderer>;
|
|
635
|
-
unboundStoryFn: LegacyStoryFn<TRenderer>;
|
|
636
|
-
};
|
|
637
|
-
|
|
638
|
-
export { Args as A, ComponentAnnotations as C, DecoratorFunction as D, LoaderFunction as L, NormalizedStoriesSpecifier as N, Parameters as P, RenderContext as R, StrictArgs as S, ArgTypes as a, Addon_StoryApi as b, AnnotatedStoryFn as c, ArgsStoryFn as d, ArgsFromMeta as e, StoryAnnotations as f, StoryContext as g, ProjectAnnotations as h, StoryIndex as i, Renderer as j, StoryContextForEnhancers as k, StrictArgTypes as l };
|