@storybook/react-native 8.0.0-alpha.4 → 8.2.0-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/index.d.ts +20 -11
- package/dist/index.js +81 -3021
- package/dist/preview.d.ts +6 -13
- package/dist/preview.js +21 -4
- package/jest.config.js +9 -0
- package/metro/withStorybook.js +53 -0
- package/package.json +10 -30
- package/scripts/__snapshots__/generate.test.js.snap +77 -20
- package/scripts/common.js +1 -1
- package/scripts/generate.js +18 -6
- package/scripts/generate.test.js +10 -0
- package/scripts/loader.js +1 -1
- package/template/cli/stories/Button/Button.stories.tsx +7 -5
- package/template/cli/stories/Button/Button.tsx +1 -1
- package/template/cli/storybook.requires.ts +25 -10
- package/dist/index.d-3fb25d8d.d.ts +0 -1520
package/dist/preview.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
4
|
-
import 'http';
|
|
1
|
+
import * as _storybook_csf from '@storybook/csf';
|
|
2
|
+
import { Preview } from '@storybook/react';
|
|
3
|
+
import { Renderer, StoryContextForEnhancers } from '@storybook/core/types';
|
|
5
4
|
|
|
6
|
-
declare const
|
|
7
|
-
|
|
8
|
-
parameters: {
|
|
9
|
-
docs: {
|
|
10
|
-
extractArgTypes: _storybook_docs_tools.ArgTypesExtractor;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
5
|
+
declare const enhanceArgTypes: <TRenderer extends Renderer>(context: StoryContextForEnhancers<TRenderer, _storybook_csf.Args>) => _storybook_csf.StrictArgTypes<_storybook_csf.Args>;
|
|
6
|
+
declare const preview: Preview;
|
|
14
7
|
|
|
15
|
-
export {
|
|
8
|
+
export { preview as default, enhanceArgTypes };
|
package/dist/preview.js
CHANGED
|
@@ -19,16 +19,33 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/preview.ts
|
|
20
20
|
var preview_exports = {};
|
|
21
21
|
__export(preview_exports, {
|
|
22
|
-
default: () => preview_default
|
|
22
|
+
default: () => preview_default,
|
|
23
|
+
enhanceArgTypes: () => enhanceArgTypes
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(preview_exports);
|
|
25
26
|
var import_entry_preview_docs = require("@storybook/react/dist/entry-preview-docs");
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
|
|
27
|
+
var import_preview_api = require("@storybook/core/preview-api");
|
|
28
|
+
var enhanceArgTypes = (context) => {
|
|
29
|
+
const {
|
|
30
|
+
component,
|
|
31
|
+
argTypes: userArgTypes,
|
|
32
|
+
parameters: { docs = {} }
|
|
33
|
+
} = context;
|
|
34
|
+
const { extractArgTypes } = docs;
|
|
35
|
+
const extractedArgTypes = extractArgTypes && component ? extractArgTypes(component) : {};
|
|
36
|
+
const withExtractedTypes = extractedArgTypes ? (0, import_preview_api.combineParameters)(extractedArgTypes, userArgTypes) : userArgTypes;
|
|
37
|
+
return withExtractedTypes;
|
|
38
|
+
};
|
|
39
|
+
var preview = {
|
|
40
|
+
argTypesEnhancers: [enhanceArgTypes],
|
|
29
41
|
parameters: {
|
|
30
42
|
docs: {
|
|
31
43
|
extractArgTypes: import_entry_preview_docs.parameters.docs.extractArgTypes
|
|
32
44
|
}
|
|
33
45
|
}
|
|
34
46
|
};
|
|
47
|
+
var preview_default = preview;
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
enhanceArgTypes
|
|
51
|
+
});
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @type {import('jest').Config} */
|
|
2
|
+
const config = {
|
|
3
|
+
preset: 'react-native',
|
|
4
|
+
modulePathIgnorePatterns: ['dist/'],
|
|
5
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
|
6
|
+
transformIgnorePatterns: ['node_modules/(?!react-native|@react-native)'],
|
|
7
|
+
setupFilesAfterEnv: ['<rootDir>/../../node_modules/react-native-gesture-handler/jestSetup.js'],
|
|
8
|
+
};
|
|
9
|
+
module.exports = config;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const { generate } = require('../scripts/generate');
|
|
4
|
+
|
|
5
|
+
let alreadyReplaced = false;
|
|
6
|
+
|
|
7
|
+
module.exports = (config, { configPath, enabled }) => {
|
|
8
|
+
if (!enabled) {
|
|
9
|
+
return config;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
generate({
|
|
13
|
+
configPath: configPath ?? path.resolve(process.cwd(), './.storybook'),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
...config,
|
|
18
|
+
transformer: {
|
|
19
|
+
...config.transformer,
|
|
20
|
+
unstable_allowRequireContext: true,
|
|
21
|
+
},
|
|
22
|
+
resolver: {
|
|
23
|
+
...config.resolver,
|
|
24
|
+
unstable_enablePackageExports: true,
|
|
25
|
+
resolveRequest: (context, moduleName, platform) => {
|
|
26
|
+
const defaultResolveResult = context.resolveRequest(context, moduleName, platform);
|
|
27
|
+
|
|
28
|
+
// workaround for template files with invalid imports
|
|
29
|
+
if (defaultResolveResult?.filePath?.includes?.('@storybook/react/template/cli')) {
|
|
30
|
+
return {
|
|
31
|
+
type: 'empty',
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// workaround for unsupported regex
|
|
36
|
+
if (defaultResolveResult?.filePath?.includes?.('@storybook/core/dist/docs-tools/index')) {
|
|
37
|
+
if (!alreadyReplaced) {
|
|
38
|
+
const filepath = path.resolve(defaultResolveResult?.filePath);
|
|
39
|
+
|
|
40
|
+
const input = fs.readFileSync(filepath, 'utf-8');
|
|
41
|
+
|
|
42
|
+
const output = input.replace(/new RegExp\(([^)]+).*, "u"\)/g, 'new RegExp("")');
|
|
43
|
+
|
|
44
|
+
fs.writeFileSync(filepath, output);
|
|
45
|
+
alreadyReplaced = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return defaultResolveResult;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0-alpha.0",
|
|
4
4
|
"description": "A better way to develop React Native Components for your app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"*.js",
|
|
30
30
|
"*.d.ts",
|
|
31
31
|
"scripts/*",
|
|
32
|
+
"metro/*",
|
|
32
33
|
"template/**/*"
|
|
33
34
|
],
|
|
34
35
|
"scripts": {
|
|
@@ -37,33 +38,13 @@
|
|
|
37
38
|
"test": "jest",
|
|
38
39
|
"test:ci": "jest"
|
|
39
40
|
},
|
|
40
|
-
"jest": {
|
|
41
|
-
"modulePathIgnorePatterns": [
|
|
42
|
-
"dist/"
|
|
43
|
-
],
|
|
44
|
-
"moduleFileExtensions": [
|
|
45
|
-
"ts",
|
|
46
|
-
"tsx",
|
|
47
|
-
"js",
|
|
48
|
-
"jsx",
|
|
49
|
-
"json",
|
|
50
|
-
"node"
|
|
51
|
-
],
|
|
52
|
-
"preset": "react-native"
|
|
53
|
-
},
|
|
54
41
|
"dependencies": {
|
|
55
|
-
"@storybook/
|
|
56
|
-
"@storybook/client-logger": "^8",
|
|
57
|
-
"@storybook/core-common": "^8",
|
|
58
|
-
"@storybook/core-events": "^8",
|
|
42
|
+
"@storybook/core": "8.2.0-beta.0",
|
|
59
43
|
"@storybook/csf": "^0.1.1",
|
|
60
|
-
"@storybook/docs-tools": "^8",
|
|
61
44
|
"@storybook/global": "^5.0.0",
|
|
62
|
-
"@storybook/
|
|
63
|
-
"@storybook/
|
|
64
|
-
"@storybook/react": "^8",
|
|
65
|
-
"@storybook/react-native-theming": "^8.0.0-alpha.4",
|
|
66
|
-
"@storybook/react-native-ui": "^8.0.0-alpha.4",
|
|
45
|
+
"@storybook/react": "8.2.0-beta.0",
|
|
46
|
+
"@storybook/react-native-theming": "^8.2.0-alpha.0",
|
|
47
|
+
"@storybook/react-native-ui": "^8.2.0-alpha.0",
|
|
67
48
|
"chokidar": "^3.5.1",
|
|
68
49
|
"commander": "^8.2.0",
|
|
69
50
|
"dedent": "^1.5.1",
|
|
@@ -75,15 +56,14 @@
|
|
|
75
56
|
"util": "^0.12.4"
|
|
76
57
|
},
|
|
77
58
|
"devDependencies": {
|
|
78
|
-
"@storybook/types": "^8",
|
|
79
59
|
"@types/jest": "^29.4.3",
|
|
80
|
-
"@types/react": "~18.2.
|
|
60
|
+
"@types/react": "~18.2.79",
|
|
81
61
|
"babel-jest": "^29.4.3",
|
|
82
|
-
"jest": "
|
|
62
|
+
"jest": "29.7.0",
|
|
83
63
|
"jotai": "^2.6.2",
|
|
84
64
|
"react-test-renderer": "18.2.0",
|
|
85
65
|
"tsup": "^7.2.0",
|
|
86
|
-
"typescript": "
|
|
66
|
+
"typescript": "~5.3.3"
|
|
87
67
|
},
|
|
88
68
|
"peerDependencies": {
|
|
89
69
|
"@gorhom/bottom-sheet": ">=4",
|
|
@@ -98,5 +78,5 @@
|
|
|
98
78
|
"publishConfig": {
|
|
99
79
|
"access": "public"
|
|
100
80
|
},
|
|
101
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "56cad3ccee28ceae70cc7e2fc9b63ec28384eecf"
|
|
102
82
|
}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
exports[`loader writeRequires when there are different file extensions writes the story imports 1`] = `
|
|
4
4
|
"
|
|
5
5
|
/* do not change this file, it is auto generated by storybook. */
|
|
6
|
-
|
|
7
|
-
import { start,
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
import { start, updateView } from '@storybook/react-native';
|
|
8
|
+
|
|
9
9
|
import "@storybook/addon-ondevice-notes/register";
|
|
10
10
|
import "@storybook/addon-ondevice-controls/register";
|
|
11
11
|
import "@storybook/addon-ondevice-backgrounds/register";
|
|
@@ -34,13 +34,16 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
34
34
|
// @ts-ignore
|
|
35
35
|
module?.hot?.accept?.();
|
|
36
36
|
|
|
37
|
+
|
|
38
|
+
|
|
37
39
|
if (!global.view) {
|
|
38
40
|
global.view = start({
|
|
39
41
|
annotations,
|
|
40
|
-
storyEntries: normalizedStories
|
|
42
|
+
storyEntries: normalizedStories,
|
|
43
|
+
|
|
41
44
|
});
|
|
42
45
|
} else {
|
|
43
|
-
updateView(global.view, annotations, normalizedStories);
|
|
46
|
+
updateView(global.view, annotations, normalizedStories, );
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
export const view = global.view;
|
|
@@ -50,9 +53,9 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
50
53
|
exports[`loader writeRequires when there is a configuration object writes the story imports 1`] = `
|
|
51
54
|
"
|
|
52
55
|
/* do not change this file, it is auto generated by storybook. */
|
|
53
|
-
|
|
54
|
-
import { start,
|
|
55
|
-
|
|
56
|
+
|
|
57
|
+
import { start, updateView } from '@storybook/react-native';
|
|
58
|
+
|
|
56
59
|
import "@storybook/addon-ondevice-notes/register";
|
|
57
60
|
import "@storybook/addon-ondevice-controls/register";
|
|
58
61
|
import "@storybook/addon-ondevice-backgrounds/register";
|
|
@@ -81,13 +84,16 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
81
84
|
// @ts-ignore
|
|
82
85
|
module?.hot?.accept?.();
|
|
83
86
|
|
|
87
|
+
|
|
88
|
+
|
|
84
89
|
if (!global.view) {
|
|
85
90
|
global.view = start({
|
|
86
91
|
annotations,
|
|
87
|
-
storyEntries: normalizedStories
|
|
92
|
+
storyEntries: normalizedStories,
|
|
93
|
+
|
|
88
94
|
});
|
|
89
95
|
} else {
|
|
90
|
-
updateView(global.view, annotations, normalizedStories);
|
|
96
|
+
updateView(global.view, annotations, normalizedStories, );
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
export const view = global.view;
|
|
@@ -97,9 +103,9 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
97
103
|
exports[`loader writeRequires when there is a story glob writes the story imports 1`] = `
|
|
98
104
|
"
|
|
99
105
|
/* do not change this file, it is auto generated by storybook. */
|
|
100
|
-
|
|
101
|
-
import { start,
|
|
102
|
-
|
|
106
|
+
|
|
107
|
+
import { start, updateView } from '@storybook/react-native';
|
|
108
|
+
|
|
103
109
|
import "@storybook/addon-ondevice-notes/register";
|
|
104
110
|
import "@storybook/addon-ondevice-controls/register";
|
|
105
111
|
import "@storybook/addon-ondevice-backgrounds/register";
|
|
@@ -128,13 +134,16 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
128
134
|
// @ts-ignore
|
|
129
135
|
module?.hot?.accept?.();
|
|
130
136
|
|
|
137
|
+
|
|
138
|
+
|
|
131
139
|
if (!global.view) {
|
|
132
140
|
global.view = start({
|
|
133
141
|
annotations,
|
|
134
|
-
storyEntries: normalizedStories
|
|
142
|
+
storyEntries: normalizedStories,
|
|
143
|
+
|
|
135
144
|
});
|
|
136
145
|
} else {
|
|
137
|
-
updateView(global.view, annotations, normalizedStories);
|
|
146
|
+
updateView(global.view, annotations, normalizedStories, );
|
|
138
147
|
}
|
|
139
148
|
|
|
140
149
|
export const view = global.view;
|
|
@@ -144,9 +153,9 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
144
153
|
exports[`loader writeRequires when there is no preview does not add preview related stuff 1`] = `
|
|
145
154
|
"
|
|
146
155
|
/* do not change this file, it is auto generated by storybook. */
|
|
147
|
-
|
|
148
|
-
import { start,
|
|
149
|
-
|
|
156
|
+
|
|
157
|
+
import { start, updateView } from '@storybook/react-native';
|
|
158
|
+
|
|
150
159
|
import "@storybook/addon-ondevice-notes/register";
|
|
151
160
|
import "@storybook/addon-ondevice-controls/register";
|
|
152
161
|
import "@storybook/addon-ondevice-backgrounds/register";
|
|
@@ -175,13 +184,61 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
175
184
|
// @ts-ignore
|
|
176
185
|
module?.hot?.accept?.();
|
|
177
186
|
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
if (!global.view) {
|
|
190
|
+
global.view = start({
|
|
191
|
+
annotations,
|
|
192
|
+
storyEntries: normalizedStories,
|
|
193
|
+
|
|
194
|
+
});
|
|
195
|
+
} else {
|
|
196
|
+
updateView(global.view, annotations, normalizedStories, );
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export const view = global.view;
|
|
200
|
+
"
|
|
201
|
+
`;
|
|
202
|
+
|
|
203
|
+
exports[`loader writeRequires when using js writes the story imports without types 1`] = `
|
|
204
|
+
"
|
|
205
|
+
/* do not change this file, it is auto generated by storybook. */
|
|
206
|
+
|
|
207
|
+
import { start, updateView } from '@storybook/react-native';
|
|
208
|
+
|
|
209
|
+
import "@storybook/addon-ondevice-notes/register";
|
|
210
|
+
import "@storybook/addon-ondevice-controls/register";
|
|
211
|
+
import "@storybook/addon-ondevice-backgrounds/register";
|
|
212
|
+
import "@storybook/addon-ondevice-actions/register";
|
|
213
|
+
|
|
214
|
+
const normalizedStories = [{
|
|
215
|
+
titlePrefix: "",
|
|
216
|
+
directory: "./scripts/mocks/all-config-files",
|
|
217
|
+
files: "FakeStory.stories.tsx",
|
|
218
|
+
importPathMatcher: /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/,
|
|
219
|
+
|
|
220
|
+
req: require.context('./', false, /^\\.[\\\\/](?:FakeStory\\.stories\\.tsx)$/)
|
|
221
|
+
}];
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
const annotations = [require('./preview'),require("@storybook/react-native/dist/preview"), require('@storybook/addon-actions/preview')];
|
|
226
|
+
|
|
227
|
+
global.STORIES = normalizedStories;
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
module?.hot?.accept?.();
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
178
234
|
if (!global.view) {
|
|
179
235
|
global.view = start({
|
|
180
236
|
annotations,
|
|
181
|
-
storyEntries: normalizedStories
|
|
237
|
+
storyEntries: normalizedStories,
|
|
238
|
+
|
|
182
239
|
});
|
|
183
240
|
} else {
|
|
184
|
-
updateView(global.view, annotations, normalizedStories);
|
|
241
|
+
updateView(global.view, annotations, normalizedStories, );
|
|
185
242
|
}
|
|
186
243
|
|
|
187
244
|
export const view = global.view;
|
package/scripts/common.js
CHANGED
package/scripts/generate.js
CHANGED
|
@@ -4,7 +4,7 @@ const {
|
|
|
4
4
|
getMain,
|
|
5
5
|
getPreviewExists,
|
|
6
6
|
} = require('./common');
|
|
7
|
-
const { normalizeStories, globToRegexp } = require('@storybook/core
|
|
7
|
+
const { normalizeStories, globToRegexp } = require('@storybook/core/common');
|
|
8
8
|
const fs = require('fs');
|
|
9
9
|
const prettier = require('prettier');
|
|
10
10
|
const path = require('path');
|
|
@@ -41,7 +41,7 @@ function generate({ configPath, absolute = false, useJs = false }) {
|
|
|
41
41
|
directory: "${specifier.directory}",
|
|
42
42
|
files: "${specifier.files}",
|
|
43
43
|
importPathMatcher: /${reg.source}/,
|
|
44
|
-
// @ts-ignore
|
|
44
|
+
${useJs ? '' : '// @ts-ignore'}
|
|
45
45
|
req: require.context('${pathToStory}', ${r}, ${m})
|
|
46
46
|
}`;
|
|
47
47
|
});
|
|
@@ -55,6 +55,15 @@ function generate({ configPath, absolute = false, useJs = false }) {
|
|
|
55
55
|
? "require('@storybook/addon-actions/preview')"
|
|
56
56
|
: '';
|
|
57
57
|
|
|
58
|
+
let options = '';
|
|
59
|
+
let optionsVar = '';
|
|
60
|
+
const reactNativeOptions = main.reactNative;
|
|
61
|
+
|
|
62
|
+
if (reactNativeOptions && typeof reactNativeOptions === 'object') {
|
|
63
|
+
optionsVar = `const options = ${JSON.stringify(reactNativeOptions)}`;
|
|
64
|
+
options = 'options';
|
|
65
|
+
}
|
|
66
|
+
|
|
58
67
|
const previewExists = getPreviewExists({ configPath });
|
|
59
68
|
|
|
60
69
|
const annotations = `[${previewExists ? "require('./preview')," : ''}${doctools}, ${enhancer}]`;
|
|
@@ -80,17 +89,20 @@ function generate({ configPath, absolute = false, useJs = false }) {
|
|
|
80
89
|
const annotations = ${annotations};
|
|
81
90
|
|
|
82
91
|
global.STORIES = normalizedStories;
|
|
83
|
-
|
|
84
|
-
// @ts-ignore
|
|
92
|
+
|
|
93
|
+
${useJs ? '' : '// @ts-ignore'}
|
|
85
94
|
module?.hot?.accept?.();
|
|
86
95
|
|
|
96
|
+
${optionsVar}
|
|
97
|
+
|
|
87
98
|
if (!global.view) {
|
|
88
99
|
global.view = start({
|
|
89
100
|
annotations,
|
|
90
|
-
storyEntries: normalizedStories
|
|
101
|
+
storyEntries: normalizedStories,
|
|
102
|
+
${options}
|
|
91
103
|
});
|
|
92
104
|
} else {
|
|
93
|
-
updateView(global.view, annotations, normalizedStories);
|
|
105
|
+
updateView(global.view, annotations, normalizedStories, ${options});
|
|
94
106
|
}
|
|
95
107
|
|
|
96
108
|
export const view = global.view;
|
package/scripts/generate.test.js
CHANGED
|
@@ -30,6 +30,16 @@ describe('loader', () => {
|
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
+
describe('when using js', () => {
|
|
34
|
+
it('writes the story imports without types', () => {
|
|
35
|
+
generate({ configPath: 'scripts/mocks/all-config-files', useJs: true });
|
|
36
|
+
expect(pathMock).toEqual(
|
|
37
|
+
path.resolve(__dirname, 'mocks/all-config-files/storybook.requires.js')
|
|
38
|
+
);
|
|
39
|
+
expect(fileContentMock).toMatchSnapshot();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
33
43
|
describe('when there are different file extensions', () => {
|
|
34
44
|
it('writes the story imports', () => {
|
|
35
45
|
generate({ configPath: 'scripts/mocks/file-extensions' });
|
package/scripts/loader.js
CHANGED
|
@@ -2,7 +2,7 @@ const path = require('path');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const glob = require('glob');
|
|
4
4
|
const prettier = require('prettier');
|
|
5
|
-
const { normalizeStories } = require('@storybook/core
|
|
5
|
+
const { normalizeStories } = require('@storybook/core/common');
|
|
6
6
|
const {
|
|
7
7
|
toRequireContext,
|
|
8
8
|
getFilePathExtension,
|
|
@@ -2,7 +2,7 @@ import { View } from 'react-native';
|
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
3
|
import { MyButton } from './Button';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const meta = {
|
|
6
6
|
title: 'MyButton',
|
|
7
7
|
component: MyButton,
|
|
8
8
|
argTypes: {
|
|
@@ -18,13 +18,15 @@ const MyButtonMeta: Meta<typeof MyButton> = {
|
|
|
18
18
|
</View>
|
|
19
19
|
),
|
|
20
20
|
],
|
|
21
|
-
}
|
|
21
|
+
} satisfies Meta<typeof MyButton>;
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
type Story = StoryObj<typeof meta>;
|
|
24
26
|
|
|
25
|
-
export const Basic:
|
|
27
|
+
export const Basic: Story = {};
|
|
26
28
|
|
|
27
|
-
export const AnotherExample:
|
|
29
|
+
export const AnotherExample: Story = {
|
|
28
30
|
args: {
|
|
29
31
|
text: 'Another example',
|
|
30
32
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* do not change this file, it is auto generated by storybook. */
|
|
2
2
|
|
|
3
|
-
import { start } from '@storybook/react-native';
|
|
3
|
+
import { start, updateView } from '@storybook/react-native';
|
|
4
4
|
|
|
5
5
|
import '@storybook/addon-ondevice-controls/register';
|
|
6
6
|
import '@storybook/addon-ondevice-actions/register';
|
|
@@ -21,14 +21,29 @@ const normalizedStories = [
|
|
|
21
21
|
},
|
|
22
22
|
];
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
declare global {
|
|
25
|
+
var view: ReturnType<typeof start>;
|
|
26
|
+
var STORIES: typeof normalizedStories;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const annotations = [
|
|
30
|
+
require('./preview'),
|
|
31
|
+
require('@storybook/react-native/dist/preview'),
|
|
32
|
+
require('@storybook/addon-actions/preview'),
|
|
33
|
+
];
|
|
34
|
+
|
|
25
35
|
global.STORIES = normalizedStories;
|
|
26
36
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
module?.hot?.accept?.();
|
|
39
|
+
|
|
40
|
+
if (!global.view) {
|
|
41
|
+
global.view = start({
|
|
42
|
+
annotations,
|
|
43
|
+
storyEntries: normalizedStories,
|
|
44
|
+
});
|
|
45
|
+
} else {
|
|
46
|
+
updateView(global.view, annotations, normalizedStories);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const view = global.view;
|