@storybook/nextjs 8.3.0-alpha.0 → 8.3.0-alpha.10

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 (63) hide show
  1. package/dist/chunk-42AJV46F.mjs +3 -0
  2. package/dist/chunk-EPPXVIAF.mjs +20 -0
  3. package/dist/compatibility/redirect-status-code.compat.mjs +1 -1
  4. package/dist/compatibility/segment.compat.mjs +1 -1
  5. package/dist/export-mocks/cache/index.d.ts +5 -5
  6. package/dist/export-mocks/cache/index.mjs +1 -1
  7. package/dist/export-mocks/headers/index.d.ts +18 -18
  8. package/dist/export-mocks/headers/index.js +1 -1
  9. package/dist/export-mocks/headers/index.mjs +2 -2
  10. package/dist/export-mocks/index.js +1 -1
  11. package/dist/export-mocks/index.mjs +5 -5
  12. package/dist/export-mocks/navigation/index.d.ts +13 -13
  13. package/dist/export-mocks/navigation/index.js +1 -1
  14. package/dist/export-mocks/navigation/index.mjs +3 -3
  15. package/dist/export-mocks/router/index.d.ts +9 -6
  16. package/dist/export-mocks/router/index.js +1 -1
  17. package/dist/export-mocks/router/index.mjs +2 -2
  18. package/dist/font/webpack/loader/storybook-nextjs-font-loader.js +4 -4
  19. package/dist/font/webpack/loader/storybook-nextjs-font-loader.mjs +10 -10
  20. package/dist/image-context.mjs +1 -1
  21. package/dist/images/decorator.mjs +1 -1
  22. package/dist/images/next-image.d.ts +2 -1
  23. package/dist/images/next-image.js +1 -1
  24. package/dist/images/next-image.mjs +2 -2
  25. package/dist/images/next-legacy-image.d.ts +1 -1
  26. package/dist/images/next-legacy-image.js +1 -1
  27. package/dist/images/next-legacy-image.mjs +2 -2
  28. package/dist/{index.d-e10eb603.d.ts → index.d-5a935e77.d.ts} +70 -27
  29. package/dist/index.d.ts +33 -27
  30. package/dist/index.js +1 -1
  31. package/dist/index.mjs +7 -6
  32. package/dist/next-image-loader-stub.d.ts +1 -1
  33. package/dist/next-image-loader-stub.js +2 -2
  34. package/dist/next-image-loader-stub.mjs +6 -6
  35. package/dist/preset.d.ts +2 -2
  36. package/dist/preset.js +1 -1
  37. package/dist/preview.js +1 -1
  38. package/dist/preview.mjs +2 -2
  39. package/dist/react-18-Y5ANLNUV.mjs +7 -0
  40. package/dist/rsc/server-only.mjs +1 -1
  41. package/dist/swc/next-swc-loader-patch.js +1 -1
  42. package/dist/swc/next-swc-loader-patch.mjs +3 -3
  43. package/dist/{types-6414f95f.d.ts → types-a7a34fc4.d.ts} +3 -5
  44. package/package.json +9 -9
  45. package/template/cli/.eslintrc.json +0 -1
  46. package/template/cli/js/Button.jsx +8 -18
  47. package/template/cli/js/Button.stories.js +1 -0
  48. package/template/cli/js/Configure.mdx +10 -10
  49. package/template/cli/js/Header.jsx +1 -0
  50. package/template/cli/js/Header.stories.js +1 -0
  51. package/template/cli/js/Page.stories.js +2 -1
  52. package/template/cli/ts-3-8/Button.stories.ts +1 -0
  53. package/template/cli/ts-3-8/Button.tsx +7 -18
  54. package/template/cli/ts-3-8/Configure.mdx +10 -10
  55. package/template/cli/ts-3-8/Page.stories.ts +1 -1
  56. package/template/cli/ts-4-9/Button.stories.ts +1 -0
  57. package/template/cli/ts-4-9/Button.tsx +7 -18
  58. package/template/cli/ts-4-9/Configure.mdx +10 -10
  59. package/template/cli/ts-4-9/Header.stories.ts +1 -0
  60. package/template/cli/ts-4-9/Page.stories.ts +1 -1
  61. package/dist/chunk-QUZPS4B6.mjs +0 -3
  62. package/dist/chunk-TNOZHPK5.mjs +0 -20
  63. package/template/stories/dynamic-component.js +0 -5
