@storybook/nextjs 7.0.0-beta.8 → 7.0.0-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.
Files changed (45) hide show
  1. package/README.md +116 -7
  2. package/dist/chunk-YPQDI6HO.mjs +1 -0
  3. package/dist/font/webpack/loader/storybook-nextjs-font-loader.d.ts +3 -0
  4. package/dist/font/webpack/loader/storybook-nextjs-font-loader.js +40 -0
  5. package/dist/font/webpack/loader/storybook-nextjs-font-loader.mjs +40 -0
  6. package/dist/index.js +1 -1
  7. package/dist/next-image-loader-stub.js +1 -1
  8. package/dist/next-image-loader-stub.mjs +1 -1
  9. package/dist/preset.d.ts +23 -19
  10. package/dist/preset.js +1 -1
  11. package/dist/preset.mjs +1 -1
  12. package/dist/preview.d.ts +8 -1
  13. package/dist/preview.js +1 -10
  14. package/dist/preview.mjs +1 -10
  15. package/package.json +44 -15
  16. package/template/cli/js/Button.stories.js +1 -1
  17. package/template/cli/js/Header.stories.js +2 -2
  18. package/template/cli/js/Introduction.mdx +2 -2
  19. package/template/cli/ts/Button.stories.ts +46 -0
  20. package/template/cli/ts/Button.tsx +52 -0
  21. package/template/cli/ts/Header.stories.ts +26 -0
  22. package/template/cli/ts/Header.tsx +56 -0
  23. package/template/cli/{ts-legacy/Introduction.stories.mdx → ts/Introduction.mdx} +1 -1
  24. package/template/cli/ts/Page.stories.ts +29 -0
  25. package/template/cli/ts/Page.tsx +73 -0
  26. package/template/cli/{ts-legacy → ts-3-8}/Button.stories.ts +1 -1
  27. package/template/cli/{ts-legacy → ts-3-8}/Header.stories.ts +2 -2
  28. package/template/cli/ts-3-8/Introduction.mdx +228 -0
  29. package/template/cli/{ts-legacy → ts-3-8}/Page.tsx +1 -1
  30. package/template/next-env.d.ts +7 -0
  31. package/template/stories/Image.stories.jsx +1 -1
  32. package/template/stories_12-js/ImageFuture.stories.jsx +1 -1
  33. package/template/stories_default-js/Font.jsx +64 -0
  34. package/template/stories_default-js/Font.stories.jsx +23 -0
  35. package/template/stories_default-js/Head.stories.jsx +34 -0
  36. package/template/stories_default-js/ImageLegacy.stories.jsx +1 -1
  37. package/template/stories_default-js/Navigation.stories.jsx +23 -2
  38. package/template/stories_default-js/fonts/OFL.txt +93 -0
  39. package/template/stories_default-js/fonts/RubikStorm-Regular.ttf +0 -0
  40. package/template/stories_default-ts/Navigation.stories.tsx +2 -1
  41. package/dist/app-router-provider-ZH4HRNON.mjs +0 -1
  42. package/dist/chunk-4MG4OZFL.mjs +0 -1
  43. /package/template/cli/{ts-legacy → ts-3-8}/Button.tsx +0 -0
  44. /package/template/cli/{ts-legacy → ts-3-8}/Header.tsx +0 -0
  45. /package/template/cli/{ts-legacy → ts-3-8}/Page.stories.ts +0 -0
