@storybook/react-native 9.0.9 → 9.0.14

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/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { StoryIndex, PreparedStory, NormalizedStoriesSpecifier, Addon_StorySortP
3
3
  import { ReactRenderer } from '@storybook/react';
4
4
  export { ArgTypes, Args, Decorator, Loader, Meta, Parameters, Preview, StoryFn, StoryObj } from '@storybook/react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
- import { StoryContext } from '@storybook/csf';
6
+ import { StoryContext } from 'storybook/internal/csf';
7
7
  import { Theme } from '@storybook/react-native-theming';
8
8
  export { Theme, darkTheme, theme } from '@storybook/react-native-theming';
9
9
  import { SBUI } from '@storybook/react-native-ui-common';
@@ -32,15 +32,31 @@ type DeepPartial<T> = T extends object ? {
32
32
  type ThemePartial = DeepPartial<Theme>;
33
33
  type Params = {
34
34
  onDeviceUI?: boolean;
35
+ /**
36
+ * Set as false to disable the wrapper around the story view.
37
+ * NOTE We may remove this in the future for a better solution.
38
+ * default: true
39
+ */
40
+ hasStoryWrapper?: boolean;
41
+ /**
42
+ * Enable websockets for the storybook server to remotely control the storybook
43
+ * default: false
44
+ */
35
45
  enableWebsockets?: boolean;
36
46
  query?: string;
47
+ /** The host for the websocket server. default: localhost */
37
48
  host?: string;
49
+ /** The port for the websocket server. default: 7007 */
38
50
  port?: number;
39
51
  secured?: boolean;
52
+ /** The initial story */
40
53
  initialSelection?: InitialSelection;
54
+ /** Whether to persist story selection. default: true */
41
55
  shouldPersistSelection?: boolean;
42
56
  theme: ThemePartial;
57
+ /** Used for persisting story selection. required. */
43
58
  storage?: Storage;
59
+ /** The custom UI component to use instead of the default UI */
44
60
  CustomUIComponent?: SBUI;
45
61
  };
46
62
  declare class View {
package/dist/index.js CHANGED
@@ -43,11 +43,11 @@ var import_react_native_theming3 = require("@storybook/react-native-theming");
43
43
  var import_react_native4 = require("react-native");
44
44
  var import_manager_api2 = require("storybook/internal/manager-api");
45
45
  var import_preview_api2 = require("storybook/internal/preview-api");
46
- var import_csf2 = require("@storybook/csf");
46
+ var import_csf2 = require("storybook/internal/csf");
47
47
  var import_channels2 = require("storybook/internal/channels");
48
48
 
49
49
  // src/View.tsx
50
- var import_csf = require("@storybook/csf");
50
+ var import_csf = require("storybook/internal/csf");
51
51
  var import_react_native_theming2 = require("@storybook/react-native-theming");
52
52
  var import_react_native_ui_common = require("@storybook/react-native-ui-common");
53
53
  var import_channels = require("storybook/internal/channels");
@@ -789,7 +789,7 @@ var errorContainerStyle = {
789
789
  alignItems: "center",
790
790
  justifyContent: "center"
791
791
  };
792
- var StoryView = () => {
792
+ var StoryView = ({ useWrapper = true }) => {
793
793
  const context = useStoryContext();
794
794
  const id = context?.id;
795
795
  const theme3 = (0, import_react_native_theming.useTheme)();
@@ -805,18 +805,21 @@ var StoryView = () => {
805
805
  }, [context?.title, context?.name]);
806
806
  if (context && context.unboundStoryFn) {
807
807
  const { unboundStoryFn: StoryComponent } = context;
808
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
809
- import_react_native2.View,
810
- {
811
- style: containerStyle,
812
- testID: id,
813
- accessibilityLabel: id,
814
- importantForAccessibility: "no",
815
- onStartShouldSetResponder: dismissOnStartResponder,
816
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ErrorBoundary, { onError, children: StoryComponent && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StoryComponent, { ...context }) })
817
- },
818
- id
819
- );
808
+ if (useWrapper) {
809
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
810
+ import_react_native2.View,
811
+ {
812
+ style: containerStyle,
813
+ testID: id,
814
+ accessibilityLabel: id,
815
+ importantForAccessibility: "no",
816
+ onStartShouldSetResponder: dismissOnStartResponder,
817
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ErrorBoundary, { onError, children: StoryComponent && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StoryComponent, { ...context }) })
818
+ },
819
+ id
820
+ );
821
+ }
822
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ErrorBoundary, { onError, children: StoryComponent && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StoryComponent, { ...context }) });
820
823
  }
