@storybook/react 7.0.0-alpha.46 → 7.0.0-alpha.48

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 (167) hide show
  1. package/dist/config.d.ts +1 -1
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +1 -1
  4. package/dist/index.mjs +1 -1
  5. package/package.json +9 -8
  6. package/template/cli/.eslintrc.json +5 -0
  7. package/template/cli/js/Button.jsx +50 -0
  8. package/template/cli/js/Button.stories.js +41 -0
  9. package/template/cli/js/Header.jsx +59 -0
  10. package/template/cli/js/Header.stories.js +22 -0
  11. package/template/cli/js/Page.jsx +69 -0
  12. package/template/cli/js/Page.stories.js +25 -0
  13. package/template/cli/ts/Button.stories.ts +47 -0
  14. package/template/cli/ts/Button.tsx +48 -0
  15. package/template/cli/ts/Header.stories.ts +26 -0
  16. package/template/cli/ts/Header.tsx +56 -0
  17. package/template/cli/ts/Page.stories.ts +29 -0
  18. package/template/cli/ts/Page.tsx +73 -0
  19. package/template/components/Button.jsx +13 -0
  20. package/template/components/Form.jsx +36 -0
  21. package/template/components/Html.jsx +9 -0
  22. package/template/components/Pre.jsx +20 -0
  23. package/template/components/index.js +9 -0
  24. package/template/stories/decorators.stories.tsx +28 -0
  25. package/template/stories/docgen-components/10017-ts-union/argTypes.snapshot +36 -0
  26. package/template/stories/docgen-components/10017-ts-union/docgen.snapshot +34 -0
  27. package/template/stories/docgen-components/10017-ts-union/input.tsx +12 -0
  28. package/template/stories/docgen-components/10017-ts-union/properties.snapshot +32 -0
  29. package/template/stories/docgen-components/10278-ts-multiple-components/argTypes.snapshot +26 -0
  30. package/template/stories/docgen-components/10278-ts-multiple-components/docgen.snapshot +49 -0
  31. package/template/stories/docgen-components/10278-ts-multiple-components/input.tsx +27 -0
  32. package/template/stories/docgen-components/10278-ts-multiple-components/properties.snapshot +22 -0
  33. package/template/stories/docgen-components/8140-js-prop-types-oneof/argTypes.snapshot +127 -0
  34. package/template/stories/docgen-components/8140-js-prop-types-oneof/docgen.snapshot +97 -0
  35. package/template/stories/docgen-components/8140-js-prop-types-oneof/input.jsx +27 -0
  36. package/template/stories/docgen-components/8140-js-prop-types-oneof/properties.snapshot +89 -0
  37. package/template/stories/docgen-components/8143-ts-imported-types/argTypes.snapshot +27 -0
  38. package/template/stories/docgen-components/8143-ts-imported-types/docgen.snapshot +22 -0
  39. package/template/stories/docgen-components/8143-ts-imported-types/input.tsx +10 -0
  40. package/template/stories/docgen-components/8143-ts-imported-types/properties.snapshot +23 -0
  41. package/template/stories/docgen-components/8143-ts-imported-types/types.ts +3 -0
  42. package/template/stories/docgen-components/8143-ts-react-fc-generics/argTypes.snapshot +27 -0
  43. package/template/stories/docgen-components/8143-ts-react-fc-generics/docgen.snapshot +24 -0
  44. package/template/stories/docgen-components/8143-ts-react-fc-generics/input.tsx +10 -0
  45. package/template/stories/docgen-components/8143-ts-react-fc-generics/properties.snapshot +21 -0
  46. package/template/stories/docgen-components/8428-js-static-prop-types/argTypes.snapshot +25 -0
  47. package/template/stories/docgen-components/8428-js-static-prop-types/docgen.snapshot +37 -0
  48. package/template/stories/docgen-components/8428-js-static-prop-types/input.jsx +20 -0
  49. package/template/stories/docgen-components/8428-js-static-prop-types/properties.snapshot +21 -0
  50. package/template/stories/docgen-components/8740-ts-multi-props/argTypes.snapshot +27 -0
  51. package/template/stories/docgen-components/8740-ts-multi-props/docgen.snapshot +49 -0
  52. package/template/stories/docgen-components/8740-ts-multi-props/input.tsx +23 -0
  53. package/template/stories/docgen-components/8740-ts-multi-props/properties.snapshot +21 -0
  54. package/template/stories/docgen-components/8894-9511-ts-forward-ref/argTypes.snapshot +48 -0
  55. package/template/stories/docgen-components/8894-9511-ts-forward-ref/docgen.snapshot +39 -0
  56. package/template/stories/docgen-components/8894-9511-ts-forward-ref/input.tsx +31 -0
  57. package/template/stories/docgen-components/8894-9511-ts-forward-ref/properties.snapshot +34 -0
  58. package/template/stories/docgen-components/9023-js-hoc/argTypes.snapshot +89 -0
  59. package/template/stories/docgen-components/9023-js-hoc/docgen.snapshot +84 -0
  60. package/template/stories/docgen-components/9023-js-hoc/input.jsx +40 -0
  61. package/template/stories/docgen-components/9023-js-hoc/properties.snapshot +67 -0
  62. package/template/stories/docgen-components/9399-js-proptypes-shape/argTypes.snapshot +39 -0
  63. package/template/stories/docgen-components/9399-js-proptypes-shape/docgen.snapshot +48 -0
  64. package/template/stories/docgen-components/9399-js-proptypes-shape/input.jsx +16 -0
  65. package/template/stories/docgen-components/9399-js-proptypes-shape/properties.snapshot +35 -0
  66. package/template/stories/docgen-components/9465-ts-type-props/argTypes.snapshot +28 -0
  67. package/template/stories/docgen-components/9465-ts-type-props/docgen.snapshot +33 -0
  68. package/template/stories/docgen-components/9465-ts-type-props/input.tsx +12 -0
  69. package/template/stories/docgen-components/9465-ts-type-props/properties.snapshot +24 -0
  70. package/template/stories/docgen-components/9493-ts-display-name/argTypes.snapshot +62 -0
  71. package/template/stories/docgen-components/9493-ts-display-name/docgen.snapshot +50 -0
  72. package/template/stories/docgen-components/9493-ts-display-name/input.tsx +30 -0
  73. package/template/stories/docgen-components/9493-ts-display-name/properties.snapshot +52 -0
  74. package/template/stories/docgen-components/9556-ts-react-default-exports/argTypes.snapshot +28 -0
  75. package/template/stories/docgen-components/9556-ts-react-default-exports/docgen.snapshot +32 -0
  76. package/template/stories/docgen-components/9556-ts-react-default-exports/input.tsx +12 -0
  77. package/template/stories/docgen-components/9556-ts-react-default-exports/properties.snapshot +24 -0
  78. package/template/stories/docgen-components/9575-ts-camel-case/argTypes.snapshot +28 -0
  79. package/template/stories/docgen-components/9575-ts-camel-case/docgen.snapshot +38 -0
  80. package/template/stories/docgen-components/9575-ts-camel-case/input.tsx +26 -0
  81. package/template/stories/docgen-components/9575-ts-camel-case/properties.snapshot +24 -0
  82. package/template/stories/docgen-components/9586-js-react-memo/argTypes.snapshot +41 -0
  83. package/template/stories/docgen-components/9586-js-react-memo/docgen.snapshot +42 -0
  84. package/template/stories/docgen-components/9586-js-react-memo/input.jsx +15 -0
  85. package/template/stories/docgen-components/9586-js-react-memo/properties.snapshot +34 -0
  86. package/template/stories/docgen-components/9591-ts-import-types/Bar.tsx +3 -0
  87. package/template/stories/docgen-components/9591-ts-import-types/argTypes.snapshot +25 -0
  88. package/template/stories/docgen-components/9591-ts-import-types/docgen.snapshot +21 -0
  89. package/template/stories/docgen-components/9591-ts-import-types/input.tsx +10 -0
  90. package/template/stories/docgen-components/9591-ts-import-types/properties.snapshot +21 -0
  91. package/template/stories/docgen-components/9626-js-default-values/argTypes.snapshot +27 -0
  92. package/template/stories/docgen-components/9626-js-default-values/docgen.snapshot +25 -0
  93. package/template/stories/docgen-components/9626-js-default-values/input.jsx +5 -0
  94. package/template/stories/docgen-components/9626-js-default-values/properties.snapshot +21 -0
  95. package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/argTypes.snapshot +42 -0
  96. package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/docgen.snapshot +36 -0
  97. package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/input.jsx +13 -0
  98. package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/properties.snapshot +35 -0
  99. package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/argTypes.snapshot +53 -0
  100. package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/docgen.snapshot +45 -0
  101. package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/input.tsx +18 -0
  102. package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/properties.snapshot +43 -0
  103. package/template/stories/docgen-components/9764-ts-extend-props/argTypes.snapshot +72 -0
  104. package/template/stories/docgen-components/9764-ts-extend-props/docgen.snapshot +41 -0
  105. package/template/stories/docgen-components/9764-ts-extend-props/input.tsx +17 -0
  106. package/template/stories/docgen-components/9764-ts-extend-props/properties.snapshot +56 -0
  107. package/template/stories/docgen-components/9827-ts-default-values/argTypes.snapshot +72 -0
  108. package/template/stories/docgen-components/9827-ts-default-values/docgen.snapshot +52 -0
  109. package/template/stories/docgen-components/9827-ts-default-values/input.tsx +17 -0
  110. package/template/stories/docgen-components/9827-ts-default-values/properties.snapshot +56 -0
  111. package/template/stories/docgen-components/9832-ts-enum-export/argTypes.snapshot +3 -0
  112. package/template/stories/docgen-components/9832-ts-enum-export/docgen.snapshot +16 -0
  113. package/template/stories/docgen-components/9832-ts-enum-export/input.tsx +8 -0
  114. package/template/stories/docgen-components/9832-ts-enum-export/properties.snapshot +7 -0
  115. package/template/stories/docgen-components/9922-ts-component-props/argTypes.snapshot +25 -0
  116. package/template/stories/docgen-components/9922-ts-component-props/docgen.snapshot +35 -0
  117. package/template/stories/docgen-components/9922-ts-component-props/input.tsx +24 -0
  118. package/template/stories/docgen-components/9922-ts-component-props/properties.snapshot +21 -0
  119. package/template/stories/docgen-components/imported.js +1 -0
  120. package/template/stories/docgen-components/js-class-component/argTypes.snapshot +386 -0
  121. package/template/stories/docgen-components/js-class-component/docgen.snapshot +252 -0
  122. package/template/stories/docgen-components/js-class-component/input.jsx +57 -0
  123. package/template/stories/docgen-components/js-class-component/properties.snapshot +286 -0
  124. package/template/stories/docgen-components/js-function-component/argTypes.snapshot +386 -0
  125. package/template/stories/docgen-components/js-function-component/docgen.snapshot +236 -0
  126. package/template/stories/docgen-components/js-function-component/input.jsx +50 -0
  127. package/template/stories/docgen-components/js-function-component/properties.snapshot +286 -0
  128. package/template/stories/docgen-components/js-function-component-inline-defaults/argTypes.snapshot +386 -0
  129. package/template/stories/docgen-components/js-function-component-inline-defaults/docgen.snapshot +247 -0
  130. package/template/stories/docgen-components/js-function-component-inline-defaults/input.jsx +65 -0
  131. package/template/stories/docgen-components/js-function-component-inline-defaults/properties.snapshot +286 -0
  132. package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/argTypes.snapshot +237 -0
  133. package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/docgen.snapshot +124 -0
  134. package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/input.jsx +41 -0
  135. package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/properties.snapshot +151 -0
  136. package/template/stories/docgen-components/js-proptypes/docgen.snapshot +1770 -0
  137. package/template/stories/docgen-components/js-proptypes/ext.js +13 -0
  138. package/template/stories/docgen-components/js-proptypes/input.jsx +497 -0
  139. package/template/stories/docgen-components/jsdoc/argTypes.snapshot +969 -0
  140. package/template/stories/docgen-components/jsdoc/docgen.snapshot +548 -0
  141. package/template/stories/docgen-components/jsdoc/input.jsx +231 -0
  142. package/template/stories/docgen-components/jsdoc/properties.snapshot +857 -0
  143. package/template/stories/docgen-components/ts-function-component/argTypes.snapshot +396 -0
  144. package/template/stories/docgen-components/ts-function-component/docgen.snapshot +241 -0
  145. package/template/stories/docgen-components/ts-function-component/input.tsx +52 -0
  146. package/template/stories/docgen-components/ts-function-component/properties.snapshot +296 -0
  147. package/template/stories/docgen-components/ts-function-component-inline-defaults/argTypes.snapshot +279 -0
  148. package/template/stories/docgen-components/ts-function-component-inline-defaults/docgen.snapshot +151 -0
  149. package/template/stories/docgen-components/ts-function-component-inline-defaults/input.tsx +80 -0
  150. package/template/stories/docgen-components/ts-function-component-inline-defaults/properties.snapshot +177 -0
  151. package/template/stories/docgen-components/ts-html/argTypes.snapshot +3 -0
  152. package/template/stories/docgen-components/ts-html/docgen.snapshot +12 -0
  153. package/template/stories/docgen-components/ts-html/input.tsx +12 -0
  154. package/template/stories/docgen-components/ts-html/properties.snapshot +7 -0
  155. package/template/stories/docgen-components/ts-jsdoc/argTypes.snapshot +3 -0
  156. package/template/stories/docgen-components/ts-jsdoc/docgen.snapshot +21 -0
  157. package/template/stories/docgen-components/ts-jsdoc/input.tsx +27 -0
  158. package/template/stories/docgen-components/ts-jsdoc/properties.snapshot +7 -0
  159. package/template/stories/docgen-components/ts-types/argTypes.snapshot +656 -0
  160. package/template/stories/docgen-components/ts-types/docgen.snapshot +317 -0
  161. package/template/stories/docgen-components/ts-types/input.tsx +130 -0
  162. package/template/stories/docgen-components/ts-types/properties.snapshot +410 -0
  163. package/template/stories/errors.stories.tsx +37 -0
  164. package/template/stories/hooks.stories.tsx +17 -0
  165. package/template/stories/js-argtypes.stories.jsx +91 -0
  166. package/template/stories/react-mdx.stories.mdx +26 -0
  167. package/template/stories/ts-argtypes.stories.tsx +81 -0
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as lib_docs_tools_dist from 'lib/docs-tools/dist';
2
- import * as lib_types_dist from 'lib/types/dist';
3
2
  import { R as ReactFramework, S as StoryFnReactReturnType } from './types-e57bba30.js';
