@storybook/react-native-web-vite 9.0.0-alpha.1 → 9.0.0-alpha.11

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
@@ -2,6 +2,7 @@ import { CompatibleString } from 'storybook/internal/types';
2
2
  import { FrameworkOptions as FrameworkOptions$1, StorybookConfig as StorybookConfig$1 } from '@storybook/react-vite';
3
3
  import { Options, BabelOptions } from '@vitejs/plugin-react';
4
4
  import { BabelPluginOptions } from 'vite-plugin-babel';
5
+ export * from '@storybook/react';
5
6
  export { __definePreview as definePreview } from '@storybook/react';
6
7
 
7
8
  type FrameworkOptions = FrameworkOptions$1 & {
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var index_exports={};__export(index_exports,{definePreview:()=>import_react.__definePreview});module.exports=__toCommonJS(index_exports);var import_react=require("@storybook/react");0&&(module.exports={definePreview});
1
+ "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__reExport=(target,mod,secondTarget)=>(__copyProps(target,mod,"default"),secondTarget&&__copyProps(secondTarget,mod,"default"));var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var index_exports={};__export(index_exports,{definePreview:()=>import_react.__definePreview});module.exports=__toCommonJS(index_exports);var import_react=require("@storybook/react");__reExport(index_exports,require("@storybook/react"),module.exports);0&&(module.exports={definePreview,...require("@storybook/react")});
package/dist/index.mjs CHANGED
@@ -1 +1,2 @@
1
+ export * from '@storybook/react';
1
2
  export { __definePreview as definePreview } from '@storybook/react';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native-web-vite",
3
- "version": "9.0.0-alpha.1",
3
+ "version": "9.0.0-alpha.11",
4
4
  "description": "Develop react-native components an isolated web environment with hot reloading.",
5
5
  "keywords": [
6
6
  "storybook"
@@ -63,9 +63,9 @@
63
63
  "@babel/preset-react": "^7.26.3",
64
64
  "@bunchtogether/vite-plugin-flow": "^1.0.2",
65
65
  "@joshwooding/vite-plugin-react-docgen-typescript": "0.5.0",
66
- "@storybook/builder-vite": "9.0.0-alpha.1",
67
- "@storybook/react": "9.0.0-alpha.1",
68
- "@storybook/react-vite": "9.0.0-alpha.1",
66
+ "@storybook/builder-vite": "9.0.0-alpha.11",
67
+ "@storybook/react": "9.0.0-alpha.11",
68
+ "@storybook/react-vite": "9.0.0-alpha.11",
69
69
  "@vitejs/plugin-react": "^4.3.2",
70
70
  "vite-plugin-babel": "^1.3.0",
71
71
  "vite-plugin-commonjs": "^0.10.4",
@@ -80,7 +80,7 @@
80
80
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
81
81
  "react-native": ">=0.74.5",
82
82
  "react-native-web": "^0.19.12",
83
- "storybook": "^9.0.0-alpha.1",
83
+ "storybook": "^9.0.0-alpha.11",
84
84
  "vite": "^5.0.0 || ^6.0.0"
85
85
  },
86
86
  "engines": {
@@ -1,6 +1,5 @@
1
- import { fn } from '@storybook/test';
2
-
3
1
  import { View } from 'react-native';
2
+ import { fn } from 'storybook/test';
4
3
 
5
4
  import { Button } from './Button';
6
5
 
@@ -13,10 +13,9 @@ export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => (
13
13
  <View style={styles.buttonContainer}>
14
14
  {user ? (
15
15
  <>
16
- <>
17
- <Text>Welcome, </Text>
18
- <Text style={styles.userName}>{user.name}!</Text>
19
- </>
16
+ <Text>Welcome, </Text>
17
+ <Text style={styles.userName}>{user.name}!</Text>
18
+
20
19
  <Button style={styles.button} size="small" onPress={onLogout} label="Log out" />
21
20
  </>
22
21
  ) : (
@@ -42,15 +42,15 @@ export const Page = () => {
42
42
  </Text>
43
43
 
44
44
  <View>
45
- <View>
45
+ <Text>
46
46
  Use a higher-level connected component. Storybook helps you compose such data from the
47
47
  "args" of child component stories
48
- </View>
48
+ </Text>
49
49
 
50
- <View>
50
+ <Text>
51
51
  Assemble data in the page component from your services. You can mock these services out
52
52
  using Storybook.
53
- </View>
53
+ </Text>
54
54
  </View>
55
55
 
56
56
  <Text style={styles.p}>
@@ -1,4 +1,4 @@
1
- import { expect, userEvent, within } from '@storybook/test';
1
+ import { expect, userEvent, within } from 'storybook/test';
2
2
 
3
3
  import { Page } from './Page';
4
4
 
@@ -1,7 +1,7 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import { fn } from '@storybook/test';
1
+ import type { Meta, StoryObj } from '@storybook/react-native-web-vite';
3
2
 
4
3
  import { View } from 'react-native';
4
+ import { fn } from 'storybook/test';
5
5
 
6
6
  import { Button } from './Button';
7
7
 
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
1
+ import type { Meta, StoryObj } from '@storybook/react-native-web-vite';
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,10 +18,9 @@ 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
  ) : (
@@ -1,5 +1,6 @@
1
- import type { Meta } from '@storybook/react';
2
- import { expect, userEvent, within } from '@storybook/test';
1
+ import type { Meta } from '@storybook/react-native-web-vite';
2
+
3
+ import { expect, userEvent, within } from 'storybook/test';
3
4
 
4
5
  import { Page } from './Page';
5
6
 
@@ -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{' '}
@@ -1,53 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import { fn } from '@storybook/test';
3
-
4
- import { View } from 'react-native';
5
-
6
- import { Button } from './Button';
7
-
8
- const meta: Meta<typeof Button> = {
9
- title: 'Example/Button',
10
- component: Button,
11
- decorators: [
12
- (Story) => (
13
- <View style={{ flex: 1, alignItems: 'flex-start' }}>
14
- <Story />
15
- </View>
16
- ),
17
- ],
18
- // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
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
21
- args: { onPress: fn() },
22
- };
23
-
24
- export default meta;
25
-
26
- type Story = StoryObj<typeof meta>;
27
-
28
- export const Primary: Story = {
29
- args: {
30
- primary: true,
31
- label: 'Button',
32
- },
33
- };
34
-
35
- export const Secondary: Story = {
36
- args: {
37
- label: 'Button',
38
- },
39
- };
40
-
41
- export const Large: Story = {
42
- args: {
43
- size: 'large',
44
- label: 'Button',
45
- },
46
- };
47
-
48
- export const Small: Story = {
49
- args: {
50
- size: 'small',
51
- label: 'Button',
52
- },
53
- };
@@ -1,99 +0,0 @@
1
- import type { StyleProp, ViewStyle } from 'react-native';
2
- import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
3
-
4
- export interface ButtonProps {
5
- /** Is this the principal call to action on the page? */
6
- primary?: boolean;
7
- /** What background color to use */
8
- backgroundColor?: string;
9
- /** How large should the button be? */
10
- size?: 'small' | 'medium' | 'large';
11
- /** Button contents */
12
- label: string;
13
- /** Optional click handler */
14
- onPress?: () => void;
15
- }
16
-
17
- /** Primary UI component for user interaction */
18
- export const Button = ({
19
- primary = false,
20
- size = 'medium',
21
- backgroundColor,
22
- label,
23
- onPress,
24
- }: ButtonProps) => {
25
- const modeStyle = primary ? styles.primary : styles.secondary;
26
- const textModeStyle = primary ? styles.primaryText : styles.secondaryText;
27
-
28
- const sizeStyle = styles[size];
29
- const textSizeStyle = textSizeStyles[size];
30
-
31
- return (
32
- <TouchableOpacity accessibilityRole="button" activeOpacity={0.6} onPress={onPress}>
33
- <View
34
- style={[
35
- styles.button,
36
- modeStyle,
37
- sizeStyle,
38
- style,
39
- !!backgroundColor && { backgroundColor },
40
- { borderColor: 'black' },
41
- ]}
42
- >
43
- <Text style={[textModeStyle, textSizeStyle]}>{label}</Text>
44
- </View>
45
- </TouchableOpacity>
46
- );
47
- };
48
-
49
- const styles = StyleSheet.create({
50
- button: {
51
- borderWidth: 0,
52
- borderRadius: 48,
53
- },
54
- buttonText: {
55
- fontWeight: '700',
56
- lineHeight: 1,
57
- },
58
- primary: {
59
- backgroundColor: '#1ea7fd',
60
- },
61
- primaryText: {
62
- color: 'white',
63
- },
64
- secondary: {
65
- backgroundColor: 'transparent',
66
- borderColor: 'rgba(0, 0, 0, 0.15)',
67
- borderWidth: 1,
68
- },
69
- secondaryText: {
70
- color: '#333',
71
- },
72
- small: {
73
- paddingVertical: 10,
74
- paddingHorizontal: 16,
75
- },
76
- smallText: {
77
- fontSize: 12,
78
- },
79
- medium: {
80
- paddingVertical: 11,
81
- paddingHorizontal: 20,
82
- },
83
- mediumText: {
84
- fontSize: 14,
85
- },
86
- large: {
87
- paddingVertical: 12,
88
- paddingHorizontal: 24,
89
- },
90
- largeText: {
91
- fontSize: 16,
92
- },
93
- });
94
-
95
- const textSizeStyles = {
96
- small: styles.smallText,
97
- medium: styles.mediumText,
98
- large: styles.largeText,
99
- };
@@ -1,33 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
-
3
- import { Header } from './Header';
4
-
5
- const meta: Meta<typeof Header> = {
6
- title: 'Example/Header',
7
- component: Header,
8
- // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
9
- tags: ['autodocs'],
10
- };
11
-
12
- export default meta;
13
-
14
- type Story = StoryObj<typeof meta>;
15
-
16
- export const LoggedIn: Story = {
17
- args: {
18
- user: {
19
- name: 'Jane Doe',
20
- },
21
- onLogin: () => {},
22
- onLogout: () => {},
23
- onCreateAccount: () => {},
24
- },
25
- };
26
-
27
- export const LoggedOut: Story = {
28
- args: {
29
- onLogin: () => {},
30
- onLogout: () => {},
31
- onCreateAccount: () => {},
32
- },
33
- };
@@ -1,78 +0,0 @@
1
- import { StyleSheet, Text, View } from 'react-native';
2
-
3
- import { Button } from './Button';
4
-
5
- export type HeaderProps = {
6
- user?: {};
7
- onLogin: () => void;
8
- onLogout: () => void;
9
- onCreateAccount: () => void;
10
- };
11
-
12
- export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => (
13
- <View>
14
- <View style={styles.wrapper}>
15
- <View style={styles.logoContainer}>
16
- <Text style={styles.h1}>Acme</Text>
17
- </View>
18
-
19
- <View style={styles.buttonContainer}>
20
- {user ? (
21
- <>
22
- <>
23
- <Text>Welcome, </Text>
24
- <Text style={styles.userName}>{user.name}!</Text>
25
- </>
26
- <Button style={styles.button} size="small" onPress={onLogout} label="Log out" />
27
- </>
28
- ) : (
29
- <>
30
- <Button style={styles.button} size="small" onPress={onLogin} label="Log in" />
31
-
32
- <Button
33
- style={styles.button}
34
- primary
35
- size="small"
36
- onPress={onCreateAccount}
37
- label="Sign up"
38
- />
39
- </>
40
- )}
41
- </View>
42
- </View>
43
- </View>
44
- );
45
-
46
- const styles = StyleSheet.create({
47
- wrapper: {
48
- borderBottomWidth: 1,
49
- borderBottomColor: 'rgba(0, 0, 0, 0.1)',
50
- paddingVertical: 15,
51
- paddingHorizontal: 20,
52
- flexDirection: 'row',
53
- justifyContent: 'space-between',
54
- },
55
- h1: {
56
- fontWeight: '900',
57
- fontSize: 20,
58
- marginTop: 6,
59
- marginBottom: 6,
60
- marginLeft: 10,
61
- color: 'black',
62
- alignSelf: 'flex-start',
63
- },
64
- logoContainer: {
65
- flexDirection: 'row',
66
- alignItems: 'center',
67
- },
68
- button: {
69
- marginLeft: 10,
70
- },
71
- buttonContainer: {
72
- flexDirection: 'row',
73
- alignItems: 'center',
74
- },
75
- userName: {
76
- fontWeight: '700',
77
- },
78
- });
@@ -1,28 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import { expect, userEvent, within } from '@storybook/test';
3
-
4
- import { Page } from './Page';
5
-
6
- const meta: Meta<typeof Page> = {
7
- title: 'Example/Page',
8
- component: Page,
9
- };
10
-
11
- export default meta;
12
-
13
- type Story = StoryObj<typeof meta>;
14
-
15
- export const LoggedIn: Story = {
16
- play: async ({ canvasElement }) => {
17
- const canvas = within(canvasElement);
18
- const loginButton = canvas.getByRole('button', { name: /Log in/i });
19
- await expect(loginButton).toBeInTheDocument();
20
- await userEvent.click(loginButton);
21
- // FIXME: await expect(loginButton).not.toBeInTheDocument();
22
-
23
- const logoutButton = canvas.getByRole('button', { name: /Log out/i });
24
- await expect(logoutButton).toBeInTheDocument();
25
- },
26
- };
27
-
28
- export const LoggedOut: Story = {};
@@ -1,162 +0,0 @@
1
- import { useState } from 'react';
2
-
3
- import { Linking, StyleSheet, Text, View } from 'react-native';
4
-
5
- import { Header } from './Header';
6
-
7
- export const Page = () => {
8
- const [user, setUser] = useState();
9
-
10
- return (
11
- <View>
12
- <Header
13
- user={user}
14
- onLogin={() => setUser({ name: 'Jane Doe' })}
15
- onLogout={() => setUser(undefined)}
16
- onCreateAccount={() => setUser({ name: 'Jane Doe' })}
17
- />
18
-
19
- <View style={styles.section}>
20
- <Text role="heading" style={styles.h2}>
21
- Pages in Storybook
22
- </Text>
23
-
24
- <Text style={styles.p}>
25
- We recommend building UIs with a{' '}
26
- <Text
27
- style={[styles.a, { fontWeight: 'bold' }]}
28
- role="link"
29
- onPress={() => {
30
- Linking.openURL('https://componentdriven.org');
31
- }}
32
- >
33
- <Text>component-driven</Text>
34
- </Text>{' '}
35
- process starting with atomic components and ending with pages.
36
- </Text>
37
-
38
- <Text style={styles.p}>
39
- Render pages with mock data. This makes it easy to build and review page states without
40
- needing to navigate to them in your app. Here are some handy patterns for managing page
41
- data in Storybook:
42
- </Text>
43
-
44
- <View>
45
- <View>
46
- Use a higher-level connected component. Storybook helps you compose such data from the
47
- "args" of child component stories
48
- </View>
49
-
50
- <View>
51
- Assemble data in the page component from your services. You can mock these services out
52
- using Storybook.
53
- </View>
54
- </View>
55
-
56
- <Text style={styles.p}>
57
- Get a guided tutorial on component-driven development at{' '}
58
- <Text
59
- style={styles.a}
60
- role="link"
61
- onPress={() => {
62
- Linking.openURL('https://storybook.js.org/tutorials/');
63
- }}
64
- >
65
- Storybook tutorials
66
- </Text>
67
- . Read more in the{' '}
68
- <Text
69
- style={styles.a}
70
- role="link"
71
- onPress={() => {
72
- Linking.openURL('https://storybook.js.org/docs');
73
- }}
74
- >
75
- docs
76
- </Text>
77
- .
78
- </Text>
79
-
80
- <View style={styles.tipWrapper}>
81
- <View style={styles.tip}>
82
- <Text style={styles.tipText}>Tip </Text>
83
- </View>
84
-
85
- <Text>Adjust the width of the canvas with the </Text>
86
-
87
- <Text>Viewports addon in the toolbar</Text>
88
- </View>
89
- </View>
90
- </View>
91
- );
92
- };
93
-
94
- const styles = StyleSheet.create({
95
- section: {
96
- fontFamily: "'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif",
97
- fontSize: 14,
98
- lineHeight: 24,
99
- paddingVertical: 48,
100
- paddingHorizontal: 20,
101
- marginHorizontal: 'auto',
102
- maxWidth: 600,
103
- color: '#333',
104
- },
105
-
106
- h2: {
107
- fontWeight: '900',
108
- fontSize: 32,
109
- lineHeight: 1,
110
- marginBottom: 4,
111
- },
112
-
113
- p: {
114
- marginVertical: 16,
115
- marginHorizontal: 0,
116
- },
117
-
118
- a: {
119
- color: '#1ea7fd',
120
- },
121
-
122
- ul: {
123
- paddingLeft: 30,
124
- marginVertical: 16,
125
- },
126
-
127
- li: {
128
- marginBottom: 8,
129
- },
130
-
131
- tip: {
132
- alignSelf: 'flex-start',
133
- borderRadius: 16,
134
- backgroundColor: '#e7fdd8',
135
- paddingVertical: 4,
136
- paddingHorizontal: 12,
137
- marginRight: 10,
138
- marginBottom: 4,
139
- },
140
- tipText: {
141
- fontSize: 11,
142
- lineHeight: 12,
143
- fontWeight: '700',
144
- color: '#66bf3c',
145
- },
146
-
147
- tipWrapper: {
148
- fontSize: 13,
149
- lineHeight: 20,
150
- marginTop: 40,
151
- marginBottom: 40,
152
- flexDirection: 'row',
153
- flexWrap: 'wrap',
154
- },
155
-
156
- tipWrapperSvg: {
157
- height: 12,
158
- width: 12,
159
- marginRight: 4,
160
- marginTop: 3,
161
- },
162
- });