@storybook/react-native 9.0.0-alpha.1 → 9.0.0-alpha.8

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/babel.config.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // note this file is used by jest to make it not shit itself
2
2
  module.exports = {
3
- presets: ['module:@react-native/babel-preset'],
3
+ presets: ['babel-preset-expo'],
4
4
  };
package/dist/index.d.ts CHANGED
@@ -100,6 +100,7 @@ interface StorybookConfig {
100
100
  options?: Record<string, any>;
101
101
  }>;
102
102
  reactNative?: ReactNativeOptions;
103
+ framework?: '@storybook/react-native';
103
104
  }
104
105
 
105
106
  export { StorybookConfig, getProjectAnnotations, prepareStories, start, updateView };
package/dist/index.js CHANGED
@@ -1164,10 +1164,11 @@ function prepareStories({
1164
1164
  const exportValue = fileExports[key];
1165
1165
  if (!exportValue)
1166
1166
  return;
1167
- const name = (0, import_csf2.storyNameFromExport)(key);
1168
1167
  const title = makeTitle(filename, specifier, meta.title);
1169
1168
  if (title) {
1170
- const id = (0, import_csf2.toId)(title, name);
1169
+ const nameFromExport = (0, import_csf2.storyNameFromExport)(key);
1170
+ const id = (0, import_csf2.toId)(title, nameFromExport);
1171
+ const name = exportValue?.name || exportValue?.storyName || nameFromExport;
1171
1172
  index.entries[id] = {
1172
1173
  type: "story",
1173
1174
  id,
@@ -1282,7 +1283,6 @@ function start({
1282
1283
  setQueryParams: () => {
1283
1284
  },
1284
1285
  setSelection: (selection) => {
1285
- console.log("setSelection", selection);
1286
1286
  preview.selectionStore.selection = selection;
1287
1287
  }
1288
1288
  };
package/jest.config.js CHANGED
@@ -1,13 +1,8 @@
1
1
  /** @type {import('jest').Config} */
2
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
- transform: {
9
- '^.+\\.(js)$': ['babel-jest', { plugins: ['babel-plugin-syntax-hermes-parser'] }],
10
- '^.+\\.(ts|tsx)$': 'babel-jest',
11
- },
3
+ preset: 'jest-expo',
4
+ transformIgnorePatterns: [
5
+ '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
+ ],
12
7
  };
13
8
  module.exports = config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native",
3
- "version": "9.0.0-alpha.1",
3
+ "version": "9.0.0-alpha.8",
4
4
  "description": "A better way to develop React Native Components for your app",
5
5
  "keywords": [
6
6
  "react",
@@ -25,7 +25,8 @@
25
25
  ".": "./dist/index.js",
26
26
  "./metro/withStorybook": "./dist/metro/withStorybook.js",
27
27
  "./preview": "./dist/preview.js",
28
- "./scripts/generate": "./scripts/generate.js"
28
+ "./scripts/generate": "./scripts/generate.js",
29
+ "./preset": "./preset.js"
29
30
  },
30
31
  "files": [
31
32
  "bin/**/*",
@@ -47,16 +48,15 @@
47
48
  "dependencies": {
48
49
  "@storybook/csf": "^0.1.13",
49
50
  "@storybook/global": "^5.0.0",
50
- "@storybook/react": "9.0.0-alpha.3",
51
- "@storybook/react-native-theming": "^9.0.0-alpha.1",
52
- "@storybook/react-native-ui": "^9.0.0-alpha.1",
51
+ "@storybook/react": "9.0.0-alpha.8",
52
+ "@storybook/react-native-theming": "^9.0.0-alpha.8",
53
+ "@storybook/react-native-ui": "^9.0.0-alpha.8",
53
54
  "commander": "^8.2.0",
54
55
  "dedent": "^1.5.1",
55
56
  "deepmerge": "^4.3.0",
56
57
  "prettier": "^2.4.1",
57
58
  "react-native-url-polyfill": "^2.0.0",
58
59
  "setimmediate": "^1.0.5",
59
- "storybook": "9.0.0-alpha.3",
60
60
  "type-fest": "~2.19",
61
61
  "util": "^0.12.4",
62
62
  "ws": "^8.18.0"
@@ -65,12 +65,14 @@
65
65
  "@types/jest": "^29.4.3",
66
66
  "@types/react": "~18.3.12",
67
67
  "babel-jest": "^29.7.0",
68
- "babel-plugin-syntax-hermes-parser": "^0.25.0",
68
+ "babel-preset-expo": "^12.0.9",
69
69
  "jest": "^29.7.0",
70
+ "jest-expo": "~52.0.6",
70
71
  "jotai": "^2.6.2",
71
72
  "react": "18.3.1",
72
73
  "react-native": "0.76.7",
73
74
  "react-test-renderer": "^18.3.1",
75
+ "storybook": "9.0.0-alpha.8",
74
76
  "tsup": "^7.2.0",
75
77
  "typescript": "^5.3.3"
76
78
  },
@@ -79,7 +81,8 @@
79
81
  "react": "*",
80
82
  "react-native": ">=0.72.0",
81
83
  "react-native-gesture-handler": ">=2",
82
- "react-native-safe-area-context": "*"
84
+ "react-native-safe-area-context": "*",
85
+ "storybook": "9.0.0-alpha.8"
83
86
  },
84
87
  "engines": {
85
88
  "node": ">=8.0.0"
@@ -87,5 +90,5 @@
87
90
  "publishConfig": {
88
91
  "access": "public"
89
92
  },
90
- "gitHead": "ec42eef3ebdf389ebf9cf669d425712db99f9e37"
93
+ "gitHead": "16659266d8aa9816490af41d0a840579a2f96805"
91
94
  }
package/preset.js ADDED
@@ -0,0 +1,2 @@
1
+ // just to be a valid framework
2
+ module.exports = {};
@@ -4,6 +4,8 @@ const { generate } = require('./generate');
4
4
  let pathMock;
5
5
  let fileContentMock;
6
6
 
7
+ global.window.navigator = {};
8
+
7
9
  jest.mock('fs', () => ({
8
10
  ...jest.requireActual('fs'),
9
11
  writeFileSync: (filePath, fileContent, opts) => {
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from '@storybook/react-native-web-vite';
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
2
 
3
3
  import { View } from 'react-native';
4
4
  import { fn } from 'storybook/test';
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from '@storybook/react-native-web-vite';
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
2
 
3
3
  import { Header } from './Header';
4
4
 
@@ -3,7 +3,7 @@ import { StyleSheet, Text, View } from 'react-native';
3
3
  import { Button } from './Button';
4
4
 
5
5
  export type HeaderProps = {
6
- user?: {};
6
+ user?: { name: string };
7
7
  onLogin: () => void;
8
8
  onLogout: () => void;
9
9
  onCreateAccount: () => void;
@@ -18,15 +18,15 @@ export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps
18
18
  <View style={styles.buttonContainer}>
19
19
  {user ? (
20
20
  <>
21
- <>
22
- <Text>Welcome, </Text>
23
- <Text style={styles.userName}>{user.name}!</Text>
24
- </>
21
+ <Text>Welcome, </Text>
22
+ <Text style={styles.userName}>{user.name}!</Text>
23
+
25
24
  <Button style={styles.button} size="small" onPress={onLogout} label="Log out" />
26
25
  </>
27
26
  ) : (
28
27
  <>
29
28
  <Button style={styles.button} size="small" onPress={onLogin} label="Log in" />
29
+
30
30
  <Button
31
31
  style={styles.button}
32
32
  primary
@@ -1,6 +1,4 @@
1
- import type { Meta } from '@storybook/react-native-web-vite';
2
-
3
- import { expect, userEvent, within } from 'storybook/test';
1
+ import type { Meta } from '@storybook/react';
4
2
 
5
3
  import { Page } from './Page';
6
4
 
@@ -9,17 +7,4 @@ export default {
9
7
  component: Page,
10
8
  } as Meta<typeof Page>;
11
9
 
12
- export const LoggedIn = {
13
- play: async ({ canvasElement }) => {
14
- const canvas = within(canvasElement);
15
- const loginButton = canvas.getByRole('button', { name: /Log in/i });
16
- await expect(loginButton).toBeInTheDocument();
17
- await userEvent.click(loginButton);
18
- // FIXME: await expect(loginButton).not.toBeInTheDocument();
19
-
20
- const logoutButton = canvas.getByRole('button', { name: /Log out/i });
21
- await expect(logoutButton).toBeInTheDocument();
22
- },
23
- };
24
-
25
- export const LoggedOut = {};
10
+ export const Default = {};
@@ -5,7 +5,7 @@ import { Linking, StyleSheet, Text, View } from 'react-native';
5
5
  import { Header } from './Header';
6
6
 
7
7
  export const Page = () => {
8
- const [user, setUser] = useState();
8
+ const [user, setUser] = useState<{ name: string } | undefined>();
9
9
 
10
10
  return (
11
11
  <View>
@@ -39,14 +39,14 @@ export const Page = () => {
39
39
  data in Storybook:
40
40
  </Text>
41
41
  <View>
42
- <View>
42
+ <Text>
43
43
  Use a higher-level connected component. Storybook helps you compose such data from the
44
44
  "args" of child component stories
45
- </View>
46
- <View>
45
+ </Text>
46
+ <Text>
47
47
  Assemble data in the page component from your services. You can mock these services out
48
48
  using Storybook.
49
- </View>
49
+ </Text>
50
50
  </View>
51
51
  <Text style={styles.p}>
52
52
  Get a guided tutorial on component-driven development at{' '}
@@ -71,13 +71,6 @@ export const Page = () => {
71
71
  </Text>
72
72
  .
73
73
  </Text>
74
- <View style={styles.tipWrapper}>
75
- <View style={styles.tip}>
76
- <Text style={styles.tipText}>Tip </Text>
77
- </View>
78
- <Text>Adjust the width of the canvas with the </Text>
79
- <Text>Viewports addon in the toolbar</Text>
80
- </View>
81
74
  </View>
82
75
  </View>
83
76
  );