@storybook/react-native 7.6.10-alpha.4 → 7.6.10-rc.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native",
3
- "version": "7.6.10-alpha.4",
3
+ "version": "7.6.10-rc.0",
4
4
  "description": "A better way to develop React Native Components for your app",
5
5
  "keywords": [
6
6
  "react",
@@ -63,7 +63,7 @@
63
63
  "@storybook/preview-api": "^7.6.10",
64
64
  "@storybook/preview-web": "^7.6.10",
65
65
  "@storybook/react": "^7.6.10",
66
- "@storybook/react-native-theming": "^7.6.10-alpha.4",
66
+ "@storybook/react-native-theming": "^7.6.10-rc.0",
67
67
  "chokidar": "^3.5.1",
68
68
  "commander": "^8.2.0",
69
69
  "dedent": "^1.5.1",
@@ -97,5 +97,5 @@
97
97
  "publishConfig": {
98
98
  "access": "public"
99
99
  },
100
- "gitHead": "43c2b5b932a0361178b010f90533069f14007677"
100
+ "gitHead": "405a69ec5ee81752f7f923b6f2521ed1577001b5"
101
101
  }
package/readme.md CHANGED
@@ -6,7 +6,7 @@ This readme is for the 7.6 version, you can find older versions by browsing the
6
6
 
