@storybook/nextjs 7.0.0-alpha.59 → 7.0.0-alpha.61
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/README.md +217 -52
- package/dist/app-router-provider-5WPYJFG6.mjs +1 -0
- package/dist/preset.d.ts +0 -4
- package/dist/preset.js +2 -2
- package/dist/preset.mjs +1 -1
- package/dist/preview.js +6 -6
- package/dist/preview.mjs +2 -2
- package/package.json +9 -9
- package/template/stories/DynamicImport.stories.jsx +20 -0
- package/template/stories/dynamic-component.js +5 -0
- package/template/{stories → stories_12-js}/Link.stories.jsx +0 -0
- package/template/stories_default-js/Link.stories.jsx +82 -0
- package/template/stories_default-js/Link.stories.module.css +3 -0
- package/template/stories_default-js/Navigation.stories.jsx +77 -0
- package/template/stories_default-js/Router.stories.jsx +69 -0
- package/template/stories_default-ts/Link.stories.module.css +3 -0
- package/template/stories_default-ts/Link.stories.tsx +85 -0
- package/template/stories_default-ts/Navigation.stories.tsx +78 -0
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
- [Remote Images](#remote-images)
|
|
15
15
|
- [Optimization](#optimization)
|
|
16
16
|
- [AVIF](#avif)
|
|
17
|
+
- [Next.js Navigation](#nextjs-navigation)
|
|
17
18
|
- [Next.js Routing](#nextjs-routing)
|
|
18
19
|
- [Overriding defaults](#overriding-defaults)
|
|
19
20
|
- [Global Defaults](#global-defaults)
|
|
@@ -38,7 +39,9 @@
|
|
|
38
39
|
|
|
39
40
|
👉 [Next.js's Image Component](#nextjss-image-component)
|
|
40
41
|
|
|
41
|
-
👉 [Next.js Routing](#nextjs-routing)
|
|
42
|
+
👉 [Next.js Routing (next/router)](#nextjs-routing)
|
|
43
|
+
|
|
44
|
+
👉 [Next.js Navigation (next/navigation)](#nextjs-navigation)
|
|
42
45
|
|
|
43
46
|
👉 [Sass/Scss](#sassscss)
|
|
44
47
|
|
|
@@ -58,7 +61,7 @@
|
|
|
58
61
|
|
|
59
62
|
## Requirements
|
|
60
63
|
|
|
61
|
-
- [Next.js](https://nextjs.org/) >=
|
|
64
|
+
- [Next.js](https://nextjs.org/) >= 12.x
|
|
62
65
|
- [Storybook](https://storybook.js.org/) >= 7.x
|
|
63
66
|
|
|
64
67
|
## Getting Started
|
|
@@ -167,22 +170,176 @@ export default function Home() {
|
|
|
167
170
|
}
|
|
168
171
|
```
|
|
169
172
|
|
|
170
|
-
####
|
|
173
|
+
#### AVIF
|
|
171
174
|
|
|
172
|
-
|
|
175
|
+
This format is not supported by this framework yet. Feel free to [open up an issue](https://github.com/storybookjs/storybook/issues) if this is something you want to see.
|
|
173
176
|
|
|
174
|
-
|
|
177
|
+
### Next.js Navigation
|
|
175
178
|
|
|
176
|
-
|
|
179
|
+
Please note that [next/navigation](https://beta.nextjs.org/docs/upgrade-guide#step-5-migrating-routing-hooks) can only be used in components/pages of the `app` directory of Next.js v13 or higher.
|
|
177
180
|
|
|
178
|
-
####
|
|
181
|
+
#### Set `nextjs.appDirectory` to `true`
|
|
179
182
|
|
|
180
|
-
|
|
183
|
+
If your story imports components that use `next/navigation`, you need to set the parameter `nextjs.appDirectory` to `true` in your Story:
|
|
184
|
+
|
|
185
|
+
```js
|
|
186
|
+
// SomeComponentThatUsesTheRouter.stories.js
|
|
187
|
+
import SomeComponentThatUsesTheNavigation from './SomeComponentThatUsesTheNavigation';
|
|
188
|
+
|
|
189
|
+
export default {
|
|
190
|
+
component: SomeComponentThatUsesTheNavigation,
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// if you have the actions addon
|
|
194
|
+
// you can click the links and see the route change events there
|
|
195
|
+
export const Example = {
|
|
196
|
+
parameters: {
|
|
197
|
+
nextjs: {
|
|
198
|
+
appDirectory: true,
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
If your Next.js project uses the `app` directory for every page (in other words, it does not have a `pages` directory), you can set the parameter `nextjs.appDirectory` to `true` in the [preview.js](https://storybook.js.org/docs/react/configure/overview#configure-story-rendering) file to apply it to all stories.
|
|
205
|
+
|
|
206
|
+
```js
|
|
207
|
+
// .storybook/preview.js
|
|
208
|
+
|
|
209
|
+
export const parameters = {
|
|
210
|
+
nextjs: {
|
|
211
|
+
appDirectory: true,
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
The parameter `nextjs.appDirectory` defaults to `false` if not set.
|
|
217
|
+
|
|
218
|
+
#### Overriding defaults
|
|
219
|
+
|
|
220
|
+
Per-story overrides can be done by adding a `nextjs.navigation` property onto the story [parameters](https://storybook.js.org/docs/react/writing-stories/parameters). The framework will shallowly merge whatever you put here into the router.
|
|
221
|
+
|
|
222
|
+
```js
|
|
223
|
+
// SomeComponentThatUsesTheNavigation.stories.js
|
|
224
|
+
import SomeComponentThatUsesTheNavigation from './SomeComponentThatUsesTheNavigation';
|
|
225
|
+
|
|
226
|
+
export default {
|
|
227
|
+
component: SomeComponentThatUsesTheNavigation,
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
// if you have the actions addon
|
|
231
|
+
// you can click the links and see the route change events there
|
|
232
|
+
export const Example = {
|
|
233
|
+
parameters: {
|
|
234
|
+
nextjs: {
|
|
235
|
+
appDirectory: true,
|
|
236
|
+
navigation: {
|
|
237
|
+
pathname: '/some-default-path',
|
|
238
|
+
query: {
|
|
239
|
+
foo: 'bar',
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
#### Global Defaults
|
|
248
|
+
|
|
249
|
+
Global defaults can be set in [preview.js](https://storybook.js.org/docs/react/configure/overview#configure-story-rendering) and will be shallowly merged with the default router.
|
|
250
|
+
|
|
251
|
+
```js
|
|
252
|
+
// .storybook/preview.js
|
|
253
|
+
|
|
254
|
+
export const parameters = {
|
|
255
|
+
nextjs: {
|
|
256
|
+
appDirectory: true,
|
|
257
|
+
navigation: {
|
|
258
|
+
pathname: '/some-default-path',
|
|
259
|
+
query: {
|
|
260
|
+
foo: 'bar',
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
#### Default Navigation Context
|
|
268
|
+
|
|
269
|
+
The default values on the stubbed navigation context are as follows:
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
const defaultNavigationContext = {
|
|
273
|
+
push(...args) {
|
|
274
|
+
action('nextNavigation.push')(...args);
|
|
275
|
+
},
|
|
276
|
+
replace(...args) {
|
|
277
|
+
action('nextNavigation.replace')(...args);
|
|
278
|
+
},
|
|
279
|
+
forward(...args) {
|
|
280
|
+
action('nextNavigation.forward')(...args);
|
|
281
|
+
},
|
|
282
|
+
back(...args) {
|
|
283
|
+
action('nextNavigation.back')(...args);
|
|
284
|
+
},
|
|
285
|
+
prefetch(...args) {
|
|
286
|
+
action('nextNavigation.prefetch')(...args);
|
|
287
|
+
},
|
|
288
|
+
refresh: () => {
|
|
289
|
+
action('nextNavigation.refresh')();
|
|
290
|
+
},
|
|
291
|
+
pathname: '/',
|
|
292
|
+
query: {},
|
|
293
|
+
};
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
#### Actions Integration Caveats
|
|
297
|
+
|
|
298
|
+
If you override a function, you lose the automatic action tab integration and have to build it out yourself.
|
|
299
|
+
|
|
300
|
+
```js
|
|
301
|
+
// .storybook/preview.js
|
|
302
|
+
|
|
303
|
+
export const parameters = {
|
|
304
|
+
nextjs: {
|
|
305
|
+
appDirectory: true,
|
|
306
|
+
navigation: {
|
|
307
|
+
push() {
|
|
308
|
+
// The default implementation that logs the action into the action tab is lost
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Doing this yourself looks something like this (make sure you install the `@storybook/addon-actions` package):
|
|
316
|
+
|
|
317
|
+
```js
|
|
318
|
+
// .storybook/preview.js
|
|
319
|
+
import { action } from '@storybook/addon-actions';
|
|
320
|
+
|
|
321
|
+
export const parameters = {
|
|
322
|
+
nextjs: {
|
|
323
|
+
appDirectory: true,
|
|
324
|
+
navigation: {
|
|
325
|
+
push(...args) {
|
|
326
|
+
// custom logic can go here
|
|
327
|
+
// this logs to the actions tab
|
|
328
|
+
action('nextNavigation.push')(...args);
|
|
329
|
+
// return whatever you want here
|
|
330
|
+
return Promise.resolve(true);
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
};
|
|
335
|
+
```
|
|
181
336
|
|
|
182
337
|
### Next.js Routing
|
|
183
338
|
|
|
184
339
|
[Next.js's router](https://nextjs.org/docs/routing/introduction) is automatically stubbed for you so that when the router is interacted with, all of its interactions are automatically logged to the [Storybook actions tab](https://storybook.js.org/docs/react/essentials/actions) if you have the actions addon.
|
|
185
340
|
|
|
341
|
+
You should only use `next/router` in the `pages` directory of Next.js v13 or higher. In the `app` directory, it is necessary to use `next/navigation`.
|
|
342
|
+
|
|
186
343
|
#### Overriding defaults
|
|
187
344
|
|
|
188
345
|
Per-story overrides can be done by adding a `nextRouter` property onto the story [parameters](https://storybook.js.org/docs/react/writing-stories/parameters). The framework will shallowly merge whatever you put here into the router.
|
|
@@ -199,11 +356,13 @@ export default {
|
|
|
199
356
|
// you can click the links and see the route change events there
|
|
200
357
|
export const Example = {
|
|
201
358
|
parameters: {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
359
|
+
nextjs: {
|
|
360
|
+
router: {
|
|
361
|
+
path: '/profile/[id]',
|
|
362
|
+
asPath: '/profile/ryanclementshax',
|
|
363
|
+
query: {
|
|
364
|
+
id: 'ryanclementshax',
|
|
365
|
+
},
|
|
207
366
|
},
|
|
208
367
|
},
|
|
209
368
|
},
|
|
@@ -215,13 +374,15 @@ export const Example = {
|
|
|
215
374
|
Global defaults can be set in [preview.js](https://storybook.js.org/docs/react/configure/overview#configure-story-rendering) and will be shallowly merged with the default router.
|
|
216
375
|
|
|
217
376
|
```js
|
|
218
|
-
// .storybook/
|
|
377
|
+
// .storybook/preview.js
|
|
219
378
|
|
|
220
379
|
export const parameters = {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
380
|
+
nextjs: {
|
|
381
|
+
router: {
|
|
382
|
+
path: '/some-default-path',
|
|
383
|
+
asPath: '/some-default-path',
|
|
384
|
+
query: {},
|
|
385
|
+
},
|
|
225
386
|
},
|
|
226
387
|
};
|
|
227
388
|
```
|
|
@@ -232,44 +393,52 @@ The default values on the stubbed router are as follows (see [globals](https://s
|
|
|
232
393
|
|
|
233
394
|
```ts
|
|
234
395
|
const defaultRouter = {
|
|
235
|
-
|
|
236
|
-
route: '/',
|
|
237
|
-
pathname: '/',
|
|
238
|
-
query: {},
|
|
239
|
-
asPath: '/',
|
|
240
|
-
push(...args: unknown[]) {
|
|
396
|
+
push(...args) {
|
|
241
397
|
action('nextRouter.push')(...args);
|
|
242
398
|
return Promise.resolve(true);
|
|
243
399
|
},
|
|
244
|
-
replace(...args
|
|
400
|
+
replace(...args) {
|
|
245
401
|
action('nextRouter.replace')(...args);
|
|
246
402
|
return Promise.resolve(true);
|
|
247
403
|
},
|
|
248
|
-
reload(...args
|
|
404
|
+
reload(...args) {
|
|
249
405
|
action('nextRouter.reload')(...args);
|
|
250
406
|
},
|
|
251
|
-
back(...args
|
|
407
|
+
back(...args) {
|
|
252
408
|
action('nextRouter.back')(...args);
|
|
253
409
|
},
|
|
254
|
-
|
|
410
|
+
forward() {
|
|
411
|
+
action('nextRouter.forward')();
|
|
412
|
+
},
|
|
413
|
+
prefetch(...args) {
|
|
255
414
|
action('nextRouter.prefetch')(...args);
|
|
256
415
|
return Promise.resolve();
|
|
257
416
|
},
|
|
258
|
-
beforePopState(...args
|
|
417
|
+
beforePopState(...args) {
|
|
259
418
|
action('nextRouter.beforePopState')(...args);
|
|
260
419
|
},
|
|
261
420
|
events: {
|
|
262
|
-
on(...args
|
|
421
|
+
on(...args) {
|
|
263
422
|
action('nextRouter.events.on')(...args);
|
|
264
423
|
},
|
|
265
|
-
off(...args
|
|
424
|
+
off(...args) {
|
|
266
425
|
action('nextRouter.events.off')(...args);
|
|
267
426
|
},
|
|
268
|
-
emit(...args
|
|
427
|
+
emit(...args) {
|
|
269
428
|
action('nextRouter.events.emit')(...args);
|
|
270
429
|
},
|
|
271
430
|
},
|
|
431
|
+
// The locale should be configured [globally](https://storybook.js.org/docs/react/essentials/toolbars-and-globals#globals)
|
|
432
|
+
locale: globals?.locale,
|
|
433
|
+
asPath: '/',
|
|
434
|
+
basePath: '/',
|
|
272
435
|
isFallback: false,
|
|
436
|
+
isLocaleDomain: false,
|
|
437
|
+
isReady: true,
|
|
438
|
+
isPreview: false,
|
|
439
|
+
route: '/',
|
|
440
|
+
pathname: '/',
|
|
441
|
+
query: {},
|
|
273
442
|
};
|
|
274
443
|
```
|
|
275
444
|
|
|
@@ -278,12 +447,14 @@ const defaultRouter = {
|
|
|
278
447
|
If you override a function, you lose the automatic action tab integration and have to build it out yourself.
|
|
279
448
|
|
|
280
449
|
```js
|
|
281
|
-
// .storybook/
|
|
450
|
+
// .storybook/preview.js
|
|
282
451
|
|
|
283
452
|
export const parameters = {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
453
|
+
nextjs: {
|
|
454
|
+
router: {
|
|
455
|
+
push() {
|
|
456
|
+
// The default implementation that logs the action into the action tab is lost
|
|
457
|
+
},
|
|
287
458
|
},
|
|
288
459
|
},
|
|
289
460
|
};
|
|
@@ -292,17 +463,19 @@ export const parameters = {
|
|
|
292
463
|
Doing this yourself looks something like this (make sure you install the `@storybook/addon-actions` package):
|
|
293
464
|
|
|
294
465
|
```js
|
|
295
|
-
// .storybook/
|
|
466
|
+
// .storybook/preview.js
|
|
296
467
|
import { action } from '@storybook/addon-actions';
|
|
297
468
|
|
|
298
469
|
export const parameters = {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
470
|
+
nextjs: {
|
|
471
|
+
router: {
|
|
472
|
+
push(...args) {
|
|
473
|
+
// custom logic can go here
|
|
474
|
+
// this logs to the actions tab
|
|
475
|
+
action('nextRouter.push')(...args);
|
|
476
|
+
// return whatever you want here
|
|
477
|
+
return Promise.resolve(true);
|
|
478
|
+
},
|
|
306
479
|
},
|
|
307
480
|
},
|
|
308
481
|
};
|
|
@@ -404,14 +577,6 @@ You can use your own babel config too. This is an example of how you can customi
|
|
|
404
577
|
}
|
|
405
578
|
```
|
|
406
579
|
|
|
407
|
-
If you use a monorepo, you may need to add the babel config yourself to your storybook project. Just add a babel config to your storybook project with the following contents to get started.
|
|
408
|
-
|
|
409
|
-
```json
|
|
410
|
-
{
|
|
411
|
-
"presets": ["next/babel"]
|
|
412
|
-
}
|
|
413
|
-
```
|
|
414
|
-
|
|
415
580
|
### Postcss
|
|
416
581
|
|
|
417
582
|
Next.js lets you [customize postcss config](https://nextjs.org/docs/advanced-features/customizing-postcss-config#default-behavior). Thus this framework will automatically handle your postcss config for you.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-LAHENP5R.mjs";import React from"react";import{AppRouterContext}from"next/dist/shared/lib/app-router-context";import{PathnameContext,SearchParamsContext}from"next/dist/shared/lib/hooks-client-context";var AppRouterProvider=({children,action,routeParams})=>{let{pathname,query,...restRouteParams}=routeParams;return React.createElement(AppRouterContext.Provider,{value:{push(...args){action("nextNavigation.push")(...args)},replace(...args){action("nextNavigation.replace")(...args)},forward(...args){action("nextNavigation.forward")(...args)},back(...args){action("nextNavigation.back")(...args)},prefetch(...args){action("nextNavigation.prefetch")(...args)},refresh:()=>{action("nextNavigation.refresh")()},...restRouteParams}},React.createElement(SearchParamsContext.Provider,{value:new URLSearchParams(query)},React.createElement(PathnameContext.Provider,{value:pathname},children)))},app_router_provider_default=AppRouterProvider;export{app_router_provider_default as default};
|
package/dist/preset.d.ts
CHANGED
|
@@ -993,10 +993,6 @@ interface StorybookConfig {
|
|
|
993
993
|
* Enable the step debugger functionality in Addon-interactions.
|
|
994
994
|
*/
|
|
995
995
|
interactionsDebugger?: boolean;
|
|
996
|
-
/**
|
|
997
|
-
* Use Storybook 7.0 babel config scheme
|
|
998
|
-
*/
|
|
999
|
-
babelModeV7?: boolean;
|
|
1000
996
|
/**
|
|
1001
997
|
* Filter args with a "target" on the type from the render function (EXPERIMENTAL)
|
|
1002
998
|
*/
|
package/dist/preset.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var Z=Object.create;var
|
|
1
|
+
"use strict";var Z=Object.create;var x=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var se=(e,t)=>{for(var o in t)x(e,o,{get:t[o],enumerable:!0})},h=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of oe(t))!re.call(e,s)&&s!==o&&x(e,s,{get:()=>t[s],enumerable:!(r=ee(t,s))||r.enumerable});return e};var n=(e,t,o)=>(o=e!=null?Z(te(e)):{},h(t||!e||!e.__esModule?x(o,"default",{value:e,enumerable:!0}):o,e)),ie=e=>h(x({},"__esModule",{value:!0}),e);var ye={};se(ye,{addons:()=>me,babel:()=>de,config:()=>ue,core:()=>ge,frameworkOptions:()=>le,webpackFinal:()=>xe});module.exports=ie(ye);var c=require("path"),Q=require("@babel/core"),Y=require("@storybook/core-common");var b=n(require("semver")),V=require("webpack");var k=n(require("path")),R=require("webpack"),j=require("next/constants"),P=n(require("find-up")),E=require("fs-extra"),S=n(require("ts-dedent")),I=require("url"),O=e=>{var t;(t=e.plugins)==null||t.push(new R.DefinePlugin({"process.env.__NEXT_VERSION":JSON.stringify(f())}))},f=()=>require(y("next/package.json")).version,ne=async e=>["mjs","js"].reduce(async(o,r)=>(await o||(o=(0,P.default)(`next.config.${r}`,{cwd:e})),o),Promise.resolve(void 0)),_=async({baseConfig:e={},nextConfigPath:t,configDir:o})=>{let r=t||await ne(o);if(!r||await(0,E.pathExists)(r)===!1)throw new Error(S.default`
|
|
2
2
|
Could not find or resolve your Next config file. Please provide the next config file path as a framework option.
|
|
3
3
|
|
|
4
4
|
More info: https://github.com/storybookjs/storybook/blob/next/code/frameworks/nextjs/README.md#options
|
|
5
|
-
`);let s=await import((0,
|
|
5
|
+
`);let s=await import((0,I.pathToFileURL)(r).href),i=typeof s=="function"?s(j.PHASE_DEVELOPMENT_SERVER,{defaultConfig:e}):s;return i.default||i},p=(e,t,o)=>{e.resolve??={},e.resolve.alias??={};let r=e.resolve.alias,s=y(`${o??t}`);Array.isArray(r)?r.push({name:t,alias:s}):r[t]=s},y=e=>{let t=require.resolve(e,{paths:[k.default.resolve()]}),r=t.lastIndexOf(e.replace(/\//g,k.default.sep))+e.length;return t.substring(0,r)};var A=async({baseConfig:e,nextConfigPath:t,configDir:o})=>{let r=await _({baseConfig:e,nextConfigPath:t,configDir:o});return p(e,"next/config"),pe(e,r),r},W=f(),pe=(e,t)=>{var s,i;let o={"process.env.__NEXT_RUNTIME_CONFIG":JSON.stringify({serverRuntimeConfig:{},publicRuntimeConfig:t.publicRuntimeConfig})},r=(s=t.experimental)==null?void 0:s.newNextLinkBehavior;b.default.gte(W,"13.0.0")&&b.default.lt(W,"13.0.6")&&r!==!1?o["process.env.__NEXT_NEW_LINK_BEHAVIOR"]=!0:o["process.env.__NEXT_NEW_LINK_BEHAVIOR"]=r,(i=e.plugins)==null||i.push(new V.DefinePlugin(o))};var v=require("next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent"),w=require("next/dist/build/webpack/config/blocks/css/loaders/file-resolve"),$=n(require("semver"));var q=(e,t)=>{var r,s,i;let o=(r=e.module)==null?void 0:r.rules;o==null||o.forEach((m,l)=>{typeof m!="string"&&m.test instanceof RegExp&&m.test.test("test.css")&&(o[l]={test:/\.css$/,use:["style-loader",{loader:"css-loader",options:{importLoaders:1,...F(t),modules:{auto:!0,getLocalIdent:v.getCssModuleLocalIdent}}},"postcss-loader"]})}),o==null||o.push({test:/\.(scss|sass)$/,use:["style-loader",{loader:"css-loader",options:{importLoaders:3,...F(t),modules:{auto:!0,getLocalIdent:v.getCssModuleLocalIdent}}},"postcss-loader","resolve-url-loader",{loader:"sass-loader",options:{sourceMap:!0,sassOptions:t.sassOptions,additionalData:((s=t.sassOptions)==null?void 0:s.prependData)||((i=t.sassOptions)==null?void 0:i.additionalData)}}]})},F=e=>ae()?{url:{filter:L(e)},import:{filter:T(e)}}:{url:L(e),import:T(e)},L=e=>(t,o)=>{var r;return(0,w.cssFileResolve)(t,o,(r=e.experimental)==null?void 0:r.urlImports)},T=e=>(t,o,r)=>{var s;return(0,w.cssFileResolve)(typeof t=="string"?t:t.url,r,(s=e.experimental)==null?void 0:s.urlImports)},ae=()=>{try{let e=require(y("css-loader/package.json")).version;return $.default.gte(e,"6.0.0")}catch{return!1}};var D=n(require("tsconfig-paths-webpack-plugin")),M=require("tsconfig-paths"),B=e=>{let t=(0,M.loadConfig)();t.resultType==="failed"||!t.baseUrl||(e.resolve??={},e.resolve.plugins??=[],e.resolve.plugins.push(new D.default({configFile:t.configFileAbsolutePath,extensions:[".js",".jsx",".ts",".tsx"]})))};var U=n(require("semver"));var J=e=>{let t=fe();p(e,t)},fe=()=>{let e=f();return U.default.gte(e,"11.1.0")?"next/dist/shared/lib/router-context":"next/dist/next-server/lib/router-context"};var X=n(require("semver"));var H=e=>{let t=f();X.default.gte(t,"12.0.0")?p(e,"styled-jsx"):(p(e,"styled-jsx/babel"),p(e,"styled-jsx/css"),p(e,"styled-jsx/macro"),p(e,"styled-jsx/server"),p(e,"styled-jsx/style"),p(e,"styled-jsx/webpack"))};var K=n(require("semver"));var G=e=>{ce(e),p(e,"next/image")},ce=e=>{var s,i,m;let t=f();if(K.default.lt(t,"11.0.0"))return;let o=(s=e.module)==null?void 0:s.rules,r=o==null?void 0:o.find(l=>typeof l!="string"&&l.test instanceof RegExp&&l.test.test("test.jpg"));!r||(r.test=/\.(apng|eot|otf|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/,o==null||o.push({test:/\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,issuer:{not:/\.(css|scss|sass)$/},use:[{loader:require.resolve("@storybook/nextjs/next-image-loader-stub.js"),options:{filename:(i=r.generator)==null?void 0:i.filename}}]}),o==null||o.push({test:/\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,issuer:/\.(css|scss|sass)$/,type:"asset/resource",generator:{filename:(m=r.generator)==null?void 0:m.filename}}))};var u=n(require("semver")),d=require("webpack");function z(e){let t=f(),o=u.default.satisfies(t,"~12"),r=u.default.satisfies(t,"~13"),s=u.default.lt(t,"13.0.0"),i=u.default.lt(t,"12.0.0");e.plugins=e.plugins??[],r||e.plugins.push(new d.IgnorePlugin({resourceRegExp:/next\/legacy\/image$/})),o||e.plugins.push(new d.IgnorePlugin({resourceRegExp:/next\/future\/image$/})),s&&e.plugins.push(new d.IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/hooks-client-context$/})),i&&e.plugins.push(new d.IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/app-router-context$/}))}var me=[(0,c.dirname)(require.resolve((0,c.join)("@storybook/preset-react-webpack","package.json"))),(0,c.dirname)(require.resolve((0,c.join)("@storybook/builder-webpack5","package.json")))],C={},le=async(e,t)=>{let o=await t.presets.apply("framework");return typeof o=="string"?{name:o,options:C}:typeof o>"u"?{name:require.resolve("@storybook/nextjs"),options:C}:{name:o.name,options:{...C,...o.options}}},ge=async(e,t)=>{let o=await t.presets.apply("framework");return{...e,builder:{name:(0,c.dirname)(require.resolve((0,c.join)("@storybook/builder-webpack5","package.json"))),options:typeof o=="string"?{}:o.options.builder||{}},renderer:(0,c.dirname)(require.resolve((0,c.join)("@storybook/react","package.json")))}},ue=(e=[])=>[...e,require.resolve("@storybook/nextjs/preview.js")],de=async e=>{var m,l,N;let t=(0,Q.loadPartialConfig)({...e,filename:`${(0,Y.getProjectRoot)()}/__fake__.js`}),o=t==null?void 0:t.options,r=a=>typeof a=="object"&&a!==null&&"file"in a;((m=o==null?void 0:o.presets)==null?void 0:m.find(a=>{var g;return Array.isArray(a)&&a[0]==="next/babel"||a==="next/babel"||r(a)&&((g=a.file)==null?void 0:g.request)==="next/babel"}))||(l=o==null?void 0:o.presets)==null||l.push("next/babel");let i=(N=o==null?void 0:o.presets)==null?void 0:N.filter(a=>{var g;return!(r(a)&&((g=a.file)==null?void 0:g.request)===require.resolve("@babel/preset-react"))});return{...o,presets:i,babelrc:!1,configFile:!1}},xe=async(e,t)=>{let o=await t.presets.apply("frameworkOptions"),{options:{nextConfigPath:r}={}}=o,s=await A({baseConfig:e,nextConfigPath:r,configDir:t.configDir});return z(e),O(e),B(e),q(e,s),G(e),J(e),H(e),e};0&&(module.exports={addons,babel,config,core,frameworkOptions,webpackFinal});
|
package/dist/preset.mjs
CHANGED
|
@@ -2,4 +2,4 @@ import{__require}from"./chunk-LAHENP5R.mjs";import{dirname,join}from"path";impor
|
|
|
2
2
|
Could not find or resolve your Next config file. Please provide the next config file path as a framework option.
|
|
3
3
|
|
|
4
4
|
More info: https://github.com/storybookjs/storybook/blob/next/code/frameworks/nextjs/README.md#options
|
|
5
|
-
`);let nextConfigExport=await import(pathToFileURL(nextConfigFile).href),nextConfig=typeof nextConfigExport=="function"?nextConfigExport(PHASE_DEVELOPMENT_SERVER,{defaultConfig:baseConfig}):nextConfigExport;return nextConfig.default||nextConfig},addScopedAlias=(baseConfig,name,alias)=>{baseConfig.resolve??={},baseConfig.resolve.alias??={};let aliasConfig=baseConfig.resolve.alias,scopedAlias=scopedResolve(`${alias??name}`);Array.isArray(aliasConfig)?aliasConfig.push({name,alias:scopedAlias}):aliasConfig[name]=scopedAlias},scopedResolve=id=>{let scopedModulePath=__require.resolve(id,{paths:[path.resolve()]}),beginningOfMainScriptPath=scopedModulePath.lastIndexOf(id.replace(/\//g,path.sep))+id.length;return scopedModulePath.substring(0,beginningOfMainScriptPath)};var configureConfig=async({baseConfig,nextConfigPath,configDir})=>{let nextConfig=await resolveNextConfig({baseConfig,nextConfigPath,configDir});return addScopedAlias(baseConfig,"next/config"),setupRuntimeConfig(baseConfig,nextConfig),nextConfig},version=getNextjsVersion(),setupRuntimeConfig=(baseConfig,nextConfig)=>{let definePluginConfig={"process.env.__NEXT_RUNTIME_CONFIG":JSON.stringify({serverRuntimeConfig:{},publicRuntimeConfig:nextConfig.publicRuntimeConfig})},newNextLinkBehavior=nextConfig.experimental?.newNextLinkBehavior;
|
|
5
|
+
`);let nextConfigExport=await import(pathToFileURL(nextConfigFile).href),nextConfig=typeof nextConfigExport=="function"?nextConfigExport(PHASE_DEVELOPMENT_SERVER,{defaultConfig:baseConfig}):nextConfigExport;return nextConfig.default||nextConfig},addScopedAlias=(baseConfig,name,alias)=>{baseConfig.resolve??={},baseConfig.resolve.alias??={};let aliasConfig=baseConfig.resolve.alias,scopedAlias=scopedResolve(`${alias??name}`);Array.isArray(aliasConfig)?aliasConfig.push({name,alias:scopedAlias}):aliasConfig[name]=scopedAlias},scopedResolve=id=>{let scopedModulePath=__require.resolve(id,{paths:[path.resolve()]}),beginningOfMainScriptPath=scopedModulePath.lastIndexOf(id.replace(/\//g,path.sep))+id.length;return scopedModulePath.substring(0,beginningOfMainScriptPath)};var configureConfig=async({baseConfig,nextConfigPath,configDir})=>{let nextConfig=await resolveNextConfig({baseConfig,nextConfigPath,configDir});return addScopedAlias(baseConfig,"next/config"),setupRuntimeConfig(baseConfig,nextConfig),nextConfig},version=getNextjsVersion(),setupRuntimeConfig=(baseConfig,nextConfig)=>{let definePluginConfig={"process.env.__NEXT_RUNTIME_CONFIG":JSON.stringify({serverRuntimeConfig:{},publicRuntimeConfig:nextConfig.publicRuntimeConfig})},newNextLinkBehavior=nextConfig.experimental?.newNextLinkBehavior;semver.gte(version,"13.0.0")&&semver.lt(version,"13.0.6")&&newNextLinkBehavior!==!1?definePluginConfig["process.env.__NEXT_NEW_LINK_BEHAVIOR"]=!0:definePluginConfig["process.env.__NEXT_NEW_LINK_BEHAVIOR"]=newNextLinkBehavior,baseConfig.plugins?.push(new DefinePlugin2(definePluginConfig))};import{getCssModuleLocalIdent}from"next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent";import{cssFileResolve}from"next/dist/build/webpack/config/blocks/css/loaders/file-resolve";import semver2 from"semver";var configureCss=(baseConfig,nextConfig)=>{let rules=baseConfig.module?.rules;rules?.forEach((rule,i)=>{typeof rule!="string"&&rule.test instanceof RegExp&&rule.test.test("test.css")&&(rules[i]={test:/\.css$/,use:["style-loader",{loader:"css-loader",options:{importLoaders:1,...getImportAndUrlCssLoaderOptions(nextConfig),modules:{auto:!0,getLocalIdent:getCssModuleLocalIdent}}},"postcss-loader"]})}),rules?.push({test:/\.(scss|sass)$/,use:["style-loader",{loader:"css-loader",options:{importLoaders:3,...getImportAndUrlCssLoaderOptions(nextConfig),modules:{auto:!0,getLocalIdent:getCssModuleLocalIdent}}},"postcss-loader","resolve-url-loader",{loader:"sass-loader",options:{sourceMap:!0,sassOptions:nextConfig.sassOptions,additionalData:nextConfig.sassOptions?.prependData||nextConfig.sassOptions?.additionalData}}]})},getImportAndUrlCssLoaderOptions=nextConfig=>isCssLoaderV6()?{url:{filter:getUrlResolver(nextConfig)},import:{filter:getImportResolver(nextConfig)}}:{url:getUrlResolver(nextConfig),import:getImportResolver(nextConfig)},getUrlResolver=nextConfig=>(url,resourcePath)=>cssFileResolve(url,resourcePath,nextConfig.experimental?.urlImports),getImportResolver=nextConfig=>(url,_,resourcePath)=>cssFileResolve(typeof url=="string"?url:url.url,resourcePath,nextConfig.experimental?.urlImports),isCssLoaderV6=()=>{try{let cssLoaderVersion=__require(scopedResolve("css-loader/package.json")).version;return semver2.gte(cssLoaderVersion,"6.0.0")}catch{return!1}};import TsconfigPathsPlugin from"tsconfig-paths-webpack-plugin";import{loadConfig}from"tsconfig-paths";var configureImports=baseConfig=>{let configLoadResult=loadConfig();configLoadResult.resultType==="failed"||!configLoadResult.baseUrl||(baseConfig.resolve??={},baseConfig.resolve.plugins??=[],baseConfig.resolve.plugins.push(new TsconfigPathsPlugin({configFile:configLoadResult.configFileAbsolutePath,extensions:[".js",".jsx",".ts",".tsx"]})))};import semver3 from"semver";var configureRouting=baseConfig=>{let routerContextPath=getRouterContextPath();addScopedAlias(baseConfig,routerContextPath)},getRouterContextPath=()=>{let version2=getNextjsVersion();return semver3.gte(version2,"11.1.0")?"next/dist/shared/lib/router-context":"next/dist/next-server/lib/router-context"};import semver4 from"semver";var configureStyledJsx=baseConfig=>{let version2=getNextjsVersion();semver4.gte(version2,"12.0.0")?addScopedAlias(baseConfig,"styled-jsx"):(addScopedAlias(baseConfig,"styled-jsx/babel"),addScopedAlias(baseConfig,"styled-jsx/css"),addScopedAlias(baseConfig,"styled-jsx/macro"),addScopedAlias(baseConfig,"styled-jsx/server"),addScopedAlias(baseConfig,"styled-jsx/style"),addScopedAlias(baseConfig,"styled-jsx/webpack"))};import semver5 from"semver";var configureImages=baseConfig=>{configureStaticImageImport(baseConfig),addScopedAlias(baseConfig,"next/image")},configureStaticImageImport=baseConfig=>{let version2=getNextjsVersion();if(semver5.lt(version2,"11.0.0"))return;let rules=baseConfig.module?.rules,assetRule=rules?.find(rule=>typeof rule!="string"&&rule.test instanceof RegExp&&rule.test.test("test.jpg"));!assetRule||(assetRule.test=/\.(apng|eot|otf|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/,rules?.push({test:/\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,issuer:{not:/\.(css|scss|sass)$/},use:[{loader:__require.resolve("@storybook/nextjs/next-image-loader-stub.js"),options:{filename:assetRule.generator?.filename}}]}),rules?.push({test:/\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,issuer:/\.(css|scss|sass)$/,type:"asset/resource",generator:{filename:assetRule.generator?.filename}}))};import semver6 from"semver";import{IgnorePlugin}from"webpack";function configureNextImport(baseConfig){let nextJSVersion=getNextjsVersion(),isNext12=semver6.satisfies(nextJSVersion,"~12"),isNext13=semver6.satisfies(nextJSVersion,"~13"),isNextVersionSmallerThan13=semver6.lt(nextJSVersion,"13.0.0"),isNextVersionSmallerThan12=semver6.lt(nextJSVersion,"12.0.0");baseConfig.plugins=baseConfig.plugins??[],isNext13||baseConfig.plugins.push(new IgnorePlugin({resourceRegExp:/next\/legacy\/image$/})),isNext12||baseConfig.plugins.push(new IgnorePlugin({resourceRegExp:/next\/future\/image$/})),isNextVersionSmallerThan13&&baseConfig.plugins.push(new IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/hooks-client-context$/})),isNextVersionSmallerThan12&&baseConfig.plugins.push(new IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/app-router-context$/}))}var addons=[dirname(__require.resolve(join("@storybook/preset-react-webpack","package.json"))),dirname(__require.resolve(join("@storybook/builder-webpack5","package.json")))],defaultFrameworkOptions={},frameworkOptions=async(_,options)=>{let config2=await options.presets.apply("framework");return typeof config2=="string"?{name:config2,options:defaultFrameworkOptions}:typeof config2>"u"?{name:__require.resolve("@storybook/nextjs"),options:defaultFrameworkOptions}:{name:config2.name,options:{...defaultFrameworkOptions,...config2.options}}},core=async(config2,options)=>{let framework=await options.presets.apply("framework");return{...config2,builder:{name:dirname(__require.resolve(join("@storybook/builder-webpack5","package.json"))),options:typeof framework=="string"?{}:framework.options.builder||{}},renderer:dirname(__require.resolve(join("@storybook/react","package.json")))}},config=(entry=[])=>[...entry,__require.resolve("@storybook/nextjs/preview.js")],babel=async baseConfig=>{let options=loadPartialConfig({...baseConfig,filename:`${getProjectRoot()}/__fake__.js`})?.options,isPresetConfigItem=preset=>typeof preset=="object"&&preset!==null&&"file"in preset;options?.presets?.find(preset=>Array.isArray(preset)&&preset[0]==="next/babel"||preset==="next/babel"||isPresetConfigItem(preset)&&preset.file?.request==="next/babel")||options?.presets?.push("next/babel");let presets=options?.presets?.filter(preset=>!(isPresetConfigItem(preset)&&preset.file?.request===__require.resolve("@babel/preset-react")));return{...options,presets,babelrc:!1,configFile:!1}},webpackFinal=async(baseConfig,options)=>{let frameworkOptions2=await options.presets.apply("frameworkOptions"),{options:{nextConfigPath}={}}=frameworkOptions2,nextConfig=await configureConfig({baseConfig,nextConfigPath,configDir:options.configDir});return configureNextImport(baseConfig),configureRuntimeNextjsVersionResolution(baseConfig),configureImports(baseConfig),configureCss(baseConfig,nextConfig),configureImages(baseConfig),configureRouting(baseConfig),configureStyledJsx(baseConfig),baseConfig};export{addons,babel,config,core,frameworkOptions,webpackFinal};
|
package/dist/preview.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var te=Object.create;var _=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var se=(i,e)=>()=>(i&&(e=i(i=0)),e);var w=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),A=(i,e)=>{for(var n in e)_(i,n,{get:e[n],enumerable:!0})},O=(i,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ie(e))!oe.call(i,r)&&r!==n&&_(i,r,{get:()=>e[r],enumerable:!(t=re(e,r))||t.enumerable});return i};var d=(i,e,n)=>(n=i!=null?te(ne(i)):{},O(e||!i||!i.__esModule?_(n,"default",{value:i,enumerable:!0}):n,i)),ae=i=>O(_({},"__esModule",{value:!0}),i);var D={};A(D,{default:()=>ce});var v,L,S,le,ce,$=se(()=>{"use strict";v=d(require("react")),L=require("next/dist/shared/lib/app-router-context"),S=require("next/dist/shared/lib/hooks-client-context"),le=({children:i,action:e,routeParams:n})=>{let{pathname:t,query:r,...s}=n;return v.default.createElement(L.AppRouterContext.Provider,{value:{push(...o){e("nextNavigation.push")(...o)},replace(...o){e("nextNavigation.replace")(...o)},forward(...o){e("nextNavigation.forward")(...o)},back(...o){e("nextNavigation.back")(...o)},prefetch(...o){e("nextNavigation.prefetch")(...o)},refresh:()=>{e("nextNavigation.refresh")()},...s}},v.default.createElement(S.SearchParamsContext.Provider,{value:new URLSearchParams(r)},v.default.createElement(S.PathnameContext.Provider,{value:t},i)))},ce=le});var X=w(()=>{});var K=w(m=>{X();var p=require("react");function de(i){return i&&typeof i=="object"&&"default"in i?i:{default:i}}var P=de(p);function B(i,e){for(var n=0;n<e.length;n++){var t=e[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(i,t.key,t)}}function he(i,e,n){return e&&B(i.prototype,e),n&&B(i,n),i}var R=typeof process<"u"&&process.env&&process.env.NODE_ENV==="production",N=function(i){return Object.prototype.toString.call(i)==="[object String]"},pe=function(){function i(n){var t=n===void 0?{}:n,r=t.name,s=r===void 0?"stylesheet":r,o=t.optimizeForSpeed,a=o===void 0?R:o;u(N(s),"`name` must be a string"),this._name=s,this._deletedRulePlaceholder="#"+s+"-deleted-rule____{}",u(typeof a=="boolean","`optimizeForSpeed` must be a boolean"),this._optimizeForSpeed=a,this._serverSheet=void 0,this._tags=[],this._injected=!1,this._rulesCount=0;var c=typeof window<"u"&&document.querySelector('meta[property="csp-nonce"]');this._nonce=c?c.getAttribute("content"):null}var e=i.prototype;return e.setOptimizeForSpeed=function(t){u(typeof t=="boolean","`setOptimizeForSpeed` accepts a boolean"),u(this._rulesCount===0,"optimizeForSpeed cannot be when rules have already been inserted"),this.flush(),this._optimizeForSpeed=t,this.inject()},e.isOptimizeForSpeed=function(){return this._optimizeForSpeed},e.inject=function(){var t=this;if(u(!this._injected,"sheet already injected"),this._injected=!0,typeof window<"u"&&this._optimizeForSpeed){this._tags[0]=this.makeStyleTag(this._name),this._optimizeForSpeed="insertRule"in this.getSheet(),this._optimizeForSpeed||(R||console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode."),this.flush(),this._injected=!0);return}this._serverSheet={cssRules:[],insertRule:function(r,s){return typeof s=="number"?t._serverSheet.cssRules[s]={cssText:r}:t._serverSheet.cssRules.push({cssText:r}),s},deleteRule:function(r){t._serverSheet.cssRules[r]=null}}},e.getSheetForTag=function(t){if(t.sheet)return t.sheet;for(var r=0;r<document.styleSheets.length;r++)if(document.styleSheets[r].ownerNode===t)return document.styleSheets[r]},e.getSheet=function(){return this.getSheetForTag(this._tags[this._tags.length-1])},e.insertRule=function(t,r){if(u(N(t),"`insertRule` accepts only strings"),typeof window>"u")return typeof r!="number"&&(r=this._serverSheet.cssRules.length),this._serverSheet.insertRule(t,r),this._rulesCount++;if(this._optimizeForSpeed){var s=this.getSheet();typeof r!="number"&&(r=s.cssRules.length);try{s.insertRule(t,r)}catch{return R||console.warn(`StyleSheet: illegal rule:
|
|
2
2
|
|
|
3
|
-
`+
|
|
3
|
+
`+t+`
|
|
4
4
|
|
|
5
|
-
See https://stackoverflow.com/q/20007992 for more info`),-1}}else{var
|
|
5
|
+
See https://stackoverflow.com/q/20007992 for more info`),-1}}else{var o=this._tags[r];this._tags.push(this.makeStyleTag(this._name,t,o))}return this._rulesCount++},e.replaceRule=function(t,r){if(this._optimizeForSpeed||typeof window>"u"){var s=typeof window<"u"?this.getSheet():this._serverSheet;if(r.trim()||(r=this._deletedRulePlaceholder),!s.cssRules[t])return t;s.deleteRule(t);try{s.insertRule(r,t)}catch{R||console.warn(`StyleSheet: illegal rule:
|
|
6
6
|
|
|
7
|
-
`+
|
|
7
|
+
`+r+`
|
|
8
8
|
|
|
9
|
-
See https://stackoverflow.com/q/20007992 for more info`),
|
|
10
|
-
`)]}).filter(function(
|
|
9
|
+
See https://stackoverflow.com/q/20007992 for more info`),s.insertRule(this._deletedRulePlaceholder,t)}}else{var o=this._tags[t];u(o,"old rule at index `"+t+"` not found"),o.textContent=r}return t},e.deleteRule=function(t){if(typeof window>"u"){this._serverSheet.deleteRule(t);return}if(this._optimizeForSpeed)this.replaceRule(t,"");else{var r=this._tags[t];u(r,"rule at index `"+t+"` not found"),r.parentNode.removeChild(r),this._tags[t]=null}},e.flush=function(){this._injected=!1,this._rulesCount=0,typeof window<"u"?(this._tags.forEach(function(t){return t&&t.parentNode.removeChild(t)}),this._tags=[]):this._serverSheet.cssRules=[]},e.cssRules=function(){var t=this;return typeof window>"u"?this._serverSheet.cssRules:this._tags.reduce(function(r,s){return s?r=r.concat(Array.prototype.map.call(t.getSheetForTag(s).cssRules,function(o){return o.cssText===t._deletedRulePlaceholder?null:o})):r.push(null),r},[])},e.makeStyleTag=function(t,r,s){r&&u(N(r),"makeStyleTag accepts only strings as second parameter");var o=document.createElement("style");this._nonce&&o.setAttribute("nonce",this._nonce),o.type="text/css",o.setAttribute("data-"+t,""),r&&o.appendChild(document.createTextNode(r));var a=document.head||document.getElementsByTagName("head")[0];return s?a.insertBefore(o,s):a.appendChild(o),o},he(i,[{key:"length",get:function(){return this._rulesCount}}]),i}();function u(i,e){if(!i)throw new Error("StyleSheet: "+e+".")}function me(i){for(var e=5381,n=i.length;n;)e=e*33^i.charCodeAt(--n);return e>>>0}var ye=me,_e=function(i){return i.replace(/\/style/gi,"\\/style")},h={};function C(i,e){if(!e)return"jsx-"+i;var n=String(e),t=i+n;return h[t]||(h[t]="jsx-"+ye(i+"-"+n)),h[t]}function G(i,e){var n=/__jsx-style-dynamic-selector/g;typeof window>"u"&&(e=_e(e));var t=i+e;return h[t]||(h[t]=e.replace(n,i)),h[t]}function ve(i,e){return e===void 0&&(e={}),i.map(function(n){var t=n[0],r=n[1];return P.default.createElement("style",{id:"__"+t,key:"__"+t,nonce:e.nonce?e.nonce:void 0,dangerouslySetInnerHTML:{__html:r}})})}var Se=function(){function i(n){var t=n===void 0?{}:n,r=t.styleSheet,s=r===void 0?null:r,o=t.optimizeForSpeed,a=o===void 0?!1:o;this._sheet=s||new pe({name:"styled-jsx",optimizeForSpeed:a}),this._sheet.inject(),s&&typeof a=="boolean"&&(this._sheet.setOptimizeForSpeed(a),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),this._fromServer=void 0,this._indices={},this._instancesCounts={}}var e=i.prototype;return e.add=function(t){var r=this;this._optimizeForSpeed===void 0&&(this._optimizeForSpeed=Array.isArray(t.children),this._sheet.setOptimizeForSpeed(this._optimizeForSpeed),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),typeof window<"u"&&!this._fromServer&&(this._fromServer=this.selectFromServer(),this._instancesCounts=Object.keys(this._fromServer).reduce(function(f,ee){return f[ee]=0,f},{}));var s=this.getIdAndRules(t),o=s.styleId,a=s.rules;if(o in this._instancesCounts){this._instancesCounts[o]+=1;return}var c=a.map(function(f){return r._sheet.insertRule(f)}).filter(function(f){return f!==-1});this._indices[o]=c,this._instancesCounts[o]=1},e.remove=function(t){var r=this,s=this.getIdAndRules(t).styleId;if(ge(s in this._instancesCounts,"styleId: `"+s+"` not found"),this._instancesCounts[s]-=1,this._instancesCounts[s]<1){var o=this._fromServer&&this._fromServer[s];o?(o.parentNode.removeChild(o),delete this._fromServer[s]):(this._indices[s].forEach(function(a){return r._sheet.deleteRule(a)}),delete this._indices[s]),delete this._instancesCounts[s]}},e.update=function(t,r){this.add(r),this.remove(t)},e.flush=function(){this._sheet.flush(),this._sheet.inject(),this._fromServer=void 0,this._indices={},this._instancesCounts={}},e.cssRules=function(){var t=this,r=this._fromServer?Object.keys(this._fromServer).map(function(o){return[o,t._fromServer[o]]}):[],s=this._sheet.cssRules();return r.concat(Object.keys(this._indices).map(function(o){return[o,t._indices[o].map(function(a){return s[a].cssText}).join(t._optimizeForSpeed?"":`
|
|
10
|
+
`)]}).filter(function(o){return Boolean(o[1])}))},e.styles=function(t){return ve(this.cssRules(),t)},e.getIdAndRules=function(t){var r=t.children,s=t.dynamic,o=t.id;if(s){var a=C(o,s);return{styleId:a,rules:Array.isArray(r)?r.map(function(c){return G(a,c)}):[G(a,r)]}}return{styleId:C(o),rules:Array.isArray(r)?r:[r]}},e.selectFromServer=function(){var t=Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]'));return t.reduce(function(r,s){var o=s.id.slice(2);return r[o]=s,r},{})},i}();function ge(i,e){if(!i)throw new Error("StyleSheetRegistry: "+e+".")}var x=p.createContext(null);x.displayName="StyleSheetContext";function b(){return new Se}function Re(i){var e=i.registry,n=i.children,t=p.useContext(x),r=p.useState(function(){return t||e||b()}),s=r[0];return P.default.createElement(x.Provider,{value:s},n)}function H(){return p.useContext(x)}var Pe=P.default.useInsertionEffect||P.default.useLayoutEffect,M=typeof window<"u"?b():void 0;function U(i){var e=M||H();return e?typeof window>"u"?(e.add(i),null):(Pe(function(){return e.add(i),function(){e.remove(i)}},[i.id,String(i.dynamic)]),null):null}U.dynamic=function(i){return i.map(function(e){var n=e[0],t=e[1];return C(n,t)}).join(" ")};m.StyleRegistry=Re;m.createStyleRegistry=b;m.style=U;m.useStyleRegistry=H});var W=w((Oe,Q)=>{Q.exports=K()});var we={};A(we,{decorators:()=>Fe});module.exports=ae(we);var k=require("next/config");(0,k.setConfig)(process.env.__NEXT_RUNTIME_CONFIG);var l=d(require("react"));var E=require("next/dist/shared/lib/router-context"),T=d(require("react")),ue=({children:i,action:e,routeParams:n,globals:t})=>T.default.createElement(E.RouterContext.Provider,{value:{push(...r){return e("nextRouter.push")(...r),Promise.resolve(!0)},replace(...r){return e("nextRouter.replace")(...r),Promise.resolve(!0)},reload(...r){e("nextRouter.reload")(...r)},back(...r){e("nextRouter.back")(...r)},forward(){e("nextRouter.forward")()},prefetch(...r){return e("nextRouter.prefetch")(...r),Promise.resolve()},beforePopState(...r){e("nextRouter.beforePopState")(...r)},events:{on(...r){e("nextRouter.events.on")(...r)},off(...r){e("nextRouter.events.off")(...r)},emit(...r){e("nextRouter.events.emit")(...r)}},locale:t==null?void 0:t.locale,route:"/",asPath:"/",basePath:"/",isFallback:!1,isLocaleDomain:!1,isReady:!0,isPreview:!1,...n}},i),q=ue;var fe=l.lazy(()=>Promise.resolve().then(()=>($(),D))),g;try{g=require("@storybook/addon-actions").action}catch{g=()=>()=>{}}var J={pathname:"/",query:{}},V=(i,{globals:e,parameters:n})=>{var r,s,o;return((r=n.nextjs)==null?void 0:r.appDirectory)??!1?l.createElement(fe,{action:g,routeParams:{...J,...(s=n.nextjs)==null?void 0:s.navigation}},l.createElement(i,null)):l.createElement(q,{action:g,globals:e,routeParams:{...J,...(o=n.nextjs)==null?void 0:o.router}},l.createElement(i,null))};var y=d(require("react")),z;try{z=W().StyleRegistry}catch{z=y.Fragment}var Y=i=>y.createElement(z,null,y.createElement(i,null));var F=d(require("react")),I=d(require("semver")),j=({src:i,width:e,quality:n})=>{let t=[];if(i||t.push("src"),e||t.push("width"),t.length>0)throw new Error(`Next Image Optimization requires ${t.join(", ")} to be provided. Make sure you pass them as props to the \`next/image\` component. Received: ${JSON.stringify({src:i,width:e,quality:n})}`);return`${i}?w=${e}&q=${n??75}`},Z=require("next/image"),xe=Z.default;Object.defineProperty(Z,"default",{configurable:!0,value:i=>F.createElement(xe,{...i,loader:i.loader??j})});if(I.default.satisfies(process.env.__NEXT_VERSION,"^13.0.0")){let e=require("next/legacy/image").default;Object.defineProperty(e,"default",{configurable:!0,value:n=>F.createElement(e,{...n,loader:n.loader??j})})}if(I.default.satisfies(process.env.__NEXT_VERSION,"^12.2.0")){let e=require("next/future/image").default;Object.defineProperty(e,"default",{configurable:!0,value:n=>F.createElement(e,{...n,loader:n.loader??j})})}var Fe=[Y,V];0&&(module.exports={decorators});
|
package/dist/preview.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__commonJS,__require}from"./chunk-LAHENP5R.mjs";var require_client_only=__commonJS({"../../node_modules/client-only/index.js"(){}});var require_index=__commonJS({"../../node_modules/styled-jsx/dist/index/index.js"(exports){require_client_only();var
|
|
1
|
+
import{__commonJS,__require}from"./chunk-LAHENP5R.mjs";var require_client_only=__commonJS({"../../node_modules/client-only/index.js"(){}});var require_index=__commonJS({"../../node_modules/styled-jsx/dist/index/index.js"(exports){require_client_only();var React5=__require("react");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React5);function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),Constructor}var isProd=typeof process<"u"&&process.env&&process.env.NODE_ENV==="production",isString=function(o){return Object.prototype.toString.call(o)==="[object String]"},StyleSheet=function(){function StyleSheet2(param){var ref=param===void 0?{}:param,_name=ref.name,name=_name===void 0?"stylesheet":_name,_optimizeForSpeed=ref.optimizeForSpeed,optimizeForSpeed=_optimizeForSpeed===void 0?isProd:_optimizeForSpeed;invariant$1(isString(name),"`name` must be a string"),this._name=name,this._deletedRulePlaceholder="#"+name+"-deleted-rule____{}",invariant$1(typeof optimizeForSpeed=="boolean","`optimizeForSpeed` must be a boolean"),this._optimizeForSpeed=optimizeForSpeed,this._serverSheet=void 0,this._tags=[],this._injected=!1,this._rulesCount=0;var node=typeof window<"u"&&document.querySelector('meta[property="csp-nonce"]');this._nonce=node?node.getAttribute("content"):null}var _proto=StyleSheet2.prototype;return _proto.setOptimizeForSpeed=function(bool){invariant$1(typeof bool=="boolean","`setOptimizeForSpeed` accepts a boolean"),invariant$1(this._rulesCount===0,"optimizeForSpeed cannot be when rules have already been inserted"),this.flush(),this._optimizeForSpeed=bool,this.inject()},_proto.isOptimizeForSpeed=function(){return this._optimizeForSpeed},_proto.inject=function(){var _this=this;if(invariant$1(!this._injected,"sheet already injected"),this._injected=!0,typeof window<"u"&&this._optimizeForSpeed){this._tags[0]=this.makeStyleTag(this._name),this._optimizeForSpeed="insertRule"in this.getSheet(),this._optimizeForSpeed||(isProd||console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode."),this.flush(),this._injected=!0);return}this._serverSheet={cssRules:[],insertRule:function(rule,index){return typeof index=="number"?_this._serverSheet.cssRules[index]={cssText:rule}:_this._serverSheet.cssRules.push({cssText:rule}),index},deleteRule:function(index){_this._serverSheet.cssRules[index]=null}}},_proto.getSheetForTag=function(tag){if(tag.sheet)return tag.sheet;for(var i=0;i<document.styleSheets.length;i++)if(document.styleSheets[i].ownerNode===tag)return document.styleSheets[i]},_proto.getSheet=function(){return this.getSheetForTag(this._tags[this._tags.length-1])},_proto.insertRule=function(rule,index){if(invariant$1(isString(rule),"`insertRule` accepts only strings"),typeof window>"u")return typeof index!="number"&&(index=this._serverSheet.cssRules.length),this._serverSheet.insertRule(rule,index),this._rulesCount++;if(this._optimizeForSpeed){var sheet=this.getSheet();typeof index!="number"&&(index=sheet.cssRules.length);try{sheet.insertRule(rule,index)}catch{return isProd||console.warn(`StyleSheet: illegal rule:
|
|
2
2
|
|
|
3
3
|
`+rule+`
|
|
4
4
|
|
|
@@ -7,4 +7,4 @@ See https://stackoverflow.com/q/20007992 for more info`),-1}}else{var insertionP
|
|
|
7
7
|
`+rule+`
|
|
8
8
|
|
|
9
9
|
See https://stackoverflow.com/q/20007992 for more info`),sheet.insertRule(this._deletedRulePlaceholder,index)}}else{var tag=this._tags[index];invariant$1(tag,"old rule at index `"+index+"` not found"),tag.textContent=rule}return index},_proto.deleteRule=function(index){if(typeof window>"u"){this._serverSheet.deleteRule(index);return}if(this._optimizeForSpeed)this.replaceRule(index,"");else{var tag=this._tags[index];invariant$1(tag,"rule at index `"+index+"` not found"),tag.parentNode.removeChild(tag),this._tags[index]=null}},_proto.flush=function(){this._injected=!1,this._rulesCount=0,typeof window<"u"?(this._tags.forEach(function(tag){return tag&&tag.parentNode.removeChild(tag)}),this._tags=[]):this._serverSheet.cssRules=[]},_proto.cssRules=function(){var _this=this;return typeof window>"u"?this._serverSheet.cssRules:this._tags.reduce(function(rules,tag){return tag?rules=rules.concat(Array.prototype.map.call(_this.getSheetForTag(tag).cssRules,function(rule){return rule.cssText===_this._deletedRulePlaceholder?null:rule})):rules.push(null),rules},[])},_proto.makeStyleTag=function(name,cssString,relativeToTag){cssString&&invariant$1(isString(cssString),"makeStyleTag accepts only strings as second parameter");var tag=document.createElement("style");this._nonce&&tag.setAttribute("nonce",this._nonce),tag.type="text/css",tag.setAttribute("data-"+name,""),cssString&&tag.appendChild(document.createTextNode(cssString));var head=document.head||document.getElementsByTagName("head")[0];return relativeToTag?head.insertBefore(tag,relativeToTag):head.appendChild(tag),tag},_createClass(StyleSheet2,[{key:"length",get:function(){return this._rulesCount}}]),StyleSheet2}();function invariant$1(condition,message){if(!condition)throw new Error("StyleSheet: "+message+".")}function hash(str){for(var _$hash=5381,i=str.length;i;)_$hash=_$hash*33^str.charCodeAt(--i);return _$hash>>>0}var stringHash=hash,sanitize=function(rule){return rule.replace(/\/style/gi,"\\/style")},cache={};function computeId(baseId,props){if(!props)return"jsx-"+baseId;var propsToString=String(props),key=baseId+propsToString;return cache[key]||(cache[key]="jsx-"+stringHash(baseId+"-"+propsToString)),cache[key]}function computeSelector(id,css){var selectoPlaceholderRegexp=/__jsx-style-dynamic-selector/g;typeof window>"u"&&(css=sanitize(css));var idcss=id+css;return cache[idcss]||(cache[idcss]=css.replace(selectoPlaceholderRegexp,id)),cache[idcss]}function mapRulesToStyle(cssRules,options){return options===void 0&&(options={}),cssRules.map(function(args){var id=args[0],css=args[1];return React__default.default.createElement("style",{id:"__"+id,key:"__"+id,nonce:options.nonce?options.nonce:void 0,dangerouslySetInnerHTML:{__html:css}})})}var StyleSheetRegistry=function(){function StyleSheetRegistry2(param){var ref=param===void 0?{}:param,_styleSheet=ref.styleSheet,styleSheet=_styleSheet===void 0?null:_styleSheet,_optimizeForSpeed=ref.optimizeForSpeed,optimizeForSpeed=_optimizeForSpeed===void 0?!1:_optimizeForSpeed;this._sheet=styleSheet||new StyleSheet({name:"styled-jsx",optimizeForSpeed}),this._sheet.inject(),styleSheet&&typeof optimizeForSpeed=="boolean"&&(this._sheet.setOptimizeForSpeed(optimizeForSpeed),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),this._fromServer=void 0,this._indices={},this._instancesCounts={}}var _proto=StyleSheetRegistry2.prototype;return _proto.add=function(props){var _this=this;this._optimizeForSpeed===void 0&&(this._optimizeForSpeed=Array.isArray(props.children),this._sheet.setOptimizeForSpeed(this._optimizeForSpeed),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),typeof window<"u"&&!this._fromServer&&(this._fromServer=this.selectFromServer(),this._instancesCounts=Object.keys(this._fromServer).reduce(function(acc,tagName){return acc[tagName]=0,acc},{}));var ref=this.getIdAndRules(props),styleId=ref.styleId,rules=ref.rules;if(styleId in this._instancesCounts){this._instancesCounts[styleId]+=1;return}var indices=rules.map(function(rule){return _this._sheet.insertRule(rule)}).filter(function(index){return index!==-1});this._indices[styleId]=indices,this._instancesCounts[styleId]=1},_proto.remove=function(props){var _this=this,styleId=this.getIdAndRules(props).styleId;if(invariant(styleId in this._instancesCounts,"styleId: `"+styleId+"` not found"),this._instancesCounts[styleId]-=1,this._instancesCounts[styleId]<1){var tagFromServer=this._fromServer&&this._fromServer[styleId];tagFromServer?(tagFromServer.parentNode.removeChild(tagFromServer),delete this._fromServer[styleId]):(this._indices[styleId].forEach(function(index){return _this._sheet.deleteRule(index)}),delete this._indices[styleId]),delete this._instancesCounts[styleId]}},_proto.update=function(props,nextProps){this.add(nextProps),this.remove(props)},_proto.flush=function(){this._sheet.flush(),this._sheet.inject(),this._fromServer=void 0,this._indices={},this._instancesCounts={}},_proto.cssRules=function(){var _this=this,fromServer=this._fromServer?Object.keys(this._fromServer).map(function(styleId){return[styleId,_this._fromServer[styleId]]}):[],cssRules2=this._sheet.cssRules();return fromServer.concat(Object.keys(this._indices).map(function(styleId){return[styleId,_this._indices[styleId].map(function(index){return cssRules2[index].cssText}).join(_this._optimizeForSpeed?"":`
|
|
10
|
-
`)]}).filter(function(rule){return Boolean(rule[1])}))},_proto.styles=function(options){return mapRulesToStyle(this.cssRules(),options)},_proto.getIdAndRules=function(props){var css=props.children,dynamic=props.dynamic,id=props.id;if(dynamic){var styleId=computeId(id,dynamic);return{styleId,rules:Array.isArray(css)?css.map(function(rule){return computeSelector(styleId,rule)}):[computeSelector(styleId,css)]}}return{styleId:computeId(id),rules:Array.isArray(css)?css:[css]}},_proto.selectFromServer=function(){var elements=Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]'));return elements.reduce(function(acc,element){var id=element.id.slice(2);return acc[id]=element,acc},{})},StyleSheetRegistry2}();function invariant(condition,message){if(!condition)throw new Error("StyleSheetRegistry: "+message+".")}var StyleSheetContext=
|
|
10
|
+
`)]}).filter(function(rule){return Boolean(rule[1])}))},_proto.styles=function(options){return mapRulesToStyle(this.cssRules(),options)},_proto.getIdAndRules=function(props){var css=props.children,dynamic=props.dynamic,id=props.id;if(dynamic){var styleId=computeId(id,dynamic);return{styleId,rules:Array.isArray(css)?css.map(function(rule){return computeSelector(styleId,rule)}):[computeSelector(styleId,css)]}}return{styleId:computeId(id),rules:Array.isArray(css)?css:[css]}},_proto.selectFromServer=function(){var elements=Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]'));return elements.reduce(function(acc,element){var id=element.id.slice(2);return acc[id]=element,acc},{})},StyleSheetRegistry2}();function invariant(condition,message){if(!condition)throw new Error("StyleSheetRegistry: "+message+".")}var StyleSheetContext=React5.createContext(null);StyleSheetContext.displayName="StyleSheetContext";function createStyleRegistry(){return new StyleSheetRegistry}function StyleRegistry2(param){var configuredRegistry=param.registry,children=param.children,rootRegistry=React5.useContext(StyleSheetContext),ref=React5.useState(function(){return rootRegistry||configuredRegistry||createStyleRegistry()}),registry=ref[0];return React__default.default.createElement(StyleSheetContext.Provider,{value:registry},children)}function useStyleRegistry(){return React5.useContext(StyleSheetContext)}var useInsertionEffect=React__default.default.useInsertionEffect||React__default.default.useLayoutEffect,defaultRegistry=typeof window<"u"?createStyleRegistry():void 0;function JSXStyle(props){var registry=defaultRegistry||useStyleRegistry();return registry?typeof window>"u"?(registry.add(props),null):(useInsertionEffect(function(){return registry.add(props),function(){registry.remove(props)}},[props.id,String(props.dynamic)]),null):null}JSXStyle.dynamic=function(info){return info.map(function(tagInfo){var baseId=tagInfo[0],props=tagInfo[1];return computeId(baseId,props)}).join(" ")};exports.StyleRegistry=StyleRegistry2;exports.createStyleRegistry=createStyleRegistry;exports.style=JSXStyle;exports.useStyleRegistry=useStyleRegistry}});var require_styled_jsx=__commonJS({"../../node_modules/styled-jsx/index.js"(exports,module){module.exports=require_index()}});import{setConfig}from"next/config";setConfig(process.env.__NEXT_RUNTIME_CONFIG);import*as React2 from"react";import{RouterContext}from"next/dist/shared/lib/router-context";import React from"react";var PageRouterProvider=({children,action:action2,routeParams,globals})=>React.createElement(RouterContext.Provider,{value:{push(...args){return action2("nextRouter.push")(...args),Promise.resolve(!0)},replace(...args){return action2("nextRouter.replace")(...args),Promise.resolve(!0)},reload(...args){action2("nextRouter.reload")(...args)},back(...args){action2("nextRouter.back")(...args)},forward(){action2("nextRouter.forward")()},prefetch(...args){return action2("nextRouter.prefetch")(...args),Promise.resolve()},beforePopState(...args){action2("nextRouter.beforePopState")(...args)},events:{on(...args){action2("nextRouter.events.on")(...args)},off(...args){action2("nextRouter.events.off")(...args)},emit(...args){action2("nextRouter.events.emit")(...args)}},locale:globals?.locale,route:"/",asPath:"/",basePath:"/",isFallback:!1,isLocaleDomain:!1,isReady:!0,isPreview:!1,...routeParams}},children),page_router_provider_default=PageRouterProvider;var AppRouterProvider=React2.lazy(()=>import("./app-router-provider-5WPYJFG6.mjs")),action;try{action=__require("@storybook/addon-actions").action}catch{action=()=>()=>{}}var defaultRouterParams={pathname:"/",query:{}},RouterDecorator=(Story,{globals,parameters})=>parameters.nextjs?.appDirectory??!1?React2.createElement(AppRouterProvider,{action,routeParams:{...defaultRouterParams,...parameters.nextjs?.navigation}},React2.createElement(Story,null)):React2.createElement(page_router_provider_default,{action,globals,routeParams:{...defaultRouterParams,...parameters.nextjs?.router}},React2.createElement(Story,null));import*as React3 from"react";var StyleRegistry;try{StyleRegistry=require_styled_jsx().StyleRegistry}catch{StyleRegistry=React3.Fragment}var StyledJsxDecorator=Story=>React3.createElement(StyleRegistry,null,React3.createElement(Story,null));import*as React4 from"react";import semver from"semver";var defaultLoader=({src,width,quality})=>{let missingValues=[];if(src||missingValues.push("src"),width||missingValues.push("width"),missingValues.length>0)throw new Error(`Next Image Optimization requires ${missingValues.join(", ")} to be provided. Make sure you pass them as props to the \`next/image\` component. Received: ${JSON.stringify({src,width,quality})}`);return`${src}?w=${width}&q=${quality??75}`},NextImage=__require("next/image"),OriginalNextImage=NextImage.default;Object.defineProperty(NextImage,"default",{configurable:!0,value:props=>React4.createElement(OriginalNextImage,{...props,loader:props.loader??defaultLoader})});if(semver.satisfies(process.env.__NEXT_VERSION,"^13.0.0")){let OriginalNextLegacyImage=__require("next/legacy/image").default;Object.defineProperty(OriginalNextLegacyImage,"default",{configurable:!0,value:props=>React4.createElement(OriginalNextLegacyImage,{...props,loader:props.loader??defaultLoader})})}if(semver.satisfies(process.env.__NEXT_VERSION,"^12.2.0")){let OriginalNextFutureImage=__require("next/future/image").default;Object.defineProperty(OriginalNextFutureImage,"default",{configurable:!0,value:props=>React4.createElement(OriginalNextFutureImage,{...props,loader:props.loader??defaultLoader})})}var decorators=[StyledJsxDecorator,RouterDecorator];export{decorators};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/nextjs",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.61",
|
|
4
4
|
"description": "Storybook for Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
"prep": "../../../scripts/prepare/bundle.ts"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@storybook/builder-webpack5": "7.0.0-alpha.
|
|
63
|
-
"@storybook/core-common": "7.0.0-alpha.
|
|
64
|
-
"@storybook/node-logger": "7.0.0-alpha.
|
|
65
|
-
"@storybook/preset-react-webpack": "7.0.0-alpha.
|
|
66
|
-
"@storybook/preview-api": "7.0.0-alpha.
|
|
67
|
-
"@storybook/react": "7.0.0-alpha.
|
|
62
|
+
"@storybook/builder-webpack5": "7.0.0-alpha.61",
|
|
63
|
+
"@storybook/core-common": "7.0.0-alpha.61",
|
|
64
|
+
"@storybook/node-logger": "7.0.0-alpha.61",
|
|
65
|
+
"@storybook/preset-react-webpack": "7.0.0-alpha.61",
|
|
66
|
+
"@storybook/preview-api": "7.0.0-alpha.61",
|
|
67
|
+
"@storybook/react": "7.0.0-alpha.61",
|
|
68
68
|
"@types/node": "^16.0.0",
|
|
69
69
|
"find-up": "^5.0.0",
|
|
70
70
|
"fs-extra": "^9.0.1",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"tsconfig-paths-webpack-plugin": "^3.5.2"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@storybook/addon-actions": "7.0.0-alpha.
|
|
83
|
+
"@storybook/addon-actions": "7.0.0-alpha.61",
|
|
84
84
|
"next": "^13.0.5",
|
|
85
85
|
"typescript": "^4.9.3",
|
|
86
86
|
"webpack": "^5.65.0"
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
],
|
|
120
120
|
"platform": "node"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "ec1df6fe1b11ad6084b9f3ea4b5f6bee3fca58be"
|
|
123
123
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import dynamic from 'next/dynamic';
|
|
2
|
+
import React, { Suspense } from 'react';
|
|
3
|
+
|
|
4
|
+
const DynamicComponent = dynamic(() => import('./dynamic-component'), {
|
|
5
|
+
ssr: false,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
function Component() {
|
|
9
|
+
return (
|
|
10
|
+
<Suspense fallback="Loading...">
|
|
11
|
+
<DynamicComponent />
|
|
12
|
+
</Suspense>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
component: Component,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const Default = {};
|
|
File without changes
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
|
|
5
|
+
import style from './Link.stories.module.css';
|
|
6
|
+
|
|
7
|
+
// `onClick`, `href`, and `ref` need to be passed to the DOM element
|
|
8
|
+
// for proper handling
|
|
9
|
+
const MyButton = React.forwardRef(function Button({ onClick, href, children }, ref) {
|
|
10
|
+
return (
|
|
11
|
+
<a href={href} onClick={onClick} ref={ref}>
|
|
12
|
+
{children}
|
|
13
|
+
</a>
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const Component = () => (
|
|
18
|
+
<ul>
|
|
19
|
+
<li>
|
|
20
|
+
<Link href="/">Normal Link</Link>
|
|
21
|
+
</li>
|
|
22
|
+
<li>
|
|
23
|
+
<Link
|
|
24
|
+
href={{
|
|
25
|
+
pathname: '/with-url-object',
|
|
26
|
+
query: { name: 'test' },
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
With URL Object
|
|
30
|
+
</Link>
|
|
31
|
+
</li>
|
|
32
|
+
<li>
|
|
33
|
+
<Link href="/replace-url" replace>
|
|
34
|
+
Replace the URL instead of push
|
|
35
|
+
</Link>
|
|
36
|
+
</li>
|
|
37
|
+
<li>
|
|
38
|
+
<Link href="/legacy-behaviour" legacyBehavior>
|
|
39
|
+
<a>Legacy behavior</a>
|
|
40
|
+
</Link>
|
|
41
|
+
</li>
|
|
42
|
+
<li>
|
|
43
|
+
<Link href="/child-is-functional-component" passHref legacyBehavior>
|
|
44
|
+
<MyButton>child is a functional component</MyButton>
|
|
45
|
+
</Link>
|
|
46
|
+
</li>
|
|
47
|
+
<li>
|
|
48
|
+
<Link href="/#hashid" scroll={false}>
|
|
49
|
+
Disables scrolling to the top
|
|
50
|
+
</Link>
|
|
51
|
+
</li>
|
|
52
|
+
<li>
|
|
53
|
+
<Link href="/no-prefetch" prefetch={false}>
|
|
54
|
+
No Prefetching
|
|
55
|
+
</Link>
|
|
56
|
+
</li>
|
|
57
|
+
<li>
|
|
58
|
+
<Link style={{ color: 'red' }} href="/with-style">
|
|
59
|
+
With style
|
|
60
|
+
</Link>
|
|
61
|
+
</li>
|
|
62
|
+
<li>
|
|
63
|
+
<Link className={style.link} href="/with-classname">
|
|
64
|
+
With className
|
|
65
|
+
</Link>
|
|
66
|
+
</li>
|
|
67
|
+
</ul>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
export default {
|
|
71
|
+
component: Component,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const Default = {};
|
|
75
|
+
|
|
76
|
+
export const InAppDir = {
|
|
77
|
+
parameters: {
|
|
78
|
+
nextjs: {
|
|
79
|
+
appDirectory: true,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { useRouter, usePathname, useSearchParams } from 'next/navigation';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
function Component() {
|
|
5
|
+
const router = useRouter();
|
|
6
|
+
const pathname = usePathname();
|
|
7
|
+
const searchParams = useSearchParams();
|
|
8
|
+
|
|
9
|
+
const searchParamsList = Array.from(searchParams.entries());
|
|
10
|
+
|
|
11
|
+
const routerActions = [
|
|
12
|
+
{
|
|
13
|
+
cb: () => router.back(),
|
|
14
|
+
name: 'Go back',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
cb: () => router.forward(),
|
|
18
|
+
name: 'Go forward',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
cb: () => router.prefetch('/prefetched-html'),
|
|
22
|
+
name: 'Prefetch',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
cb: () => router.push('/push-html', { forceOptimisticNavigation: true }),
|
|
26
|
+
name: 'Push HTML',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
cb: () => router.refresh(),
|
|
30
|
+
name: 'Refresh',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
cb: () => router.replace('/replaced-html', { forceOptimisticNavigation: true }),
|
|
34
|
+
name: 'Replace',
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div>
|
|
40
|
+
<div>pathname: {pathname}</div>
|
|
41
|
+
<div>
|
|
42
|
+
searchparams:{' '}
|
|
43
|
+
<ul>
|
|
44
|
+
{searchParamsList.map(([key, value]) => (
|
|
45
|
+
<li key={key}>
|
|
46
|
+
{key}: {value}
|
|
47
|
+
</li>
|
|
48
|
+
))}
|
|
49
|
+
</ul>
|
|
50
|
+
</div>
|
|
51
|
+
{routerActions.map(({ cb, name }) => (
|
|
52
|
+
<div key={name} style={{ marginBottom: '1em' }}>
|
|
53
|
+
<button type="button" onClick={cb}>
|
|
54
|
+
{name}
|
|
55
|
+
</button>
|
|
56
|
+
</div>
|
|
57
|
+
))}
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default {
|
|
63
|
+
component: Component,
|
|
64
|
+
parameters: {
|
|
65
|
+
nextjs: {
|
|
66
|
+
appDirectory: true,
|
|
67
|
+
navigation: {
|
|
68
|
+
pathname: '/hello',
|
|
69
|
+
query: {
|
|
70
|
+
foo: 'bar',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const Default = {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { useRouter } from 'next/router';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
function Component() {
|
|
5
|
+
const router = useRouter();
|
|
6
|
+
const searchParams = router.query;
|
|
7
|
+
|
|
8
|
+
const routerActions = [
|
|
9
|
+
{
|
|
10
|
+
cb: () => router.back(),
|
|
11
|
+
name: 'Go back',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
cb: () => router.forward(),
|
|
15
|
+
name: 'Go forward',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
cb: () => router.prefetch('/prefetched-html'),
|
|
19
|
+
name: 'Prefetch',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
cb: () => router.push('/push-html', { forceOptimisticNavigation: true }),
|
|
23
|
+
name: 'Push HTML',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
cb: () => router.replace('/replaced-html', { forceOptimisticNavigation: true }),
|
|
27
|
+
name: 'Replace',
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div>
|
|
33
|
+
<div>pathname: {router.pathname}</div>
|
|
34
|
+
<div>
|
|
35
|
+
searchparams:{' '}
|
|
36
|
+
<ul>
|
|
37
|
+
{Object.entries(searchParams).map(([key, value]) => (
|
|
38
|
+
<li key={key}>
|
|
39
|
+
{key}: {value}
|
|
40
|
+
</li>
|
|
41
|
+
))}
|
|
42
|
+
</ul>
|
|
43
|
+
</div>
|
|
44
|
+
{routerActions.map(({ cb, name }) => (
|
|
45
|
+
<div key={name} style={{ marginBottom: '1em' }}>
|
|
46
|
+
<button type="button" onClick={cb}>
|
|
47
|
+
{name}
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
))}
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default {
|
|
56
|
+
component: Component,
|
|
57
|
+
parameters: {
|
|
58
|
+
nextjs: {
|
|
59
|
+
router: {
|
|
60
|
+
pathname: '/hello',
|
|
61
|
+
query: {
|
|
62
|
+
foo: 'bar',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const Default = {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Link from 'next/link';
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
|
|
5
|
+
import style from './Link.stories.module.css';
|
|
6
|
+
|
|
7
|
+
// `onClick`, `href`, and `ref` need to be passed to the DOM element
|
|
8
|
+
// for proper handling
|
|
9
|
+
const MyButton = React.forwardRef<
|
|
10
|
+
HTMLAnchorElement,
|
|
11
|
+
React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>
|
|
12
|
+
>(function Button({ onClick, href, children }, ref) {
|
|
13
|
+
return (
|
|
14
|
+
<a href={href} onClick={onClick} ref={ref}>
|
|
15
|
+
{children}
|
|
16
|
+
</a>
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const Component = () => (
|
|
21
|
+
<ul>
|
|
22
|
+
<li>
|
|
23
|
+
<Link href="/">Normal Link</Link>
|
|
24
|
+
</li>
|
|
25
|
+
<li>
|
|
26
|
+
<Link
|
|
27
|
+
href={{
|
|
28
|
+
pathname: '/with-url-object',
|
|
29
|
+
query: { name: 'test' },
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
With URL Object
|
|
33
|
+
</Link>
|
|
34
|
+
</li>
|
|
35
|
+
<li>
|
|
36
|
+
<Link href="/replace-url" replace>
|
|
37
|
+
Replace the URL instead of push
|
|
38
|
+
</Link>
|
|
39
|
+
</li>
|
|
40
|
+
<li>
|
|
41
|
+
<Link href="/legacy-behaviour" legacyBehavior>
|
|
42
|
+
<a>Legacy behavior</a>
|
|
43
|
+
</Link>
|
|
44
|
+
</li>
|
|
45
|
+
<li>
|
|
46
|
+
<Link href="/child-is-functional-component" passHref legacyBehavior>
|
|
47
|
+
<MyButton>child is a functional component</MyButton>
|
|
48
|
+
</Link>
|
|
49
|
+
</li>
|
|
50
|
+
<li>
|
|
51
|
+
<Link href="/#hashid" scroll={false}>
|
|
52
|
+
Disables scrolling to the top
|
|
53
|
+
</Link>
|
|
54
|
+
</li>
|
|
55
|
+
<li>
|
|
56
|
+
<Link href="/no-prefetch" prefetch={false}>
|
|
57
|
+
No Prefetching
|
|
58
|
+
</Link>
|
|
59
|
+
</li>
|
|
60
|
+
<li>
|
|
61
|
+
<Link style={{ color: 'red' }} href="/with-style">
|
|
62
|
+
With style
|
|
63
|
+
</Link>
|
|
64
|
+
</li>
|
|
65
|
+
<li>
|
|
66
|
+
<Link className={style.link} href="/with-classname">
|
|
67
|
+
With className
|
|
68
|
+
</Link>
|
|
69
|
+
</li>
|
|
70
|
+
</ul>
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
export default {
|
|
74
|
+
component: Component,
|
|
75
|
+
} as Meta<typeof Component>;
|
|
76
|
+
|
|
77
|
+
export const Default: StoryObj<typeof Component> = {};
|
|
78
|
+
|
|
79
|
+
export const InAppDir: StoryObj<typeof Component> = {
|
|
80
|
+
parameters: {
|
|
81
|
+
nextjs: {
|
|
82
|
+
appDirectory: true,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { useRouter, usePathname, useSearchParams } from 'next/navigation';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
|
|
5
|
+
function Component() {
|
|
6
|
+
const router = useRouter();
|
|
7
|
+
const pathname = usePathname();
|
|
8
|
+
const searchParams = useSearchParams();
|
|
9
|
+
|
|
10
|
+
const searchParamsList = Array.from(searchParams.entries());
|
|
11
|
+
|
|
12
|
+
const routerActions = [
|
|
13
|
+
{
|
|
14
|
+
cb: () => router.back(),
|
|
15
|
+
name: 'Go back',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
cb: () => router.forward(),
|
|
19
|
+
name: 'Go forward',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
cb: () => router.prefetch('/prefetched-html'),
|
|
23
|
+
name: 'Prefetch',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
cb: () => router.push('/push-html', { forceOptimisticNavigation: true }),
|
|
27
|
+
name: 'Push HTML',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
cb: () => router.refresh(),
|
|
31
|
+
name: 'Refresh',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
cb: () => router.replace('/replaced-html', { forceOptimisticNavigation: true }),
|
|
35
|
+
name: 'Replace',
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div>
|
|
41
|
+
<div>pathname: {pathname}</div>
|
|
42
|
+
<div>
|
|
43
|
+
searchparams:{' '}
|
|
44
|
+
<ul>
|
|
45
|
+
{searchParamsList.map(([key, value]) => (
|
|
46
|
+
<li key={key}>
|
|
47
|
+
{key}: {value}
|
|
48
|
+
</li>
|
|
49
|
+
))}
|
|
50
|
+
</ul>
|
|
51
|
+
</div>
|
|
52
|
+
{routerActions.map(({ cb, name }) => (
|
|
53
|
+
<div key={name} style={{ marginBottom: '1em' }}>
|
|
54
|
+
<button type="button" onClick={cb}>
|
|
55
|
+
{name}
|
|
56
|
+
</button>
|
|
57
|
+
</div>
|
|
58
|
+
))}
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default {
|
|
64
|
+
component: Component,
|
|
65
|
+
parameters: {
|
|
66
|
+
nextjs: {
|
|
67
|
+
appDirectory: true,
|
|
68
|
+
navigation: {
|
|
69
|
+
pathname: '/hello',
|
|
70
|
+
query: {
|
|
71
|
+
foo: 'bar',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
} as Meta<typeof Component>;
|
|
77
|
+
|
|
78
|
+
export const Default: StoryObj<typeof Component> = {};
|