@storybook/vue3 7.0.0-alpha.5 → 7.0.0-alpha.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-YPCW34O2.mjs +4 -0
- package/dist/config.d.ts +21 -0
- package/dist/config.js +4 -0
- package/dist/config.mjs +1 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +4 -0
- package/dist/index.mjs +1 -0
- package/dist/render-913dae32.d.ts +14 -0
- package/jest.config.js +11 -0
- package/package.json +49 -15
- package/preview.js +1 -1
- package/template/cli/Button.stories.js +48 -0
- package/template/cli/Button.vue +52 -0
- package/template/cli/Header.stories.js +41 -0
- package/template/cli/Header.vue +41 -0
- package/template/cli/Page.stories.js +30 -0
- package/template/cli/Page.vue +88 -0
- package/template/components/Button.vue +52 -0
- package/template/components/Form.vue +44 -0
- package/template/components/Html.vue +20 -0
- package/template/components/Pre.vue +34 -0
- package/template/components/button.css +30 -0
- package/template/components/index.js +9 -0
- package/template/stories/GlobalUsage.stories.js +29 -0
- package/template/stories/GlobalUsage.vue +3 -0
- package/template/stories/OverrideArgs.stories.js +43 -0
- package/template/stories/OverrideArgs.vue +40 -0
- package/template/stories/decorators.stories.js +66 -0
- package/template/stories/preview.js +13 -0
- package/template/stories/vue3-mdx.stories.mdx +46 -0
- package/LICENSE +0 -21
- package/dist/cjs/config.js +0 -36
- package/dist/cjs/docs/config.js +0 -21
- package/dist/cjs/docs/extractArgTypes.js +0 -53
- package/dist/cjs/index.js +0 -91
- package/dist/cjs/preview/config.js +0 -33
- package/dist/cjs/preview/decorateStory.js +0 -66
- package/dist/cjs/preview/globals.js +0 -11
- package/dist/cjs/preview/index.js +0 -67
- package/dist/cjs/preview/render.js +0 -84
- package/dist/cjs/preview/types-6-0.js +0 -5
- package/dist/cjs/preview/types-7-0.js +0 -5
- package/dist/cjs/preview/types.js +0 -5
- package/dist/esm/config.js +0 -6
- package/dist/esm/docs/config.js +0 -10
- package/dist/esm/docs/extractArgTypes.js +0 -42
- package/dist/esm/index.js +0 -4
- package/dist/esm/preview/config.js +0 -5
- package/dist/esm/preview/decorateStory.js +0 -58
- package/dist/esm/preview/globals.js +0 -6
- package/dist/esm/preview/index.js +0 -37
- package/dist/esm/preview/render.js +0 -66
- package/dist/esm/preview/types-6-0.js +0 -1
- package/dist/esm/preview/types-7-0.js +0 -1
- package/dist/esm/preview/types.js +0 -1
- package/dist/types/config.d.ts +0 -10
- package/dist/types/docs/config.d.ts +0 -9
- package/dist/types/docs/extractArgTypes.d.ts +0 -2
- package/dist/types/index.d.ts +0 -2
- package/dist/types/preview/config.d.ts +0 -5
- package/dist/types/preview/decorateStory.d.ts +0 -3
- package/dist/types/preview/globals.d.ts +0 -1
- package/dist/types/preview/index.d.ts +0 -30
- package/dist/types/preview/render.d.ts +0 -6
- package/dist/types/preview/types-6-0.d.ts +0 -35
- package/dist/types/preview/types-7-0.d.ts +0 -9
- package/dist/types/preview/types.d.ts +0 -15
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{h as f}from"vue";import{sanitizeStoryContextUpdate as R}from"@storybook/store";function l(e){return typeof e=="function"?{render:e,name:e.name}:e}function c(e,o){let r=e;return r==null?null:o?{...l(r),components:{...r.components||{},story:o}}:{render(){return f(r)}}}function F(e,o){return o.reduce((r,p)=>u=>{let t,n=p(m=>(t=r({...u,...R(m)}),t),u);return t||(t=r(u)),n===t?t:c(n,t)},r=>c(e(r)))}import{dedent as C}from"ts-dedent";import{createApp as V,h as i}from"vue";var A=(e,o)=>{let{id:r,component:p}=o;if(!p)throw new Error(`Unable to render story ${r} as the component annotation is missing from the default export`);return i(p,e)},d=e=>{},L=e=>{d=e},s=new Map;function b({title:e,name:o,storyFn:r,showMain:p,showError:u,showException:t},n){let m,y=V({unmounted(){s.delete(n)},render(){return s.set(n,y),d(y),i(m)}});if(y.config.errorHandler=a=>t(a),m=r(),!m){u({title:`Expecting a Vue component from the story: "${o}" of "${e}".`,description:C`
|
|
2
|
+
Did you forget to return the Vue component from the story?
|
|
3
|
+
Use "() => ({ template: '<my-comp></my-comp>' })" or "() => ({ components: MyComp, template: '<my-comp></my-comp>' })" when defining the story.
|
|
4
|
+
`});return}p(),s.get(n)?.unmount(),y.mount(n)}export{F as a,A as b,L as c,b as d};
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as lib_docs_tools_dist from 'lib/docs-tools/dist';
|
|
2
|
+
import * as lib_types_dist from 'lib/types/dist';
|
|
3
|
+
import { V as VueRenderer } from './render-913dae32.js';
|
|
4
|
+
export { r as render, a as renderToCanvas } from './render-913dae32.js';
|
|
5
|
+
import { LegacyStoryFn, DecoratorFunction } from '@storybook/types';
|
|
6
|
+
import 'vue';
|
|
7
|
+
|
|
8
|
+
declare const argTypesEnhancers: (<TRenderer extends lib_types_dist.Renderer>(context: lib_types_dist.StoryContextForEnhancers<TRenderer, lib_types_dist.Args>) => lib_types_dist.StrictArgTypes<lib_types_dist.Args>)[];
|
|
9
|
+
|
|
10
|
+
declare function decorateStory(storyFn: LegacyStoryFn<VueRenderer>, decorators: DecoratorFunction<VueRenderer>[]): LegacyStoryFn<VueRenderer>;
|
|
11
|
+
|
|
12
|
+
declare const parameters: {
|
|
13
|
+
docs: {
|
|
14
|
+
inlineStories: boolean;
|
|
15
|
+
extractArgTypes: lib_docs_tools_dist.ArgTypesExtractor;
|
|
16
|
+
extractComponentDescription: typeof lib_docs_tools_dist.extractComponentDescription;
|
|
17
|
+
};
|
|
18
|
+
framework: "vue3";
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { decorateStory as applyDecorators, argTypesEnhancers, parameters };
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";var f=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var D=(e,t)=>{for(var r in t)f(e,r,{get:t[r],enumerable:!0})},L=(e,t,r,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of v(t))!w.call(e,o)&&o!==r&&f(e,o,{get:()=>t[o],enumerable:!(p=k(t,o))||p.enumerable});return e};var O=e=>L(f({},"__esModule",{value:!0}),e);var P={};D(P,{applyDecorators:()=>A,argTypesEnhancers:()=>C,parameters:()=>M,render:()=>S,renderToCanvas:()=>V});module.exports=O(P);var i=require("@storybook/docs-tools");var a=require("@storybook/docs-tools"),U=["props","events","slots","methods"],R=e=>{if(!(0,a.hasDocgen)(e))return null;let t={};return U.forEach(r=>{(0,a.extractComponentProps)(e,r).forEach(({propDef:o,docgenInfo:n,jsDocTags:s})=>{let{name:m,type:u,description:c,defaultValue:d,required:E}=o,b=r==="props"?(0,a.convert)(n):{name:"void"};t[m]={name:m,description:c,type:{required:E,...b},table:{type:u,jsDocTags:s,defaultValue:d,category:r}}})}),t};var g={docs:{inlineStories:!0,extractArgTypes:R,extractComponentDescription:i.extractComponentDescription}},C=[i.enhanceArgTypes];var x=require("ts-dedent"),y=require("vue"),S=(e,t)=>{let{id:r,component:p}=t;if(!p)throw new Error(`Unable to render story ${r} as the component annotation is missing from the default export`);return(0,y.h)(p,e)},$=e=>{};var l=new Map;function V({title:e,name:t,storyFn:r,showMain:p,showError:o,showException:n},s){var c;let m,u=(0,y.createApp)({unmounted(){l.delete(s)},render(){return l.set(s,u),$(u),(0,y.h)(m)}});if(u.config.errorHandler=d=>n(d),m=r(),!m){o({title:`Expecting a Vue component from the story: "${t}" of "${e}".`,description:x.dedent`
|
|
2
|
+
Did you forget to return the Vue component from the story?
|
|
3
|
+
Use "() => ({ template: '<my-comp></my-comp>' })" or "() => ({ components: MyComp, template: '<my-comp></my-comp>' })" when defining the story.
|
|
4
|
+
`});return}p(),(c=l.get(s))==null||c.unmount(),u.mount(s)}var T=require("vue"),F=require("@storybook/store");function z(e){return typeof e=="function"?{render:e,name:e.name}:e}function h(e,t){let r=e;return r==null?null:t?{...z(r),components:{...r.components||{},story:t}}:{render(){return(0,T.h)(r)}}}function A(e,t){return t.reduce((r,p)=>o=>{let n,s=p(m=>(n=r({...o,...(0,F.sanitizeStoryContextUpdate)(m)}),n),o);return n||(n=r(o)),s===n?n:h(s,n)},r=>h(e(r)))}var M={framework:"vue3",...g};0&&(module.exports={applyDecorators,argTypesEnhancers,parameters,render,renderToCanvas});
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as l,b as u,d as x}from"./chunk-YPCW34O2.mjs";import{extractComponentDescription as E,enhanceArgTypes as S}from"@storybook/docs-tools";import{hasDocgen as T,extractComponentProps as g,convert as h}from"@storybook/docs-tools";var A=["props","events","slots","methods"],s=e=>{if(!T(e))return null;let t={};return A.forEach(r=>{g(e,r).forEach(({propDef:a,docgenInfo:n,jsDocTags:c})=>{let{name:o,type:m,description:y,defaultValue:f,required:i}=a,d=r==="props"?h(n):{name:"void"};t[o]={name:o,description:y,type:{required:i,...d},table:{type:m,jsDocTags:c,defaultValue:f,category:r}}})}),t};var p={docs:{inlineStories:!0,extractArgTypes:s,extractComponentDescription:E}},v=[S];var w={framework:"vue3",...p};export{l as applyDecorators,v as argTypesEnhancers,w as parameters,u as render,x as renderToCanvas};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as _storybook_types from '@storybook/types';
|
|
2
|
+
import { Addon_ClientStoryApi, Addon_Loadable, Args, ComponentAnnotations, AnnotatedStoryFn, ArgsStoryFn, ArgsFromMeta, StoryAnnotations, StrictArgs, DecoratorFunction, LoaderFunction, StoryContext as StoryContext$1 } from '@storybook/types';
|
|
3
|
+
export { ArgTypes, Args, Parameters, StrictArgs } from '@storybook/types';
|
|
4
|
+
import { App, ComponentOptions, FunctionalComponent, ConcreteComponent } from 'vue';
|
|
5
|
+
import { V as VueRenderer } from './render-913dae32.js';
|
|
6
|
+
export { V as VueRenderer, s as setup } from './render-913dae32.js';
|
|
7
|
+
import { Simplify, SetOptional } from 'type-fest';
|
|
8
|
+
|
|
9
|
+
interface ClientApi extends Addon_ClientStoryApi<VueRenderer['storyResult']> {
|
|
10
|
+
configure(loader: Addon_Loadable, module: NodeModule): void;
|
|
11
|
+
forceReRender(): void;
|
|
12
|
+
raw: () => any;
|
|
13
|
+
load: (...args: any[]) => void;
|
|
14
|
+
app: App;
|
|
15
|
+
}
|
|
16
|
+
declare const storiesOf: ClientApi['storiesOf'];
|
|
17
|
+
declare const configure: ClientApi['configure'];
|
|
18
|
+
declare const forceReRender: () => void;
|
|
19
|
+
declare const raw: ((...args: any[]) => never) | (() => _storybook_types.Store_BoundStory<VueRenderer>[]);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Metadata to configure the stories for a component.
|
|
23
|
+
*
|
|
24
|
+
* @see [Default export](https://storybook.js.org/docs/formats/component-story-format/#default-export)
|
|
25
|
+
*/
|
|
26
|
+
type Meta<TCmpOrArgs = Args> = ComponentAnnotations<VueRenderer, ComponentPropsOrProps<TCmpOrArgs>>;
|
|
27
|
+
/**
|
|
28
|
+
* Story function that represents a CSFv2 component example.
|
|
29
|
+
*
|
|
30
|
+
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
|
|
31
|
+
*/
|
|
32
|
+
type StoryFn<TCmpOrArgs = Args> = AnnotatedStoryFn<VueRenderer, ComponentPropsOrProps<TCmpOrArgs>>;
|
|
33
|
+
/**
|
|
34
|
+
* Story function that represents a CSFv3 component example.
|
|
35
|
+
*
|
|
36
|
+
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
|
|
37
|
+
*/
|
|
38
|
+
type StoryObj<TMetaOrCmpOrArgs = Args> = TMetaOrCmpOrArgs extends {
|
|
39
|
+
render?: ArgsStoryFn<VueRenderer, any>;
|
|
40
|
+
component?: infer Component;
|
|
41
|
+
args?: infer DefaultArgs;
|
|
42
|
+
} ? Simplify<ComponentProps<Component> & ArgsFromMeta<VueRenderer, TMetaOrCmpOrArgs>> extends infer TArgs ? StoryAnnotations<VueRenderer, TArgs, SetOptional<TArgs, Extract<keyof TArgs, keyof DefaultArgs>>> : never : StoryAnnotations<VueRenderer, ComponentPropsOrProps<TMetaOrCmpOrArgs>>;
|
|
43
|
+
type ComponentProps<C> = C extends ComponentOptions<infer P> ? P : C extends FunctionalComponent<infer P> ? P : unknown;
|
|
44
|
+
type ComponentPropsOrProps<TCmpOrArgs> = TCmpOrArgs extends ConcreteComponent<any> ? unknown extends ComponentProps<TCmpOrArgs> ? TCmpOrArgs : ComponentProps<TCmpOrArgs> : TCmpOrArgs;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Use `StoryFn` instead.
|
|
47
|
+
* Use `StoryObj` if you want to migrate to CSF3, which uses objects instead of functions to represent stories.
|
|
48
|
+
* You can read more about the CSF3 format here: https://storybook.js.org/blog/component-story-format-3-0/
|
|
49
|
+
*
|
|
50
|
+
* Story function that represents a CSFv2 component example.
|
|
51
|
+
*
|
|
52
|
+
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
|
|
53
|
+
*/
|
|
54
|
+
type Story<TArgs = Args> = StoryFn<TArgs>;
|
|
55
|
+
type Decorator<TArgs = StrictArgs> = DecoratorFunction<VueRenderer, TArgs>;
|
|
56
|
+
type Loader<TArgs = StrictArgs> = LoaderFunction<VueRenderer, TArgs>;
|
|
57
|
+
type StoryContext<TArgs = StrictArgs> = StoryContext$1<VueRenderer, TArgs>;
|
|
58
|
+
|
|
59
|
+
export { Decorator, Loader, Meta, Story, StoryContext, StoryFn, StoryObj, configure, forceReRender, raw, storiesOf };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";var L=Object.create;var d=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var M=(e,r)=>{for(var o in r)d(e,o,{get:r[o],enumerable:!0})},f=(e,r,o,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of _(r))!E.call(e,t)&&t!==o&&d(e,t,{get:()=>r[t],enumerable:!(n=T(r,t))||n.enumerable});return e};var D=(e,r,o)=>(o=e!=null?L(k(e)):{},f(r||!e||!e.__esModule?d(o,"default",{value:e,enumerable:!0}):o,e)),U=e=>f(d({},"__esModule",{value:!0}),e);var H={};M(H,{configure:()=>N,forceReRender:()=>W,raw:()=>B,setup:()=>F,storiesOf:()=>K});module.exports=U(H);var l=D(require("global")),{window:$}=l.default;$.STORYBOOK_ENV="vue3";var w=require("@storybook/core-client");var C=require("vue"),V=require("@storybook/store");function z(e){return typeof e=="function"?{render:e,name:e.name}:e}function R(e,r){let o=e;return o==null?null:r?{...z(o),components:{...o.components||{},story:r}}:{render(){return(0,C.h)(o)}}}function g(e,r){return r.reduce((o,n)=>t=>{let p,u=n(i=>(p=o({...t,...(0,V.sanitizeStoryContextUpdate)(i)}),p),t);return p||(p=o(t)),u===p?p:R(u,p)},o=>R(e(o)))}var A=require("ts-dedent"),m=require("vue"),S=(e,r)=>{let{id:o,component:n}=r;if(!n)throw new Error(`Unable to render story ${o} as the component annotation is missing from the default export`);return(0,m.h)(n,e)},x=e=>{},F=e=>{x=e},a=new Map;function h({title:e,name:r,storyFn:o,showMain:n,showError:t,showException:p},u){var c;let i,s=(0,m.createApp)({unmounted(){a.delete(u)},render(){return a.set(u,s),x(s),(0,m.h)(i)}});if(s.config.errorHandler=v=>p(v),i=o(),!i){t({title:`Expecting a Vue component from the story: "${r}" of "${e}".`,description:A.dedent`
|
|
2
|
+
Did you forget to return the Vue component from the story?
|
|
3
|
+
Use "() => ({ template: '<my-comp></my-comp>' })" or "() => ({ components: MyComp, template: '<my-comp></my-comp>' })" when defining the story.
|
|
4
|
+
`});return}n(),(c=a.get(u))==null||c.unmount(),s.mount(u)}var O="vue3",y=(0,w.start)(h,{decorateStory:g,render:S}),K=(e,r)=>y.clientApi.storiesOf(e,r).addParameters({framework:O}),N=(...e)=>y.configure(O,...e),{forceReRender:W}=y,{raw:B}=y.clientApi;var b;(b=module==null?void 0:module.hot)==null||b.decline();0&&(module.exports={configure,forceReRender,raw,setup,storiesOf});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r,b as t,c as d,d as i}from"./chunk-YPCW34O2.mjs";import s from"global";var{window:a}=s;a.STORYBOOK_ENV="vue3";import{start as f}from"@storybook/core-client";var n="vue3",e=f(i,{decorateStory:r,render:t}),A=(o,p)=>e.clientApi.storiesOf(o,p).addParameters({framework:n}),y=(...o)=>e.configure(n,...o),{forceReRender:R}=e,{raw:x}=e.clientApi;module?.hot?.decline();export{y as configure,R as forceReRender,x as raw,d as setup,A as storiesOf};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { WebRenderer, ArgsStoryFn, Store_RenderContext } from '@storybook/types';
|
|
2
|
+
import { ConcreteComponent } from 'vue';
|
|
3
|
+
|
|
4
|
+
type StoryFnVueReturnType = ConcreteComponent<any>;
|
|
5
|
+
interface VueRenderer extends WebRenderer {
|
|
6
|
+
component: Omit<ConcreteComponent<this['T']>, 'props'>;
|
|
7
|
+
storyResult: StoryFnVueReturnType;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare const render: ArgsStoryFn<VueRenderer>;
|
|
11
|
+
declare const setup: (fn: (app: any) => void) => void;
|
|
12
|
+
declare function renderToCanvas({ title, name, storyFn, showMain, showError, showException }: Store_RenderContext<VueRenderer>, canvasElement: VueRenderer['canvasElement']): void;
|
|
13
|
+
|
|
14
|
+
export { VueRenderer as V, renderToCanvas as a, render as r, setup as s };
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const baseConfig = require('../../jest.config.browser');
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
...baseConfig,
|
|
6
|
+
displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
|
|
7
|
+
transform: {
|
|
8
|
+
...baseConfig.transform,
|
|
9
|
+
'^.+\\.vue$': '@vue/vue3-jest',
|
|
10
|
+
},
|
|
11
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/vue3",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.51",
|
|
4
4
|
"description": "Storybook Vue 3 renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -19,44 +19,78 @@
|
|
|
19
19
|
"url": "https://opencollective.com/storybook"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"require": "./dist/index.js",
|
|
25
|
+
"import": "./dist/index.mjs",
|
|
26
|
+
"types": "./dist/index.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"./preview": {
|
|
29
|
+
"require": "./dist/config.js",
|
|
30
|
+
"import": "./dist/config.mjs",
|
|
31
|
+
"types": "./dist/config.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": {
|
|
34
|
+
"require": "./package.json",
|
|
35
|
+
"import": "./package.json",
|
|
36
|
+
"types": "./package.json"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"main": "dist/index.js",
|
|
40
|
+
"module": "dist/index.mjs",
|
|
41
|
+
"types": "dist/index.d.ts",
|
|
25
42
|
"files": [
|
|
26
|
-
"bin/**/*",
|
|
27
43
|
"dist/**/*",
|
|
44
|
+
"template/**/*",
|
|
28
45
|
"README.md",
|
|
29
46
|
"*.js",
|
|
30
47
|
"*.d.ts"
|
|
31
48
|
],
|
|
32
49
|
"scripts": {
|
|
33
|
-
"
|
|
50
|
+
"check": "vue-tsc --noEmit",
|
|
51
|
+
"prep": "../../../scripts/prepare/bundle.ts"
|
|
34
52
|
},
|
|
35
53
|
"dependencies": {
|
|
36
|
-
"@storybook/addons": "7.0.0-alpha.
|
|
37
|
-
"@storybook/core-client": "7.0.0-alpha.
|
|
38
|
-
"@storybook/
|
|
39
|
-
"@storybook/
|
|
40
|
-
"@storybook/
|
|
41
|
-
"core-js": "^3.8.2",
|
|
54
|
+
"@storybook/addons": "7.0.0-alpha.51",
|
|
55
|
+
"@storybook/core-client": "7.0.0-alpha.51",
|
|
56
|
+
"@storybook/docs-tools": "7.0.0-alpha.51",
|
|
57
|
+
"@storybook/store": "7.0.0-alpha.51",
|
|
58
|
+
"@storybook/types": "7.0.0-alpha.51",
|
|
42
59
|
"global": "^4.4.0",
|
|
43
60
|
"react": "16.14.0",
|
|
44
61
|
"react-dom": "16.14.0",
|
|
45
|
-
"ts-dedent": "^2.0.0"
|
|
62
|
+
"ts-dedent": "^2.0.0",
|
|
63
|
+
"type-fest": "2.19.0"
|
|
46
64
|
},
|
|
47
65
|
"devDependencies": {
|
|
48
|
-
"
|
|
66
|
+
"@digitak/esrun": "^3.2.2",
|
|
67
|
+
"@vue/vue3-jest": "29",
|
|
68
|
+
"typescript": "^4.9.3",
|
|
69
|
+
"vue": "^3.2.41",
|
|
70
|
+
"vue-tsc": "^1.0.8"
|
|
49
71
|
},
|
|
50
72
|
"peerDependencies": {
|
|
51
73
|
"@babel/core": "*",
|
|
52
74
|
"babel-loader": "^7.0.0 || ^8.0.0",
|
|
53
75
|
"vue": "^3.0.0"
|
|
54
76
|
},
|
|
77
|
+
"peerDependenciesMeta": {
|
|
78
|
+
"babel-loader": {
|
|
79
|
+
"optional": true
|
|
80
|
+
}
|
|
81
|
+
},
|
|
55
82
|
"engines": {
|
|
56
83
|
"node": ">=10.13.0"
|
|
57
84
|
},
|
|
58
85
|
"publishConfig": {
|
|
59
86
|
"access": "public"
|
|
60
87
|
},
|
|
61
|
-
"
|
|
88
|
+
"bundler": {
|
|
89
|
+
"entries": [
|
|
90
|
+
"./src/index.ts",
|
|
91
|
+
"./src/config.ts"
|
|
92
|
+
],
|
|
93
|
+
"platform": "browser"
|
|
94
|
+
},
|
|
95
|
+
"gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
|
|
62
96
|
}
|
package/preview.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './dist/
|
|
1
|
+
export * from './dist/config.mjs';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import MyButton from './Button.vue';
|
|
2
|
+
|
|
3
|
+
// More on how to set up stories at: https://storybook.js.org/docs/7.0/vue/writing-stories/introduction
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Example/Button',
|
|
6
|
+
component: MyButton,
|
|
7
|
+
tags: ['docsPage'],
|
|
8
|
+
argTypes: {
|
|
9
|
+
backgroundColor: {
|
|
10
|
+
control: 'color',
|
|
11
|
+
},
|
|
12
|
+
onClick: {},
|
|
13
|
+
size: {
|
|
14
|
+
control: {
|
|
15
|
+
type: 'select',
|
|
16
|
+
},
|
|
17
|
+
options: ['small', 'medium', 'large'],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// More on writing stories with args: https://storybook.js.org/docs/7.0/vue/writing-stories/args
|
|
23
|
+
export const Primary = {
|
|
24
|
+
args: {
|
|
25
|
+
primary: true,
|
|
26
|
+
label: 'Button',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Secondary = {
|
|
31
|
+
args: {
|
|
32
|
+
label: 'Button',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Large = {
|
|
37
|
+
args: {
|
|
38
|
+
size: 'large',
|
|
39
|
+
label: 'Button',
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const Small = {
|
|
44
|
+
args: {
|
|
45
|
+
size: 'small',
|
|
46
|
+
label: 'Button',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<button type="button" :class="classes" @click="onClick" :style="style">{{ label }}</button>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import './button.css';
|
|
7
|
+
import { reactive, computed } from 'vue';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
name: 'my-button',
|
|
11
|
+
|
|
12
|
+
props: {
|
|
13
|
+
label: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
primary: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false,
|
|
20
|
+
},
|
|
21
|
+
size: {
|
|
22
|
+
type: String,
|
|
23
|
+
validator: function (value) {
|
|
24
|
+
return ['small', 'medium', 'large'].indexOf(value) !== -1;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
backgroundColor: {
|
|
28
|
+
type: String,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
emits: ['click'],
|
|
33
|
+
|
|
34
|
+
setup(props, { emit }) {
|
|
35
|
+
props = reactive(props);
|
|
36
|
+
return {
|
|
37
|
+
classes: computed(() => ({
|
|
38
|
+
'storybook-button': true,
|
|
39
|
+
'storybook-button--primary': props.primary,
|
|
40
|
+
'storybook-button--secondary': !props.primary,
|
|
41
|
+
[`storybook-button--${props.size || 'medium'}`]: true,
|
|
42
|
+
})),
|
|
43
|
+
style: computed(() => ({
|
|
44
|
+
backgroundColor: props.backgroundColor,
|
|
45
|
+
})),
|
|
46
|
+
onClick() {
|
|
47
|
+
emit('click');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
</script>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import MyHeader from './Header.vue';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Example/Header',
|
|
5
|
+
component: MyHeader,
|
|
6
|
+
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/7.0/vue/writing-docs/docs-page
|
|
7
|
+
tags: ['docsPage'],
|
|
8
|
+
render: (args) => ({
|
|
9
|
+
// Components used in your story `template` are defined in the `components` object
|
|
10
|
+
components: {
|
|
11
|
+
MyHeader,
|
|
12
|
+
},
|
|
13
|
+
// The story's `args` need to be mapped into the template through the `setup()` method
|
|
14
|
+
setup() {
|
|
15
|
+
// Story args can be spread into the returned object
|
|
16
|
+
return {
|
|
17
|
+
...args,
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
// Then, the spread values can be accessed directly in the template
|
|
21
|
+
template: '<my-header :user="user" />',
|
|
22
|
+
}),
|
|
23
|
+
parameters: {
|
|
24
|
+
// More on how to position stories at: https://storybook.js.org/docs/7.0/vue/configure/story-layout
|
|
25
|
+
layout: 'fullscreen',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const LoggedIn = {
|
|
30
|
+
args: {
|
|
31
|
+
user: {
|
|
32
|
+
name: 'Jane Doe',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const LoggedOut = {
|
|
38
|
+
args: {
|
|
39
|
+
user: null,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<header>
|
|
3
|
+
<div class="wrapper">
|
|
4
|
+
<div>
|
|
5
|
+
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
|
6
|
+
<g fill="none" fill-rule="evenodd">
|
|
7
|
+
<path d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z" fill="#FFF" />
|
|
8
|
+
<path d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z" fill="#555AB9" />
|
|
9
|
+
<path d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z" fill="#91BAF8" />
|
|
10
|
+
</g>
|
|
11
|
+
</svg>
|
|
12
|
+
<h1>Acme</h1>
|
|
13
|
+
</div>
|
|
14
|
+
<div>
|
|
15
|
+
<span class="welcome" v-if="user">Welcome, <b>{{ user.name }}</b>!</span>
|
|
16
|
+
<my-button size="small" @click="$emit('logout')" label="Log out" v-if="user" />
|
|
17
|
+
<my-button size="small" @click="$emit('login')" label="Log in" v-if="!user" />
|
|
18
|
+
<my-button primary size="small" @click="$emit('createAccount')" label="Sign up" v-if="!user" />
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</header>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import './header.css';
|
|
26
|
+
import MyButton from './Button.vue';
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
name: 'my-header',
|
|
30
|
+
|
|
31
|
+
components: { MyButton },
|
|
32
|
+
|
|
33
|
+
props: {
|
|
34
|
+
user: {
|
|
35
|
+
type: Object,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
emits: ['login', 'logout', 'createAccount'],
|
|
40
|
+
};
|
|
41
|
+
</script>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { within, userEvent } from '@storybook/testing-library';
|
|
2
|
+
import MyPage from './Page.vue';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Example/Page',
|
|
6
|
+
component: MyPage,
|
|
7
|
+
parameters: {
|
|
8
|
+
// More on how to position stories at: https://storybook.js.org/docs/7.0/vue/configure/story-layout
|
|
9
|
+
layout: 'fullscreen',
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const LoggedOut = {};
|
|
14
|
+
|
|
15
|
+
// More on interaction testing: https://storybook.js.org/docs/7.0/vue/writing-tests/interaction-testing
|
|
16
|
+
export const LoggedIn = {
|
|
17
|
+
render: () => ({
|
|
18
|
+
components: {
|
|
19
|
+
MyPage,
|
|
20
|
+
},
|
|
21
|
+
template: '<my-page />',
|
|
22
|
+
}),
|
|
23
|
+
play: async ({ canvasElement }) => {
|
|
24
|
+
const canvas = within(canvasElement);
|
|
25
|
+
const loginButton = await canvas.getByRole('button', {
|
|
26
|
+
name: /Log in/i,
|
|
27
|
+
});
|
|
28
|
+
await userEvent.click(loginButton);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<article>
|
|
3
|
+
<my-header
|
|
4
|
+
:user="user"
|
|
5
|
+
@login="onLogin"
|
|
6
|
+
@logout="onLogout"
|
|
7
|
+
@createAccount="onCreateAccount"
|
|
8
|
+
/>
|
|
9
|
+
|
|
10
|
+
<section>
|
|
11
|
+
<h2>Pages in Storybook</h2>
|
|
12
|
+
<p>
|
|
13
|
+
We recommend building UIs with a
|
|
14
|
+
<a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
|
|
15
|
+
<strong>component-driven</strong>
|
|
16
|
+
</a>
|
|
17
|
+
process starting with atomic components and ending with pages.
|
|
18
|
+
</p>
|
|
19
|
+
<p>
|
|
20
|
+
Render pages with mock data. This makes it easy to build and review page states without
|
|
21
|
+
needing to navigate to them in your app. Here are some handy patterns for managing page data
|
|
22
|
+
in Storybook:
|
|
23
|
+
</p>
|
|
24
|
+
<ul>
|
|
25
|
+
<li>
|
|
26
|
+
Use a higher-level connected component. Storybook helps you compose such data from the
|
|
27
|
+
"args" of child component stories
|
|
28
|
+
</li>
|
|
29
|
+
<li>
|
|
30
|
+
Assemble data in the page component from your services. You can mock these services out
|
|
31
|
+
using Storybook.
|
|
32
|
+
</li>
|
|
33
|
+
</ul>
|
|
34
|
+
<p>
|
|
35
|
+
Get a guided tutorial on component-driven development at
|
|
36
|
+
<a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer"
|
|
37
|
+
>Storybook tutorials</a
|
|
38
|
+
>
|
|
39
|
+
. Read more in the
|
|
40
|
+
<a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">docs</a>
|
|
41
|
+
.
|
|
42
|
+
</p>
|
|
43
|
+
<div class="tip-wrapper">
|
|
44
|
+
<span class="tip">Tip</span>
|
|
45
|
+
Adjust the width of the canvas with the
|
|
46
|
+
<svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
|
|
47
|
+
<g fill="none" fill-rule="evenodd">
|
|
48
|
+
<path
|
|
49
|
+
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"
|
|
50
|
+
id="a"
|
|
51
|
+
fill="#999"
|
|
52
|
+
/>
|
|
53
|
+
</g>
|
|
54
|
+
</svg>
|
|
55
|
+
Viewports addon in the toolbar
|
|
56
|
+
</div>
|
|
57
|
+
</section>
|
|
58
|
+
</article>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<script>
|
|
62
|
+
import './page.css';
|
|
63
|
+
import MyHeader from './Header.vue';
|
|
64
|
+
|
|
65
|
+
export default {
|
|
66
|
+
name: 'my-page',
|
|
67
|
+
|
|
68
|
+
components: { MyHeader },
|
|
69
|
+
|
|
70
|
+
data() {
|
|
71
|
+
return {
|
|
72
|
+
user: null
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
methods: {
|
|
77
|
+
onLogin() {
|
|
78
|
+
this.user = { name: 'Jane Doe' };
|
|
79
|
+
},
|
|
80
|
+
onLogout() {
|
|
81
|
+
this.user = null;
|
|
82
|
+
},
|
|
83
|
+
onCreateAccount() {
|
|
84
|
+
this.user = { name: 'Jane Doe' };
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
</script>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<button type="button" :class="classes" @click="onClick" :style="style">{{ label }}</button>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import './button.css';
|
|
7
|
+
import { reactive, computed } from 'vue';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
name: 'my-button',
|
|
11
|
+
|
|
12
|
+
props: {
|
|
13
|
+
label: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
primary: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false,
|
|
20
|
+
},
|
|
21
|
+
size: {
|
|
22
|
+
type: String,
|
|
23
|
+
validator: function (value) {
|
|
24
|
+
return ['small', 'medium', 'large'].indexOf(value) !== -1;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
backgroundColor: {
|
|
28
|
+
type: String,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
emits: ['click'],
|
|
33
|
+
|
|
34
|
+
setup(props, { emit }) {
|
|
35
|
+
props = reactive(props);
|
|
36
|
+
return {
|
|
37
|
+
classes: computed(() => ({
|
|
38
|
+
'storybook-button': true,
|
|
39
|
+
'storybook-button--primary': props.primary,
|
|
40
|
+
'storybook-button--secondary': !props.primary,
|
|
41
|
+
[`storybook-button--${props.size || 'medium'}`]: true,
|
|
42
|
+
})),
|
|
43
|
+
style: computed(() => ({
|
|
44
|
+
backgroundColor: props.backgroundColor,
|
|
45
|
+
})),
|
|
46
|
+
onClick() {
|
|
47
|
+
emit('click');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
</script>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<form id="interaction-test-form" @submit.prevent="onSubmit">
|
|
3
|
+
<label>
|
|
4
|
+
Enter Value
|
|
5
|
+
<input type="text" data-testid="value" :value="value" required @click="setValue" />
|
|
6
|
+
</label>
|
|
7
|
+
<button type="submit">Submit</button>
|
|
8
|
+
<p v-if="complete">Completed!!</p>
|
|
9
|
+
</form>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
export default {
|
|
14
|
+
name: 'my-form',
|
|
15
|
+
|
|
16
|
+
props: {
|
|
17
|
+
onSuccess: {
|
|
18
|
+
type: Function,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
data() {
|
|
23
|
+
return {
|
|
24
|
+
value: '',
|
|
25
|
+
complete: false,
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
methods: {
|
|
30
|
+
setValue(event) {
|
|
31
|
+
this.value = event.target.value;
|
|
32
|
+
},
|
|
33
|
+
onSubmit() {
|
|
34
|
+
this.onSuccess(this.value);
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
this.complete = true;
|
|
37
|
+
}, 500);
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
this.complete = false;
|
|
40
|
+
}, 1500);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
</script>
|