3
+ import * as lib_types_dist from 'lib/types/dist';
4
4
  import { ArgsStoryFn, Store_RenderContext } from '@storybook/types';
5
5
  import 'react';
6
6
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _storybook_types from '@storybook/types';
2
2
  import { Args, DecoratorFunction, Addon_ClientStoryApi, Addon_Loadable, ComponentAnnotations, AnnotatedStoryFn, ArgsStoryFn, ArgsFromMeta, StoryAnnotations, ProjectAnnotations, Store_ComposedStory, Store_CSFExports, Store_StoriesWithPartialProps } from '@storybook/types';
3
3
  import { R as ReactFramework, S as StoryFnReactReturnType } from './types-e57bba30.js';
4
+ export { R as ReactFramework } from './types-e57bba30.js';
4
5
  import { ComponentType, ComponentProps, JSXElementConstructor } from 'react';
5
6
  import { Simplify, SetOptional } from 'type-fest';
6
7
 
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var _=Object.create;var m=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var L=(o,t)=>{for(var e in t)m(o,e,{get:t[e],enumerable:!0})},y=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of v(t))!U.call(o,s)&&s!==e&&m(o,s,{get:()=>t[s],enumerable:!(r=T(t,s))||r.enumerable});return o};var p=(o,t,e)=>(e=o!=null?_(W(o)):{},y(t||!o||!o.__esModule?m(e,"default",{value:o,enumerable:!0}):e,o)),N=o=>y(m({},"__esModule",{value:!0}),o);var Z={};L(Z,{composeStories:()=>X,composeStory:()=>b,configure:()=>q,forceReRender:()=>z,raw:()=>H,setGlobalConfig:()=>J,setProjectAnnotations:()=>M,storiesOf:()=>$});module.exports=N(Z);var S=p(require("global")),{window:A}=S.default;A&&(A.STORYBOOK_ENV="react");var k=require("@storybook/core-client");var F=p(require("global")),n=p(require("react")),a=p(require("react-dom")),{FRAMEWORK_OPTIONS:i}=F.default,d=new Map,l=(o,t)=>{let{id:e,component:r}=t;if(!r)throw new Error(`Unable to render story ${e} as the component annotation is missing from the default export`);return n.default.createElement(r,{...o})},O=({callback:o,children:t})=>{let e=(0,n.useRef)();return(0,n.useLayoutEffect)(()=>{e.current!==o&&(e.current=o,o())},[o]),t},G=async(o,t)=>{let e=await Y(t);return new Promise(r=>{e?e.render(n.default.createElement(O,{callback:()=>r(null)},o)):a.default.render(o,t,()=>r(null))})},V=a.version&&(a.version.startsWith("18")||a.version.startsWith("0.0.0")),B=(i==null?void 0:i.legacyRootApi)!==!0,h=B&&V,g=o=>{let t=d.get(o);t&&h?(t.unmount(),d.delete(o)):a.default.unmountComponentAtNode(o)},Y=async o=>{if(!h)return null;let t=d.get(o);return t||(t=(await import("react-dom/client")).default.createRoot(o),d.set(o,t)),t},R=class extends n.Component{constructor(){super(...arguments);this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidMount(){let{hasError:e}=this.state,{showMain:r}=this.props;e||r()}componentDidCatch(e){let{showException:r}=this.props;r(e)}render(){let{hasError:e}=this.state,{children:r}=this.props;return e?null:r}},C=i!=null&&i.strictMode?n.StrictMode:n.Fragment;async function x({storyContext:o,unboundStoryFn:t,showMain:e,showException:r,forceRemount:s},u){let w=n.default.createElement(R,{showMain:e,showException:r},n.default.createElement(t,{...o})),D=C?n.default.createElement(C,null,w):w;return s&&g(u),await G(D,u),()=>g(u)}var E="react",f=(0,k.start)(x,{render:l}),$=(o,t)=>f.clientApi.storiesOf(o,t).addParameters({framework:E}),q=(...o)=>f.configure(E,...o),z=f.forceReRender,H=f.clientApi.raw;var c=require("@storybook/store"),P=require("@storybook/client-logger");function M(o){(0,c.setProjectAnnotations)(o)}function J(o){(0,P.deprecate)("setGlobalConfig is deprecated. Use setProjectAnnotations instead."),M(o)}var Q={render:l};function b(o,t,e,r){return(0,c.composeStory)(o,t,e,Q,r)}function X(o,t){return(0,c.composeStories)(o,t,b)}var j;(j=module==null?void 0:module.hot)==null||j.decline();0&&(module.exports={composeStories,composeStory,configure,forceReRender,raw,setGlobalConfig,setProjectAnnotations,storiesOf});
1
+ "use strict";var j=Object.create;var c=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var X=(t,o)=>{for(var e in o)c(t,e,{get:o[e],enumerable:!0})},C=(t,o,e,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of _(o))!J.call(t,s)&&s!==e&&c(t,s,{get:()=>o[s],enumerable:!(r=D(o,s))||r.enumerable});return t};var m=(t,o,e)=>(e=t!=null?j(v(t)):{},C(o||!t||!t.__esModule?c(e,"default",{value:t,enumerable:!0}):e,t)),W=t=>C(c({},"__esModule",{value:!0}),t);var Z={};X(Z,{composeStories:()=>Q,composeStory:()=>O,configure:()=>Y,forceReRender:()=>$,raw:()=>q,setGlobalConfig:()=>z,setProjectAnnotations:()=>P,storiesOf:()=>B});module.exports=W(Z);var R=m(require("global")),{window:S}=R.default;S&&(S.STORYBOOK_ENV="react");var T=require("@storybook/core-client");var F=m(require("global")),n=m(require("react")),a=m(require("react-dom")),{FRAMEWORK_OPTIONS:p}=F.default,y=new Map,A=(t,o)=>{let{id:e,component:r}=o;if(!r)throw new Error(`Unable to render story ${e} as the component annotation is missing from the default export`);return n.default.createElement(r,{...t})},U=({callback:t,children:o})=>{let e=(0,n.useRef)();return(0,n.useLayoutEffect)(()=>{e.current!==t&&(e.current=t,t())},[t]),o},L=async(t,o)=>{let e=await V(o);return new Promise(r=>{e?e.render(n.default.createElement(U,{callback:()=>r(null)},t)):a.default.render(t,o,()=>r(null))})},N=a.version&&(a.version.startsWith("18")||a.version.startsWith("0.0.0")),G=(p==null?void 0:p.legacyRootApi)!==!0,x=G&&N,u=t=>{let o=y.get(t);o&&x?(o.unmount(),y.delete(t)):a.default.unmountComponentAtNode(t)},V=async t=>{if(!x)return null;let o=y.get(t);return o||(o=(await import("react-dom/client")).default.createRoot(t),y.set(t,o)),o},f=class extends n.Component{constructor(){super(...arguments);this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidMount(){let{hasError:e}=this.state,{showMain:r}=this.props;e||r()}componentDidCatch(e){let{showException:r}=this.props;r(e)}render(){let{hasError:e}=this.state,{children:r}=this.props;return e?null:r}},w=p!=null&&p.strictMode?n.StrictMode:n.Fragment;async function k({storyContext:t,unboundStoryFn:o,showMain:e,showException:r,forceRemount:s},l){let g=n.default.createElement(f,{showMain:e,showException:r},n.default.createElement(o,{...t})),b=w?n.default.createElement(w,null,g):g;return s&&u(l),await L(b,l),()=>u(l)}var E="react",d=(0,T.start)(k,{render:A}),B=(t,o)=>d.clientApi.storiesOf(t,o).addParameters({framework:E}),Y=(...t)=>d.configure(E,...t),$=d.forceReRender,q=d.clientApi.raw;var i=require("@storybook/store"),h=require("@storybook/client-logger");function P(t){(0,i.setProjectAnnotations)(t)}function z(t){(0,h.deprecate)("setGlobalConfig is deprecated. Use setProjectAnnotations instead."),P(t)}var H={render:A};function O(t,o,e,r){return(0,i.composeStory)(t,o,e,H,r)}function Q(t,o){return(0,i.composeStories)(t,o,O)}var M;(M=module==null?void 0:module.hot)==null||M.decline();0&&(module.exports={composeStories,composeStory,configure,forceReRender,raw,setGlobalConfig,setProjectAnnotations,storiesOf});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as e,b as p}from"./chunk-Y6TTZ4RO.mjs";import A from"global";var{window:a}=A;a&&(a.STORYBOOK_ENV="react");import{start as c}from"@storybook/core-client";var m="react",n=c(p,{render:e}),k=(o,t)=>n.clientApi.storiesOf(o,t).addParameters({framework:m}),x=(...o)=>n.configure(m,...o),w=n.forceReRender,O=n.clientApi.raw;import{composeStory as y,composeStories as g,setProjectAnnotations as d}from"@storybook/store";import{deprecate as S}from"@storybook/client-logger";function C(o){d(o)}function E(o){S("setGlobalConfig is deprecated. Use setProjectAnnotations instead."),C(o)}var f={render:e};function l(o,t,s,i){return y(o,t,s,f,i)}function b(o,t){return g(o,t,l)}module?.hot?.decline();export{b as composeStories,l as composeStory,x as configure,w as forceReRender,O as raw,E as setGlobalConfig,C as setProjectAnnotations,k as storiesOf};
1
+ import{a as e,b as p}from"./chunk-Y6TTZ4RO.mjs";import c from"global";var{window:a}=c;a&&(a.STORYBOOK_ENV="react");import{start as A}from"@storybook/core-client";var m="react",n=A(p,{render:e}),k=(o,t)=>n.clientApi.storiesOf(o,t).addParameters({framework:m}),x=(...o)=>n.configure(m,...o),w=n.forceReRender,O=n.clientApi.raw;import{composeStory as y,composeStories as g,setProjectAnnotations as d}from"@storybook/store";import{deprecate as S}from"@storybook/client-logger";function C(o){d(o)}function E(o){S("setGlobalConfig is deprecated. Use setProjectAnnotations instead."),C(o)}var f={render:e};function l(o,t,s,i){return y(o,t,s,f,i)}function b(o,t){return g(o,t,l)}module?.hot?.decline();export{b as composeStories,l as composeStory,x as configure,w as forceReRender,O as raw,E as setGlobalConfig,C as setProjectAnnotations,k as storiesOf};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react",
3
- "version": "7.0.0-alpha.46",
3
+ "version": "7.0.0-alpha.48",
4
4
  "description": "Storybook React renderer",