821
824
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.View, { style: errorContainerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text2, { children: "Please open the sidebar and select a story to preview." }) });
822
825
  };
@@ -953,7 +956,8 @@ var View3 = class {
953
956
  onDeviceUI = true,
954
957
  enableWebsockets = false,
955
958
  storage,
956
- CustomUIComponent
959
+ CustomUIComponent,
960
+ hasStoryWrapper: storyViewWrapper = true
957
961
  } = params;
958
962
  const getFullUI = (enabled) => {
959
963
  if (enabled) {
@@ -1121,7 +1125,7 @@ var View3 = class {
1121
1125
  setStory: (newStoryId) => self._channel.emit(import_core_events.SET_CURRENT_STORY, { storyId: newStoryId }),
1122
1126
  storage,
1123
1127
  theme: appliedTheme,
1124
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StoryView_default, {})
1128
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StoryView_default, { useWrapper: storyViewWrapper })
1125
1129
  }
1126
1130
  );
1127
1131
  }
@@ -1133,11 +1137,11 @@ var View3 = class {
1133
1137
  storyHash,
1134
1138
  story,
1135
1139
  setStory: (newStoryId) => self._channel.emit(import_core_events.SET_CURRENT_STORY, { storyId: newStoryId }),
1136
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StoryView_default, {})
1140
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StoryView_default, { useWrapper: storyViewWrapper })
1137
1141
  }
1138
1142
  );
1139
1143
  } else {
1140
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StoryView_default, {});
1144
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StoryView_default, { useWrapper: storyViewWrapper });
1141
1145
  }
1142
1146
  };
1143
1147
  };