7
7
  For more information about storybook visit: [storybook.js.org](https://storybook.js.org)
8
8
 
9
- > NOTE: `@storybook/react-native` requires atleast 7.6.9, if you install other storybook core packages they should be `^7.6.9` or newer.
9
+ > NOTE: `@storybook/react-native` requires atleast 7.6.10, if you install other storybook core packages they should be `^7.6.10` or newer.
10
10
 
11
11
  If you want to help out or are just curious then check out the [project board](https://github.com/orgs/storybookjs/projects/12) to see the open issues.
12
12
 
@@ -57,9 +57,9 @@ Run init to setup your project with all the dependencies and configuration files
57
57
  npx sb@latest init --type react_native
58
58
  ```
59
59
 
60
- The only thing left to do is return Storybook's UI in your app entry point (such as `App.js`) like this:
60
+ The only thing left to do is return Storybook's UI in your app entry point (such as `App.tsx`) like this:
61
61
 
62
- ```jsx
62
+ ```tsx
63
63
  export { default } from './.storybook';
64
64
  ```
65
65
 
@@ -69,7 +69,7 @@ If you want to add everything yourself check out the the manual guide [here](htt
69
69
 
70
70
  #### Additional steps: Update your metro config
71
71
 
72
- We require the unstable_allowRequireContext transformer option to enable dynamic story imports based on the stories glob in `main.js`. We can also call the storybook generate function from the metro config to automatically generate the `storybook.requires.js` file when metro runs.
72
+ We require the unstable_allowRequireContext transformer option to enable dynamic story imports based on the stories glob in `main.ts`. We can also call the storybook generate function from the metro config to automatically generate the `storybook.requires.ts` file when metro runs.
73
73
 
74
74
  **Expo**
75
75
 
@@ -120,14 +120,19 @@ module.exports = {
120
120
 
121
121
  In storybook we use a syntax called CSF that looks like this:
122
122
 
123
- ```jsx
123
+ ```tsx
124
+ import type { Meta, StoryObj } from '@storybook/react';
124
125
  import { MyButton } from './Button';
125
126
 
126
- export default {
127
+ const meta = {
127
128
  component: MyButton,
128
- };
129
+ } satisfies Meta<typeof MyButton>;
130
+
131
+ export default meta;
129
132
 
130
- export const Basic = {
133
+ type Story = StoryObj<typeof meta>;
134
+
135
+ export const Basic: Story = {
131
136
  args: {
132
137
  text: 'Hello World',
133
138
  color: 'purple',
@@ -135,23 +140,29 @@ export const Basic = {
135
140
  };
136
141
  ```
137
142
 
138
- You should configure the path to your story files in the `main.js` config file from the `.storybook` folder.
143
+ You should configure the path to your story files in the `main.ts` config file from the `.storybook` folder.
139
144
 
140
- ```js
141
- // .storybook/main.js
145
+ ```ts
146
+ // .storybook/main.ts
147
+ import { StorybookConfig } from '@storybook/react-native';
142
148
 
143
- module.exports = {
149
+ const main: StorybookConfig = {
144
150
  stories: ['../components/**/*.stories.?(ts|tsx|js|jsx)'],
145
151
  addons: [],
146
152
  };
153
+
154
+ export default main;
147
155
  ```
148
156
 
149
157
  ### Decorators and Parameters
150
158
 
151
159
  For stories you can add decorators and parameters on the default export or on a specifc story.
152
160
 
153
- ```jsx
154
- export default {
161
+ ```tsx
162
+ import type { Meta } from '@storybook/react';
163
+ import { Button } from './Button';
164
+
165
+ const meta = {
155
166
  title: 'Button',
156
167
  component: Button,
157
168
  decorators: [
@@ -170,32 +181,40 @@ export default {
170
181
  ],
171
182
  },
172
183
  },
173
- };
184
+ } satisfies Meta<typeof Button>;
185
+
186
+ export default meta;
174
187
  ```
175
188
 
176
- For global decorators and parameters, you can add them to `preview.js` inside your `.storybook` folder.
189
+ For global decorators and parameters, you can add them to `preview.tsx` inside your `.storybook` folder.
177
190
 
178
- ```jsx
179
- // .storybook/preview.js
191
+ ```tsx
192
+ // .storybook/preview.tsx
193
+ import type { Preview } from '@storybook/react';
180
194
  import { withBackgrounds } from '@storybook/addon-ondevice-backgrounds';
181
- export const decorators = [
182
- withBackgrounds,
183
- (Story) => (
184
- <View style={{ flex: 1, color: 'blue' }}>
185
- <Story />
186
- </View>
187
- ),
188
- ];
189
- export const parameters = {
190
- backgrounds: {
191
- default: 'plain',
192
- values: [
193
- { name: 'plain', value: 'white' },
194
- { name: 'warm', value: 'hotpink' },
195
- { name: 'cool', value: 'deepskyblue' },
196
- ],
195
+
196
+ const preview: Preview = {
197
+ decorators: [
198
+ withBackgrounds,
199
+ (Story) => (
200
+ <View style={{ flex: 1, color: 'blue' }}>
201
+ <Story />
202
+ </View>
203
+ ),
204
+ ],
205
+ parameters: {
206
+ backgrounds: {
207
+ default: 'plain',
208
+ values: [
209
+ { name: 'plain', value: 'white' },
210
+ { name: 'warm', value: 'hotpink' },
211
+ { name: 'cool', value: 'deepskyblue' },
212
+ ],
213
+ },
197
214
  },
198
215
  };
216
+
217
+ export default preview;
199
218
  ```
200
219
 
201
220
  ## Addons
@@ -210,17 +229,23 @@ Currently the addons available are:
210
229
  - [`@storybook/addon-ondevice-notes`](https://storybook.js.org/addons/@storybook/addon-ondevice-notes): Add some markdown to your stories to help document their usage
211
230
  - [`@storybook/addon-ondevice-backgrounds`](https://storybook.js.org/addons/@storybook/addon-ondevice-backgrounds): change the background of storybook to compare the look of your component against different backgrounds
212
231
 
213
- Install each one you want to use and add them to the `main.js` addons list as follows:
232
+ Install each one you want to use and add them to the `main.ts` addons list as follows:
214
233
 
215
- ```js
216
- // .storybook/main.js
217
-
218
- addons: [
219
- '@storybook/addon-ondevice-notes',
220
- '@storybook/addon-ondevice-controls',
221
- '@storybook/addon-ondevice-backgrounds',
222
- '@storybook/addon-ondevice-actions',
223
- ],
234
+ ```ts
235
+ // .storybook/main.ts
236
+ import { StorybookConfig } from '@storybook/react-native';
237
+
238
+ const main: StorybookConfig = {
239
+ // ... rest of config
240
+ addons: [
241
+ '@storybook/addon-ondevice-notes',
242
+ '@storybook/addon-ondevice-controls',
243
+ '@storybook/addon-ondevice-backgrounds',
244
+ '@storybook/addon-ondevice-actions',
245
+ ],
246
+ };
247
+
248
+ export default main;
224
249
  ```
225
250
 
226
251
  ### Using the addons in your story
@@ -256,11 +281,6 @@ You can pass these parameters to getStorybookUI call in your storybook entry poi
256
281
  -- Disable KeyboardAvoidingView wrapping Storybook's view
257
282
  keyboardAvoidingViewVerticalOffset: Number (0)
258
283
  -- With shouldDisableKeyboardAvoidingView=true, this will set the keyboardverticaloffset (https://facebook.github.io/react-native/docs/keyboardavoidingview#keyboardverticaloffset) value for KeyboardAvoidingView wrapping Storybook's view
259
- storage: Object (undefined)
260
- -- {getItem: (key: string) => Promise<string | null>;setItem: (key: string, value: string) => Promise<void>;}
261
- -- Custom storage to be used instead of AsyncStorage
262
- shouldPersistSelection: Boolean (true)
263
- -- Stores last selected story in your devices storage.
264
284
  }
265
285
  ```
266
286
 
@@ -49,15 +49,13 @@ describe('loader', () => {
49
49
  it('should work for any supported file extension', () => {
50
50
  const main = getMain({ configPath: './scripts/mocks/file-extensions' });
51
51
  expect(main).toEqual({
52
- default: {
53
- stories: ['./FakeStory.stories.tsx'],
54
- addons: [
55
- '@storybook/addon-ondevice-notes',
56
- '@storybook/addon-ondevice-controls',
57
- '@storybook/addon-ondevice-backgrounds',
58
- '@storybook/addon-ondevice-actions',
59
- ],
60
- },
52
+ stories: ['./FakeStory.stories.tsx'],
53
+ addons: [
54
+ '@storybook/addon-ondevice-notes',
55
+ '@storybook/addon-ondevice-controls',
56
+ '@storybook/addon-ondevice-backgrounds',
57
+ '@storybook/addon-ondevice-actions',
58
+ ],
61
59
  });
62
60
  });
63
61
  });
@@ -8,7 +8,7 @@ import '@storybook/addon-ondevice-actions/register';
8
8
  const normalizedStories = [
9
9
  {
10
10
  titlePrefix: '',
11
- directory: './stories',
11
+ directory: './.storybook/stories',
12
12
  files: '**/*.stories.?(ts|tsx|js|jsx)',
13
13
  importPathMatcher:
14
14
  /^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/,