5
5
  "keywords": [
6
6
  "storybook"
@@ -41,6 +41,7 @@
41
41
  "types": "dist/index.d.ts",
42
42
  "files": [
43
43
  "dist/**/*",
44
+ "template/**/*",
44
45
  "types/**/*",
45
46
  "README.md",
46
47
  "*.js",
@@ -51,12 +52,12 @@
51
52
  "prep": "../../../scripts/prepare/bundle.ts"
52
53
  },
53
54
  "dependencies": {
54
- "@storybook/addons": "7.0.0-alpha.46",
55
- "@storybook/client-logger": "7.0.0-alpha.46",
56
- "@storybook/core-client": "7.0.0-alpha.46",
57
- "@storybook/docs-tools": "7.0.0-alpha.46",
58
- "@storybook/store": "7.0.0-alpha.46",
59
- "@storybook/types": "7.0.0-alpha.46",
55
+ "@storybook/addons": "7.0.0-alpha.48",
56
+ "@storybook/client-logger": "7.0.0-alpha.48",
57
+ "@storybook/core-client": "7.0.0-alpha.48",
58
+ "@storybook/docs-tools": "7.0.0-alpha.48",
59
+ "@storybook/store": "7.0.0-alpha.48",
60
+ "@storybook/types": "7.0.0-alpha.48",
60
61
  "@types/estree": "^0.0.51",
61
62
  "@types/node": "^16.0.0",
62
63
  "acorn": "^7.4.1",
@@ -103,5 +104,5 @@
103
104
  ],
104
105
  "platform": "browser"
105
106
  },