@@ -159,10 +159,14 @@ var require_generate = __commonJS({
159
159
  files: "${specifier.files}",
160
160
  importPathMatcher: /${reg.source}/,
161
161
  ${useJs ? "" : "// @ts-ignore"}
162
- req: require.context('${pathToStory}', ${r}, ${m})
162
+ req: require.context(
163
+ '${pathToStory}',
164
+ ${r},
165
+ ${m}
166
+ ),
163
167
  }`;
164
168
  });
165
- let registerAddons = "";
169
+ const registeredAddons = [];
166
170
  for (const addon of main.addons) {
167
171
  const registerPath = resolveAddonFile(
168
172
  getAddonName(addon),
@@ -171,8 +175,7 @@ var require_generate = __commonJS({
171
175
  configPath
172
176
  );
173
177
  if (registerPath) {
174
- registerAddons += `import "${registerPath}";
175
- `;
178
+ registeredAddons.push(`import "${registerPath}";`);
176
179
  }
177
180
  }
178
181
  const docToolsAnnotation = 'require("@storybook/react-native/preview")';
@@ -211,14 +214,14 @@ declare global {
211
214
  var view: View;
212
215
  var STORIES: typeof normalizedStories;
213
216
  }
214
- `;
217
+ `;
215
218
  const fileContent = `/* do not change this file, it is auto generated by storybook. */
216
219
  import { start, updateView${useJs ? "" : ", View"} } from '@storybook/react-native';
217
220
 
218
- ${registerAddons}
221
+ ${registeredAddons.join("\n")}
219
222
 
220
223
  const normalizedStories = [
221
- ${normalizedStories.join(",\n ")}
224
+ ${normalizedStories.join(",\n")}
222
225
  ];
223
226
 
224
227
  ${useJs ? "" : globalTypes}
@@ -236,10 +239,10 @@ if (!global.view) {
236
239
  global.view = start({
237
240
  annotations,
238
241
  storyEntries: normalizedStories,
239
- ${options}
242
+ ${options ? ` ${options},` : ""}
240
243
  });
241
244
  } else {
242
- updateView(global.view, annotations, normalizedStories, ${options});
245
+ updateView(global.view, annotations, normalizedStories${options ? `, ${options}` : ""});
243
246
  }
244
247
 
245
248
  export const view${useJs ? "" : ": View"} = global.view;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native",
3
- "version": "9.0.9",
3
+ "version": "9.0.14",
4
4
  "description": "A better way to develop React Native Components for your app",
5
5
  "keywords": [
6
6
  "react",
@@ -46,12 +46,11 @@
46
46
  "test:update": "jest --updateSnapshot"
47
47
  },
48
48
  "dependencies": {
49
- "@storybook/csf": "^0.1.13",
50
49
  "@storybook/global": "^5.0.0",
51
- "@storybook/react": "^9.0.9",
52
- "@storybook/react-native-theming": "^9.0.9",
53
- "@storybook/react-native-ui": "^9.0.9",
54
- "@storybook/react-native-ui-common": "^9.0.9",
50
+ "@storybook/react": "9.0.14",
51
+ "@storybook/react-native-theming": "^9.0.14",
52
+ "@storybook/react-native-ui": "^9.0.14",
53
+ "@storybook/react-native-ui-common": "^9.0.14",
55
54
  "commander": "^8.2.0",
56
55
  "dedent": "^1.5.1",
57
56
  "deepmerge": "^4.3.0",
@@ -72,7 +71,7 @@
72
71
  "react": "19.0.0",
73
72
  "react-native": "0.79.2",
74
73
  "react-test-renderer": "^19.1.0",
75
- "storybook": "^9.0.9",
74
+ "storybook": "9.0.14",
76
75
  "tsup": "^7.2.0",
77
76
  "typescript": "~5.8.3"
78
77
  },
@@ -83,7 +82,7 @@
83
82
  "react-native-gesture-handler": ">=2",
84
83
  "react-native-reanimated": ">=2",
85
84
  "react-native-safe-area-context": "*",
86
- "storybook": "^9.0.9"
85
+ "storybook": "9.0.14"
87
86
  },
