@storybook/react-native 7.6.9-alpha.0 → 7.6.10-alpha.1
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/V6.js +32 -15
- package/dist/View-3a0f8584.d.ts +64 -0
- package/dist/index.d-cff8c6fa.d.ts +198 -0
- package/dist/index.d.ts +3 -6
- package/dist/index.js +32 -15
- package/dist/preview.d.ts +1 -1
- package/package.json +16 -16
- package/readme.md +5 -0
- package/scripts/mocks/exclude-config-files/exclude-components/FakeComponent.tsx +1 -1
- package/scripts/mocks/file-extensions/main.ts +1 -3
- package/template/cli/index.ts +13 -0
- package/template/cli/preview.tsx +14 -0
- package/template/cli/stories/Button/{Button.stories.js → Button.stories.tsx} +4 -4
- package/template/cli/stories/Button/{Button.js → Button.tsx} +6 -2
- package/template/cli/storybook.requires.ts +34 -0
- package/dist/View-63944515.d.ts +0 -111
- package/dist/index.d-c716d0d7.d.ts +0 -638
- package/template/cli/index.js +0 -7
- package/template/cli/preview.js +0 -8
- package/template/cli/storybook.requires.js +0 -54
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-3a0f8584.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 };
|
package/dist/V6.js
CHANGED
|
@@ -80,14 +80,21 @@ var import_preview_api3 = require("@storybook/preview-api");
|
|
|
80
80
|
var import_preview_web = require("@storybook/preview-web");
|
|
81
81
|
|
|
82
82
|
// src/View.tsx
|
|
83
|
-
var import_async_storage = __toESM(require("@react-native-async-storage/async-storage"));
|
|
84
83
|
var import_csf = require("@storybook/csf");
|
|
85
|
-
var import_preview_api2 = require("@storybook/preview-api");
|
|
86
84
|
var import_manager_api2 = require("@storybook/manager-api");
|
|
85
|
+
var import_preview_api2 = require("@storybook/preview-api");
|
|
87
86
|
var import_react_native_theming12 = require("@storybook/react-native-theming");
|
|
88
87
|
var import_react16 = require("react");
|
|
89
88
|
var import_react_native_safe_area_context3 = require("react-native-safe-area-context");
|
|
90
89
|
|
|
90
|
+
// src/components/OnDeviceUI/OnDeviceUI.tsx
|
|
91
|
+
var import_react_native_theming10 = require("@storybook/react-native-theming");
|
|
92
|
+
var import_react15 = __toESM(require("react"));
|
|
93
|
+
var import_react_native14 = require("react-native");
|
|
94
|
+
|
|
95
|
+
// src/constants.ts
|
|
96
|
+
var ANIMATION_DURATION_TRANSITION = 400;
|
|
97
|
+
|
|
91
98
|
// src/hooks.tsx
|
|
92
99
|
var import_react2 = __toESM(require("react"));
|
|
93
100
|
|
|
@@ -841,14 +848,6 @@ function useSelectedAddon(initialValue) {
|
|
|
841
848
|
return result;
|
|
842
849
|
}
|
|
843
850
|
|
|
844
|
-
// src/components/OnDeviceUI/OnDeviceUI.tsx
|
|
845
|
-
var import_react_native_theming10 = require("@storybook/react-native-theming");
|
|
846
|
-
var import_react15 = __toESM(require("react"));
|
|
847
|
-
var import_react_native14 = require("react-native");
|
|
848
|
-
|
|
849
|
-
// src/constants.ts
|
|
850
|
-
var ANIMATION_DURATION_TRANSITION = 400;
|
|
851
|
-
|
|
852
851
|
// src/components/StoryListView/StoryListView.tsx
|
|
853
852
|
var import_core_events = __toESM(require("@storybook/core-events"));
|
|
854
853
|
var import_react_native_theming = require("@storybook/react-native-theming");
|
|
@@ -1952,6 +1951,7 @@ var OnDeviceUI_default = import_react15.default.memo(OnDeviceUI);
|
|
|
1952
1951
|
// src/View.tsx
|
|
1953
1952
|
var import_channels = require("@storybook/channels");
|
|
1954
1953
|
var import_core_events2 = __toESM(require("@storybook/core-events"));
|
|
1954
|
+
var import_dedent = __toESM(require("dedent"));
|
|
1955
1955
|
var import_deepmerge = __toESM(require("deepmerge"));
|
|
1956
1956
|
var import_react_native16 = require("react-native");
|
|
1957
1957
|
|
|
@@ -2012,6 +2012,7 @@ var View10 = class {
|
|
|
2012
2012
|
_preview;
|
|
2013
2013
|
_asyncStorageStoryId;
|
|
2014
2014
|
_webUrl;
|
|
2015
|
+
_storage;
|
|
2015
2016
|
_channel;
|
|
2016
2017
|
constructor(preview, channel) {
|
|
2017
2018
|
this._preview = preview;
|
|
@@ -2034,8 +2035,8 @@ var View10 = class {
|
|
|
2034
2035
|
if (shouldPersistSelection) {
|
|
2035
2036
|
try {
|
|
2036
2037
|
let value = this._asyncStorageStoryId;
|
|
2037
|
-
if (!value) {
|
|
2038
|
-
value = await
|
|
2038
|
+
if (!value && this._storage != null) {
|
|
2039
|
+
value = await this._storage.getItem(STORAGE_KEY);
|
|
2039
2040
|
this._asyncStorageStoryId = value;
|
|
2040
2041
|
}
|
|
2041
2042
|
const exists = value && Object.keys(this._storyIndex.entries).includes(value);
|
|
@@ -2062,7 +2063,13 @@ var View10 = class {
|
|
|
2062
2063
|
});
|
|
2063
2064
|
};
|
|
2064
2065
|
getStorybookUI = (params = {}) => {
|
|
2065
|
-
const {
|
|
2066
|
+
const {
|
|
2067
|
+
shouldPersistSelection = true,
|
|
2068
|
+
onDeviceUI = true,
|
|
2069
|
+
enableWebsockets = false,
|
|
2070
|
+
storage
|
|
2071
|
+
} = params;
|
|
2072
|
+
this._storage = storage;
|
|
2066
2073
|
const initialStory = this._getInitialStory(params);
|
|
2067
2074
|
if (enableWebsockets) {
|
|
2068
2075
|
console.log("websockets enabled");
|
|
@@ -2103,8 +2110,18 @@ var View10 = class {
|
|
|
2103
2110
|
(0, import_react16.useEffect)(() => {
|
|
2104
2111
|
self._setStory = (newStory) => {
|
|
2105
2112
|
setContext(newStory);
|
|
2106
|
-
if (shouldPersistSelection) {
|
|
2107
|
-
|
|
2113
|
+
if (shouldPersistSelection && !storage) {
|
|
2114
|
+
console.warn(import_dedent.default`Please set storage in getStorybookUI like this:
|
|
2115
|
+
const StorybookUIRoot = view.getStorybookUI({
|
|
2116
|
+
storage: {
|
|
2117
|
+
getItem: AsyncStorage.getItem,
|
|
2118
|
+
setItem: AsyncStorage.setItem,
|
|
2119
|
+
},
|
|
2120
|
+
});
|
|
2121
|
+
`);
|
|
2122
|
+
}
|
|
2123
|
+
if (shouldPersistSelection && !!this._storage) {
|
|
2124
|
+
this._storage.setItem(STORAGE_KEY, newStory.id).catch((e) => {
|
|
2108
2125
|
console.warn("storybook-log: error writing to async storage", e);
|
|
2109
2126
|
});
|
|
2110
2127
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { ReactRenderer } from '@storybook/react';
|
|
5
|
+
import { Theme } from '@storybook/react-native-theming';
|
|
6
|
+
import { S as StoryIndex } from './index.d-cff8c6fa.js';
|
|
7
|
+
import { Channel } from '@storybook/channels';
|
|
8
|
+
|
|
9
|
+
interface Storage {
|
|
10
|
+
getItem: (key: string) => Promise<string | null>;
|
|
11
|
+
setItem: (key: string, value: string) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
type StoryKind = string;
|
|
14
|
+
type StoryName = string;
|
|
15
|
+
type InitialSelection = `${StoryKind}--${StoryName}` | {
|
|
16
|
+
/**
|
|
17
|
+
* Kind is the default export name or the storiesOf("name") name
|
|
18
|
+
*/
|
|
19
|
+
kind: StoryKind;
|
|
20
|
+
/**
|
|
21
|
+
* Name is the named export or the .add("name") name
|
|
22
|
+
*/
|
|
23
|
+
name: StoryName;
|
|
24
|
+
};
|
|
25
|
+
type DeepPartial<T> = T extends object ? {
|
|
26
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
27
|
+
} : T;
|
|
28
|
+
type Params = {
|
|
29
|
+
onDeviceUI?: boolean;
|
|
30
|
+
enableWebsockets?: boolean;
|
|
31
|
+
query?: string;
|
|
32
|
+
host?: string;
|
|
33
|
+
port?: number;
|
|
34
|
+
secured?: boolean;
|
|
35
|
+
initialSelection?: InitialSelection;
|
|
36
|
+
shouldPersistSelection?: boolean;
|
|
37
|
+
tabOpen?: number;
|
|
38
|
+
isUIHidden?: boolean;
|
|
39
|
+
isSplitPanelVisible?: boolean;
|
|
40
|
+
shouldDisableKeyboardAvoidingView?: boolean;
|
|
41
|
+
keyboardAvoidingViewVerticalOffset?: number;
|
|
42
|
+
theme: DeepPartial<Theme>;
|
|
43
|
+
storage?: Storage;
|
|
44
|
+
};
|
|
45
|
+
declare class View {
|
|
46
|
+
_storyIndex: StoryIndex;
|
|
47
|
+
_setStory: (story: StoryContext<ReactRenderer>) => void;
|
|
48
|
+
_forceRerender: () => void;
|
|
49
|
+
_ready: boolean;
|
|
50
|
+
_preview: PreviewWithSelection<ReactRenderer>;
|
|
51
|
+
_asyncStorageStoryId: string;
|
|
52
|
+
_webUrl: string;
|
|
53
|
+
_storage: Storage;
|
|
54
|
+
_channel: Channel;
|
|
55
|
+
constructor(preview: PreviewWithSelection<ReactRenderer>, channel: Channel);
|
|
56
|
+
_getInitialStory: ({ initialSelection, shouldPersistSelection, }?: Partial<Params>) => Promise<{
|
|
57
|
+
storySpecifier: string;
|
|
58
|
+
viewMode: string;
|
|
59
|
+
}>;
|
|
60
|
+
_getServerChannel: (params?: Partial<Params>) => Channel;
|
|
61
|
+
getStorybookUI: (params?: Partial<Params>) => () => react_jsx_runtime.JSX.Element;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
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-3a0f8584.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/index.js
CHANGED
|
@@ -73,14 +73,21 @@ var import_preview_web = require("@storybook/preview-api/dist/preview-web");
|
|
|
73
73
|
var import_channels2 = require("@storybook/channels");
|
|
74
74
|
|
|
75
75
|
// src/View.tsx
|
|
76
|
-
var import_async_storage = __toESM(require("@react-native-async-storage/async-storage"));
|
|
77
76
|
var import_csf = require("@storybook/csf");
|
|
78
|
-
var import_preview_api2 = require("@storybook/preview-api");
|
|
79
77
|
var import_manager_api2 = require("@storybook/manager-api");
|
|
78
|
+
var import_preview_api2 = require("@storybook/preview-api");
|
|
80
79
|
var import_react_native_theming12 = require("@storybook/react-native-theming");
|
|
81
80
|
var import_react16 = require("react");
|
|
82
81
|
var import_react_native_safe_area_context3 = require("react-native-safe-area-context");
|
|
83
82
|
|
|
83
|
+
// src/components/OnDeviceUI/OnDeviceUI.tsx
|
|
84
|
+
var import_react_native_theming10 = require("@storybook/react-native-theming");
|
|
85
|
+
var import_react15 = __toESM(require("react"));
|
|
86
|
+
var import_react_native14 = require("react-native");
|
|
87
|
+
|
|
88
|
+
// src/constants.ts
|
|
89
|
+
var ANIMATION_DURATION_TRANSITION = 400;
|
|
90
|
+
|
|
84
91
|
// src/hooks.tsx
|
|
85
92
|
var import_react2 = __toESM(require("react"));
|
|
86
93
|
|
|
@@ -834,14 +841,6 @@ function useSelectedAddon(initialValue) {
|
|
|
834
841
|
return result;
|
|
835
842
|
}
|
|
836
843
|
|
|
837
|
-
// src/components/OnDeviceUI/OnDeviceUI.tsx
|
|
838
|
-
var import_react_native_theming10 = require("@storybook/react-native-theming");
|
|
839
|
-
var import_react15 = __toESM(require("react"));
|
|
840
|
-
var import_react_native14 = require("react-native");
|
|
841
|
-
|
|
842
|
-
// src/constants.ts
|
|
843
|
-
var ANIMATION_DURATION_TRANSITION = 400;
|
|
844
|
-
|
|
845
844
|
// src/components/StoryListView/StoryListView.tsx
|
|
846
845
|
var import_core_events = __toESM(require("@storybook/core-events"));
|
|
847
846
|
var import_react_native_theming = require("@storybook/react-native-theming");
|
|
@@ -1945,6 +1944,7 @@ var OnDeviceUI_default = import_react15.default.memo(OnDeviceUI);
|
|
|
1945
1944
|
// src/View.tsx
|
|
1946
1945
|
var import_channels = require("@storybook/channels");
|
|
1947
1946
|
var import_core_events2 = __toESM(require("@storybook/core-events"));
|
|
1947
|
+
var import_dedent = __toESM(require("dedent"));
|
|
1948
1948
|
var import_deepmerge = __toESM(require("deepmerge"));
|
|
1949
1949
|
var import_react_native16 = require("react-native");
|
|
1950
1950
|
|
|
@@ -2005,6 +2005,7 @@ var View10 = class {
|
|
|
2005
2005
|
_preview;
|
|
2006
2006
|
_asyncStorageStoryId;
|
|
2007
2007
|
_webUrl;
|
|
2008
|
+
_storage;
|
|
2008
2009
|
_channel;
|
|
2009
2010
|
constructor(preview, channel) {
|
|
2010
2011
|
this._preview = preview;
|
|
@@ -2027,8 +2028,8 @@ var View10 = class {
|
|
|
2027
2028
|
if (shouldPersistSelection) {
|
|
2028
2029
|
try {
|
|
2029
2030
|
let value = this._asyncStorageStoryId;
|
|
2030
|
-
if (!value) {
|
|
2031
|
-
value = await
|
|
2031
|
+
if (!value && this._storage != null) {
|
|
2032
|
+
value = await this._storage.getItem(STORAGE_KEY);
|
|
2032
2033
|
this._asyncStorageStoryId = value;
|
|
2033
2034
|
}
|
|
2034
2035
|
const exists = value && Object.keys(this._storyIndex.entries).includes(value);
|
|
@@ -2055,7 +2056,13 @@ var View10 = class {
|
|
|
2055
2056
|
});
|
|
2056
2057
|
};
|
|
2057
2058
|
getStorybookUI = (params = {}) => {
|
|
2058
|
-
const {
|
|
2059
|
+
const {
|
|
2060
|
+
shouldPersistSelection = true,
|
|
2061
|
+
onDeviceUI = true,
|
|
2062
|
+
enableWebsockets = false,
|
|
2063
|
+
storage
|
|
2064
|
+
} = params;
|
|
2065
|
+
this._storage = storage;
|
|
2059
2066
|
const initialStory = this._getInitialStory(params);
|
|
2060
2067
|
if (enableWebsockets) {
|
|
2061
2068
|
console.log("websockets enabled");
|
|
@@ -2096,8 +2103,18 @@ var View10 = class {
|
|
|
2096
2103
|
(0, import_react16.useEffect)(() => {
|
|
2097
2104
|
self._setStory = (newStory) => {
|
|
2098
2105
|
setContext(newStory);
|
|
2099
|
-
if (shouldPersistSelection) {
|
|
2100
|
-
|
|
2106
|
+
if (shouldPersistSelection && !storage) {
|
|
2107
|
+
console.warn(import_dedent.default`Please set storage in getStorybookUI like this:
|
|
2108
|
+
const StorybookUIRoot = view.getStorybookUI({
|
|
2109
|
+
storage: {
|
|
2110
|
+
getItem: AsyncStorage.getItem,
|
|
2111
|
+
setItem: AsyncStorage.setItem,
|
|
2112
|
+
},
|
|
2113
|
+
});
|
|
2114
|
+
`);
|
|
2115
|
+
}
|
|
2116
|
+
if (shouldPersistSelection && !!this._storage) {
|
|
2117
|
+
this._storage.setItem(STORAGE_KEY, newStory.id).catch((e) => {
|
|
2101
2118
|
console.warn("storybook-log: error writing to async storage", e);
|
|
2102
2119
|
});
|
|
2103
2120
|
}
|
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.1",
|
|
4
4
|
"description": "A better way to develop React Native Components for your app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -51,22 +51,23 @@
|
|
|
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.1",
|
|
68
68
|
"chokidar": "^3.5.1",
|
|
69
69
|
"commander": "^8.2.0",
|
|
70
|
+
"dedent": "^1.5.1",
|
|
70
71
|
"deepmerge": "^4.3.0",
|
|
71
72
|
"glob": "^7.1.7",
|
|
72
73
|
"prettier": "^2.4.1",
|
|
@@ -75,7 +76,7 @@
|
|
|
75
76
|
"util": "^0.12.4"
|
|
76
77
|
},
|
|
77
78
|
"devDependencies": {
|
|
78
|
-
"@storybook/types": "^7.6.
|
|
79
|
+
"@storybook/types": "^7.6.10",
|
|
79
80
|
"@types/jest": "^29.4.3",
|
|
80
81
|
"@types/react": "~18.2.14",
|
|
81
82
|
"babel-jest": "^29.4.3",
|
|
@@ -87,7 +88,6 @@
|
|
|
87
88
|
"typescript": "^5.3.3"
|
|
88
89
|
},
|
|
89
90
|
"peerDependencies": {
|
|
90
|
-
"@react-native-async-storage/async-storage": ">=1",
|
|
91
91
|
"react": "*",
|
|
92
92
|
"react-native": ">=0.57.0",
|
|
93
93
|
"react-native-safe-area-context": "*"
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"publishConfig": {
|
|
99
99
|
"access": "public"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "8b2e96767cc361ae5382c5ba0ba9d6ea6112634f"
|
|
102
102
|
}
|
package/readme.md
CHANGED
|
@@ -256,6 +256,11 @@ You can pass these parameters to getStorybookUI call in your storybook entry poi
|
|
|
256
256
|
-- Disable KeyboardAvoidingView wrapping Storybook's view
|
|
257
257
|
keyboardAvoidingViewVerticalOffset: Number (0)
|
|
258
258
|
-- With shouldDisableKeyboardAvoidingView=true, this will set the keyboardverticaloffset (https://facebook.github.io/react-native/docs/keyboardavoidingview#keyboardverticaloffset) value for KeyboardAvoidingView wrapping Storybook's view
|
|
259
|
+
storage: Object (undefined)
|
|
260
|
+
-- {getItem: (key: string) => Promise<string | null>;setItem: (key: string, value: string) => Promise<void>;}
|
|
261
|
+
-- Custom storage to be used instead of AsyncStorage
|
|
262
|
+
shouldPersistSelection: Boolean (true)
|
|
263
|
+
-- Stores last selected story in your devices storage.
|
|
259
264
|
}
|
|
260
265
|
```
|
|
261
266
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const FakeComponentExcluded = () => null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
2
|
+
import { view } from './storybook.requires';
|
|
3
|
+
|
|
4
|
+
import './storybook.requires';
|
|
5
|
+
|
|
6
|
+
const StorybookUIRoot = view.getStorybookUI({
|
|
7
|
+
storage: {
|
|
8
|
+
getItem: AsyncStorage.getItem,
|
|
9
|
+
setItem: AsyncStorage.setItem,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export default StorybookUIRoot;
|