106
- "gitHead": "c64b5be851ed2affac56e1daaac3f453fbe6f230"
107
+ "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
107
108
  }
@@ -0,0 +1,5 @@
1
+ {
2
+ "rules": {
3
+ "import/extensions": "off"
4
+ }
5
+ }
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import './button.css';
4
+
5
+ /**
6
+ * Primary UI component for user interaction
7
+ */
8
+ export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
9
+ const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
10
+ return (
11
+ <button
12
+ type="button"
13
+ className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
14
+ style={backgroundColor && { backgroundColor }}
15
+ {...props}
16
+ >
17
+ {label}
18
+ </button>
19
+ );
20
+ };
21
+
22
+ Button.propTypes = {
23
+ /**
24
+ * Is this the principal call to action on the page?
25
+ */
26
+ primary: PropTypes.bool,
27
+ /**
28
+ * What background color to use
29
+ */
30
+ backgroundColor: PropTypes.string,
31
+ /**
32
+ * How large should the button be?
33
+ */
34
+ size: PropTypes.oneOf(['small', 'medium', 'large']),
35
+ /**
36
+ * Button contents
37
+ */
38
+ label: PropTypes.string.isRequired,
39
+ /**
40
+ * Optional click handler
41
+ */
42
+ onClick: PropTypes.func,
43
+ };
44
+
45
+ Button.defaultProps = {
46
+ backgroundColor: null,
47
+ primary: false,
48
+ size: 'medium',
49
+ onClick: undefined,
50
+ };
@@ -0,0 +1,41 @@
1
+ import { Button } from './Button';
2
+
3
+ // More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
4
+ export default {
5
+ title: 'Example/Button',
6
+ component: Button,
7
+ // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
8
+ tags: ['docsPage'],
9
+ // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
10
+ argTypes: {
11
+ backgroundColor: { control: 'color' },
12
+ },
13
+ };
14
+
15
+ // More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
16
+ export const Primary = {
17
+ args: {
18
+ primary: true,
19
+ label: 'Button',
20
+ },
21
+ };
22
+
23
+ export const Secondary = {
24
+ args: {
25
+ label: 'Button',
26
+ },
27
+ };
28
+
29
+ export const Large = {
30
+ args: {
31
+ size: 'large',
32
+ label: 'Button',
33
+ },
34
+ };
35
+
36
+ export const Small = {
37
+ args: {
38
+ size: 'small',
39
+ label: 'Button',
40
+ },
41
+ };
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ import { Button } from './Button';
5
+ import './header.css';
6
+
7
+ export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => (
8
+ <header>
9
+ <div className="wrapper">
10
+ <div>
11
+ <svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
12
+ <g fill="none" fillRule="evenodd">
13
+ <path
14
+ d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
15
+ fill="#FFF"
16
+ />
17
+ <path
18
+ d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
19
+ fill="#555AB9"
20
+ />
21
+ <path
22
+ d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
23
+ fill="#91BAF8"
24
+ />
25
+ </g>
26
+ </svg>
27
+ <h1>Acme</h1>
28
+ </div>
29
+ <div>
30
+ {user ? (
31
+ <>
32
+ <span className="welcome">
33
+ Welcome, <b>{user.name}</b>!
34
+ </span>
35
+ <Button size="small" onClick={onLogout} label="Log out" />
36
+ </>
37
+ ) : (
38
+ <>
39
+ <Button size="small" onClick={onLogin} label="Log in" />
40
+ <Button primary size="small" onClick={onCreateAccount} label="Sign up" />
41
+ </>
42
+ )}
43
+ </div>
44
+ </div>
45
+ </header>
46
+ );
47
+
48
+ Header.propTypes = {
49
+ user: PropTypes.shape({
50
+ name: PropTypes.string.isRequired,
51
+ }),
52
+ onLogin: PropTypes.func.isRequired,
53
+ onLogout: PropTypes.func.isRequired,
54
+ onCreateAccount: PropTypes.func.isRequired,
55
+ };
56
+
57
+ Header.defaultProps = {
58
+ user: null,
59
+ };
@@ -0,0 +1,22 @@
1
+ import { Header } from './Header';
2
+
3
+ export default {
4
+ title: 'Example/Header',
5
+ component: Header,
6
+ // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
7
+ tags: ['docsPage'],
8
+ parameters: {
9
+ // More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
10
+ layout: 'fullscreen',
11
+ },
12
+ };
13
+
14
+ export const LoggedIn = {
15
+ args: {
16
+ user: {
17
+ name: 'Jane Doe',
18
+ },
19
+ },
20
+ };
21
+
22
+ export const LoggedOut = {};
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+
3
+ import { Header } from './Header';
4
+ import './page.css';
5
+
6
+ export const Page = () => {
7
+ const [user, setUser] = React.useState();
8
+
9
+ return (
10
+ <article>
11
+ <Header
12
+ user={user}
13
+ onLogin={() => setUser({ name: 'Jane Doe' })}
14
+ onLogout={() => setUser(undefined)}
15
+ onCreateAccount={() => setUser({ name: 'Jane Doe' })}
16
+ />
17
+
18
+ <section>
19
+ <h2>Pages in Storybook</h2>
20
+ <p>
21
+ We recommend building UIs with a{' '}
22
+ <a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
23
+ <strong>component-driven</strong>
24
+ </a>{' '}
25
+ process starting with atomic components and ending with pages.
26
+ </p>
27
+ <p>
28
+ Render pages with mock data. This makes it easy to build and review page states without
29
+ needing to navigate to them in your app. Here are some handy patterns for managing page
30
+ data in Storybook:
31
+ </p>
32
+ <ul>
33
+ <li>
34
+ Use a higher-level connected component. Storybook helps you compose such data from the
35
+ "args" of child component stories
36
+ </li>
37
+ <li>
38
+ Assemble data in the page component from your services. You can mock these services out
39
+ using Storybook.
40
+ </li>
41
+ </ul>
42
+ <p>
43
+ Get a guided tutorial on component-driven development at{' '}
44
+ <a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer">
45
+ Storybook tutorials
46
+ </a>
47
+ . Read more in the{' '}
48
+ <a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">
49
+ docs
50
+ </a>
51
+ .
52
+ </p>
53
+ <div className="tip-wrapper">
54
+ <span className="tip">Tip</span> Adjust the width of the canvas with the{' '}
55
+ <svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
56
+ <g fill="none" fillRule="evenodd">
57
+ <path
58
+ d="M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0 01-.5-.4V5.7c0-.3.2-.5.5-.5zm0-2.1h6.9c.3 0 .5.2.5.4v7a.5.5 0 01-1 0V4H1.5a.5.5 0 010-1zm0-2.1h9c.3 0 .5.2.5.4v9.1a.5.5 0 01-1 0V2H1.5a.5.5 0 010-1zm4.3 5.2H2V10h3.8V6.2z"
59
+ id="a"
60
+ fill="#999"
61
+ />
62
+ </g>
63
+ </svg>
64
+ Viewports addon in the toolbar
65
+ </div>
66
+ </section>
67
+ </article>
68
+ );
69
+ };
@@ -0,0 +1,25 @@
1
+ import { within, userEvent } from '@storybook/testing-library';
2
+
3
+ import { Page } from './Page';
4
+
5
+ export default {
6
+ title: 'Example/Page',
7
+ component: Page,
8
+ parameters: {
9
+ // More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
10
+ layout: 'fullscreen',
11
+ },
12
+ };
13
+
14
+ export const LoggedOut = {};
15
+
16
+ // More on interaction testing: https://storybook.js.org/docs/react/writing-tests/interaction-testing
17
+ export const LoggedIn = {
18
+ play: async ({ canvasElement }) => {
19
+ const canvas = within(canvasElement);
20
+ const loginButton = await canvas.getByRole('button', {
21
+ name: /Log in/i,
22
+ });
23
+ await userEvent.click(loginButton);
24
+ },
25
+ };
@@ -0,0 +1,47 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import { Button } from './Button';
4
+
5
+ // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
6
+ const meta: Meta<typeof Button> = {
7
+ title: 'Example/Button',
8
+ component: Button,
9
+ // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
10
+ tags: ['docsPage'],
11
+ // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
12
+ argTypes: {
13
+ backgroundColor: { control: 'color' },
14
+ },
15
+ };
16
+
17
+ export default meta;
18
+ type Story = StoryObj<typeof Button>;
19
+
20
+ // More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
21
+ export const Primary: Story = {
22
+ // More on args: https://storybook.js.org/docs/react/writing-stories/args
23
+ args: {
24
+ primary: true,
25
+ label: 'Button',
26
+ },
27
+ };
28
+
29
+ export const Secondary: Story = {
30
+ args: {
31
+ label: 'Button',
32
+ },
33
+ };
34
+
35
+ export const Large: Story = {
36
+ args: {
37
+ size: 'large',
38
+ label: 'Button',
39
+ },
40
+ };
41
+
42
+ export const Small: Story = {
43
+ args: {
44
+ size: 'small',
45
+ label: 'Button',
46
+ },
47
+ };
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import './button.css';
3
+
4
+ interface ButtonProps {
5
+ /**
6
+ * Is this the principal call to action on the page?
7
+ */
8
+ primary?: boolean;
9
+ /**
10
+ * What background color to use
11
+ */
12
+ backgroundColor?: string;
13
+ /**
14
+ * How large should the button be?
15
+ */
16
+ size?: 'small' | 'medium' | 'large';
17
+ /**
18
+ * Button contents
19
+ */
20
+ label: string;
21
+ /**
22
+ * Optional click handler
23
+ */
24
+ onClick?: () => void;
25
+ }
26
+
27
+ /**
28
+ * Primary UI component for user interaction
29
+ */
30
+ export const Button = ({
31
+ primary = false,
32
+ size = 'medium',
33
+ backgroundColor,
34
+ label,
35
+ ...props
36
+ }: ButtonProps) => {
37
+ const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
38
+ return (
39
+ <button
40
+ type="button"
41
+ className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
42
+ style={{ backgroundColor }}
43
+ {...props}
44
+ >
45
+ {label}
46
+ </button>
47
+ );
48
+ };
@@ -0,0 +1,26 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Header } from './Header';
3
+
4
+ const meta: Meta<typeof Header> = {
5
+ title: 'Example/Header',
6
+ component: Header,
7
+ // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
8
+ tags: ['docsPage'],
9
+ parameters: {
10
+ // More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
11
+ layout: 'fullscreen',
12
+ },
13
+ };
14
+
15
+ export default meta;
16
+ type Story = StoryObj<typeof Header>;
17
+
18
+ export const LoggedIn: Story = {
19
+ args: {
20
+ user: {
21
+ name: 'Jane Doe',
22
+ },
23
+ },
24
+ };
25
+
26
+ export const LoggedOut: Story = {};
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+
3
+ import { Button } from './Button';
4
+ import './header.css';
5
+
6
+ type User = {
7
+ name: string;
8
+ };
9
+
10
+ interface HeaderProps {
11
+ user?: User;
12
+ onLogin: () => void;
13
+ onLogout: () => void;
14
+ onCreateAccount: () => void;
15
+ }
16
+
17
+ export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => (
18
+ <header>
19
+ <div className="wrapper">
20
+ <div>
21
+ <svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
22
+ <g fill="none" fillRule="evenodd">
23
+ <path
24
+ d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
25
+ fill="#FFF"
26
+ />
27
+ <path
28
+ d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
29
+ fill="#555AB9"
30
+ />
31
+ <path
32
+ d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
33
+ fill="#91BAF8"
34
+ />
35
+ </g>
36
+ </svg>
37
+ <h1>Acme</h1>
38
+ </div>
39
+ <div>
40
+ {user ? (
41
+ <>
42
+ <span className="welcome">
43
+ Welcome, <b>{user.name}</b>!
44
+ </span>
45
+ <Button size="small" onClick={onLogout} label="Log out" />
46
+ </>
47
+ ) : (
48
+ <>
49
+ <Button size="small" onClick={onLogin} label="Log in" />
50
+ <Button primary size="small" onClick={onCreateAccount} label="Sign up" />
51
+ </>
52
+ )}
53
+ </div>
54
+ </div>
55
+ </header>
56
+ );
@@ -0,0 +1,29 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { within, userEvent } from '@storybook/testing-library';
3
+
4
+ import { Page } from './Page';
5
+
6
+ const meta: Meta<typeof Page> = {
7
+ title: 'Example/Page',
8
+ component: Page,
9
+ parameters: {
10
+ // More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
11
+ layout: 'fullscreen',
12
+ },
13
+ };
14
+
15
+ export default meta;
16
+ type Story = StoryObj<typeof Page>;
17
+
18
+ export const LoggedOut: Story = {};
19
+
20
+ // More on interaction testing: https://storybook.js.org/docs/react/writing-tests/interaction-testing
21
+ export const LoggedIn: Story = {
22
+ play: async ({ canvasElement }) => {
23
+ const canvas = within(canvasElement);
24
+ const loginButton = await canvas.getByRole('button', {
25
+ name: /Log in/i,
26
+ });
27
+ await userEvent.click(loginButton);
28
+ },
29
+ };
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+
3
+ import { Header } from './Header';
4
+ import './page.css';
5
+
6
+ type User = {
7
+ name: string;
8
+ };
9
+
10
+ export const Page: React.VFC = () => {
11
+ const [user, setUser] = React.useState<User>();
12
+
13
+ return (
14
+ <article>
15
+ <Header
16
+ user={user}
17
+ onLogin={() => setUser({ name: 'Jane Doe' })}
18
+ onLogout={() => setUser(undefined)}
19
+ onCreateAccount={() => setUser({ name: 'Jane Doe' })}
20
+ />
21
+
22
+ <section>
23
+ <h2>Pages in Storybook</h2>
24
+ <p>
25
+ We recommend building UIs with a{' '}
26
+ <a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
27
+ <strong>component-driven</strong>
28
+ </a>{' '}
29
+ process starting with atomic components and ending with pages.
30
+ </p>
31
+ <p>
32
+ Render pages with mock data. This makes it easy to build and review page states without
33
+ needing to navigate to them in your app. Here are some handy patterns for managing page
34
+ data in Storybook:
35
+ </p>
36
+ <ul>
37
+ <li>
38
+ Use a higher-level connected component. Storybook helps you compose such data from the
39
+ "args" of child component stories
40
+ </li>
41
+ <li>
42
+ Assemble data in the page component from your services. You can mock these services out
43
+ using Storybook.
44
+ </li>
45
+ </ul>
46
+ <p>
47
+ Get a guided tutorial on component-driven development at{' '}
48
+ <a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer">
49
+ Storybook tutorials
50
+ </a>
51
+ . Read more in the{' '}
52
+ <a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">
53
+ docs
54
+ </a>
55
+ .
56
+ </p>
57
+ <div className="tip-wrapper">
58
+ <span className="tip">Tip</span> Adjust the width of the canvas with the{' '}
59
+ <svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
60
+ <g fill="none" fillRule="evenodd">
61
+ <path
62
+ d="M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0 01-.5-.4V5.7c0-.3.2-.5.5-.5zm0-2.1h6.9c.3 0 .5.2.5.4v7a.5.5 0 01-1 0V4H1.5a.5.5 0 010-1zm0-2.1h9c.3 0 .5.2.5.4v9.1a.5.5 0 01-1 0V2H1.5a.5.5 0 010-1zm4.3 5.2H2V10h3.8V6.2z"
63
+ id="a"
64
+ fill="#999"
65
+ />
66
+ </g>
67
+ </svg>
68
+ Viewports addon in the toolbar
69
+ </div>
70
+ </section>
71
+ </article>
72
+ );
73
+ };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ export const Button = ({ onClick, label }) => (
5
+ <button type="button" onClick={onClick}>
6
+ {label}
7
+ </button>
8
+ );
9
+
10
+ Button.propTypes = {
11
+ onClick: PropTypes.func.isRequired,
12
+ label: PropTypes.string.isRequired,
13
+ };