@storybook/react-native 9.1.1-alpha.1 → 10.0.0-beta.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.
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  // scripts/common.js
28
28
  var require_common = __commonJS({
29
29
  "scripts/common.js"(exports2, module2) {
30
- var { globToRegexp, serverRequire } = require("storybook/internal/common");
30
+ var { globToRegexp } = require("storybook/internal/common");
31
31
  var path2 = require("path");
32
32
  var fs = require("fs");
33
33
  var cwd = process.cwd();
@@ -40,10 +40,6 @@ var require_common = __commonJS({
40
40
  match
41
41
  };
42
42
  };
43
- function requireUncached(module3) {
44
- delete require.cache[require.resolve(module3)];
45
- return serverRequire(module3);
46
- }
47
43
  var supportedExtensions = ["js", "jsx", "ts", "tsx", "cjs", "mjs"];
48
44
  function getFilePathExtension({ configPath }, fileName) {
49
45
  for (const ext of supportedExtensions) {
@@ -54,14 +50,6 @@ var require_common = __commonJS({
54
50
  }
55
51
  return null;
56
52
  }
57
- function getMain({ configPath }) {
58
- const fileExtension = getFilePathExtension({ configPath }, "main");
59
- if (fileExtension === null) {
60
- throw new Error("main config file not found");
61
- }
62
- const mainPath = path2.resolve(cwd, configPath, `main.${fileExtension}`);
63
- return requireUncached(mainPath);
64
- }
65
53
  function ensureRelativePathHasDot(relativePath) {
66
54
  return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
67
55
  }
@@ -103,9 +91,7 @@ var require_common = __commonJS({
103
91
  }
104
92
  module2.exports = {
105
93
  toRequireContext,
106
- requireUncached,
107
94
  getFilePathExtension,
108
- getMain,
109
95
  ensureRelativePathHasDot,
110
96
  getPreviewExists,
111
97
  resolveAddonFile,
@@ -120,16 +106,15 @@ var require_generate = __commonJS({
120
106
  var {
121
107
  toRequireContext,
122
108
  ensureRelativePathHasDot,
123
- getMain,
124
109
  getPreviewExists,
125
110
  resolveAddonFile,
126
111
  getAddonName
127
112
  } = require_common();
128
- var { normalizeStories, globToRegexp } = require("storybook/internal/common");
113
+ var { normalizeStories, globToRegexp, loadMainConfig } = require("storybook/internal/common");
129
114
  var fs = require("fs");
130
115
  var path2 = require("path");
131
116
  var cwd = process.cwd();
132
- function generate2({
117
+ async function generate2({
133
118
  configPath,
134
119
  /* absolute = false, */
135
120
  useJs = false,
@@ -140,8 +125,7 @@ var require_generate = __commonJS({
140
125
  configPath,
141
126
  `storybook.requires.${useJs ? "js" : "ts"}`
142
127
  );
143
- const mainImport = getMain({ configPath });
144
- const main = mainImport.default ?? mainImport;
128
+ const main = await loadMainConfig({ configDir: configPath, cwd });
145
129
  const storiesSpecifiers = normalizeStories(main.stories, {
146
130
  configDir: configPath,
147
131
  workingDir: cwd
@@ -32,7 +32,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
32
32
  // scripts/common.js
33
33
  var require_common = __commonJS({
34
34
  "scripts/common.js"(exports2, module2) {
35
- var { globToRegexp, serverRequire } = require("storybook/internal/common");
35
+ var { globToRegexp } = require("storybook/internal/common");
36
36
  var path2 = require("path");
37
37
  var fs = require("fs");
38
38
  var cwd = process.cwd();
@@ -45,10 +45,6 @@ var require_common = __commonJS({
45
45
  match
46
46
  };
47
47
  };
48
- function requireUncached(module3) {
49
- delete require.cache[require.resolve(module3)];
50
- return serverRequire(module3);
51
- }
52
48
  var supportedExtensions = ["js", "jsx", "ts", "tsx", "cjs", "mjs"];
53
49
  function getFilePathExtension({ configPath }, fileName) {
54
50
  for (const ext of supportedExtensions) {
@@ -59,14 +55,6 @@ var require_common = __commonJS({
59
55
  }
60
56
  return null;
61
57
  }
62
- function getMain({ configPath }) {
63
- const fileExtension = getFilePathExtension({ configPath }, "main");
64
- if (fileExtension === null) {
65
- throw new Error("main config file not found");
66
- }
67
- const mainPath = path2.resolve(cwd, configPath, `main.${fileExtension}`);
68
- return requireUncached(mainPath);
69
- }
70
58
  function ensureRelativePathHasDot(relativePath) {
71
59
  return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
72
60
  }
@@ -108,9 +96,7 @@ var require_common = __commonJS({
108
96
  }
109
97
  module2.exports = {
110
98
  toRequireContext,
111
- requireUncached,
112
99
  getFilePathExtension,
113
- getMain,
114
100
  ensureRelativePathHasDot,
115
101
  getPreviewExists,
116
102
  resolveAddonFile,
@@ -125,16 +111,15 @@ var require_generate = __commonJS({
125
111
  var {
126
112
  toRequireContext,
127
113
  ensureRelativePathHasDot,
128
- getMain,
129
114
  getPreviewExists,
130
115
  resolveAddonFile,
131
116
  getAddonName
132
117
  } = require_common();
133
- var { normalizeStories, globToRegexp } = require("storybook/internal/common");
118
+ var { normalizeStories, globToRegexp, loadMainConfig } = require("storybook/internal/common");
134
119
  var fs = require("fs");
135
120
  var path2 = require("path");
136
121
  var cwd = process.cwd();
137
- function generate2({
122
+ async function generate2({
138
123
  configPath,
139
124
  /* absolute = false, */
140
125
  useJs = false,
@@ -145,8 +130,7 @@ var require_generate = __commonJS({
145
130
  configPath,
146
131
  `storybook.requires.${useJs ? "js" : "ts"}`
147
132
  );
148
- const mainImport = getMain({ configPath });
149
- const main = mainImport.default ?? mainImport;
133
+ const main = await loadMainConfig({ configDir: configPath, cwd });
150
134
  const storiesSpecifiers = normalizeStories(main.stories, {
151
135
  configDir: configPath,
152
136
  workingDir: cwd
package/dist/preview.js CHANGED
@@ -22,7 +22,7 @@ __export(preview_exports, {
22
22
  default: () => preview_default
23
23
  });
24
24
  module.exports = __toCommonJS(preview_exports);
25
- var import_entry_preview_docs = require("@storybook/react/dist/entry-preview-docs.mjs");
25
+ var import_entry_preview_docs = require("@storybook/react/entry-preview-docs");
26
26
  var preview = {
27
27
  argTypesEnhancers: import_entry_preview_docs.argTypesEnhancers,
28
28
  parameters: {
package/jest.config.js CHANGED
@@ -1,8 +1,11 @@
1
1
  /** @type {import('jest').Config} */
2
2
  const config = {
3
3
  preset: 'jest-expo',
4
+ setupFiles: ['<rootDir>/setup.js'],
5
+
4
6
  transformIgnorePatterns: [
5
7
  'node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@sentry/react-native|native-base|react-native-svg|storybook/.*|@storybook/.*|uuid)',
6
8
  ],
9
+ testPathIgnorePatterns: ['/node_modules/', '/scripts/generate\\.test\\.js$'],
7
10
  };
8
11
  module.exports = config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native",
3
- "version": "9.1.1-alpha.1",
3
+ "version": "10.0.0-beta.0",
4
4
  "description": "A better way to develop React Native Components for your app",
5
5
  "keywords": [
6
6
  "react",
@@ -42,19 +42,21 @@
42
42
  "scripts": {
43
43
  "dev": "npx --yes tsx buildscripts/gendtsdev.ts && tsup --watch",
44
44
  "prepare": "rm -rf dist/ && tsup",
45
- "test": "jest",
46
- "test:ci": "jest",
47
- "test:update": "jest --updateSnapshot"
45
+ "test": "jest && yarn test:generate",
46
+ "test:ci": "jest && yarn test:generate",
47
+ "test:generate": "node --test scripts/generate.test.js",
48
+ "test:generate:update": "node --test --test-update-snapshots scripts/generate.test.js"
48
49
  },
49
50
  "dependencies": {
50
51
  "@storybook/global": "^5.0.0",
51
- "@storybook/react": "^9.1.2",
52
- "@storybook/react-native-theming": "^9.1.1-alpha.1",
53
- "@storybook/react-native-ui": "^9.1.1-alpha.1",
54
- "@storybook/react-native-ui-common": "^9.1.1-alpha.1",
52
+ "@storybook/react": "10.0.0-beta.0",
53
+ "@storybook/react-native-theming": "^10.0.0-beta.0",
54
+ "@storybook/react-native-ui": "^10.0.0-beta.0",
55
+ "@storybook/react-native-ui-common": "^10.0.0-beta.0",
55
56
  "commander": "^8.2.0",
56
57
  "dedent": "^1.5.1",
57
58
  "deepmerge": "^4.3.0",
59
+ "esbuild-register": "^3.6.0",
58
60
  "react-native-url-polyfill": "^2.0.0",
59
61
  "setimmediate": "^1.0.5",
60
62
  "type-fest": "~2.19",
@@ -62,19 +64,20 @@
62
64
  "ws": "^8.18.0"
63
65
  },
64
66
  "devDependencies": {
67
+ "@babel/plugin-transform-class-static-block": "^7.27.1",
65
68
  "@types/jest": "^29.4.3",
66
- "@types/react": "~19.0.10",
69
+ "@types/react": "~19.1.10",
67
70
  "babel-jest": "^29.7.0",
68
71
  "babel-preset-expo": "^12.0.9",
69
72
  "jest": "^29.7.0",
70
- "jest-expo": "~53.0.9",
73
+ "jest-expo": "~54.0.1",
71
74
  "jotai": "^2.6.2",
72
- "react": "19.0.0",
73
- "react-native": "0.79.5",
74
- "react-test-renderer": "^19.1.0",
75
- "storybook": "^9.1.2",
75
+ "react": "19.1.0",
76
+ "react-native": "0.81.0",
77
+ "storybook": "10.0.0-beta.0",
76
78
  "tsup": "^8.5.0",
77
- "typescript": "~5.8.3"
79
+ "typescript": "~5.9.2",
80
+ "universal-test-renderer": "^0.6.0"
78
81
  },
79
82
  "peerDependencies": {
80
83
  "@gorhom/bottom-sheet": ">=4",
@@ -83,7 +86,7 @@
83
86
  "react-native-gesture-handler": ">=2",
84
87
  "react-native-reanimated": ">=2",
85
88
  "react-native-safe-area-context": "*",
86
- "storybook": ">=9"
89
+ "storybook": ">=10 || 10.0.0-beta.0 || ^10"
87
90
  },
88
91
  "peerDependenciesMeta": {
89
92
  "@gorhom/bottom-sheet": {
@@ -100,10 +103,10 @@
100
103
  }
101
104
  },
102
105
  "engines": {
103
- "node": ">=8.0.0"
106
+ "node": ">=20"
104
107
  },
105
108
  "publishConfig": {
106
109
  "access": "public"
107
110
  },
108
- "gitHead": "cc38bfb53177171ffb92d228c0bcde0e4d01d767"
111
+ "gitHead": "2a6a4f7e68024b71178cad8ea0dc08cbba7dca1b"
109
112
  }
package/scripts/common.js CHANGED
@@ -1,4 +1,4 @@
1
- const { globToRegexp, serverRequire } = require('storybook/internal/common');
1
+ const { globToRegexp } = require('storybook/internal/common');
2
2
  const path = require('path');
3
3
  const fs = require('fs');
4
4
 
@@ -18,12 +18,6 @@ const toRequireContext = (specifier) => {
18
18
  };
19
19
  };
20
20
 
21
- function requireUncached(module) {
22
- delete require.cache[require.resolve(module)];
23
-
24
- return serverRequire(module);
25
- }
26
-
27
21
  const supportedExtensions = ['js', 'jsx', 'ts', 'tsx', 'cjs', 'mjs'];
28
22
 
29
23
  function getFilePathExtension({ configPath }, fileName) {
@@ -38,18 +32,6 @@ function getFilePathExtension({ configPath }, fileName) {
38
32
  return null;
39
33
  }
40
34
 
41
- function getMain({ configPath }) {
42
- const fileExtension = getFilePathExtension({ configPath }, 'main');
43
-
44
- if (fileExtension === null) {
45
- throw new Error('main config file not found');
46
- }
47
-
48
- const mainPath = path.resolve(cwd, configPath, `main.${fileExtension}`);
49
-
50
- return requireUncached(mainPath);
51
- }
52
-
53
35
  function ensureRelativePathHasDot(relativePath) {
54
36
  return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
55
37
  }
@@ -105,9 +87,7 @@ function getAddonName(addon) {
105
87
 
106
88
  module.exports = {
107
89
  toRequireContext,
108
- requireUncached,
109
90
  getFilePathExtension,
110
- getMain,
111
91
  ensureRelativePathHasDot,
112
92
  getPreviewExists,
113
93
  resolveAddonFile,
@@ -1,28 +1,25 @@
1
1
  const {
2
2
  toRequireContext,
3
3
  ensureRelativePathHasDot,
4
- getMain,
5
4
  getPreviewExists,
6
5
  resolveAddonFile,
7
6
  getAddonName,
8
7
  } = require('./common');
9
- const { normalizeStories, globToRegexp } = require('storybook/internal/common');
8
+ const { normalizeStories, globToRegexp, loadMainConfig } = require('storybook/internal/common');
10
9
  const fs = require('fs');
11
10
 
12
11
  const path = require('path');
13
12
 
14
13
  const cwd = process.cwd();
15
14
 
16
- function generate({ configPath, /* absolute = false, */ useJs = false, docTools = true }) {
15
+ async function generate({ configPath, /* absolute = false, */ useJs = false, docTools = true }) {
17
16
  const storybookRequiresLocation = path.resolve(
18
17
  cwd,
19
18
  configPath,
20
19
  `storybook.requires.${useJs ? 'js' : 'ts'}`
21
20
  );
22
21
 
23
- const mainImport = getMain({ configPath });
24
-
25
- const main = mainImport.default ?? mainImport;
22
+ const main = await loadMainConfig({ configDir: configPath, cwd });
26
23
 
27
24
  // const reactNativeOptions = main.reactNativeOptions;
28
25
 
@@ -1,48 +1,66 @@
1
- const path = require('path');
1
+ const { describe, it, beforeEach, mock } = require('node:test');
2
+ const assert = require('node:assert');
3
+ const path = require('node:path');
2
4
  const { generate } = require('./generate');
3
5
 
4
6
  let pathMock;
5
7
  let fileContentMock;
6
8
 
7
- global.window.navigator = {};
9
+ global.window = { navigator: {} };
8
10
 
9
- jest.mock('fs', () => ({
10
- ...jest.requireActual('fs'),
11
+ const mockFs = {
11
12
  writeFileSync: (filePath, fileContent, opts) => {
12
13
  pathMock = filePath;
13
14
  fileContentMock = fileContent;
14
15
  },
15
- }));
16
+ };
16
17
 
17
18
  describe('loader', () => {
19
+ beforeEach(() => {
20
+ pathMock = undefined;
21
+ fileContentMock = undefined;
22
+ });
23
+
18
24
  describe('writeRequires', () => {
19
25
  describe('when there is a story glob', () => {
20
- it('writes the story imports', () => {
21
- generate({ configPath: 'scripts/mocks/all-config-files' });
22
- expect(pathMock).toEqual(
26
+ it('writes the story imports', async (t) => {
27
+ mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
28
+ await generate({ configPath: 'scripts/mocks/all-config-files' });
29
+ mock.reset();
30
+
31
+ assert.strictEqual(
32
+ pathMock,
23
33
  path.resolve(__dirname, 'mocks/all-config-files/storybook.requires.ts')
24
34
  );
25
- expect(fileContentMock).toMatchSnapshot();
35
+ t.assert.snapshot(fileContentMock);
26
36
  });
27
37
  });
28
38
 
29
39
  describe('when using js', () => {
30
- it('writes the story imports without types', () => {
31
- generate({ configPath: 'scripts/mocks/all-config-files', useJs: true });
32
- expect(pathMock).toEqual(
40
+ it('writes the story imports without types', async (t) => {
41
+ mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
42
+ await generate({ configPath: 'scripts/mocks/all-config-files', useJs: true });
43
+ mock.reset();
44
+
45
+ assert.strictEqual(
46
+ pathMock,
33
47
  path.resolve(__dirname, 'mocks/all-config-files/storybook.requires.js')
34
48
  );
35
- expect(fileContentMock).toMatchSnapshot();
49
+ t.assert.snapshot(fileContentMock);
36
50
  });
37
51
  });
38
52
 
39
53
  describe('when there are different file extensions', () => {
40
- it('writes the story imports', () => {
41
- generate({ configPath: 'scripts/mocks/file-extensions' });
42
- expect(pathMock).toEqual(
54
+ it('writes the story imports', async (t) => {
55
+ mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
56
+ await generate({ configPath: 'scripts/mocks/file-extensions' });
57
+ mock.reset();
58
+
59
+ assert.strictEqual(
60
+ pathMock,
43
61
  path.resolve(__dirname, 'mocks/file-extensions/storybook.requires.ts')
44
62
  );
45
- expect(fileContentMock).toMatchSnapshot();
63
+ t.assert.snapshot(fileContentMock);
46
64
  });
47
65
  });
48
66
 
@@ -50,28 +68,40 @@ describe('loader', () => {
50
68
  // describe('when there is a story glob and exclude paths globs', () => {
51
69
  // it('writes the story imports', () => {
52
70
  // generate({ configPath: 'scripts/mocks/exclude-config-files' });
53
- // expect(pathMock).toEqual(
71
+ // assert.strictEqual(
72
+ // pathMock,
54
73
  // path.resolve(__dirname, 'mocks/exclude-config-files/storybook.requires.ts')
55
74
  // );
56
75
 
57
- // expect(fileContentMock).toContain('include-components/FakeStory.stories.tsx');
58
- // expect(fileContentMock).not.toContain('exclude-components/FakeStory.stories.tsx');
76
+ // assert.ok(fileContentMock.includes('include-components/FakeStory.stories.tsx'));
77
+ // assert.ok(!fileContentMock.includes('exclude-components/FakeStory.stories.tsx'));
59
78
 
60
- // expect(fileContentMock).toMatchSnapshot();
79
+ // t.assert.snapshot(fileContentMock);
61
80
  // });
62
81
  // });
63
82
 
64
83
  describe('when there is no story glob or addons', () => {
65
- it('throws an error', () => {
66
- expect(() => generate({ configPath: 'scripts/mocks/blank-config' })).toThrow();
84
+ it('throws an error', async () => {
85
+ mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
86
+ await assert.rejects(
87
+ async () => await generate({ configPath: 'scripts/mocks/blank-config' }),
88
+ Error
89
+ );
90
+ mock.reset();
67
91
  });
68
92
  });
69
93
 
70
94
  describe('when there is no preview', () => {
71
- it('does not add preview related stuff', () => {
72
- generate({ configPath: 'scripts/mocks/no-preview' });
73
- expect(pathMock).toEqual(path.resolve(__dirname, 'mocks/no-preview/storybook.requires.ts'));
74
- expect(fileContentMock).toMatchSnapshot();
95
+ it('does not add preview related stuff', async (t) => {
96
+ mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
97
+ await generate({ configPath: 'scripts/mocks/no-preview' });
98
+ mock.reset();
99
+
100
+ assert.strictEqual(
101
+ pathMock,
102
+ path.resolve(__dirname, 'mocks/no-preview/storybook.requires.ts')
103
+ );
104
+ t.assert.snapshot(fileContentMock);
75
105
  });
76
106
  });
77
107
 
@@ -79,22 +109,27 @@ describe('loader', () => {
79
109
  // describe('when the absolute option is true', () => {
80
110
  // it('should write absolute paths to the requires file', () => {
81
111
  // generate({ configPath: 'scripts/mocks/all-config-files', absolute: true });
82
- // expect(pathMock).toEqual(
112
+ // assert.strictEqual(
113
+ // pathMock,
83
114
  // path.resolve(__dirname, 'mocks/all-config-files/storybook.requires.ts')
84
115
  // );
85
116
 
86
- // // expect(fileContentMock).toContain(`FakeStory.stories.tsx`);
87
- // expect(fileContentMock).toContain(path.resolve(__dirname, 'mocks/all-config-files'));
117
+ // // assert.ok(fileContentMock.includes(`FakeStory.stories.tsx`));
118
+ // assert.ok(fileContentMock.includes(path.resolve(__dirname, 'mocks/all-config-files')));
88
119
  // });
89
120
  // });
90
121
 
91
122
  describe('when there is a configuration object', () => {
92
- it('writes the story imports', () => {
93
- generate({ configPath: 'scripts/mocks/configuration-objects' });
94
- expect(pathMock).toEqual(
123
+ it('writes the story imports', async (t) => {
124
+ mock.method(require('fs'), 'writeFileSync', mockFs.writeFileSync);
125
+ await generate({ configPath: 'scripts/mocks/configuration-objects' });
126
+ mock.reset();
127
+
128
+ assert.strictEqual(
129
+ pathMock,
95
130
  path.resolve(__dirname, 'mocks/configuration-objects/storybook.requires.ts')
96
131
  );
97
- expect(fileContentMock).toMatchSnapshot();
132
+ t.assert.snapshot(fileContentMock);
98
133
  });
99
134
  });
100
135
  });
@@ -0,0 +1,19 @@
1
+ exports[`loader > writeRequires > when there are different file extensions > writes the story imports 1`] = `
2
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/file-extensions\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobal.STORIES = normalizedStories;\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!global.view) {\\n global.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(global.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = global.view;\\n"
3
+ `;
4
+
5
+ exports[`loader > writeRequires > when there is a configuration object > writes the story imports 1`] = `
6
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"ComponentsPrefix\\",\\n directory: \\"./scripts/mocks/configuration-objects/components\\",\\n files: \\"**/*.stories.tsx\\",\\n importPathMatcher: /^\\\\.(?:(?:^|\\\\/|(?:(?:(?!(?:^|\\\\/)\\\\.).)*?)\\\\/)(?!\\\\.)(?=.)[^/]*?\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './components',\\n true,\\n /^\\\\.(?:(?:^|\\\\/|(?:(?:(?!(?:^|\\\\/)\\\\.).)*?)\\\\/)(?!\\\\.)(?=.)[^/]*?\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobal.STORIES = normalizedStories;\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!global.view) {\\n global.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(global.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = global.view;\\n"
7
+ `;
8
+
9
+ exports[`loader > writeRequires > when there is a story glob > writes the story imports 1`] = `
10
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/all-config-files\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n}\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobal.STORIES = normalizedStories;\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!global.view) {\\n global.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(global.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = global.view;\\n"
11
+ `;
12
+
13
+ exports[`loader > writeRequires > when there is no preview > does not add preview related stuff 1`] = `
14
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView, View } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/no-preview\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n // @ts-ignore\\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\ndeclare global {\\n var view: View;\\n var STORIES: typeof normalizedStories;\\n}\\n\\n\\nconst annotations = [\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobal.STORIES = normalizedStories;\\n\\n// @ts-ignore\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!global.view) {\\n global.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(global.view, annotations, normalizedStories);\\n}\\n\\nexport const view: View = global.view;\\n"
15
+ `;
16
+
17
+ exports[`loader > writeRequires > when using js > writes the story imports without types 1`] = `
18
+ "/* do not change this file, it is auto generated by storybook. */\\nimport { start, updateView } from '@storybook/react-native';\\n\\nimport \\"@storybook/addon-ondevice-notes/register\\";\\nimport \\"@storybook/addon-ondevice-controls/register\\";\\nimport \\"@storybook/addon-ondevice-backgrounds/register\\";\\nimport \\"@storybook/addon-ondevice-actions/register\\";\\n\\nconst normalizedStories = [\\n {\\n titlePrefix: \\"\\",\\n directory: \\"./scripts/mocks/all-config-files\\",\\n files: \\"FakeStory.stories.tsx\\",\\n importPathMatcher: /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/,\\n \\n req: require.context(\\n './',\\n false,\\n /^\\\\.[\\\\\\\\/](?:FakeStory\\\\.stories\\\\.tsx)$/\\n ),\\n }\\n];\\n\\n\\n\\nconst annotations = [\\n require('./preview'),\\n require(\\"@storybook/react-native/preview\\")\\n];\\n\\nglobal.STORIES = normalizedStories;\\n\\n\\nmodule?.hot?.accept?.();\\n\\n\\n\\nif (!global.view) {\\n global.view = start({\\n annotations,\\n storyEntries: normalizedStories,\\n\\n });\\n} else {\\n updateView(global.view, annotations, normalizedStories);\\n}\\n\\nexport const view = global.view;\\n"
19
+ `;
package/setup.js ADDED
@@ -0,0 +1,6 @@
1
+ // eslint-disable-next-line no-undef
2
+ jest.doMock('react-native/Libraries/NativeComponent/ViewConfigIgnore', () => ({
3
+ ConditionallyIgnoredEventHandlers: () => undefined,
4
+ DynamicallyInjectedByGestureHandler: () => ({}),
5
+ isIgnored: () => true,
6
+ }));
@@ -17,7 +17,7 @@ const meta = {
17
17
  ],
18
18
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
19
19
  tags: ['autodocs'],
20
- // Use `fn` to spy on the onPress arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
20
+ // Use `fn` to spy on the onPress arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#story-args
21
21
  args: { onPress: fn() },
22
22
  } satisfies Meta<typeof Button>;
23
23
 
@@ -1,280 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`loader writeRequires when there are different file extensions writes the story imports 1`] = `
4
- "/* do not change this file, it is auto generated by storybook. */
5
- import { start, updateView, View } from '@storybook/react-native';
6
-
7
- import "@storybook/addon-ondevice-notes/register";
8
- import "@storybook/addon-ondevice-controls/register";
9
- import "@storybook/addon-ondevice-backgrounds/register";
10
- import "@storybook/addon-ondevice-actions/register";
11
-
12
- const normalizedStories = [
13
- {
14
- titlePrefix: "",
15
- directory: "./scripts/mocks/file-extensions",
16
- files: "FakeStory.stories.tsx",
17
- importPathMatcher: /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/,
18
- // @ts-ignore
19
- req: require.context(
20
- './',
21
- false,
22
- /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/
23
- ),
24
- }
25
- ];
26
-
27
-
28
- declare global {
29
- var view: View;
30
- var STORIES: typeof normalizedStories;
31
- }
32
-
33
-
34
- const annotations = [
35
- require('./preview'),
36
- require("@storybook/react-native/preview")
37
- ];
38
-
39
- global.STORIES = normalizedStories;
40
-
41
- // @ts-ignore
42
- module?.hot?.accept?.();
43
-
44
-
45
-
46
- if (!global.view) {
47
- global.view = start({
48
- annotations,
49
- storyEntries: normalizedStories,
50
-
51
- });
52
- } else {
53
- updateView(global.view, annotations, normalizedStories);
54
- }
55
-
56
- export const view: View = global.view;
57
- "
58
- `;
59
-
60
- exports[`loader writeRequires when there is a configuration object writes the story imports 1`] = `
61
- "/* do not change this file, it is auto generated by storybook. */
62
- import { start, updateView, View } from '@storybook/react-native';
63
-
64
- import "@storybook/addon-ondevice-notes/register";
65
- import "@storybook/addon-ondevice-controls/register";
66
- import "@storybook/addon-ondevice-backgrounds/register";
67
- import "@storybook/addon-ondevice-actions/register";
68
-
69
- const normalizedStories = [
70
- {
71
- titlePrefix: "ComponentsPrefix",
72
- directory: "./scripts/mocks/configuration-objects/components",
73
- files: "**/*.stories.tsx",
74
- importPathMatcher: /^\\.(?:(?:^|\\/|(?:(?:(?!(?:^|\\/)\\.).)*?)\\/)(?!\\.)(?=.)[^/]*?\\.stories\\.tsx)$/,
75
- // @ts-ignore
76
- req: require.context(
77
- './components',
78
- true,
79
- /^\\.(?:(?:^|\\/|(?:(?:(?!(?:^|\\/)\\.).)*?)\\/)(?!\\.)(?=.)[^/]*?\\.stories\\.tsx)$/
80
- ),
81
- }
82
- ];
83
-
84
-
85
- declare global {
86
- var view: View;
87
- var STORIES: typeof normalizedStories;
88
- }
89
-
90
-
91
- const annotations = [
92
- require('./preview'),
93
- require("@storybook/react-native/preview")
94
- ];
95
-
96
- global.STORIES = normalizedStories;
97
-
98
- // @ts-ignore
99
- module?.hot?.accept?.();
100
-
101
-
102
-
103
- if (!global.view) {
104
- global.view = start({
105
- annotations,
106
- storyEntries: normalizedStories,
107
-
108
- });
109
- } else {
110
- updateView(global.view, annotations, normalizedStories);
111
- }
112
-
113
- export const view: View = global.view;
114
- "
115
- `;
116
-
117
- exports[`loader writeRequires when there is a story glob writes the story imports 1`] = `
118
- "/* do not change this file, it is auto generated by storybook. */
119
- import { start, updateView, View } from '@storybook/react-native';
120
-
121
- import "@storybook/addon-ondevice-notes/register";
122
- import "@storybook/addon-ondevice-controls/register";
123
- import "@storybook/addon-ondevice-backgrounds/register";
124
- import "@storybook/addon-ondevice-actions/register";
125
-
126
- const normalizedStories = [
127
- {
128
- titlePrefix: "",
129
- directory: "./scripts/mocks/all-config-files",
130
- files: "FakeStory.stories.tsx",
131
- importPathMatcher: /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/,
132
- // @ts-ignore
133
- req: require.context(
134
- './',
135
- false,
136
- /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/
137
- ),
138
- }
139
- ];
140
-
141
-
142
- declare global {
143
- var view: View;
144
- var STORIES: typeof normalizedStories;
145
- }
146
-
147
-
148
- const annotations = [
149
- require('./preview'),
150
- require("@storybook/react-native/preview")
151
- ];
152
-
153
- global.STORIES = normalizedStories;
154
-
155
- // @ts-ignore
156
- module?.hot?.accept?.();
157
-
158
-
159
-
160
- if (!global.view) {
161
- global.view = start({
162
- annotations,
163
- storyEntries: normalizedStories,
164
-
165
- });
166
- } else {
167
- updateView(global.view, annotations, normalizedStories);
168
- }
169
-
170
- export const view: View = global.view;
171
- "
172
- `;
173
-
174
- exports[`loader writeRequires when there is no preview does not add preview related stuff 1`] = `
175
- "/* do not change this file, it is auto generated by storybook. */
176
- import { start, updateView, View } from '@storybook/react-native';
177
-
178
- import "@storybook/addon-ondevice-notes/register";
179
- import "@storybook/addon-ondevice-controls/register";
180
- import "@storybook/addon-ondevice-backgrounds/register";
181
- import "@storybook/addon-ondevice-actions/register";
182
-
183
- const normalizedStories = [
184
- {
185
- titlePrefix: "",
186
- directory: "./scripts/mocks/no-preview",
187
- files: "FakeStory.stories.tsx",
188
- importPathMatcher: /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/,
189
- // @ts-ignore
190
- req: require.context(
191
- './',
192
- false,
193
- /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/
194
- ),
195
- }
196
- ];
197
-
198
-
199
- declare global {
200
- var view: View;
201
- var STORIES: typeof normalizedStories;
202
- }
203
-
204
-
205
- const annotations = [
206
- require("@storybook/react-native/preview")
207
- ];
208
-
209
- global.STORIES = normalizedStories;
210
-
211
- // @ts-ignore
212
- module?.hot?.accept?.();
213
-
214
-
215
-
216
- if (!global.view) {
217
- global.view = start({
218
- annotations,
219
- storyEntries: normalizedStories,
220
-
221
- });
222
- } else {
223
- updateView(global.view, annotations, normalizedStories);
224
- }
225
-
226
- export const view: View = global.view;
227
- "
228
- `;
229
-
230
- exports[`loader writeRequires when using js writes the story imports without types 1`] = `
231
- "/* do not change this file, it is auto generated by storybook. */
232
- import { start, updateView } from '@storybook/react-native';
233
-
234
- import "@storybook/addon-ondevice-notes/register";
235
- import "@storybook/addon-ondevice-controls/register";
236
- import "@storybook/addon-ondevice-backgrounds/register";
237
- import "@storybook/addon-ondevice-actions/register";
238
-
239
- const normalizedStories = [
240
- {
241
- titlePrefix: "",
242
- directory: "./scripts/mocks/all-config-files",
243
- files: "FakeStory.stories.tsx",
244
- importPathMatcher: /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/,
245
-
246
- req: require.context(
247
- './',
248
- false,
249
- /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/
250
- ),
251
- }
252
- ];
253
-
254
-
255
-
256
- const annotations = [
257
- require('./preview'),
258
- require("@storybook/react-native/preview")
259
- ];
260
-
261
- global.STORIES = normalizedStories;
262
-
263
-
264
- module?.hot?.accept?.();
265
-
266
-
267
-
268
- if (!global.view) {
269
- global.view = start({
270
- annotations,
271
- storyEntries: normalizedStories,
272
-
273
- });
274
- } else {
275
- updateView(global.view, annotations, normalizedStories);
276
- }
277
-
278
- export const view = global.view;
279
- "
280
- `;