@@ -52,7 +52,7 @@ export const RightArrow = () => <svg
52
52
  <h4 className="sb-section-item-heading">Add styling and CSS</h4>
53
53
  <p className="sb-section-item-paragraph">Like with web applications, there are many ways to include CSS within Storybook. Learn more about setting up styling within Storybook.</p>
54
54
  <a
55
- href="https://storybook.js.org/docs/configure/styling-and-css"
55
+ href="https://storybook.js.org/docs/configure/styling-and-css/?renderer=react"
56
56
  target="_blank"
57
57
  >Learn more<RightArrow /></a>
58
58
  </div>
@@ -67,7 +67,7 @@ export const RightArrow = () => <svg
67
67
  <h4 className="sb-section-item-heading">Provide context and mocking</h4>
68
68
  <p className="sb-section-item-paragraph">Often when a story doesn't render, it's because your component is expecting a specific environment or context (like a theme provider) to be available.</p>
69
69
  <a
70
- href="https://storybook.js.org/docs/writing-stories/decorators#context-for-mocking"
70
+ href="https://storybook.js.org/docs/writing-stories/decorators/?renderer=react#context-for-mocking"
71
71
  target="_blank"
72
72
  >Learn more<RightArrow /></a>
73
73
  </div>
@@ -85,7 +85,7 @@ export const RightArrow = () => <svg
85
85
  `staticDirs` configuration option to specify folders to load when
86
86
  starting Storybook.</p>
87
87
  <a
88
- href="https://storybook.js.org/docs/configure/images-and-assets"
88
+ href="https://storybook.js.org/docs/configure/images-and-assets/?renderer=react"
89
89
  target="_blank"
90
90
  >Learn more<RightArrow /></a>
91
91
  </div>
@@ -113,7 +113,7 @@ export const RightArrow = () => <svg
113
113
  <p className="sb-section-item-paragraph">Auto-generate living,
114
114
  interactive reference documentation from your components and stories.</p>
115
115
  <a
116
- href="https://storybook.js.org/docs/writing-docs/autodocs"
116
+ href="https://storybook.js.org/docs/writing-docs/autodocs/?renderer=react"
117
117
  target="_blank"
118
118
  >Learn more<RightArrow /></a>
119
119
  </div>
@@ -128,7 +128,7 @@ export const RightArrow = () => <svg
128
128
  <h4 className="sb-section-item-heading">Publish to Chromatic</h4>
129
129
  <p className="sb-section-item-paragraph">Publish your Storybook to review and collaborate with your entire team.</p>
130
130
  <a
131
- href="https://storybook.js.org/docs/sharing/publish-storybook#publish-storybook-with-chromatic"
131
+ href="https://storybook.js.org/docs/sharing/publish-storybook/?renderer=react#publish-storybook-with-chromatic"
132
132
  target="_blank"
133
133
  >Learn more<RightArrow /></a>
134
134
  </div>
@@ -144,7 +144,7 @@ export const RightArrow = () => <svg
144
144
  <p className="sb-section-item-paragraph">Embed your stories into Figma to cross-reference the design and live
145
145
  implementation in one place.</p>
146
146
  <a
147
- href="https://storybook.js.org/docs/sharing/design-integrations#embed-storybook-in-figma-with-the-plugin"
147
+ href="https://storybook.js.org/docs/sharing/design-integrations/?renderer=react#embed-storybook-in-figma-with-the-plugin"
148
148
  target="_blank"
