@storybook/vue3 7.1.0-alpha.8 → 7.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-SRVBJOBI.mjs +6 -0
- package/dist/config.d.ts +6 -17
- package/dist/config.js +3 -44
- package/dist/config.mjs +11 -43
- package/dist/index.d.ts +10 -11
- package/dist/index.js +1 -1
- package/dist/index.mjs +8 -1
- package/dist/render-32b7dd3f.d.ts +148 -0
- package/package.json +19 -15
- package/src/typings.d.ts +1 -0
- package/template/cli/js/Header.vue +1 -1
- package/template/cli/js/Page.vue +1 -1
- package/template/cli/ts-3-8/Header.vue +1 -1
- package/template/cli/ts-3-8/Page.vue +8 -5
- package/template/cli/ts-4-9/Header.vue +1 -1
- package/template/cli/ts-4-9/Page.vue +8 -5
- package/template/components/Form.vue +1 -4
- package/template/stories/preview.js +29 -4
- package/template/{stories → stories_vue3-vite-default-ts}/CustomRenderFunctionalComponent.stories.ts +0 -2
- package/template/{stories → stories_vue3-vite-default-ts}/CustomRenderOptionsArgsFromData.stories.ts +0 -2
- package/template/stories_vue3-vite-default-ts/GlobalSetup.stories.ts +55 -0
- package/template/stories_vue3-vite-default-ts/GlobalSetup.vue +6 -0
- package/template/stories_vue3-vite-default-ts/GlobalUsage.vue +3 -0
- package/template/{stories → stories_vue3-vite-default-ts}/OverrideArgs.stories.js +3 -1
- package/template/{stories → stories_vue3-vite-default-ts}/ReactiveArgs.stories.ts +5 -3
- package/template/{stories → stories_vue3-vite-default-ts}/ReactiveDecorators.stories.ts +2 -26
- package/template/{stories → stories_vue3-vite-default-ts}/ScopedSlots.stories.ts +2 -2
- package/template/stories_vue3-vite-default-ts/SourceDecorator.stories.ts +46 -0
- package/template/stories_vue3-vite-default-ts/preview.ts +12 -0
- package/dist/chunk-7CGPMEMZ.mjs +0 -1
- package/dist/render-189b3692.d.ts +0 -14
- package/template/stories/CustomRenderOptionsArgsFromProps.stories.ts +0 -33
- package/template/stories/GlobalUsage.vue +0 -3
- /package/template/{stories → stories_vue3-vite-default-ts}/BaseLayout.vue +0 -0
- /package/template/{stories → stories_vue3-vite-default-ts}/GlobalUsage.stories.ts +0 -0
- /package/template/{stories → stories_vue3-vite-default-ts}/MySlotComponent.vue +0 -0
- /package/template/{stories → stories_vue3-vite-default-ts}/OverrideArgs.vue +0 -0
- /package/template/{stories → stories_vue3-vite-default-ts}/ReactiveArgs.vue +0 -0
- /package/template/{stories → stories_vue3-vite-default-ts}/ReactiveSlots.stories.ts +0 -0
- /package/template/{stories → stories_vue3-vite-default-ts}/Reactivity.vue +0 -0
- /package/template/{stories → stories_vue3-vite-default-ts}/decorators.stories.ts +0 -0
package/dist/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var src_exports={};__export(src_exports,{configure:()=>configure,forceReRender:()=>forceReRender,raw:()=>raw,setup:()=>setup,storiesOf:()=>storiesOf});module.exports=__toCommonJS(src_exports);var import_global=require("@storybook/global"),{window:globalWindow}=import_global.global;globalWindow.STORYBOOK_ENV="vue3";var import_preview_api2=require("@storybook/preview-api");var import_vue=require("vue"),import_preview_api=require("@storybook/preview-api");function
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var src_exports={};__export(src_exports,{configure:()=>configure,forceReRender:()=>forceReRender,raw:()=>raw,setup:()=>setup,storiesOf:()=>storiesOf});module.exports=__toCommonJS(src_exports);var import_global=require("@storybook/global"),{window:globalWindow}=import_global.global;globalWindow.STORYBOOK_ENV="vue3";var import_preview_api2=require("@storybook/preview-api");var import_vue=require("vue"),import_preview_api=require("@storybook/preview-api");function normalizeFunctionalComponent(options){return typeof options=="function"?{render:options,name:options.name}:options}function prepare(rawStory,innerStory){let story=rawStory;return story===null?null:typeof story=="function"?story:innerStory?{...normalizeFunctionalComponent(story),components:{...story.components||{},story:innerStory}}:{render(){return(0,import_vue.h)(story)}}}function decorateStory(storyFn,decorators){return decorators.reduce((decorated,decorator)=>context=>{let story,decoratedStory=decorator(update=>{let sanitizedUpdate=(0,import_preview_api.sanitizeStoryContextUpdate)(update);return update&&(sanitizedUpdate.args=Object.assign(context.args,sanitizedUpdate.args)),story=decorated({...context,...sanitizedUpdate}),story},context);return story||(story=decorated(context)),decoratedStory===story?story:prepare(decoratedStory,()=>(0,import_vue.h)(story))},context=>prepare(storyFn(context)))}var import_vue2=require("vue"),render=(props,context)=>{let{id,component:Component}=context;if(!Component)throw new Error(`Unable to render story ${id} as the component annotation is missing from the default export`);return()=>(0,import_vue2.h)(Component,props,generateSlots(context))},setupFunctions=new Set,setup=fn=>{setupFunctions.add(fn)},runSetupFunctions=(app,storyContext)=>{setupFunctions.forEach(fn=>fn(app,storyContext))},map=new Map;function renderToCanvas({storyFn,forceRemount,showMain,showException,storyContext,id},canvasElement){let existingApp=map.get(canvasElement);if(existingApp&&!forceRemount){let element=storyFn(),args=getArgs(element,storyContext);return updateArgs(existingApp.reactiveArgs,args),()=>{teardown(existingApp.vueApp,canvasElement)}}existingApp&&forceRemount&&teardown(existingApp.vueApp,canvasElement);let vueApp=(0,import_vue2.createApp)({setup(){storyContext.args=(0,import_vue2.reactive)(storyContext.args);let rootElement=storyFn(),args=getArgs(rootElement,storyContext),appState={vueApp,reactiveArgs:(0,import_vue2.reactive)(args)};return map.set(canvasElement,appState),()=>(0,import_vue2.h)(rootElement)}});return vueApp.config.errorHandler=e=>showException(e),runSetupFunctions(vueApp,storyContext),vueApp.mount(canvasElement),showMain(),()=>{teardown(vueApp,canvasElement)}}function generateSlots(context){let{argTypes}=context,slots=Object.entries(argTypes).filter(([key,value])=>{var _a2,_b;return((_b=(_a2=argTypes[key])==null?void 0:_a2.table)==null?void 0:_b.category)==="slots"}).map(([key,value])=>{let slotValue=context.args[key];return[key,typeof slotValue=="function"?slotValue:()=>slotValue]});return(0,import_vue2.reactive)(Object.fromEntries(slots))}function getArgs(element,storyContext){return element.props&&(0,import_vue2.isVNode)(element)?element.props:storyContext.args}function updateArgs(reactiveArgs,nextArgs){if(Object.keys(nextArgs).length===0)return;let currentArgs=(0,import_vue2.isReactive)(reactiveArgs)?reactiveArgs:(0,import_vue2.reactive)(reactiveArgs);Object.keys(currentArgs).forEach(key=>{key in nextArgs||delete currentArgs[key]}),Object.assign(currentArgs,nextArgs)}function teardown(storybookApp,canvasElement){storybookApp==null||storybookApp.unmount(),map.has(canvasElement)&&map.delete(canvasElement)}var RENDERER="vue3",api=(0,import_preview_api2.start)(renderToCanvas,{decorateStory,render}),storiesOf=(kind,m)=>api.clientApi.storiesOf(kind,m).addParameters({renderer:RENDERER}),configure=(...args)=>api.configure(RENDERER,...args),{forceReRender}=api,{raw}=api.clientApi;var _a;typeof module<"u"&&((_a=module==null?void 0:module.hot)==null||_a.decline());0&&(module.exports={configure,forceReRender,raw,setup,storiesOf});
|
package/dist/index.mjs
CHANGED
@@ -1 +1,8 @@
|
|
1
|
-
import{decorateStory,render
|
1
|
+
import { renderToCanvas, decorateStory, render } from './chunk-SRVBJOBI.mjs';
|
2
|
+
export { setup } from './chunk-SRVBJOBI.mjs';
|
3
|
+
import { global } from '@storybook/global';
|
4
|
+
import { start } from '@storybook/preview-api';
|
5
|
+
|
6
|
+
var{window:globalWindow}=global;globalWindow.STORYBOOK_ENV="vue3";var RENDERER="vue3",api=start(renderToCanvas,{decorateStory,render}),storiesOf=(kind,m)=>api.clientApi.storiesOf(kind,m).addParameters({renderer:RENDERER}),configure=(...args)=>api.configure(RENDERER,...args),{forceReRender}=api,{raw}=api.clientApi;typeof module<"u"&&module?.hot?.decline();
|
7
|
+
|
8
|
+
export { configure, forceReRender, raw, storiesOf };
|
@@ -0,0 +1,148 @@
|
|
1
|
+
import { ConcreteComponent, App } from 'vue';
|
2
|
+
import { WebRenderer, ArgsStoryFn as ArgsStoryFn$1, RenderContext } from '@storybook/types';
|
3
|
+
|
4
|
+
type StoryFnVueReturnType = ConcreteComponent<any>;
|
5
|
+
interface VueRenderer extends WebRenderer {
|
6
|
+
component: Omit<ConcreteComponent<this['T']>, 'props'>;
|
7
|
+
storyResult: StoryFnVueReturnType;
|
8
|
+
}
|
9
|
+
|
10
|
+
interface SBBaseType {
|
11
|
+
required?: boolean;
|
12
|
+
raw?: string;
|
13
|
+
}
|
14
|
+
type SBScalarType = SBBaseType & {
|
15
|
+
name: 'boolean' | 'string' | 'number' | 'function' | 'symbol';
|
16
|
+
};
|
17
|
+
type SBArrayType = SBBaseType & {
|
18
|
+
name: 'array';
|
19
|
+
value: SBType;
|
20
|
+
};
|
21
|
+
type SBObjectType = SBBaseType & {
|
22
|
+
name: 'object';
|
23
|
+
value: Record<string, SBType>;
|
24
|
+
};
|
25
|
+
type SBEnumType = SBBaseType & {
|
26
|
+
name: 'enum';
|
27
|
+
value: (string | number)[];
|
28
|
+
};
|
29
|
+
type SBIntersectionType = SBBaseType & {
|
30
|
+
name: 'intersection';
|
31
|
+
value: SBType[];
|
32
|
+
};
|
33
|
+
type SBUnionType = SBBaseType & {
|
34
|
+
name: 'union';
|
35
|
+
value: SBType[];
|
36
|
+
};
|
37
|
+
type SBOtherType = SBBaseType & {
|
38
|
+
name: 'other';
|
39
|
+
value: string;
|
40
|
+
};
|
41
|
+
type SBType = SBScalarType | SBEnumType | SBArrayType | SBObjectType | SBIntersectionType | SBUnionType | SBOtherType;
|
42
|
+
|
43
|
+
type StoryId = string;
|
44
|
+
type ComponentId = string;
|
45
|
+
type ComponentTitle = string;
|
46
|
+
type StoryName = string;
|
47
|
+
type Tag = string;
|
48
|
+
interface StoryIdentifier {
|
49
|
+
componentId: ComponentId;
|
50
|
+
title: ComponentTitle;
|
51
|
+
/** @deprecated */
|
52
|
+
kind: ComponentTitle;
|
53
|
+
id: StoryId;
|
54
|
+
name: StoryName;
|
55
|
+
/** @deprecated */
|
56
|
+
story: StoryName;
|
57
|
+
tags: Tag[];
|
58
|
+
}
|
59
|
+
interface Parameters {
|
60
|
+
[name: string]: any;
|
61
|
+
}
|
62
|
+
type ConditionalTest = {
|
63
|
+
truthy?: boolean;
|
64
|
+
} | {
|
65
|
+
exists: boolean;
|
66
|
+
} | {
|
67
|
+
eq: any;
|
68
|
+
} | {
|
69
|
+
neq: any;
|
70
|
+
};
|
71
|
+
type ConditionalValue = {
|
72
|
+
arg: string;
|
73
|
+
} | {
|
74
|
+
global: string;
|
75
|
+
};
|
76
|
+
type Conditional = ConditionalValue & ConditionalTest;
|
77
|
+
interface InputType {
|
78
|
+
name?: string;
|
79
|
+
description?: string;
|
80
|
+
defaultValue?: any;
|
81
|
+
type?: SBType | SBScalarType['name'];
|
82
|
+
if?: Conditional;
|
83
|
+
[key: string]: any;
|
84
|
+
}
|
85
|
+
interface StrictInputType extends InputType {
|
86
|
+
name: string;
|
87
|
+
type?: SBType;
|
88
|
+
}
|
89
|
+
interface Args {
|
90
|
+
[name: string]: any;
|
91
|
+
}
|
92
|
+
type StrictArgTypes<TArgs = Args> = {
|
93
|
+
[name in keyof TArgs]: StrictInputType;
|
94
|
+
};
|
95
|
+
type Globals = {
|
96
|
+
[name: string]: any;
|
97
|
+
};
|
98
|
+
type Renderer = {
|
99
|
+
/** What is the type of the `component` annotation in this renderer? */
|
100
|
+
component: unknown;
|
101
|
+
/** What does the story function return in this renderer? */
|
102
|
+
storyResult: unknown;
|
103
|
+
/** What type of element does this renderer render to? */
|
104
|
+
canvasElement: unknown;
|
105
|
+
T?: unknown;
|
106
|
+
};
|
107
|
+
type StoryContextForEnhancers<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryIdentifier & {
|
108
|
+
component?: (TRenderer & {
|
109
|
+
T: any;
|
110
|
+
})['component'];
|
111
|
+
subcomponents?: Record<string, (TRenderer & {
|
112
|
+
T: any;
|
113
|
+
})['component']>;
|
114
|
+
parameters: Parameters;
|
115
|
+
initialArgs: TArgs;
|
116
|
+
argTypes: StrictArgTypes<TArgs>;
|
117
|
+
};
|
118
|
+
type StoryContextUpdate<TArgs = Args> = {
|
119
|
+
args?: TArgs;
|
120
|
+
globals?: Globals;
|
121
|
+
[key: string]: any;
|
122
|
+
};
|
123
|
+
type ViewMode = 'story' | 'docs';
|
124
|
+
type StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryContextForEnhancers<TRenderer, TArgs> & Required<StoryContextUpdate<TArgs>> & {
|
125
|
+
hooks: unknown;
|
126
|
+
viewMode: ViewMode;
|
127
|
+
originalStoryFn: StoryFn<TRenderer>;
|
128
|
+
};
|
129
|
+
type StoryContext<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryContextForLoaders<TRenderer, TArgs> & {
|
130
|
+
loaded: Record<string, any>;
|
131
|
+
abortSignal: AbortSignal;
|
132
|
+
canvasElement: TRenderer['canvasElement'];
|
133
|
+
};
|
134
|
+
type LegacyStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
|
135
|
+
type ArgsStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (args: TArgs, context: StoryContext<TRenderer, TArgs>) => (TRenderer & {
|
136
|
+
T: TArgs;
|
137
|
+
})['storyResult'];
|
138
|
+
type StoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = LegacyStoryFn<TRenderer, TArgs> | ArgsStoryFn<TRenderer, TArgs>;
|
139
|
+
|
140
|
+
declare const render: ArgsStoryFn$1<VueRenderer>;
|
141
|
+
/** add a setup function to set that will be call when story is created a d
|
142
|
+
*
|
143
|
+
* @param fn
|
144
|
+
*/
|
145
|
+
declare const setup: (fn: (app: App, storyContext?: StoryContext<VueRenderer>) => void) => void;
|
146
|
+
declare function renderToCanvas({ storyFn, forceRemount, showMain, showException, storyContext, id }: RenderContext<VueRenderer>, canvasElement: VueRenderer['canvasElement']): () => void;
|
147
|
+
|
148
|
+
export { VueRenderer as V, renderToCanvas as a, render as r, setup as s };
|
package/package.json
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storybook/vue3",
|
3
|
-
"version": "7.1.0-
|
3
|
+
"version": "7.1.0-beta.0",
|
4
4
|
"description": "Storybook Vue 3 renderer",
|
5
5
|
"keywords": [
|
6
6
|
"storybook"
|
7
7
|
],
|
8
|
-
"homepage": "https://github.com/storybookjs/storybook/tree/
|
8
|
+
"homepage": "https://github.com/storybookjs/storybook/tree/next/code/renderers/vue3",
|
9
9
|
"bugs": {
|
10
10
|
"url": "https://github.com/storybookjs/storybook/issues"
|
11
11
|
},
|
12
12
|
"repository": {
|
13
13
|
"type": "git",
|
14
14
|
"url": "https://github.com/storybookjs/storybook.git",
|
15
|
-
"directory": "renderers/vue3"
|
15
|
+
"directory": "code/renderers/vue3"
|
16
16
|
},
|
17
17
|
"funding": {
|
18
18
|
"type": "opencollective",
|
@@ -21,15 +21,15 @@
|
|
21
21
|
"license": "MIT",
|
22
22
|
"exports": {
|
23
23
|
".": {
|
24
|
+
"types": "./dist/index.d.ts",
|
24
25
|
"node": "./dist/index.js",
|
25
26
|
"require": "./dist/index.js",
|
26
|
-
"import": "./dist/index.mjs"
|
27
|
-
"types": "./dist/index.d.ts"
|
27
|
+
"import": "./dist/index.mjs"
|
28
28
|
},
|
29
29
|
"./preview": {
|
30
|
+
"types": "./dist/config.d.ts",
|
30
31
|
"require": "./dist/config.js",
|
31
|
-
"import": "./dist/config.mjs"
|
32
|
-
"types": "./dist/config.d.ts"
|
32
|
+
"import": "./dist/config.mjs"
|
33
33
|
},
|
34
34
|
"./package.json": "./package.json"
|
35
35
|
},
|
@@ -48,23 +48,27 @@
|
|
48
48
|
"prep": "../../../scripts/prepare/bundle.ts"
|
49
49
|
},
|
50
50
|
"dependencies": {
|
51
|
-
"@storybook/core-client": "7.1.0-
|
52
|
-
"@storybook/docs-tools": "7.1.0-
|
51
|
+
"@storybook/core-client": "7.1.0-beta.0",
|
52
|
+
"@storybook/docs-tools": "7.1.0-beta.0",
|
53
53
|
"@storybook/global": "^5.0.0",
|
54
|
-
"@storybook/preview-api": "7.1.0-
|
55
|
-
"@storybook/types": "7.1.0-
|
54
|
+
"@storybook/preview-api": "7.1.0-beta.0",
|
55
|
+
"@storybook/types": "7.1.0-beta.0",
|
56
|
+
"lodash": "^4.17.21",
|
56
57
|
"ts-dedent": "^2.0.0",
|
57
|
-
"type-fest": "
|
58
|
+
"type-fest": "^3.11.0",
|
59
|
+
"vue-component-type-helpers": "latest"
|
58
60
|
},
|
59
61
|
"devDependencies": {
|
60
62
|
"@digitak/esrun": "^3.2.2",
|
61
63
|
"@types/prettier": "2.7.2",
|
64
|
+
"@vue/compiler-core": "^3.3.4",
|
62
65
|
"@vue/vue3-jest": "29",
|
63
66
|
"typescript": "~4.9.3",
|
64
67
|
"vue": "^3.2.47",
|
65
|
-
"vue-tsc": "
|
68
|
+
"vue-tsc": "latest"
|
66
69
|
},
|
67
70
|
"peerDependencies": {
|
71
|
+
"@vue/compiler-core": "^3.0.0",
|
68
72
|
"vue": "^3.0.0"
|
69
73
|
},
|
70
74
|
"engines": {
|
@@ -80,5 +84,5 @@
|
|
80
84
|
],
|
81
85
|
"platform": "browser"
|
82
86
|
},
|
83
|
-
"gitHead": "
|
84
|
-
}
|
87
|
+
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae17"
|
88
|
+
}
|
package/src/typings.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
declare var STORYBOOK_ENV: 'vue3';
|
package/template/cli/js/Page.vue
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<article>
|
3
3
|
<my-header :user="user" @login="onLogin" @logout="onLogout" @create-account="onCreateAccount" />
|
4
4
|
|
5
|
-
<section>
|
5
|
+
<section class="storybook-page">
|
6
6
|
<h2>Pages in Storybook</h2>
|
7
7
|
<p>
|
8
8
|
We recommend building UIs with a
|
@@ -28,7 +28,9 @@
|
|
28
28
|
</ul>
|
29
29
|
<p>
|
30
30
|
Get a guided tutorial on component-driven development at
|
31
|
-
<a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer"
|
31
|
+
<a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer"
|
32
|
+
>Storybook tutorials</a
|
33
|
+
>
|
32
34
|
. Read more in the
|
33
35
|
<a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">docs</a>
|
34
36
|
.
|
@@ -40,7 +42,9 @@
|
|
40
42
|
<g fill="none" fill-rule="evenodd">
|
41
43
|
<path
|
42
44
|
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"
|
43
|
-
id="a"
|
45
|
+
id="a"
|
46
|
+
fill="#999"
|
47
|
+
/>
|
44
48
|
</g>
|
45
49
|
</svg>
|
46
50
|
Viewports addon in the toolbar
|
@@ -55,7 +59,7 @@ import MyHeader from './Header.vue';
|
|
55
59
|
|
56
60
|
import { ref } from 'vue';
|
57
61
|
|
58
|
-
const user = ref<{ name: string } | null>(null)
|
62
|
+
const user = ref<{ name: string } | null>(null);
|
59
63
|
|
60
64
|
const onLogin = () => {
|
61
65
|
user.value = { name: 'Jane Doe' };
|
@@ -66,5 +70,4 @@ const onLogout = () => {
|
|
66
70
|
const onCreateAccount = () => {
|
67
71
|
user.value = { name: 'Jane Doe' };
|
68
72
|
};
|
69
|
-
|
70
73
|
</script>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<article>
|
3
3
|
<my-header :user="user" @login="onLogin" @logout="onLogout" @create-account="onCreateAccount" />
|
4
4
|
|
5
|
-
<section>
|
5
|
+
<section class="storybook-page">
|
6
6
|
<h2>Pages in Storybook</h2>
|
7
7
|
<p>
|
8
8
|
We recommend building UIs with a
|
@@ -28,7 +28,9 @@
|
|
28
28
|
</ul>
|
29
29
|
<p>
|
30
30
|
Get a guided tutorial on component-driven development at
|
31
|
-
<a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer"
|
31
|
+
<a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer"
|
32
|
+
>Storybook tutorials</a
|
33
|
+
>
|
32
34
|
. Read more in the
|
33
35
|
<a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">docs</a>
|
34
36
|
.
|
@@ -40,7 +42,9 @@
|
|
40
42
|
<g fill="none" fill-rule="evenodd">
|
41
43
|
<path
|
42
44
|
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"
|
43
|
-
id="a"
|
45
|
+
id="a"
|
46
|
+
fill="#999"
|
47
|
+
/>
|
44
48
|
</g>
|
45
49
|
</svg>
|
46
50
|
Viewports addon in the toolbar
|
@@ -55,7 +59,7 @@ import MyHeader from './Header.vue';
|
|
55
59
|
|
56
60
|
import { ref } from 'vue';
|
57
61
|
|
58
|
-
const user = ref<{ name: string } | null>(null)
|
62
|
+
const user = ref<{ name: string } | null>(null);
|
59
63
|
|
60
64
|
const onLogin = () => {
|
61
65
|
user.value = { name: 'Jane Doe' };
|
@@ -66,5 +70,4 @@ const onLogout = () => {
|
|
66
70
|
const onCreateAccount = () => {
|
67
71
|
user.value = { name: 'Jane Doe' };
|
68
72
|
};
|
69
|
-
|
70
73
|
</script>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<form id="interaction-test-form" @submit.prevent="onSubmit">
|
3
3
|
<label>
|
4
4
|
Enter Value
|
5
|
-
<input type="text" data-testid="value"
|
5
|
+
<input type="text" data-testid="value" v-model="value" required />
|
6
6
|
</label>
|
7
7
|
<button type="submit">Submit</button>
|
8
8
|
<p v-if="complete">Completed!!</p>
|
@@ -27,9 +27,6 @@ export default {
|
|
27
27
|
},
|
28
28
|
|
29
29
|
methods: {
|
30
|
-
setValue(event) {
|
31
|
-
this.value = event.target.value;
|
32
|
-
},
|
33
30
|
onSubmit() {
|
34
31
|
this.onSuccess(this.value);
|
35
32
|
setTimeout(() => {
|
@@ -2,12 +2,37 @@ import { global as globalThis } from '@storybook/global';
|
|
2
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
3
3
|
import { setup } from '@storybook/vue3';
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
//
|
8
|
-
//
|
5
|
+
const somePlugin = {
|
6
|
+
install: (app, options) => {
|
7
|
+
// inject a globally available $greetingText() method
|
8
|
+
// eslint-disable-next-line no-param-reassign
|
9
|
+
app.config.globalProperties.$greetingMessage = (key) => {
|
10
|
+
// retrieve a nested property in `options`
|
11
|
+
// using `key`
|
12
|
+
return options.greetings[key];
|
13
|
+
};
|
14
|
+
},
|
15
|
+
};
|
16
|
+
const someColor = 'someColor';
|
9
17
|
|
18
|
+
// add components to global scope
|
10
19
|
setup((app) => {
|
11
20
|
// This adds a component that can be used globally in stories
|
12
21
|
app.component('GlobalButton', globalThis.Components.Button);
|
13
22
|
});
|
23
|
+
|
24
|
+
// this adds a plugin to vue app that can be used globally in stories
|
25
|
+
setup((app, context) => {
|
26
|
+
app.use(somePlugin, {
|
27
|
+
greetings: {
|
28
|
+
hello: `Hello Story! from some plugin your name is ${context?.name}!`,
|
29
|
+
welcome: `Welcome Story! from some plugin your name is ${context?.name}!`,
|
30
|
+
hi: `Hi Story! from some plugin your name is ${context?.name}!`,
|
31
|
+
},
|
32
|
+
});
|
33
|
+
});
|
34
|
+
|
35
|
+
// additonal setup to provide some propriety to the app
|
36
|
+
setup((app, context) => {
|
37
|
+
app.provide(someColor, 'green');
|
38
|
+
});
|
package/template/{stories → stories_vue3-vite-default-ts}/CustomRenderFunctionalComponent.stories.ts
RENAMED
@@ -27,8 +27,6 @@ export {
|
|
27
27
|
NoDecorators,
|
28
28
|
DecoratorFunctionalComponent,
|
29
29
|
DecoratorFunctionalComponentArgsFromContext,
|
30
|
-
DecoratorFunctionalComponentArgsFromProps,
|
31
30
|
DecoratorComponentOptions,
|
32
31
|
DecoratorComponentOptionsArgsFromData,
|
33
|
-
DecoratorComponentOptionsArgsFromProps,
|
34
32
|
} from './ReactiveDecorators.stories';
|
package/template/{stories → stories_vue3-vite-default-ts}/CustomRenderOptionsArgsFromData.stories.ts
RENAMED
@@ -40,8 +40,6 @@ export {
|
|
40
40
|
NoDecorators,
|
41
41
|
DecoratorFunctionalComponent,
|
42
42
|
DecoratorFunctionalComponentArgsFromContext,
|
43
|
-
DecoratorFunctionalComponentArgsFromProps,
|
44
43
|
DecoratorComponentOptions,
|
45
44
|
DecoratorComponentOptionsArgsFromData,
|
46
|
-
DecoratorComponentOptionsArgsFromProps,
|
47
45
|
} from './ReactiveDecorators.stories';
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/// <reference types="jest" />
|
2
|
+
/// <reference types="testing-library__jest-dom" />
|
3
|
+
|
4
|
+
import { expect } from '@storybook/jest';
|
5
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
6
|
+
import { within } from '@storybook/testing-library';
|
7
|
+
import { inject } from 'vue';
|
8
|
+
import GlobalSetup from './GlobalSetup.vue';
|
9
|
+
|
10
|
+
const meta: Meta = {
|
11
|
+
component: GlobalSetup,
|
12
|
+
argTypes: {},
|
13
|
+
render: (args: any) => ({
|
14
|
+
// Components used in your story `template` are defined in the `components` object
|
15
|
+
components: { GlobalUsage: GlobalSetup },
|
16
|
+
// The story's `args` need to be mapped into the template through the `setup()` method
|
17
|
+
setup() {
|
18
|
+
const color = inject('someColor', 'red'); // <-- this is the global setup from .storybook/preview.ts
|
19
|
+
return { args: { ...args, backgroundColor: color } };
|
20
|
+
},
|
21
|
+
// And then the `args` are bound to your component with `v-bind="args"`
|
22
|
+
template: '<global-usage v-bind="args" />',
|
23
|
+
}),
|
24
|
+
} satisfies Meta<typeof GlobalSetup>;
|
25
|
+
export default meta;
|
26
|
+
|
27
|
+
type Story = StoryObj<typeof meta>;
|
28
|
+
|
29
|
+
export const Primary: Story = {
|
30
|
+
args: {
|
31
|
+
primary: true,
|
32
|
+
label: 'someColor injected from .storybook/preview.ts',
|
33
|
+
},
|
34
|
+
play: async ({ canvasElement, id }) => {
|
35
|
+
const canvas = within(canvasElement);
|
36
|
+
|
37
|
+
const button = await canvas.getByRole('button');
|
38
|
+
await expect(button).toHaveStyle('background-color: rgb(0, 128, 0)'); // <-- this provide themeColor = green from .storybook/preview.ts
|
39
|
+
|
40
|
+
const h2 = await canvas.getByRole('heading', { level: 2 });
|
41
|
+
await expect(h2).toHaveTextContent('Hi Story! from some plugin your name is Primary!');
|
42
|
+
|
43
|
+
const h3 = await canvas.getByRole('heading', { level: 3 });
|
44
|
+
await expect(h3).toHaveTextContent('Hello Story! from some plugin your name is Primary!');
|
45
|
+
|
46
|
+
const h4 = await canvas.getByRole('heading', { level: 4 });
|
47
|
+
await expect(h4).toHaveTextContent('Welcome Story! from some plugin your name is Primary!');
|
48
|
+
},
|
49
|
+
};
|
50
|
+
|
51
|
+
export const Secondary: Story = {
|
52
|
+
args: {
|
53
|
+
label: 'someColor injected from .storybook/preview.ts',
|
54
|
+
},
|
55
|
+
};
|
@@ -10,7 +10,7 @@ const icons = {
|
|
10
10
|
},
|
11
11
|
};
|
12
12
|
|
13
|
-
|
13
|
+
const meta = {
|
14
14
|
component: OverrideArgs,
|
15
15
|
argTypes: {
|
16
16
|
// To show that other props are passed through
|
@@ -39,4 +39,6 @@ export default {
|
|
39
39
|
},
|
40
40
|
};
|
41
41
|
|
42
|
+
export default meta;
|
43
|
+
|
42
44
|
export const TestOne = {};
|
@@ -88,10 +88,12 @@ export const ReactiveHtmlWrapper: Story = {
|
|
88
88
|
};
|
89
89
|
|
90
90
|
// to test that Simple html Decorators in CSF2 format are applied correctly in reactive mode
|
91
|
-
const ReactiveCSF2WrapperTempl: StoryFn = (args
|
91
|
+
const ReactiveCSF2WrapperTempl: StoryFn = (args) => ({
|
92
92
|
components: { ReactiveArgs },
|
93
|
-
|
94
|
-
|
93
|
+
setup() {
|
94
|
+
return { args };
|
95
|
+
},
|
96
|
+
template: '<ReactiveArgs v-bind="args" />',
|
95
97
|
});
|
96
98
|
|
97
99
|
export const ReactiveCSF2Wrapper = ReactiveCSF2WrapperTempl.bind({});
|
@@ -51,7 +51,7 @@ export const DecoratorFunctionalComponent: Story = {
|
|
51
51
|
decorators: [
|
52
52
|
(storyFn, context) => {
|
53
53
|
const story = storyFn();
|
54
|
-
return () => h('div', [h('h2', ['Decorator not using args']), [h(story
|
54
|
+
return () => h('div', [h('h2', ['Decorator not using args']), [h(story)]]);
|
55
55
|
},
|
56
56
|
],
|
57
57
|
};
|
@@ -61,20 +61,7 @@ export const DecoratorFunctionalComponentArgsFromContext: Story = {
|
|
61
61
|
(storyFn, context) => {
|
62
62
|
const story = storyFn();
|
63
63
|
return () =>
|
64
|
-
h('div', [
|
65
|
-
h('h2', ['Decorator using args.label: ', context.args.label]),
|
66
|
-
[h(story, context.args)],
|
67
|
-
]);
|
68
|
-
},
|
69
|
-
],
|
70
|
-
};
|
71
|
-
|
72
|
-
export const DecoratorFunctionalComponentArgsFromProps: Story = {
|
73
|
-
decorators: [
|
74
|
-
(storyFn, context) => {
|
75
|
-
const story = storyFn();
|
76
|
-
return (args) =>
|
77
|
-
h('div', [h('h2', `Decorator using args.label: ${args.label}`), h(story, context.args)]);
|
64
|
+
h('div', [h('h2', ['Decorator using args.label: ', context.args.label]), [h(story)]]);
|
78
65
|
},
|
79
66
|
],
|
80
67
|
};
|
@@ -99,14 +86,3 @@ export const DecoratorComponentOptionsArgsFromData: Story = {
|
|
99
86
|
},
|
100
87
|
],
|
101
88
|
};
|
102
|
-
|
103
|
-
export const DecoratorComponentOptionsArgsFromProps: Story = {
|
104
|
-
decorators: [
|
105
|
-
(storyFn, context) => {
|
106
|
-
return {
|
107
|
-
props: ['label'],
|
108
|
-
template: '<div><h2>Decorator using label: {{label}}</h2><story /></div>',
|
109
|
-
};
|
110
|
-
},
|
111
|
-
],
|
112
|
-
};
|
@@ -60,7 +60,7 @@ export const CustomRender: Story = {
|
|
60
60
|
setup() {
|
61
61
|
return { args };
|
62
62
|
},
|
63
|
-
template: `<MySlotComponent
|
63
|
+
template: `<MySlotComponent v-bind="args" v-slot="slotProps">
|
64
64
|
{{ slotProps.text }}, {{ slotProps.year }}
|
65
65
|
</MySlotComponent>`,
|
66
66
|
}),
|
@@ -73,7 +73,7 @@ export const CustomRenderUsingFunctionSlot: Story = {
|
|
73
73
|
setup() {
|
74
74
|
return { args };
|
75
75
|
},
|
76
|
-
template: `<MySlotComponent
|
76
|
+
template: `<MySlotComponent v-bind="args" v-slot="slotProps">
|
77
77
|
{{args.default(slotProps)}}
|
78
78
|
</MySlotComponent>`,
|
79
79
|
}),
|