88
87
  "peerDependenciesMeta": {
89
88
  "@gorhom/bottom-sheet": {
@@ -105,5 +104,5 @@
105
104
  "publishConfig": {
106
105
  "access": "public"
107
106
  },
108
- "gitHead": "6c247692ee0ede93df4e7df6e27e832e3e40a45d"
107
+ "gitHead": "19bb44781daef1f4bd1c5782c0a00d5b7fa5b943"
109
108
  }
@@ -9,7 +9,6 @@ import "@storybook/addon-ondevice-controls/register";
9
9
  import "@storybook/addon-ondevice-backgrounds/register";
10
10
  import "@storybook/addon-ondevice-actions/register";
11
11
 
12
-
13
12
  const normalizedStories = [
14
13
  {
15
14
  titlePrefix: "",
@@ -17,7 +16,11 @@ const normalizedStories = [
17
16
  files: "FakeStory.stories.tsx",
18
17
  importPathMatcher: /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/,
19
18
  // @ts-ignore
20
- req: require.context('./', false, /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/)
19
+ req: require.context(
20
+ './',
21
+ false,
22
+ /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/
23
+ ),
21
24
  }
22
25
  ];
23
26
 
@@ -26,7 +29,7 @@ declare global {
26
29
  var view: View;
27
30
  var STORIES: typeof normalizedStories;
28
31
  }
29
-
32
+
30
33
 
31
34
  const annotations = [
32
35
  require('./preview'),
@@ -44,10 +47,10 @@ if (!global.view) {
44
47
  global.view = start({
45
48
  annotations,
46
49
  storyEntries: normalizedStories,
47
-
50
+
48
51
  });
49
52
  } else {
50
- updateView(global.view, annotations, normalizedStories, );
53
+ updateView(global.view, annotations, normalizedStories);
51
54
  }
52
55
 
53
56
  export const view: View = global.view;
@@ -63,7 +66,6 @@ import "@storybook/addon-ondevice-controls/register";
63
66
  import "@storybook/addon-ondevice-backgrounds/register";
64
67
  import "@storybook/addon-ondevice-actions/register";
65
68
 
66
-
67
69
  const normalizedStories = [
68
70
  {
69
71
  titlePrefix: "ComponentsPrefix",
@@ -71,7 +73,11 @@ const normalizedStories = [
71
73
  files: "**/*.stories.tsx",
72
74
  importPathMatcher: /^\\.(?:(?:^|\\/|(?:(?:(?!(?:^|\\/)\\.).)*?)\\/)(?!\\.)(?=.)[^/]*?\\.stories\\.tsx)$/,
73
75
  // @ts-ignore
74
- req: require.context('./components', true, /^\\.(?:(?:^|\\/|(?:(?:(?!(?:^|\\/)\\.).)*?)\\/)(?!\\.)(?=.)[^/]*?\\.stories\\.tsx)$/)
76
+ req: require.context(
77
+ './components',
78
+ true,
79
+ /^\\.(?:(?:^|\\/|(?:(?:(?!(?:^|\\/)\\.).)*?)\\/)(?!\\.)(?=.)[^/]*?\\.stories\\.tsx)$/
80
+ ),
75
81
  }
76
82
  ];
77
83
 
@@ -80,7 +86,7 @@ declare global {
80
86
  var view: View;
81
87
  var STORIES: typeof normalizedStories;
82
88
  }
83
-
89
+
84
90
 
85
91
  const annotations = [
86
92
  require('./preview'),
@@ -98,10 +104,10 @@ if (!global.view) {
98
104
  global.view = start({
99
105
  annotations,
100
106
  storyEntries: normalizedStories,
101
-
107
+
102
108
  });
103
109
  } else {
104
- updateView(global.view, annotations, normalizedStories, );
110
+ updateView(global.view, annotations, normalizedStories);
105
111
  }
106
112
 
107
113
  export const view: View = global.view;
@@ -117,7 +123,6 @@ import "@storybook/addon-ondevice-controls/register";
117
123
  import "@storybook/addon-ondevice-backgrounds/register";
118
124
  import "@storybook/addon-ondevice-actions/register";
119
125
 
120
-
121
126
  const normalizedStories = [
122
127
  {
123
128
  titlePrefix: "",
@@ -125,7 +130,11 @@ const normalizedStories = [
125
130
  files: "FakeStory.stories.tsx",
126
131
  importPathMatcher: /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/,
127
132
  // @ts-ignore
128
- req: require.context('./', false, /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/)
133
+ req: require.context(
134
+ './',
135
+ false,
136
+ /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/
137
+ ),
129
138
  }
130
139
  ];
131
140
 
@@ -134,7 +143,7 @@ declare global {
134
143
  var view: View;
135
144
  var STORIES: typeof normalizedStories;
136
145
  }
137
-
146
+
138
147
 
139
148
  const annotations = [
140
149
  require('./preview'),
@@ -152,10 +161,10 @@ if (!global.view) {
152
161
  global.view = start({
153
162
  annotations,
154
163
  storyEntries: normalizedStories,
155
-
164
+
156
165
  });
157
166
  } else {
158
- updateView(global.view, annotations, normalizedStories, );
167
+ updateView(global.view, annotations, normalizedStories);
159
168
  }
160
169
 
161
170
  export const view: View = global.view;
@@ -171,7 +180,6 @@ import "@storybook/addon-ondevice-controls/register";
171
180
  import "@storybook/addon-ondevice-backgrounds/register";
172
181
  import "@storybook/addon-ondevice-actions/register";
173
182
 
174
-
175
183
  const normalizedStories = [
176
184
  {
177
185
  titlePrefix: "",
@@ -179,7 +187,11 @@ const normalizedStories = [
179
187
  files: "FakeStory.stories.tsx",
180
188
  importPathMatcher: /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/,
181
189
  // @ts-ignore
182
- req: require.context('./', false, /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/)
190
+ req: require.context(
191
+ './',
192
+ false,
193
+ /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/
194
+ ),
183
195
  }
184
196
  ];
185
197
 
@@ -188,7 +200,7 @@ declare global {
188
200
  var view: View;
189
201
  var STORIES: typeof normalizedStories;
190
202
  }
191
-
203
+
192
204
 
193
205
  const annotations = [
194
206
  require("@storybook/react-native/preview")
@@ -205,10 +217,10 @@ if (!global.view) {
205
217
  global.view = start({
206
218
  annotations,
207
219
  storyEntries: normalizedStories,
208
-
220
+
209
221
  });
210
222
  } else {
211
- updateView(global.view, annotations, normalizedStories, );
223
+ updateView(global.view, annotations, normalizedStories);
212
224
  }
213
225
 
214
226
  export const view: View = global.view;
@@ -224,7 +236,6 @@ import "@storybook/addon-ondevice-controls/register";
224
236
  import "@storybook/addon-ondevice-backgrounds/register";
225
237
  import "@storybook/addon-ondevice-actions/register";
226
238
 
227
-
228
239
  const normalizedStories = [
229
240
  {
230
241
  titlePrefix: "",
@@ -232,7 +243,11 @@ const normalizedStories = [
232
243
  files: "FakeStory.stories.tsx",
233
244
  importPathMatcher: /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/,
234
245
 
235
- req: require.context('./', false, /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/)
246
+ req: require.context(
247
+ './',
248
+ false,
249
+ /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/
250
+ ),
236
251
  }
237
252
  ];
238
253
 
@@ -254,10 +269,10 @@ if (!global.view) {
254
269
  global.view = start({
255
270
  annotations,
256
271
  storyEntries: normalizedStories,
257
-
272
+
258
273
  });
259
274
  } else {
260
- updateView(global.view, annotations, normalizedStories, );
275
+ updateView(global.view, annotations, normalizedStories);
261
276
  }
262
277
 
263
278
  export const view = global.view;
@@ -44,11 +44,15 @@ function generate({ configPath, /* absolute = false, */ useJs = false, docTools
44
44
  files: "${specifier.files}",
45
45
  importPathMatcher: /${reg.source}/,
46
46
  ${useJs ? '' : '// @ts-ignore'}
47
- req: require.context('${pathToStory}', ${r}, ${m})
47
+ req: require.context(
48
+ '${pathToStory}',
49
+ ${r},
50
+ ${m}
51
+ ),
48
52
  }`;
49
53
  });
50
54
 
51
- let registerAddons = '';
55
+ const registeredAddons = [];
52
56
 
53
57
  for (const addon of main.addons) {
54
58
  const registerPath = resolveAddonFile(
@@ -59,7 +63,7 @@ function generate({ configPath, /* absolute = false, */ useJs = false, docTools
59
63
  );
60
64
 
61
65
  if (registerPath) {
62
- registerAddons += `import "${registerPath}";\n`;
66
+ registeredAddons.push(`import "${registerPath}";`);
63
67
  }
64
68
  }
65
69
 
@@ -109,15 +113,15 @@ declare global {
109
113
  var view: View;
110
114
  var STORIES: typeof normalizedStories;
111
115
  }
112
- `;
116
+ `;
113
117
 
114
118
  const fileContent = `/* do not change this file, it is auto generated by storybook. */
115
119
  import { start, updateView${useJs ? '' : ', View'} } from '@storybook/react-native';
116
120
 
117
- ${registerAddons}
121
+ ${registeredAddons.join('\n')}
118
122
 
119
123
  const normalizedStories = [
120
- ${normalizedStories.join(',\n ')}
124
+ ${normalizedStories.join(',\n')}
121
125
  ];
122
126
 
123
127
  ${useJs ? '' : globalTypes}
@@ -135,10 +139,10 @@ if (!global.view) {
135
139
  global.view = start({
136
140
  annotations,
137
141
  storyEntries: normalizedStories,
138
- ${options}
142
+ ${options ? ` ${options},` : ''}
139
143
  });
140
144
  } else {
141
- updateView(global.view, annotations, normalizedStories, ${options});
145
+ updateView(global.view, annotations, normalizedStories${options ? `, ${options}` : ''});
142
146
  }
143
147
 
144
148
  export const view${useJs ? '' : ': View'} = global.view;