149
149
  >Learn more<RightArrow /></a>
150
150
  </div>
@@ -160,7 +160,7 @@ export const RightArrow = () => <svg
160
160
  <p className="sb-section-item-paragraph">Use stories to test a component in all its variations, no matter how
161
161
  complex.</p>
162
162
  <a
163
- href="https://storybook.js.org/docs/writing-tests"
163
+ href="https://storybook.js.org/docs/writing-tests/?renderer=react"
164
164
  target="_blank"
165
165
  >Learn more<RightArrow /></a>
166
166
  </div>
@@ -175,7 +175,7 @@ export const RightArrow = () => <svg
175
175
  <h4 className="sb-section-item-heading">Accessibility</h4>
176
176
  <p className="sb-section-item-paragraph">Automatically test your components for a11y issues as you develop.</p>
177
177
  <a
178
- href="https://storybook.js.org/docs/writing-tests/accessibility-testing"
178
+ href="https://storybook.js.org/docs/writing-tests/accessibility-testing/?renderer=react"
179
179
  target="_blank"
180
180
  >Learn more<RightArrow /></a>
181
181
  </div>
@@ -190,7 +190,7 @@ export const RightArrow = () => <svg
190
190
  <h4 className="sb-section-item-heading">Theming</h4>
191
191
  <p className="sb-section-item-paragraph">Theme Storybook's UI to personalize it to your project.</p>
192
192
  <a
193
- href="https://storybook.js.org/docs/configure/theming"
193
+ href="https://storybook.js.org/docs/configure/theming/?renderer=react"
194
194
  target="_blank"
195
195
  >Learn more<RightArrow /></a>
196
196
  </div>
@@ -202,7 +202,7 @@ export const RightArrow = () => <svg
202
202
  <h4>Addons</h4>
203
203
  <p className="sb-section-item-paragraph">Integrate your tools with Storybook to connect workflows.</p>
204
204
  <a
205
- href="https://storybook.js.org/integrations/"
205
+ href="https://storybook.js.org/addons/"
206
206
  target="_blank"
207
207
  >Discover all addons<RightArrow /></a>
208
208
  </div>
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { within, userEvent, expect } from '@storybook/test';
2
+ import { expect, userEvent, within } from '@storybook/test';
3
3
 
4
4
  import { Page } from './Page';
5
5
 
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
  import { fn } from '@storybook/test';
3
+
3
4
  import { Button } from './Button';
4
5
 
5
6
  // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
@@ -1,32 +1,21 @@
1
1
  import React from 'react';
2
+
2
3
  import './button.css';
3
4
 
4
5
  export interface ButtonProps {
5
- /**
6
- * Is this the principal call to action on the page?
7
- */
6
+ /** Is this the principal call to action on the page? */
8
7
  primary?: boolean;
9
- /**
10
- * What background color to use
11
- */
8
+ /** What background color to use */
12
9
  backgroundColor?: string;
13
- /**
14
- * How large should the button be?
15
- */
10
+ /** How large should the button be? */
16
11
  size?: 'small' | 'medium' | 'large';
17
- /**
18
- * Button contents
19
- */
12
+ /** Button contents */
20
13
  label: string;
21
- /**
22
- * Optional click handler
23
- */
14
+ /** Optional click handler */
24
15
  onClick?: () => void;
25
16
  }
26
17
 