package/README.md CHANGED
@@ -7,12 +7,18 @@
7
7
  - [Getting Started](#getting-started)
8
8
  - [In a project without Storybook](#in-a-project-without-storybook)
9
9
  - [In a project with Storybook](#in-a-project-with-storybook)
10
+ - [Automatic migration](#automatic-migration)
11
+ - [Manual migration](#manual-migration)
10
12
  - [Documentation](#documentation)
11
13
  - [Options](#options)
12
14
  - [Next.js's Image Component](#nextjss-image-component)
13
15
  - [Local Images](#local-images)
14
16
  - [Remote Images](#remote-images)
15
17
  - [AVIF](#avif)
18
+ - [Next.js Font Optimization](#nextjs-font-optimization)
19
+ - [next/font/google](#nextfontgoogle)
20
+ - [next/font/local](#nextfontlocal)
21
+ - [Not supported features of next/font](#not-supported-features-of-nextfont)
16
22
  - [Next.js Routing](#nextjs-routing)
17
23
  - [Overriding defaults](#overriding-defaults)
18
24
  - [Global Defaults](#global-defaults)
@@ -22,8 +28,10 @@
22
28
  - [Set `nextjs.appDirectory` to `true`](#set-nextjsappdirectory-to-true)
23
29
  - [Overriding defaults](#overriding-defaults-1)
24
30
  - [Global Defaults](#global-defaults-1)
31
+ - [`useSelectedLayoutSegment` and `useSelectedLayoutSegments` hook](#useselectedlayoutsegment-and-useselectedlayoutsegments-hook)
25
32
  - [Default Navigation Context](#default-navigation-context)
26
33
  - [Actions Integration Caveats](#actions-integration-caveats-1)
34
+ - [Next.js Head](#nextjs-head)
27
35
  - [Sass/Scss](#sassscss)
28
36
  - [Css/Sass/Scss Modules](#csssassscss-modules)
29
37
  - [Styled JSX](#styled-jsx)
@@ -37,14 +45,19 @@
37
45
  - [Stories for pages/components which fetch data](#stories-for-pagescomponents-which-fetch-data)
38
46
  - [Statically imported images won't load](#statically-imported-images-wont-load)
39
47
  - [Module not found: Error: Can't resolve \[package name\]](#module-not-found-error-cant-resolve-package-name)
48
+ - [What if I'm using the Vite builder?](#what-if-im-using-the-vite-builder)
40
49
  - [Acknowledgements](#acknowledgements)
41
50
 
42
51
  ## Supported Features
43
52
 
44
53
  👉 [Next.js's Image Component](#nextjss-image-component)
45
54
 
55
+ 👉 [Next.js Font Optimization](#nextjs-font-optimization)
56
+
46
57
  👉 [Next.js Routing (next/router)](#nextjs-routing)
47
58
 
59
+ 👉 [Next.js Head (next/head)](#nextjs-head)
60
+
48
61
  👉 [Next.js Navigation (next/navigation)](#nextjs-navigation)
49
62
 
50
63
  👉 [Sass/Scss](#sassscss)
@@ -88,6 +101,12 @@ This framework is designed to work with Storybook 7. If you’re not already usi
88
101
  npx storybook@next upgrade --prerelease
89
102
  ```
90
103
 
104
+ #### Automatic migration
105
+
106
+ When running the `upgrade` command above, you should get a prompt asking you to migrate to `@storybook/nextjs`, which should handle everything for you. In case that auto-migration does not work for your project, refer to the manual migration below.
107
+
108
+ #### Manual migration
109
+
91
110
  Install the framework:
92
111
 
93
112
  ```bash
@@ -98,7 +117,7 @@ Update your `main.js` to change the framework property:
98
117
 
99
118
  ```js
100
119
  // .storybook/main.js
101
- module.exports = {
120
+ export default {
102
121
  // ...
103
122
  framework: {
104
123
  // name: '@storybook/react-webpack5', // Remove this
@@ -112,7 +131,7 @@ If you were using Storybook plugins to integrate with Next.js, those are no long
112
131
 
113
132
  ```js
114
133
  // .storybook/main.js
115
- module.exports = {
134
+ export default {
116
135
  // ...
117
136
  addons: [
118
137
  // ...
@@ -133,9 +152,9 @@ For example:
133
152
 
134
153
  ```js
135
154
  // .storybook/main.js
136
- const path = require('path');
155
+ import * as path from 'path';
137
156
 
138
- module.exports = {
157
+ export default {
139
158
  // ...
140
159
  framework: {
141
160
  name: '@storybook/nextjs',
@@ -200,6 +219,54 @@ export default function Home() {
200
219
 
201
220
  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.
202
221
 
222
+ ### Next.js Font Optimization
223
+
224
+ [next/font](https://nextjs.org/docs/basic-features/font-optimization) is partially supported in Storybook. The packages `next/font/google` and `next/font/local` are supported.
225
+
226
+ #### next/font/google
227
+
228
+ You don't have to do anything. `next/font/google` is supported out of the box.
229
+
230
+ #### next/font/local
231
+
232
+ For local fonts you have to define the [src](https://nextjs.org/docs/api-reference/next/font#src) property.
233
+ The path is relative to the directory where the font loader function is called.
234
+
235
+ If the following component defines your localFont like this:
236
+
237
+ ```js
238
+ // src/components/MyComponent.js
239
+ import localFont from 'next/font/local';
240
+
241
+ const localRubikStorm = localFont({ src: './fonts/RubikStorm-Regular.ttf' });
242
+ ```
243
+
244
+ You have to tell Storybook where the `fonts` directory is located. The `from` value is relative to the `.storybook` directory. The `to` value is relative to the execution context of Storybook. Very likely it is the root of your project.
245
+
246
+ ```js
247
+ // .storybook/main.js
248
+ export default {
249
+ ...
250
+ "staticDirs": [
251
+ {
252
+ from: '../src/components/fonts',
253
+ to: 'src/components/fonts'
254
+ }
255
+ ],
256
+ }
257
+ ```
258
+
259
+ #### Not supported features of next/font
260
+
261
+ The following features are not supported (yet). Support for these features might be planned for the future:
262
+
263
+ - [Support font loaders configuration in next.config.js](https://nextjs.org/docs/basic-features/font-optimization#specifying-a-subset)
264
+ - [fallback](https://nextjs.org/docs/api-reference/next/font#fallback) option
265
+ - [adjustFontFallback](https://nextjs.org/docs/api-reference/next/font#adjustfontfallback) option
266
+ - [declarations](https://nextjs.org/docs/api-reference/next/font#declarations) option
267
+ - [preload](https://nextjs.org/docs/api-reference/next/font#preload) option gets ignored. Storybook handles Font loading its own way.
268
+ - [display](https://nextjs.org/docs/api-reference/next/font#display) option gets ignored. All fonts are loaded with display set to "block" to make Storybook load the font properly.
269
+
203
270
  ### Next.js Routing
204
271
 
205
272
  [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 Actions ctions panel if you have the [Storybook actions addon](https://storybook.js.org/docs/react/essentials/actions).
@@ -432,6 +499,40 @@ export const parameters = {
432
499
  };
433
500
  ```
434
501
 
502
+ #### `useSelectedLayoutSegment` and `useSelectedLayoutSegments` hook
503
+
504
+ The `useSelectedLayoutSegment` and `useSelectedLayoutSegments` hooks are supported in Storybook. You have to set the `nextjs.navigation.segments` parameter to return the segments you want to use.
505
+
506
+ ```js
507
+ // SomeComponentThatUsesTheNavigation.stories.js
508
+ import SomeComponentThatUsesTheNavigation from './SomeComponentThatUsesTheNavigation';
509
+
510
+ export default {
511
+ component: SomeComponentThatUsesTheNavigation,
512
+ parameters: {
513
+ nextjs: {
514
+ appDirectory: true,
515
+ navigation: {
516
+ segments: ['dashboard', 'analytics']
517
+ },
518
+ },
519
+ },
520
+ };
521
+
522
+ export const Example = {};
523
+
524
+ // SomeComponentThatUsesTheNavigation.js
525
+ import { useSelectedLayoutSegment, useSelectedLayoutSegments } from 'next/navigation';
526
+
527
+ export default function SomeComponentThatUsesTheNavigation() {
528
+ const segment = useSelectedLayoutSegment(); // dashboard
529
+ const segments = useSelectedLayoutSegments(); // ["dashboard", "analytics"]
530
+ ...
531
+ }
532
+ ```
533
+
534
+ The default value of `nextjs.navigation.segments` is `[]` if not set.
535
+
435
536
  #### Default Navigation Context
436
537
 
437
538
  The default values on the stubbed navigation context are as follows:
@@ -502,6 +603,10 @@ export const parameters = {
502
603
  };
503
604
  ```
504
605
 
606
+ ### Next.js Head
607
+
608
+ [next/head](https://nextjs.org/docs/api-reference/next/head) is supported out of the box. You can use it in your stories like you would in your Next.js application. Please keep in mind, that the Head children are placed into the head element of the iframe that Storybook uses to render your stories.
609
+
505
610
  ### Sass/Scss
506
611
 
507
612
  [Global sass/scss stylesheets](https://nextjs.org/docs/basic-features/built-in-css-support#sass-support) are supported without any additional configuration as well. Just import them into [preview.js](https://storybook.js.org/docs/react/configure/overview#configure-story-rendering)
@@ -514,9 +619,9 @@ This will automatically include any of your [custom sass configurations](https:/
514
619
 
515
620
  ```js
516
621
  // next.config.js
517
- const path = require('path');
622
+ import * as path from 'path';
518
623
 
519
- module.exports = {
624
+ export default {
520
625
  // Any options here are included in Sass compilation for your stories
521
626
  sassOptions: {
522
627
  includePaths: [path.join(__dirname, 'styles')],
@@ -680,7 +785,7 @@ Below is an example of how to add svgr support to Storybook with this framework.
680
785
 
681
786
  ```js
682
787
  // .storybook/main.js
683
- module.exports = {
788
+ export default {
684
789
  // ...
685
790
  webpackFinal: async (config) => {
686
791
  // This modifies the existing image rule to exclude .svg files
@@ -825,6 +930,10 @@ See [local images](https://nextjs.org/docs/basic-features/image-optimization#loc
825
930
 
826
931
  You might get this if you're using Yarn v2 or v3. See [Notes for Yarn v2 and v3 users](#notes-for-yarn-v2-and-v3-users) for more details.
827
932
 
933
+ #### What if I'm using the Vite builder?
934
+
935
+ The `@storybook/nextjs` package abstracts the Webpack 5 builder and provides all the necessary Webpack configuration needed (and used internally) by Next.js. Webpack is currently the official builder in Next.js, and Next.js does not support Vite, therefore it is not possible to use Vite with `@storybook/nextjs`. You can use `@storybook/react-vite` framework instead, but at the cost of having a degraded experience, and we won't be able to provide you official support.
936
+
828
937
  ## Acknowledgements
829
938
 
830
939
  This framework borrows heavily from these Storybook addons:
@@ -0,0 +1 @@
1
+ var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+x+'" is not supported')});var __esm=(fn,res)=>function(){return fn&&(res=(0,fn[__getOwnPropNames(fn)[0]])(fn=0)),res};var __commonJS=(cb,mod)=>function(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};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);export{__require,__esm,__commonJS,__export,__toCommonJS};
@@ -0,0 +1,3 @@
1
+ declare function storybookNextjsFontLoader(this: any): Promise<string>;
2
+
3
+ export { storybookNextjsFontLoader as default };
@@ -0,0 +1,40 @@
1
+ "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __esm=(fn,res)=>function(){return fn&&(res=(0,fn[__getOwnPropNames(fn)[0]])(fn=0)),res};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 __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var google_font_utils_exports={};__export(google_font_utils_exports,{fetchCSSFromGoogleFonts:()=>fetchCSSFromGoogleFonts,getFontAxes:()=>getFontAxes,getUrl:()=>getUrl,validateData:()=>validateData});var validateData,getUrl,getFontAxes,fetchCSSFromGoogleFonts,init_google_font_utils=__esm({"src/font/webpack/loader/utils/google-font-utils.ts"(){"use strict";try{let fontUtils=require("@next/font/dist/google/utils");validateData=fontUtils.validateData,getUrl=fontUtils.getUrl,getFontAxes=fontUtils.getFontAxes,fetchCSSFromGoogleFonts=fontUtils.fetchCSSFromGoogleFonts}catch{let fontUtils=require("next/dist/compiled/@next/font/dist/google/utils");validateData=fontUtils.validateData,getUrl=fontUtils.getUrl,getFontAxes=fontUtils.getFontAxes,fetchCSSFromGoogleFonts=fontUtils.fetchCSSFromGoogleFonts}}});var local_font_utils_exports={};__export(local_font_utils_exports,{validateData:()=>validateData2});var validateData2,init_local_font_utils=__esm({"src/font/webpack/loader/utils/local-font-utils.ts"(){"use strict";try{validateData2=require("@next/font/dist/local/utils").validateData}catch{validateData2=require("next/dist/compiled/@next/font/dist/local/utils").validateData}}});var storybook_nextjs_font_loader_exports={};__export(storybook_nextjs_font_loader_exports,{default:()=>storybookNextjsFontLoader});module.exports=__toCommonJS(storybook_nextjs_font_loader_exports);var import_loader_utils3=__toESM(require("next/dist/compiled/loader-utils3")),cssCache=new Map;async function getFontFaceDeclarations(options){let{fetchCSSFromGoogleFonts:fetchCSSFromGoogleFonts2,getFontAxes:getFontAxes2,getUrl:getUrl2,validateData:validateData3}=(init_google_font_utils(),__toCommonJS(google_font_utils_exports)),{fontFamily,weights,styles,selectedVariableAxes,display,variable}=validateData3(options.fontFamily,[options.props],null),fontAxes=getFontAxes2(fontFamily,weights,styles,selectedVariableAxes),url=getUrl2(fontFamily,fontAxes,display);try{let hasCachedCSS=cssCache.has(url),fontFaceCSS=hasCachedCSS?cssCache.get(url):await fetchCSSFromGoogleFonts2(url,fontFamily).catch(()=>null);if(hasCachedCSS?cssCache.delete(url):cssCache.set(url,fontFaceCSS),fontFaceCSS===null)throw Error(`Failed to fetch \`${fontFamily}\` from Google Fonts.`);return{id:import_loader_utils3.default.getHashDigest(url,"md5","hex",6),fontFamily,fontFaceCSS,weights,styles,variable}}catch{throw new Error("Google Fonts couldn't be loaded.")}}var import_loader_utils32=__toESM(require("next/dist/compiled/loader-utils3")),import_path=__toESM(require("path"));async function getFontFaceDeclarations2(options,rootContext){let localFontSrc=options.props.src,parentFolder=options.filename.split("/").slice(0,-1).join("/").replace(rootContext,""),{validateData:validateData3}=(init_local_font_utils(),__toCommonJS(local_font_utils_exports)),{weight,style,variable}=validateData3("",options.props),id=`font-${import_loader_utils32.default.getHashDigest(Buffer.from(JSON.stringify(localFontSrc)),"md5","hex",6)}`;return{id,fontFamily:id,fontFaceCSS:(()=>{if(typeof localFontSrc=="string"){let localFontPath=import_path.default.join(parentFolder,localFontSrc);return`@font-face {
2
+ font-family: ${id};
3
+ src: url(${localFontPath});
4
+ }`}return localFontSrc.map(font=>{let localFontPath=import_path.default.join(parentFolder,font.path);return`@font-face {
5
+ font-family: ${id};
6
+ src: url(${localFontPath});
7
+ ${font.weight?`font-weight: ${font.weight};`:""}
8
+ ${font.style?`font-style: ${font.style};`:""}
9
+ }`}).join("")})(),weights:weight?[weight]:[],styles:style?[style]:[],variable}}function getCSSMeta(options){let className=getClassName(options),style=getStylesObj(options),variableClassName=`__variable_${className}`,classNamesCSS=`
10
+ .${className} {
11
+ font-family: ${options.fontFamily};
12
+ ${isNextCSSPropertyValid(options.styles)?`font-style: ${options.styles[0]};`:""}
13
+ ${isNextCSSPropertyValid(options.weights)?`font-weight: ${options.weights[0]};`:""}
14
+ }
15
+
16
+ ${options.variable?`.${variableClassName} { ${options.variable}: '${options.fontFamily}'; }`:""}
17
+ `,fontFaceCSS=`${changeFontDisplayToSwap(options.fontFaceCSS)}`;return{className,fontFaceCSS,classNamesCSS,style,...options.variable?{variableClassName}:{}}}function getClassName({styles,weights,fontFamily}){let font=fontFamily.replace(" ","-").toLowerCase(),style=isNextCSSPropertyValid(styles)?styles[0]:null,weight=isNextCSSPropertyValid(weights)?weights[0]:null;return`${font}${style?`-${style}`:""}${weight?`-${weight}`:""}`}function getStylesObj({styles,weights,fontFamily}){return{fontFamily,...isNextCSSPropertyValid(styles)?{fontStyle:styles[0]}:{},...isNextCSSPropertyValid(weights)?{fontWeight:weights[0]}:{}}}function isNextCSSPropertyValid(prop){return prop.length===1&&prop[0]!=="variable"}function changeFontDisplayToSwap(css){return css.replaceAll("font-display: optional;","font-display: block;")}function setFontDeclarationsInHead({id,fontFaceCSS,classNamesCSS}){return`
18
+ if (!document.getElementById('id-${id}')) {
19
+ const fontDeclarations = \`${fontFaceCSS}\`;
20
+ const style = document.createElement('style');
21
+ style.setAttribute('id', 'font-face-${id}');
22
+ style.innerHTML = fontDeclarations;
23
+ document.head.appendChild(style);
24
+
25
+ const classNamesCSS = \`${classNamesCSS}\`;
26
+ const classNamesStyle = document.createElement('style');
27
+ classNamesStyle.setAttribute('id', 'classnames-${id}');
28
+ classNamesStyle.innerHTML = classNamesCSS;
29
+ document.head.appendChild(classNamesStyle);
30
+
31
+ }
32
+ `}async function storybookNextjsFontLoader(){let options=this.getOptions(),rootCtx=this.rootContext,fontFaceDeclaration;if((options.source==="next/font/google"||options.source==="@next/font/google")&&(fontFaceDeclaration=await getFontFaceDeclarations(options)),(options.source==="next/font/local"||options.source==="@next/font/local")&&(fontFaceDeclaration=await getFontFaceDeclarations2(options,rootCtx)),typeof fontFaceDeclaration<"u"){let cssMeta=getCSSMeta(fontFaceDeclaration);return`
33
+ ${setFontDeclarationsInHead({fontFaceCSS:cssMeta.fontFaceCSS,id:fontFaceDeclaration.id,classNamesCSS:cssMeta.classNamesCSS})}
34
+
35
+ module.exports = {
36
+ className: "${cssMeta.className}",
37
+ style: ${JSON.stringify(cssMeta.style)}
38
+ ${cssMeta.variableClassName?`, variable: "${cssMeta.variableClassName}"`:""}
39
+ }
40
+ `}return"module.exports = {}"}0&&(module.exports={});
@@ -0,0 +1,40 @@
1
+ import{__esm,__export,__require,__toCommonJS}from"../../../chunk-YPQDI6HO.mjs";var google_font_utils_exports={};__export(google_font_utils_exports,{fetchCSSFromGoogleFonts:()=>fetchCSSFromGoogleFonts,getFontAxes:()=>getFontAxes,getUrl:()=>getUrl,validateData:()=>validateData});var validateData,getUrl,getFontAxes,fetchCSSFromGoogleFonts,init_google_font_utils=__esm({"src/font/webpack/loader/utils/google-font-utils.ts"(){"use strict";try{let fontUtils=__require("@next/font/dist/google/utils");validateData=fontUtils.validateData,getUrl=fontUtils.getUrl,getFontAxes=fontUtils.getFontAxes,fetchCSSFromGoogleFonts=fontUtils.fetchCSSFromGoogleFonts}catch{let fontUtils=__require("next/dist/compiled/@next/font/dist/google/utils");validateData=fontUtils.validateData,getUrl=fontUtils.getUrl,getFontAxes=fontUtils.getFontAxes,fetchCSSFromGoogleFonts=fontUtils.fetchCSSFromGoogleFonts}}});var local_font_utils_exports={};__export(local_font_utils_exports,{validateData:()=>validateData2});var validateData2,init_local_font_utils=__esm({"src/font/webpack/loader/utils/local-font-utils.ts"(){"use strict";try{validateData2=__require("@next/font/dist/local/utils").validateData}catch{validateData2=__require("next/dist/compiled/@next/font/dist/local/utils").validateData}}});import loaderUtils from"next/dist/compiled/loader-utils3";var cssCache=new Map;async function getFontFaceDeclarations(options){let{fetchCSSFromGoogleFonts:fetchCSSFromGoogleFonts2,getFontAxes:getFontAxes2,getUrl:getUrl2,validateData:validateData3}=(init_google_font_utils(),__toCommonJS(google_font_utils_exports)),{fontFamily,weights,styles,selectedVariableAxes,display,variable}=validateData3(options.fontFamily,[options.props],null),fontAxes=getFontAxes2(fontFamily,weights,styles,selectedVariableAxes),url=getUrl2(fontFamily,fontAxes,display);try{let hasCachedCSS=cssCache.has(url),fontFaceCSS=hasCachedCSS?cssCache.get(url):await fetchCSSFromGoogleFonts2(url,fontFamily).catch(()=>null);if(hasCachedCSS?cssCache.delete(url):cssCache.set(url,fontFaceCSS),fontFaceCSS===null)throw Error(`Failed to fetch \`${fontFamily}\` from Google Fonts.`);return{id:loaderUtils.getHashDigest(url,"md5","hex",6),fontFamily,fontFaceCSS,weights,styles,variable}}catch{throw new Error("Google Fonts couldn't be loaded.")}}import loaderUtils2 from"next/dist/compiled/loader-utils3";import path from"path";async function getFontFaceDeclarations2(options,rootContext){let localFontSrc=options.props.src,parentFolder=options.filename.split("/").slice(0,-1).join("/").replace(rootContext,""),{validateData:validateData3}=(init_local_font_utils(),__toCommonJS(local_font_utils_exports)),{weight,style,variable}=validateData3("",options.props),id=`font-${loaderUtils2.getHashDigest(Buffer.from(JSON.stringify(localFontSrc)),"md5","hex",6)}`;return{id,fontFamily:id,fontFaceCSS:(()=>{if(typeof localFontSrc=="string"){let localFontPath=path.join(parentFolder,localFontSrc);return`@font-face {
2
+ font-family: ${id};
3
+ src: url(${localFontPath});
4
+ }`}return localFontSrc.map(font=>{let localFontPath=path.join(parentFolder,font.path);return`@font-face {
5
+ font-family: ${id};
6
+ src: url(${localFontPath});
7
+ ${font.weight?`font-weight: ${font.weight};`:""}
8
+ ${font.style?`font-style: ${font.style};`:""}
9
+ }`}).join("")})(),weights:weight?[weight]:[],styles:style?[style]:[],variable}}function getCSSMeta(options){let className=getClassName(options),style=getStylesObj(options),variableClassName=`__variable_${className}`,classNamesCSS=`
10
+ .${className} {
11
+ font-family: ${options.fontFamily};
12
+ ${isNextCSSPropertyValid(options.styles)?`font-style: ${options.styles[0]};`:""}
13
+ ${isNextCSSPropertyValid(options.weights)?`font-weight: ${options.weights[0]};`:""}
14
+ }
15
+
16
+ ${options.variable?`.${variableClassName} { ${options.variable}: '${options.fontFamily}'; }`:""}
17
+ `,fontFaceCSS=`${changeFontDisplayToSwap(options.fontFaceCSS)}`;return{className,fontFaceCSS,classNamesCSS,style,...options.variable?{variableClassName}:{}}}function getClassName({styles,weights,fontFamily}){let font=fontFamily.replace(" ","-").toLowerCase(),style=isNextCSSPropertyValid(styles)?styles[0]:null,weight=isNextCSSPropertyValid(weights)?weights[0]:null;return`${font}${style?`-${style}`:""}${weight?`-${weight}`:""}`}function getStylesObj({styles,weights,fontFamily}){return{fontFamily,...isNextCSSPropertyValid(styles)?{fontStyle:styles[0]}:{},...isNextCSSPropertyValid(weights)?{fontWeight:weights[0]}:{}}}function isNextCSSPropertyValid(prop){return prop.length===1&&prop[0]!=="variable"}function changeFontDisplayToSwap(css){return css.replaceAll("font-display: optional;","font-display: block;")}function setFontDeclarationsInHead({id,fontFaceCSS,classNamesCSS}){return`
18
+ if (!document.getElementById('id-${id}')) {
19
+ const fontDeclarations = \`${fontFaceCSS}\`;
20
+ const style = document.createElement('style');
21
+ style.setAttribute('id', 'font-face-${id}');
22
+ style.innerHTML = fontDeclarations;
23
+ document.head.appendChild(style);
24
+
25
+ const classNamesCSS = \`${classNamesCSS}\`;
26
+ const classNamesStyle = document.createElement('style');
27
+ classNamesStyle.setAttribute('id', 'classnames-${id}');
28
+ classNamesStyle.innerHTML = classNamesCSS;
29
+ document.head.appendChild(classNamesStyle);
30
+
31
+ }
32
+ `}async function storybookNextjsFontLoader(){let options=this.getOptions(),rootCtx=this.rootContext,fontFaceDeclaration;if((options.source==="next/font/google"||options.source==="@next/font/google")&&(fontFaceDeclaration=await getFontFaceDeclarations(options)),(options.source==="next/font/local"||options.source==="@next/font/local")&&(fontFaceDeclaration=await getFontFaceDeclarations2(options,rootCtx)),typeof fontFaceDeclaration<"u"){let cssMeta=getCSSMeta(fontFaceDeclaration);return`
33
+ ${setFontDeclarationsInHead({fontFaceCSS:cssMeta.fontFaceCSS,id:fontFaceDeclaration.id,classNamesCSS:cssMeta.classNamesCSS})}
34
+
35
+ module.exports = {
36
+ className: "${cssMeta.className}",
37
+ style: ${JSON.stringify(cssMeta.style)}
38
+ ${cssMeta.variableClassName?`, variable: "${cssMeta.variableClassName}"`:""}
39
+ }
40
+ `}return"module.exports = {}"}export{storybookNextjsFontLoader as default};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,o,p,f)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of x(o))!a.call(r,e)&&e!==p&&m(r,e,{get:()=>o[e],enumerable:!(f=t(o,e))||f.enumerable});return r};var c=r=>b(m({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
1
+ "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __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 src_exports={};module.exports=__toCommonJS(src_exports);
@@ -1 +1 @@
1
- "use strict";var m=Object.create;var a=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var l=(t,e)=>{for(var i in e)a(t,i,{get:e[i],enumerable:!0})},n=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of h(e))!d.call(t,o)&&o!==i&&a(t,o,{get:()=>e[o],enumerable:!(r=c(e,o))||r.enumerable});return t};var x=(t,e,i)=>(i=t!=null?m(u(t)):{},n(e||!t||!t.__esModule?a(i,"default",{value:t,enumerable:!0}):i,t)),g=t=>n(a({},"__esModule",{value:!0}),t);var w={};l(w,{default:()=>L});module.exports=g(w);var s=require("loader-utils"),f=x(require("image-size")),p=function(t){let{filename:e}=this.getOptions(),i=(0,s.interpolateName)(this,e.replace("[ext]",".[ext]"),{context:this.rootContext,content:t});this.emitFile(i,t);let{width:r,height:o}=(0,f.default)(this.resourcePath);return`export default ${JSON.stringify({src:i,height:o,width:r,blurDataURL:i})};`};p.raw=!0;var L=p;0&&(module.exports={});
1
+ "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __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 __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod));var import_loader_utils=require("loader-utils"),import_image_size=__toESM(require("image-size")),nextImageLoaderStub=function(content){let{filename}=this.getOptions(),outputPath=(0,import_loader_utils.interpolateName)(this,filename.replace("[ext]",".[ext]"),{context:this.rootContext,content});this.emitFile(outputPath,content);let{width,height}=(0,import_image_size.default)(this.resourcePath);return`export default ${JSON.stringify({src:outputPath,height,width,blurDataURL:outputPath})};`};nextImageLoaderStub.raw=!0;module.exports=nextImageLoaderStub;
@@ -1 +1 @@
1
- import"./chunk-4MG4OZFL.mjs";import{interpolateName}from"loader-utils";import imageSizeOf from"image-size";var nextImageLoaderStub=function(content){let{filename}=this.getOptions(),outputPath=interpolateName(this,filename.replace("[ext]",".[ext]"),{context:this.rootContext,content});this.emitFile(outputPath,content);let{width,height}=imageSizeOf(this.resourcePath);return`export default ${JSON.stringify({src:outputPath,height,width,blurDataURL:outputPath})};`};nextImageLoaderStub.raw=!0;var next_image_loader_stub_default=nextImageLoaderStub;export{next_image_loader_stub_default as default};
1
+ import{__commonJS}from"./chunk-YPQDI6HO.mjs";import{interpolateName}from"loader-utils";import imageSizeOf from"image-size";var require_next_image_loader_stub=__commonJS({"src/next-image-loader-stub.ts"(exports,module){var nextImageLoaderStub=function(content){let{filename}=this.getOptions(),outputPath=interpolateName(this,filename.replace("[ext]",".[ext]"),{context:this.rootContext,content});this.emitFile(outputPath,content);let{width,height}=imageSizeOf(this.resourcePath);return`export default ${JSON.stringify({src:outputPath,height,width,blurDataURL:outputPath})};`};nextImageLoaderStub.raw=!0;module.exports=nextImageLoaderStub}});export default require_next_image_loader_stub();
package/dist/preset.d.ts CHANGED
@@ -720,7 +720,7 @@ PackageJson$1.NonStandardEntryPoints &
720
720
  PackageJson$1.TypeScriptConfiguration &
721
721
  PackageJson$1.YarnConfiguration &
722
722
  PackageJson$1.JSPMConfiguration;
723
- declare type Tag = string;
723
+ type Tag = string;
724
724
  interface Parameters {
725
725
  [name: string]: any;
726
726
  }
@@ -876,20 +876,18 @@ interface CLIOptions {
876
876
  quiet?: boolean;
877
877
  versionUpdates?: boolean;
878
878
  releaseNotes?: boolean;
879
- dll?: boolean;
880
879
  docs?: boolean;
881
- docsDll?: boolean;
882
- uiDll?: boolean;
883
880
  debugWebpack?: boolean;
884
881
  webpackStatsJson?: string | boolean;
885
882
  outputDir?: string;
886
883
  }
887
884
  interface BuilderOptions {
888
885
  configType?: 'DEVELOPMENT' | 'PRODUCTION';
889
- ignorePreview: boolean;
890
- cache: FileSystemCache;
886
+ ignorePreview?: boolean;
887
+ cache?: FileSystemCache;
891
888
  configDir: string;
892
- docsMode: boolean;
889
+ docsMode?: boolean;
890
+ env?: (envs: Record<string, string>) => Record<string, string>;
893
891
  features?: StorybookConfig['features'];
894
892
  versionCheck?: VersionCheck;
895
893
  releaseNotesData?: ReleaseNotesData;
@@ -934,19 +932,16 @@ type CoreCommon_StorybookRefs = Record<string, {
934
932
  disable: boolean;
935
933
  }>;
936
934
  type DocsOptions = {
937
- /**
938
- * Should we generate docs entries at all under any circumstances? (i.e. can they be rendered)
939
- */
940
- enabled?: boolean;
941
935
  /**
942
936
  * What should we call the generated docs entries?
943
937
  */
944
938
  defaultName?: string;
945
939
  /**
946
- * Should we generate a docs entry per CSF file with the `docsPage` tag?
947
- * Set to 'automatic' to generate an entry irrespective of tag.
940
+ * Should we generate a docs entry per CSF file?
941
+ * Set to 'tag' (the default) to generate an entry for every CSF file with the
942
+ * 'autodocs' tag.
948
943
  */
949
- docsPage?: boolean | 'automatic';
944
+ autodocs?: boolean | 'tag';
950
945
  /**
951
946
  * Only show doc entries in the side bar (usually set with the `--docs` CLI flag)
952
947
  */
@@ -986,13 +981,14 @@ interface StorybookConfig {
986
981
  */
987
982
  storyStoreV7?: boolean;
988
983
  /**
989
- * Enable a set of planned breaking changes for SB7.0
984
+ * Do not throw errors if using `.mdx` files in SSv7
985
+ * (for internal use in sandboxes)
990
986
  */
991
- breakingChangesV7?: boolean;
987
+ storyStoreV7MdxErrors?: boolean;
992
988
  /**
993
- * Enable the step debugger functionality in Addon-interactions.
989
+ * Enable a set of planned breaking changes for SB7.0
994
990
  */
995
- interactionsDebugger?: boolean;
991
+ breakingChangesV7?: boolean;
996
992
  /**
997
993
  * Filter args with a "target" on the type from the render function (EXPERIMENTAL)
998
994
  */
@@ -1002,6 +998,14 @@ interface StorybookConfig {
1002
998
  * Will be removed in 7.0.
1003
999
  */
1004
1000
  warnOnLegacyHierarchySeparator?: boolean;
1001
+ /**
1002
+ * Use legacy MDX1, to help smooth migration to 7.0
1003
+ */
1004
+ legacyMdx1?: boolean;
1005
+ /**
1006
+ * Apply decorators from preview.js before decorators from addons or frameworks
1007
+ */
1008
+ legacyDecoratorFileOrder?: boolean;
1005
1009
  };
1006
1010
  /**
1007
1011
  * Tells Storybook where to find stories.
@@ -1010,7 +1014,7 @@ interface StorybookConfig {
1010
1014
  */
1011
1015
  stories: StoriesEntry[];
1012
1016
  /**
1013
- * Framework, e.g. '@storybook/react', required in v7
1017
+ * Framework, e.g. '@storybook/react-vite', required in v7
1014
1018
  */
1015
1019
  framework?: Preset;
1016
1020
  /**
package/dist/preset.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Y=Object.create;var x=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var re=(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 ee(t))!te.call(e,s)&&s!==o&&x(e,s,{get:()=>t[s],enumerable:!(r=Z(t,s))||r.enumerable});return e};var p=(e,t,o)=>(o=e!=null?Y(oe(e)):{},h(t||!e||!e.__esModule?x(o,"default",{value:e,enumerable:!0}):o,e)),se=e=>h(x({},"__esModule",{value:!0}),e);var xe={};re(xe,{addons:()=>ce,babel:()=>ue,config:()=>ge,core:()=>le,frameworkOptions:()=>me,webpackFinal:()=>de});module.exports=se(xe);var c=require("path"),z=require("@babel/core"),Q=require("@storybook/core-common");var b=p(require("semver")),W=require("webpack");var k=p(require("path")),R=require("webpack"),j=require("next/constants"),P=p(require("find-up")),S=require("fs-extra"),I=require("url"),E=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,ie=async e=>["mjs","js"].reduce(async(o,r)=>(await o||(o=(0,P.default)(`next.config.${r}`,{cwd:e})),o),Promise.resolve(void 0)),O=async({baseConfig:e={},nextConfigPath:t,configDir:o})=>{let r=t||await ie(o);if(!r||await(0,S.pathExists)(r)===!1)return{};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},n=(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 V=async({baseConfig:e,nextConfigPath:t,configDir:o})=>{let r=await O({baseConfig:e,nextConfigPath:t,configDir:o});return n(e,"next/config"),ne(e,r),r},_=f(),ne=(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(_,"13.0.0")&&b.default.lt(_,"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 W.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"),T=p(require("semver"));var $=(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,...A(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,...A(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)}}]})},A=e=>pe()?{url:{filter:F(e)},import:{filter:L(e)}}:{url:F(e),import:L(e)},F=e=>(t,o)=>{var r;return(0,w.cssFileResolve)(t,o,(r=e.experimental)==null?void 0:r.urlImports)},L=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)},pe=()=>{try{let e=require(y("css-loader/package.json")).version;return T.default.gte(e,"6.0.0")}catch{return!1}};var q=p(require("tsconfig-paths-webpack-plugin")),D=require("tsconfig-paths"),B=e=>{let t=(0,D.loadConfig)();t.resultType==="failed"||!t.baseUrl||(e.resolve??={},e.resolve.plugins??=[],e.resolve.plugins.push(new q.default({configFile:t.configFileAbsolutePath,extensions:[".js",".jsx",".ts",".tsx"]})))};var M=p(require("semver"));var U=e=>{let t=ae();n(e,t)},ae=()=>{let e=f();return M.default.gte(e,"11.1.0")?"next/dist/shared/lib/router-context":"next/dist/next-server/lib/router-context"};var J=p(require("semver"));var X=e=>{let t=f();J.default.gte(t,"12.0.0")?n(e,"styled-jsx"):(n(e,"styled-jsx/babel"),n(e,"styled-jsx/css"),n(e,"styled-jsx/macro"),n(e,"styled-jsx/server"),n(e,"styled-jsx/style"),n(e,"styled-jsx/webpack"))};var H=p(require("semver"));var K=e=>{fe(e),n(e,"next/image")},fe=e=>{var s,i,m;let t=f();if(H.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=p(require("semver")),d=require("webpack");function G(e){let t=f(),o=u.default.satisfies(t,"~12"),r=u.default.satisfies(t,"~13"),s=u.default.lt(t,"12.2.0"),i=u.default.lt(t,"13.0.0");e.plugins=e.plugins??[],r||e.plugins.push(new d.IgnorePlugin({resourceRegExp:/next\/legacy\/image$/})),(!o||s)&&e.plugins.push(new d.IgnorePlugin({resourceRegExp:/next\/future\/image$/})),i&&e.plugins.push(new d.IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/hooks-client-context$/})),s&&e.plugins.push(new d.IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/app-router-context$/}))}var ce=[(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={},me=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}}},le=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")))}},ge=(e=[])=>[...e,require.resolve("@storybook/nextjs/preview.js")],ue=async e=>{var m,l,N;let t=(0,z.loadPartialConfig)({...e,filename:`${(0,Q.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}},de=async(e,t)=>{let o=await t.presets.apply("frameworkOptions"),{options:{nextConfigPath:r}={}}=o,s=await V({baseConfig:e,nextConfigPath:r,configDir:t.configDir});return G(e),E(e),B(e),$(e,s),K(e),U(e),X(e),e};0&&(module.exports={addons,babel,config,core,frameworkOptions,webpackFinal});
1
+ "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __esm=(fn,res)=>function(){return fn&&(res=(0,fn[__getOwnPropNames(fn)[0]])(fn=0)),res};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 __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var jsx_pragma_exports={};__export(jsx_pragma_exports,{default:()=>jsxPragma});function jsxPragma({types:t}){return{inherits:import_plugin_syntax_jsx.default,visitor:{JSXElement(_path,state){state.set("jsx",!0)},JSXFragment(_path,state){state.set("jsx",!0)},Program:{exit(path2,state){if(state.get("jsx")){let pragma=t.identifier(state.opts.pragma),importAs=pragma,existingBinding=state.opts.reuseImport!==!1&&state.opts.importAs&&path2.scope.getBinding(state.opts.importAs);if(state.opts.property){state.opts.importAs?importAs=t.identifier(state.opts.importAs):importAs=path2.scope.generateUidIdentifier("pragma");let mapping=t.variableDeclaration("var",[t.variableDeclarator(pragma,t.memberExpression(importAs,t.identifier(state.opts.property)))]),newPath;existingBinding&&t.isVariableDeclarator(existingBinding.path.node)&&t.isCallExpression(existingBinding.path.node.init)&&t.isIdentifier(existingBinding.path.node.init.callee)&&existingBinding.path.node.init.callee.name==="require"?[newPath]=existingBinding.path.parentPath.insertAfter(mapping):[newPath]=path2.unshiftContainer("body",mapping);for(let declar of newPath.get("declarations"))path2.scope.registerBinding(newPath.node.kind,declar)}if(!existingBinding){let importSpecifier=t.importDeclaration([state.opts.import?t.importSpecifier(importAs,t.identifier(state.opts.import)):state.opts.importNamespace?t.importNamespaceSpecifier(importAs):t.importDefaultSpecifier(importAs)],t.stringLiteral(state.opts.module||"react")),[newPath]=path2.unshiftContainer("body",importSpecifier);for(let specifier of newPath.get("specifiers"))path2.scope.registerBinding("module",specifier)}}}}}}}var import_plugin_syntax_jsx,init_jsx_pragma=__esm({"src/babel/plugins/jsx-pragma.ts"(){"use strict";import_plugin_syntax_jsx=__toESM(require("next/dist/compiled/babel/plugin-syntax-jsx"))}});var optimize_hook_destructuring_exports={};__export(optimize_hook_destructuring_exports,{default:()=>optimizeHookDestructuring});function optimizeHookDestructuring({types:t}){let visitor={CallExpression(path2,state){let{onlyBuiltIns}=state.opts,libs=state.opts.lib&&(state.opts.lib===!0?["react","preact/hooks"]:[].concat(state.opts.lib));if(!t.isVariableDeclarator(path2.parent)||!t.isArrayPattern(path2.parent.id))return;let hookName=path2.node.callee.name;if(libs){let binding=path2.scope.getBinding(hookName);if(!binding||binding.kind!=="module")return;let specifier=binding.path.parent.source.value;if(!libs.some(lib=>lib===specifier))return}(onlyBuiltIns?isBuiltInHook:isHook).test(hookName)&&(path2.parent.id=t.objectPattern(path2.parent.id.elements.reduce((patterns,element,i)=>element===null?patterns:patterns.concat(t.objectProperty(t.numericLiteral(i),element)),[])))}};return{name:"optimize-hook-destructuring",visitor:{Program(path2,state){path2.traverse(visitor,state)}}}}var isHook,isBuiltInHook,init_optimize_hook_destructuring=__esm({"src/babel/plugins/optimize-hook-destructuring.ts"(){"use strict";isHook=/^use[A-Z]/,isBuiltInHook=/^use(Callback|Context|DebugValue|Effect|ImperativeHandle|LayoutEffect|Memo|Reducer|Ref|State)$/}});var react_loadable_plugin_exports={};__export(react_loadable_plugin_exports,{default:()=>react_loadable_plugin_default});function react_loadable_plugin_default({types:t}){return{visitor:{ImportDeclaration(path2,state){if(path2.node.source.value!=="next/dynamic")return;let defaultSpecifier=path2.get("specifiers").find(specifier=>specifier.isImportDefaultSpecifier());if(!defaultSpecifier)return;let bindingName=defaultSpecifier.node.local.name,binding=path2.scope.getBinding(bindingName);binding&&binding.referencePaths.forEach(refPath=>{var _a,_b,_c;let callExpression=refPath.parentPath;if(callExpression.isMemberExpression()&&callExpression.node.computed===!1){let property=callExpression.get("property");!Array.isArray(property)&&property.isIdentifier({name:"Map"})&&(callExpression=callExpression.parentPath)}if(!callExpression.isCallExpression())return;let callExpression_=callExpression,args=callExpression_.get("arguments");if(args.length>2)throw callExpression_.buildCodeFrameError("next/dynamic only accepts 2 arguments");if(!args[0])return;let loader,options;if(args[0].isObjectExpression()?options=args[0]:(args[1]||callExpression_.node.arguments.push(t.objectExpression([])),args=callExpression_.get("arguments"),loader=args[0],options=args[1]),!options.isObjectExpression())return;let properties=options.get("properties"),propertiesMap={};if(properties.forEach(property=>{let key=property.get("key");propertiesMap[key.node.name]=property}),propertiesMap.loadableGenerated||(propertiesMap.loader&&(loader=propertiesMap.loader.get("value")),propertiesMap.modules&&(loader=propertiesMap.modules.get("value")),!loader||Array.isArray(loader)))return;let dynamicImports=[],dynamicKeys=[];if(propertiesMap.ssr){let ssr=propertiesMap.ssr.get("value"),nodePath=Array.isArray(ssr)?void 0:ssr;nodePath&&nodePath.node.type==="BooleanLiteral"&&nodePath.node.value===!1&&loader&&(_a=state.file.opts.caller)!=null&&_a.isServer&&loader.replaceWith(t.arrowFunctionExpression([],t.nullLiteral(),!0))}if(loader.traverse({Import(importPath){var _a2;let importArguments=importPath.parentPath.get("arguments");if(!Array.isArray(importArguments))return;let{node}=importArguments[0];dynamicImports.push(node),dynamicKeys.push(t.binaryExpression("+",t.stringLiteral(`${(_a2=state.file.opts.caller)!=null&&_a2.pagesDir?(0,import_path2.relative)(state.file.opts.caller.pagesDir,state.file.opts.filename):state.file.opts.filename} -> `),node))}}),!!dynamicImports.length&&(options.node.properties.push(t.objectProperty(t.identifier("loadableGenerated"),t.objectExpression((_b=state.file.opts.caller)!=null&&_b.isDev||(_c=state.file.opts.caller)!=null&&_c.isServer?[t.objectProperty(t.identifier("modules"),t.arrayExpression(dynamicKeys))]:[t.objectProperty(t.identifier("webpack"),t.arrowFunctionExpression([],t.arrayExpression(dynamicImports.map(dynamicImport=>t.callExpression(t.memberExpression(t.identifier("require"),t.identifier("resolveWeak")),[dynamicImport])))))]))),loader.isCallExpression())){let arrowFunction=t.arrowFunctionExpression([],loader.node);loader.replaceWith(arrowFunction)}})}}}}var import_path2,init_react_loadable_plugin=__esm({"src/babel/plugins/react-loadable-plugin.ts"(){"use strict";import_path2=require("path")}});var amp_attributes_exports={};__export(amp_attributes_exports,{default:()=>AmpAttributePatcher});function AmpAttributePatcher(){return{visitor:{JSXOpeningElement(path2){let openingElement=path2.node,{name,attributes}=openingElement;if(name&&name.type==="JSXIdentifier"&&name.name.startsWith("amp-"))for(let attribute of attributes)attribute.type==="JSXAttribute"&&attribute.name.name==="className"&&(attribute.name.name="class")}}}}var init_amp_attributes=__esm({"src/babel/plugins/amp-attributes.ts"(){"use strict"}});var preset_exports={};__export(preset_exports,{addons:()=>addons,babel:()=>babel,config:()=>config,core:()=>core,frameworkOptions:()=>frameworkOptions,webpackFinal:()=>webpackFinal});module.exports=__toCommonJS(preset_exports);var import_path4=require("path"),import_core=require("@babel/core"),import_core_common=require("@storybook/core-common");var import_semver=__toESM(require("semver")),import_webpack2=require("webpack");var import_path=__toESM(require("path")),import_webpack=require("webpack"),import_constants=require("next/constants"),import_find_up=__toESM(require("find-up")),import_fs_extra=require("fs-extra"),import_node_url=require("url"),configureRuntimeNextjsVersionResolution=baseConfig=>{var _a;(_a=baseConfig.plugins)==null||_a.push(new import_webpack.DefinePlugin({"process.env.__NEXT_VERSION":JSON.stringify(getNextjsVersion())}))},getNextjsVersion=()=>require(scopedResolve("next/package.json")).version,findNextConfigFile=async configDir=>["mjs","js"].reduce(async(acc,ext)=>(await acc||(acc=(0,import_find_up.default)(`next.config.${ext}`,{cwd:configDir})),acc),Promise.resolve(void 0)),resolveNextConfig=async({baseConfig={},nextConfigPath,configDir})=>{let nextConfigFile=nextConfigPath||await findNextConfigFile(configDir);if(!nextConfigFile||await(0,import_fs_extra.pathExists)(nextConfigFile)===!1)return{};let nextConfigExport=await import((0,import_node_url.pathToFileURL)(nextConfigFile).href),nextConfig=typeof nextConfigExport=="function"?nextConfigExport(import_constants.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:[import_path.default.resolve()]}),beginningOfMainScriptPath=scopedModulePath.lastIndexOf(id.replace(/\//g,import_path.default.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)=>{var _a,_b;let definePluginConfig={"process.env.__NEXT_RUNTIME_CONFIG":JSON.stringify({serverRuntimeConfig:{},publicRuntimeConfig:nextConfig.publicRuntimeConfig})},newNextLinkBehavior=(_a=nextConfig.experimental)==null?void 0:_a.newNextLinkBehavior;import_semver.default.gte(version,"13.0.0")&&import_semver.default.lt(version,"13.0.6")&&newNextLinkBehavior!==!1?definePluginConfig["process.env.__NEXT_NEW_LINK_BEHAVIOR"]=!0:definePluginConfig["process.env.__NEXT_NEW_LINK_BEHAVIOR"]=newNextLinkBehavior,(_b=baseConfig.plugins)==null||_b.push(new import_webpack2.DefinePlugin(definePluginConfig))};var import_getCssModuleLocalIdent=require("next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent"),import_file_resolve=require("next/dist/build/webpack/config/blocks/css/loaders/file-resolve"),import_semver2=__toESM(require("semver"));var configureCss=(baseConfig,nextConfig)=>{var _a,_b,_c;let rules=(_a=baseConfig.module)==null?void 0:_a.rules;rules==null||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:import_getCssModuleLocalIdent.getCssModuleLocalIdent}}},"postcss-loader"]})}),rules==null||rules.push({test:/\.(scss|sass)$/,use:["style-loader",{loader:"css-loader",options:{importLoaders:3,...getImportAndUrlCssLoaderOptions(nextConfig),modules:{auto:!0,getLocalIdent:import_getCssModuleLocalIdent.getCssModuleLocalIdent}}},"postcss-loader","resolve-url-loader",{loader:"sass-loader",options:{sourceMap:!0,sassOptions:nextConfig.sassOptions,additionalData:((_b=nextConfig.sassOptions)==null?void 0:_b.prependData)||((_c=nextConfig.sassOptions)==null?void 0:_c.additionalData)}}]})},getImportAndUrlCssLoaderOptions=nextConfig=>isCssLoaderV6()?{url:{filter:getUrlResolver(nextConfig)},import:{filter:getImportResolver(nextConfig)}}:{url:getUrlResolver(nextConfig),import:getImportResolver(nextConfig)},getUrlResolver=nextConfig=>(url,resourcePath)=>{var _a;return(0,import_file_resolve.cssFileResolve)(url,resourcePath,(_a=nextConfig.experimental)==null?void 0:_a.urlImports)},getImportResolver=nextConfig=>(url,_,resourcePath)=>{var _a;return(0,import_file_resolve.cssFileResolve)(typeof url=="string"?url:url.url,resourcePath,(_a=nextConfig.experimental)==null?void 0:_a.urlImports)},isCssLoaderV6=()=>{try{let cssLoaderVersion=require(scopedResolve("css-loader/package.json")).version;return import_semver2.default.gte(cssLoaderVersion,"6.0.0")}catch{return!1}};var import_tsconfig_paths_webpack_plugin=__toESM(require("tsconfig-paths-webpack-plugin")),import_tsconfig_paths=require("tsconfig-paths"),configureImports=baseConfig=>{let configLoadResult=(0,import_tsconfig_paths.loadConfig)();configLoadResult.resultType==="failed"||!configLoadResult.baseUrl||(baseConfig.resolve??={},baseConfig.resolve.plugins??=[],baseConfig.resolve.plugins.push(new import_tsconfig_paths_webpack_plugin.default({configFile:configLoadResult.configFileAbsolutePath,extensions:[".js",".jsx",".ts",".tsx"]})))};var import_semver3=__toESM(require("semver"));var configureRouting=baseConfig=>{let routerContextPath=getRouterContextPath();addScopedAlias(baseConfig,routerContextPath)},getRouterContextPath=()=>{let version2=getNextjsVersion();return import_semver3.default.gte(version2,"11.1.0")?"next/dist/shared/lib/router-context":"next/dist/next-server/lib/router-context"};var import_semver4=__toESM(require("semver"));var configureStyledJsx=baseConfig=>{let version2=getNextjsVersion();import_semver4.default.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"))};var import_semver5=__toESM(require("semver"));var configureImages=baseConfig=>{configureStaticImageImport(baseConfig),addScopedAlias(baseConfig,"next/image")},configureStaticImageImport=baseConfig=>{var _a,_b,_c;let version2=getNextjsVersion();if(import_semver5.default.lt(version2,"11.0.0"))return;let rules=(_a=baseConfig.module)==null?void 0:_a.rules,assetRule=rules==null?void 0: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==null||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:(_b=assetRule.generator)==null?void 0:_b.filename}}]}),rules==null||rules.push({test:/\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,issuer:/\.(css|scss|sass)$/,type:"asset/resource",generator:{filename:(_c=assetRule.generator)==null?void 0:_c.filename}}))};var import_semver6=__toESM(require("semver")),import_webpack3=require("webpack");function configureNextImport(baseConfig){let nextJSVersion=getNextjsVersion(),isNext12=import_semver6.default.satisfies(nextJSVersion,"~12"),isNext13=import_semver6.default.satisfies(nextJSVersion,"~13"),isNextVersionSmallerThan12dot2=import_semver6.default.lt(nextJSVersion,"12.2.0"),isNextVersionSmallerThan13=import_semver6.default.lt(nextJSVersion,"13.0.0");baseConfig.plugins=baseConfig.plugins??[],isNext13||baseConfig.plugins.push(new import_webpack3.IgnorePlugin({resourceRegExp:/next\/legacy\/image$/})),(!isNext12||isNextVersionSmallerThan12dot2)&&baseConfig.plugins.push(new import_webpack3.IgnorePlugin({resourceRegExp:/next\/future\/image$/})),isNextVersionSmallerThan13&&baseConfig.plugins.push(new import_webpack3.IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/hooks-client-context$/})),isNextVersionSmallerThan12dot2&&baseConfig.plugins.push(new import_webpack3.IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/app-router-context$/}))}function convertNodeToJSON(types,node){if(types.isBooleanLiteral(node)||types.isStringLiteral(node)||types.isNumericLiteral(node))return node.value;if(!(node.name==="undefined"&&!node.value))return types.isNullLiteral(node)?null:types.isObjectExpression(node)?computeProps(types,node.properties):types.isArrayExpression(node)?node.elements.reduce((acc,element)=>[...acc,...(element==null?void 0:element.type)==="SpreadElement"?convertNodeToJSON(types,element.argument):[convertNodeToJSON(types,element)]],[]):{}}function computeProps(types,props){return props.reduce((acc,prop)=>{if(prop.type==="SpreadElement")return{...acc,...convertNodeToJSON(types,prop.argument)};if(prop.type!=="ObjectMethod"){let val=convertNodeToJSON(types,prop.value);if(val!==void 0&&types.isIdentifier(prop.key))return{...acc,[prop.key.name]:val}}return acc},{})}function isDefined(value){return value!==void 0}function removeTransformedVariableDeclarations(path2,types,metas){path2.parentPath.traverse({ExportNamedDeclaration(declaratorPath){var _a;(_a=declaratorPath.parentPath)!=null&&_a.isProgram()&&metas.forEach(meta=>{types.isVariableDeclaration(declaratorPath.node.declaration)&&declaratorPath.node.declaration.declarations.length===1&&types.isVariableDeclarator(declaratorPath.node.declaration.declarations[0])&&types.isIdentifier(declaratorPath.node.declaration.declarations[0].id)&&meta.identifierName===declaratorPath.node.declaration.declarations[0].id.name&&declaratorPath.replaceWith(types.exportNamedDeclaration(null,[types.exportSpecifier(types.identifier(meta.identifierName),types.identifier(meta.identifierName))]))})},VariableDeclarator(declaratorPath){var _a;(_a=declaratorPath.parentPath.parentPath)!=null&&_a.isProgram()&&metas.some(meta=>types.isIdentifier(declaratorPath.node.id)&&meta.identifierName===declaratorPath.node.id.name)&&declaratorPath.remove()}})}function replaceImportWithParamterImport(path2,types,source,metas,filename){path2.replaceWithMultiple([...metas.map(meta=>types.importDeclaration([types.importDefaultSpecifier(types.identifier(meta.identifierName))],types.stringLiteral(`storybook-nextjs-font-loader?${JSON.stringify({source:source.value,props:meta.properties,fontFamily:meta.functionName,filename})}!${source.value}`)))])}function getVariableMetasBySpecifier(program,types,specifier){return program.node.body.map(statement=>{if(!types.isVariableDeclaration(statement)&&!types.isExportNamedDeclaration(statement))return;let exportedNamedDeclaration=!types.isVariableDeclaration(statement)&&types.isVariableDeclaration(statement.declaration)&&statement.declaration.declarations.length===1?statement.declaration.declarations[0]:null,declaration=types.isVariableDeclaration(statement)?statement.declarations[0]:exportedNamedDeclaration;if(!declaration||!types.isIdentifier(declaration.id)||!types.isCallExpression(declaration.init)||(!types.isIdentifier(declaration.init.callee)||specifier.type!=="ImportSpecifier"||specifier.imported.type!=="Identifier"||declaration.init.callee.name!==specifier.imported.name)&&(!types.isIdentifier(declaration.init.callee)||specifier.type!=="ImportDefaultSpecifier"||declaration.init.callee.name!==specifier.local.name))return;let options=declaration.init.arguments[0];if(!types.isObjectExpression(options))throw program.buildCodeFrameError("Please pass an options object to the call expression of next/font functions");options.properties.forEach(property=>{if(types.isSpreadElement(property))throw program.buildCodeFrameError("Please do not use spread elements in the options object in next/font function calls")});let identifierName=declaration.id.name,properties=convertNodeToJSON(types,options),functionName=declaration.init.callee.name;return{identifierName,properties,functionName}}).filter(isDefined)}function TransformFontImports({types}){return{name:"storybook-nextjs-font-imports",visitor:{ImportDeclaration(path2,state){let{node}=path2,{source}=node,{filename=""}=state;if(source.value==="next/font/local"||source.value==="@next/font/local"){let{specifiers}=node,specifier=specifiers[0];if(!path2.parentPath.isProgram())return;let program=path2.parentPath,variableMetas=getVariableMetasBySpecifier(program,types,specifier);removeTransformedVariableDeclarations(path2,types,variableMetas),replaceImportWithParamterImport(path2,types,source,variableMetas,filename)}if(source.value==="next/font/google"||source.value==="@next/font/google"){let{specifiers}=node,variableMetas=specifiers.flatMap(specifier=>{if(!path2.parentPath.isProgram())return[];let program=path2.parentPath;return getVariableMetasBySpecifier(program,types,specifier)}).filter(isDefined);removeTransformedVariableDeclarations(path2,types,variableMetas),replaceImportWithParamterImport(path2,types,source,variableMetas,filename)}}}}}function configureNextFont(baseConfig){var _a;baseConfig.plugins=[...baseConfig.plugins||[]],baseConfig.resolveLoader={...baseConfig.resolveLoader,alias:{...(_a=baseConfig.resolveLoader)==null?void 0:_a.alias,"storybook-nextjs-font-loader":require.resolve("./font/webpack/loader/storybook-nextjs-font-loader")}}}var import_path3=require("path"),isLoadIntentTest=process.env.NODE_ENV==="test",isLoadIntentDevelopment=process.env.NODE_ENV==="development";function styledJsxOptions(options){return options=options||{},options.styleModule="styled-jsx/style",Array.isArray(options.plugins)&&(options.plugins=options.plugins.map(plugin=>{if(Array.isArray(plugin)){let[name,pluginOptions]=plugin;return[require.resolve(name),pluginOptions]}return require.resolve(plugin)})),options}function supportsStaticESM(caller){return!!(caller!=null&&caller.supportsStaticESM)}var preset_default=(api,options={})=>{var _a,_b;let supportsESM=api.caller(supportsStaticESM),isServer=api.caller(caller=>!!caller&&caller.isServer),isCallerDevelopment=api.caller(caller=>caller==null?void 0:caller.isDev),isTest=isCallerDevelopment==null&&isLoadIntentTest,isDevelopment=isCallerDevelopment===!0||isCallerDevelopment==null&&isLoadIntentDevelopment,isBabelLoader=api.caller(caller=>!!caller&&(caller.name==="babel-loader"||caller.name==="next-babel-turbo-loader")),useJsxRuntime=((_a=options["preset-react"])==null?void 0:_a.runtime)==="automatic"||Boolean(api.caller(caller=>!!caller&&caller.hasJsxRuntime))&&((_b=options["preset-react"])==null?void 0:_b.runtime)!=="classic",presetEnvConfig={modules:"auto",exclude:["transform-typeof-symbol"],...options["preset-env"]};return(isServer||isTest)&&(!presetEnvConfig.targets||!(typeof presetEnvConfig.targets=="object"&&"node"in presetEnvConfig.targets))&&(presetEnvConfig.targets={node:process.versions.node}),{sourceType:"unambiguous",presets:[[require("@babel/preset-env"),presetEnvConfig],[require("@babel/preset-react"),{development:isDevelopment||isTest,...useJsxRuntime?{runtime:"automatic"}:{pragma:"__jsx"},...options["preset-react"]}],[require("@babel/preset-typescript"),{allowNamespaces:!0,...options["preset-typescript"]}]],plugins:[!useJsxRuntime&&[(init_jsx_pragma(),__toCommonJS(jsx_pragma_exports)),{module:"react",importAs:"React",pragma:"__jsx",property:"createElement"}],[(init_optimize_hook_destructuring(),__toCommonJS(optimize_hook_destructuring_exports)),{lib:!0}],require("@babel/plugin-syntax-dynamic-import"),require("@babel/plugin-syntax-import-assertions"),(init_react_loadable_plugin(),__toCommonJS(react_loadable_plugin_exports)),[require("@babel/plugin-proposal-class-properties"),options["class-properties"]||{}],[require("@babel/plugin-proposal-object-rest-spread"),{useBuiltIns:!0}],!isServer&&[require("@babel/plugin-transform-runtime"),{corejs:!1,helpers:!0,regenerator:!0,useESModules:supportsESM&&presetEnvConfig.modules!=="commonjs",absoluteRuntime:isBabelLoader?(0,import_path3.dirname)(require.resolve("@babel/runtime/package.json")):void 0,...options["transform-runtime"]}],[isTest&&options["styled-jsx"]&&options["styled-jsx"]["babel-test"]?require("styled-jsx/babel-test"):require("styled-jsx/babel"),styledJsxOptions(options["styled-jsx"])],(init_amp_attributes(),__toCommonJS(amp_attributes_exports)),isServer&&require("@babel/plugin-syntax-bigint"),require("@babel/plugin-proposal-numeric-separator"),require("@babel/plugin-proposal-export-namespace-from")].filter(Boolean)}};var addons=[(0,import_path4.dirname)(require.resolve((0,import_path4.join)("@storybook/preset-react-webpack","package.json"))),(0,import_path4.dirname)(require.resolve((0,import_path4.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:(0,import_path4.dirname)(require.resolve((0,import_path4.join)("@storybook/builder-webpack5","package.json"))),options:typeof framework=="string"?{}:framework.options.builder||{}},renderer:(0,import_path4.dirname)(require.resolve((0,import_path4.join)("@storybook/react","package.json")))}},config=(entry=[])=>[...entry,require.resolve("@storybook/nextjs/preview.js")],babel=async baseConfig=>{var _a,_b,_c;let configPartial=(0,import_core.loadPartialConfig)({...baseConfig,filename:`${(0,import_core_common.getProjectRoot)()}/__fake__.js`}),options=configPartial==null?void 0:configPartial.options,isPresetConfigItem=preset=>typeof preset=="object"&&preset!==null&&"file"in preset,isNextBabelConfig=preset=>{var _a2;return Array.isArray(preset)&&preset[0]==="next/babel"||preset==="next/babel"||isPresetConfigItem(preset)&&((_a2=preset.file)==null?void 0:_a2.request)==="next/babel"},hasNextBabelConfig=(_a=options==null?void 0:options.presets)==null?void 0:_a.find(isNextBabelConfig),presets=((_b=options==null?void 0:options.presets)==null?void 0:_b.filter(preset=>{var _a2;return!(isPresetConfigItem(preset)&&((_a2=preset.file)==null?void 0:_a2.request)===require.resolve("@babel/preset-react")||isNextBabelConfig(preset))}))??[];hasNextBabelConfig?Array.isArray(hasNextBabelConfig)&&hasNextBabelConfig[1]?presets.push([preset_default,hasNextBabelConfig[1]]):isPresetConfigItem(hasNextBabelConfig)&&((_c=hasNextBabelConfig.file)==null?void 0:_c.request)==="next/babel"?presets.push([preset_default,hasNextBabelConfig.options]):presets.push(preset_default):presets.push(preset_default);let plugins=[...(options==null?void 0:options.plugins)??[],TransformFontImports];return{...options,plugins,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 configureNextFont(baseConfig),configureNextImport(baseConfig),configureRuntimeNextjsVersionResolution(baseConfig),configureImports(baseConfig),configureCss(baseConfig,nextConfig),configureImages(baseConfig),configureRouting(baseConfig),configureStyledJsx(baseConfig),baseConfig};0&&(module.exports={addons,babel,config,core,frameworkOptions,webpackFinal});