27
- /**
28
- * Primary UI component for user interaction
29
- */
18
+ /** Primary UI component for user interaction */
30
19
  export const Button = ({
31
20
  primary = false,
32
21
  size = 'medium',
@@ -52,7 +52,7 @@ export const RightArrow = () => <svg
52
52
  <h4 className="sb-section-item-heading">Add styling and CSS</h4>
53
53
  <p className="sb-section-item-paragraph">Like with web applications, there are many ways to include CSS within Storybook. Learn more about setting up styling within Storybook.</p>
54
54
  <a
55
- href="https://storybook.js.org/docs/configure/styling-and-css"
55
+ href="https://storybook.js.org/docs/configure/styling-and-css/?renderer=react"
56
56
  target="_blank"
57
57
  >Learn more<RightArrow /></a>
58
58
  </div>
@@ -67,7 +67,7 @@ export const RightArrow = () => <svg
67
67
  <h4 className="sb-section-item-heading">Provide context and mocking</h4>
68
68
  <p className="sb-section-item-paragraph">Often when a story doesn't render, it's because your component is expecting a specific environment or context (like a theme provider) to be available.</p>
69
69
  <a
70
- href="https://storybook.js.org/docs/writing-stories/decorators#context-for-mocking"
70
+ href="https://storybook.js.org/docs/writing-stories/decorators/?renderer=react#context-for-mocking"
71
71
  target="_blank"
72
72
  >Learn more<RightArrow /></a>
73
73
  </div>
@@ -85,7 +85,7 @@ export const RightArrow = () => <svg
85
85
  `staticDirs` configuration option to specify folders to load when
86
86
  starting Storybook.</p>
87
87
  <a
88
- href="https://storybook.js.org/docs/configure/images-and-assets"
88
+ href="https://storybook.js.org/docs/configure/images-and-assets/?renderer=react"
89
89
  target="_blank"
90
90
  >Learn more<RightArrow /></a>
91
91
  </div>
@@ -113,7 +113,7 @@ export const RightArrow = () => <svg
113
113
  <p className="sb-section-item-paragraph">Auto-generate living,
114
114
  interactive reference documentation from your components and stories.</p>
115
115
  <a
116
- href="https://storybook.js.org/docs/writing-docs/autodocs"
116
+ href="https://storybook.js.org/docs/writing-docs/autodocs/?renderer=react"
117
117
  target="_blank"
118
118
  >Learn more<RightArrow /></a>
119
119
  </div>
@@ -128,7 +128,7 @@ export const RightArrow = () => <svg
128
128
  <h4 className="sb-section-item-heading">Publish to Chromatic</h4>
129
129
  <p className="sb-section-item-paragraph">Publish your Storybook to review and collaborate with your entire team.</p>
130
130
  <a
131
- href="https://storybook.js.org/docs/sharing/publish-storybook#publish-storybook-with-chromatic"
131
+ href="https://storybook.js.org/docs/sharing/publish-storybook/?renderer=react#publish-storybook-with-chromatic"
132
132
  target="_blank"
133
133
  >Learn more<RightArrow /></a>
134
134
  </div>
@@ -144,7 +144,7 @@ export const RightArrow = () => <svg
144
144
  <p className="sb-section-item-paragraph">Embed your stories into Figma to cross-reference the design and live
145
145
  implementation in one place.</p>
146
146
  <a
147
- href="https://storybook.js.org/docs/sharing/design-integrations#embed-storybook-in-figma-with-the-plugin"
147
+ href="https://storybook.js.org/docs/sharing/design-integrations/?renderer=react#embed-storybook-in-figma-with-the-plugin"
148
148
  target="_blank"
149
149
  >Learn more<RightArrow /></a>
150
150
  </div>
@@ -160,7 +160,7 @@ export const RightArrow = () => <svg
160
160
  <p className="sb-section-item-paragraph">Use stories to test a component in all its variations, no matter how
161
161
  complex.</p>
162
162
  <a
163
- href="https://storybook.js.org/docs/writing-tests"
163
+ href="https://storybook.js.org/docs/writing-tests/?renderer=react"
164
164
  target="_blank"
165
165
  >Learn more<RightArrow /></a>
166
166
  </div>
@@ -175,7 +175,7 @@ export const RightArrow = () => <svg
175
175
  <h4 className="sb-section-item-heading">Accessibility</h4>
176
176
  <p className="sb-section-item-paragraph">Automatically test your components for a11y issues as you develop.</p>
177
177
  <a
178
- href="https://storybook.js.org/docs/writing-tests/accessibility-testing"
178
+ href="https://storybook.js.org/docs/writing-tests/accessibility-testing/?renderer=react"
179
179
  target="_blank"
180
180
  >Learn more<RightArrow /></a>
181
181
  </div>
@@ -190,7 +190,7 @@ export const RightArrow = () => <svg
190
190
  <h4 className="sb-section-item-heading">Theming</h4>
191
191
  <p className="sb-section-item-paragraph">Theme Storybook's UI to personalize it to your project.</p>
192
192
  <a
193
- href="https://storybook.js.org/docs/configure/theming"
193
+ href="https://storybook.js.org/docs/configure/theming/?renderer=react"
194
194
  target="_blank"
195
195
  >Learn more<RightArrow /></a>
196
196
  </div>
@@ -202,7 +202,7 @@ export const RightArrow = () => <svg
202
202
  <h4>Addons</h4>
203
203
  <p className="sb-section-item-paragraph">Integrate your tools with Storybook to connect workflows.</p>
204
204
  <a
205
- href="https://storybook.js.org/integrations/"
205
+ href="https://storybook.js.org/addons/"
206
206
  target="_blank"
207
207
  >Discover all addons<RightArrow /></a>
208
208
  </div>
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
  import { fn } from '@storybook/test';
3
+
3
4
  import { Header } from './Header';
4
5
 
5
6
  const meta = {
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { within, userEvent, expect } from '@storybook/test';
2
+ import { expect, userEvent, within } from '@storybook/test';
3
3
 
4
4
  import { Page } from './Page';
5
5
 
@@ -1,3 +0,0 @@
1
- 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 __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 Error('Dynamic require of "'+x+'" is not supported')});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 __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod));
2
-
3
- export { __commonJS, __export, __require, __toESM };
@@ -1,20 +0,0 @@
1
- import { ImageDecorator } from './chunk-NQ32RFK2.mjs';
2
- import { __export } from './chunk-QUZPS4B6.mjs';
3
- import { setConfig } from 'next/config';
4
- import * as React from 'react';
5
- import React__default, { useMemo } from 'react';
6
- import { GlobalLayoutRouterContext, AppRouterContext, LayoutRouterContext } from 'next/dist/shared/lib/app-router-context.shared-runtime';
7
- import { PathParamsContext, PathnameContext, SearchParamsContext } from 'next/dist/shared/lib/hooks-client-context.shared-runtime';
8
- import { PAGE_SEGMENT_KEY } from 'next/dist/shared/lib/segment';
9
- import { createNavigation, getRouter } from '@storybook/nextjs/navigation.mock';
10
- import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime';
11
- import { createRouter, getRouter as getRouter$1 } from '@storybook/nextjs/router.mock';
12
- import { RedirectBoundary } from 'next/dist/client/components/redirect-boundary';
13
- import { StyleRegistry } from 'styled-jsx';
14
- import { HeadManagerContext } from 'next/dist/shared/lib/head-manager-context.shared-runtime';
15
- import initHeadManager from 'next/dist/client/head-manager';
16
- import { isNextRouterError } from 'next/dist/client/components/is-next-router-error';
17
-
18
- var preview_exports={};__export(preview_exports,{decorators:()=>decorators,loaders:()=>loaders,parameters:()=>parameters});setConfig(process.env.__NEXT_RUNTIME_CONFIG);function getSelectedParams(currentTree,params={}){let parallelRoutes=currentTree[1];for(let parallelRoute of Object.values(parallelRoutes)){let segment=parallelRoute[0],isDynamicParameter=Array.isArray(segment),segmentValue=isDynamicParameter?segment[1]:segment;if(!segmentValue||segmentValue.startsWith(PAGE_SEGMENT_KEY))continue;isDynamicParameter&&(segment[2]==="c"||segment[2]==="oc")?params[segment[0]]=segment[1].split("/"):isDynamicParameter&&(params[segment[0]]=segment[1]),params=getSelectedParams(parallelRoute,params);}return params}var getParallelRoutes=segmentsList=>{let segment=segmentsList.shift();return segment?[segment,{children:getParallelRoutes(segmentsList)}]:[]},AppRouterProvider=({children,routeParams})=>{let{pathname,query,segments=[]}=routeParams,tree=[pathname,{children:getParallelRoutes([...segments])}],pathParams=useMemo(()=>getSelectedParams(tree),[tree]);return React__default.createElement(PathParamsContext.Provider,{value:pathParams},React__default.createElement(PathnameContext.Provider,{value:pathname},React__default.createElement(SearchParamsContext.Provider,{value:new URLSearchParams(query)},React__default.createElement(GlobalLayoutRouterContext.Provider,{value:{changeByServerResponse(){},buildId:"storybook",tree,focusAndScrollRef:{apply:!1,hashFragment:null,segmentPaths:[tree],onlyHashChange:!1},nextUrl:pathname}},React__default.createElement(AppRouterContext.Provider,{value:getRouter()},React__default.createElement(LayoutRouterContext.Provider,{value:{childNodes:new Map,tree,url:pathname}},children))))))};var PageRouterProvider=({children})=>React__default.createElement(RouterContext.Provider,{value:getRouter$1()},children);var defaultRouterParams={pathname:"/",query:{}},RouterDecorator=(Story,{parameters:parameters2})=>parameters2.nextjs?.appDirectory??!1?AppRouterProvider?React.createElement(AppRouterProvider,{routeParams:{...defaultRouterParams,...parameters2.nextjs?.navigation}},React.createElement(RedirectBoundary,null,React.createElement(Story,null))):null:React.createElement(PageRouterProvider,null,React.createElement(Story,null));var StyledJsxDecorator=Story=>React.createElement(StyleRegistry,null,React.createElement(Story,null));var HeadManagerProvider=({children})=>{let headManager=useMemo(initHeadManager,[]);return headManager.getIsSsr=()=>!1,React__default.createElement(HeadManagerContext.Provider,{value:headManager},children)},head_manager_provider_default=HeadManagerProvider;var HeadManagerDecorator=Story=>React.createElement(head_manager_provider_default,null,React.createElement(Story,null));function addNextHeadCount(){let meta=document.createElement("meta");meta.name="next-head-count",meta.content="0",document.head.appendChild(meta);}function isAsyncClientComponentError(error){return typeof error=="string"&&(error.includes("A component was suspended by an uncached promise.")||error.includes("async/await is not yet supported in Client Components"))}addNextHeadCount();var origConsoleError=globalThis.console.error;globalThis.console.error=(...args)=>{let error=args[0];isNextRouterError(error)||isAsyncClientComponentError(error)||origConsoleError.apply(globalThis.console,args);};globalThis.addEventListener("error",ev=>{if(isNextRouterError(ev.error)||isAsyncClientComponentError(ev.error)){ev.preventDefault();return}});var decorators=[StyledJsxDecorator,ImageDecorator,RouterDecorator,HeadManagerDecorator],loaders=async({globals,parameters:parameters2})=>{let{router,appDirectory}=parameters2.nextjs??{};appDirectory?createNavigation(router):createRouter({locale:globals.locale,...router});},parameters={docs:{source:{excludeDecorators:!0}},react:{rootOptions:{onCaughtError(error){isNextRouterError(error)||console.error(error);}}}};
19
-
20
- export { decorators, loaders, parameters, preview_exports };
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
-
3
- export default function DynamicComponent() {
4
- return <div>I am a dynamically loaded component</div>;
5
- }