diff --git a/code/renderers/vue3/src/decorateStory.ts b/code/renderers/vue3/src/decorateStory.ts index 3955eba07644..df9f6bb16d6c 100644 --- a/code/renderers/vue3/src/decorateStory.ts +++ b/code/renderers/vue3/src/decorateStory.ts @@ -1,9 +1,7 @@ -import type { ConcreteComponent, Component, ComponentOptions } from 'vue'; +import type { Component, ComponentOptions, ConcreteComponent } from 'vue'; import { h } from 'vue'; -import type { DecoratorFunction, StoryContext, LegacyStoryFn, Args } from '@storybook/types'; +import type { DecoratorFunction, LegacyStoryFn, StoryContext } from '@storybook/types'; import { sanitizeStoryContextUpdate } from '@storybook/preview-api'; -// eslint-disable-next-line import/no-extraneous-dependencies -import { looseEqual } from '@vue/shared'; import type { VueRenderer } from './types'; /* @@ -45,7 +43,6 @@ export function decorateStory( storyFn: LegacyStoryFn, decorators: DecoratorFunction[] ): LegacyStoryFn { - let updatedArgs: Args; return decorators.reduce( (decorated: LegacyStoryFn, decorator) => (context: StoryContext) => { let story: VueRenderer['storyResult'] | undefined; @@ -55,20 +52,16 @@ export function decorateStory( ...context, ...sanitizeStoryContextUpdate(update), }); - - if (update && update.args && !looseEqual(update.args, context.args)) - updatedArgs ??= update.args; return story; }, context); - context.args = updatedArgs ?? context.args; if (!story) story = decorated(context); if (decoratedStory === story) { return story; } - const innerStory = () => h(story!, context.args); + const innerStory = () => h(story!); return prepare(decoratedStory, innerStory) as VueRenderer['storyResult']; }, (context) => prepare(storyFn(context)) as LegacyStoryFn diff --git a/code/renderers/vue3/src/render.ts b/code/renderers/vue3/src/render.ts index 0c3102957a9c..552438220600 100644 --- a/code/renderers/vue3/src/render.ts +++ b/code/renderers/vue3/src/render.ts @@ -1,18 +1,10 @@ /* eslint-disable no-param-reassign */ -import type { App, ConcreteComponent } from 'vue'; +import type { App } from 'vue'; import { createApp, h, reactive, isVNode, isReactive } from 'vue'; -import type { RenderContext, ArgsStoryFn } from '@storybook/types'; +import type { ArgsStoryFn, RenderContext } from '@storybook/types'; import type { Args, StoryContext } from '@storybook/csf'; -import type { VueRenderer, StoryFnVueReturnType, StoryID } from './types'; - -const slotsMap = new Map< - StoryID, - { - component?: Omit, 'props'>; - reactiveSlots?: Args; - } ->(); +import type { StoryFnVueReturnType, StoryID, VueRenderer } from './types'; export const render: ArgsStoryFn = (props, context) => { const { id, component: Component } = context; @@ -22,7 +14,7 @@ export const render: ArgsStoryFn = (props, context) => { ); } - return h(Component, props, createOrUpdateSlots(context)); + return () => h(Component, props, generateSlots(context)); }; // set of setup functions that will be called when story is created @@ -82,7 +74,9 @@ export function renderToCanvas( map.set(canvasElement, appState); return () => { - return h(rootElement, appState.reactiveArgs); + // not passing args here as props + // treat the rootElement as a component without props + return h(rootElement); }; }, }); @@ -157,15 +151,3 @@ function teardown( storybookApp?.unmount(); if (map.has(canvasElement)) map.delete(canvasElement); } - -function createOrUpdateSlots(context: StoryContext) { - const { id: storyID, component } = context; - const slots = generateSlots(context); - if (slotsMap.has(storyID)) { - const app = slotsMap.get(storyID); - if (app?.reactiveSlots) updateArgs(app.reactiveSlots, slots); - return app?.reactiveSlots; - } - slotsMap.set(storyID, { component, reactiveSlots: slots }); - return slots; -} diff --git a/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderFunctionalComponent.stories.ts b/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderFunctionalComponent.stories.ts index 2e723ab01b98..bf70bc34f074 100644 --- a/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderFunctionalComponent.stories.ts +++ b/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderFunctionalComponent.stories.ts @@ -27,8 +27,6 @@ export { NoDecorators, DecoratorFunctionalComponent, DecoratorFunctionalComponentArgsFromContext, - DecoratorFunctionalComponentArgsFromProps, DecoratorComponentOptions, DecoratorComponentOptionsArgsFromData, - DecoratorComponentOptionsArgsFromProps, } from './ReactiveDecorators.stories'; diff --git a/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderOptionsArgsFromData.stories.ts b/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderOptionsArgsFromData.stories.ts index 75d25b464bff..9c904283d3bd 100644 --- a/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderOptionsArgsFromData.stories.ts +++ b/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderOptionsArgsFromData.stories.ts @@ -40,8 +40,6 @@ export { NoDecorators, DecoratorFunctionalComponent, DecoratorFunctionalComponentArgsFromContext, - DecoratorFunctionalComponentArgsFromProps, DecoratorComponentOptions, DecoratorComponentOptionsArgsFromData, - DecoratorComponentOptionsArgsFromProps, } from './ReactiveDecorators.stories'; diff --git a/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderOptionsArgsFromProps.stories.ts b/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderOptionsArgsFromProps.stories.ts deleted file mode 100644 index 68c0ee37997b..000000000000 --- a/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderOptionsArgsFromProps.stories.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { Meta } from '@storybook/vue3'; -import { defineComponent } from 'vue'; -import Reactivity from './Reactivity.vue'; -import * as ReactiveDecorators from './ReactiveDecorators.stories'; - -const meta = { - ...ReactiveDecorators.default, - component: Reactivity, - render: (args, { argTypes }) => { - return defineComponent({ - props: Object.keys(argTypes), - components: { Reactivity }, - template: `
Custom render uses options api and binds args to props: - - {{ $props.default }} - - -
`, - }); - }, -} satisfies Meta; - -export default meta; - -export { - NoDecorators, - DecoratorFunctionalComponent, - DecoratorFunctionalComponentArgsFromContext, - DecoratorFunctionalComponentArgsFromProps, - DecoratorComponentOptions, - DecoratorComponentOptionsArgsFromData, - DecoratorComponentOptionsArgsFromProps, -} from './ReactiveDecorators.stories'; diff --git a/code/renderers/vue3/template/stories_vue3-vite-default-ts/ReactiveArgs.stories.ts b/code/renderers/vue3/template/stories_vue3-vite-default-ts/ReactiveArgs.stories.ts index fce608950be9..d48352194c55 100644 --- a/code/renderers/vue3/template/stories_vue3-vite-default-ts/ReactiveArgs.stories.ts +++ b/code/renderers/vue3/template/stories_vue3-vite-default-ts/ReactiveArgs.stories.ts @@ -88,10 +88,12 @@ export const ReactiveHtmlWrapper: Story = { }; // to test that Simple html Decorators in CSF2 format are applied correctly in reactive mode -const ReactiveCSF2WrapperTempl: StoryFn = (args, { argTypes }) => ({ +const ReactiveCSF2WrapperTempl: StoryFn = (args) => ({ components: { ReactiveArgs }, - props: Object.keys(argTypes), - template: '', + setup() { + return { args }; + }, + template: '', }); export const ReactiveCSF2Wrapper = ReactiveCSF2WrapperTempl.bind({}); diff --git a/code/renderers/vue3/template/stories_vue3-vite-default-ts/ReactiveDecorators.stories.ts b/code/renderers/vue3/template/stories_vue3-vite-default-ts/ReactiveDecorators.stories.ts index 01c1727c4e8b..143cd1784559 100644 --- a/code/renderers/vue3/template/stories_vue3-vite-default-ts/ReactiveDecorators.stories.ts +++ b/code/renderers/vue3/template/stories_vue3-vite-default-ts/ReactiveDecorators.stories.ts @@ -51,7 +51,7 @@ export const DecoratorFunctionalComponent: Story = { decorators: [ (storyFn, context) => { const story = storyFn(); - return () => h('div', [h('h2', ['Decorator not using args']), [h(story, context.args)]]); + return () => h('div', [h('h2', ['Decorator not using args']), [h(story)]]); }, ], }; @@ -61,20 +61,7 @@ export const DecoratorFunctionalComponentArgsFromContext: Story = { (storyFn, context) => { const story = storyFn(); return () => - h('div', [ - h('h2', ['Decorator using args.label: ', context.args.label]), - [h(story, context.args)], - ]); - }, - ], -}; - -export const DecoratorFunctionalComponentArgsFromProps: Story = { - decorators: [ - (storyFn, context) => { - const story = storyFn(); - return (args) => - h('div', [h('h2', `Decorator using args.label: ${args.label}`), h(story, context.args)]); + h('div', [h('h2', ['Decorator using args.label: ', context.args.label]), [h(story)]]); }, ], }; @@ -99,14 +86,3 @@ export const DecoratorComponentOptionsArgsFromData: Story = { }, ], }; - -export const DecoratorComponentOptionsArgsFromProps: Story = { - decorators: [ - (storyFn, context) => { - return { - props: ['label'], - template: '

Decorator using label: {{label}}

', - }; - }, - ], -}; diff --git a/code/renderers/vue3/template/stories_vue3-vite-default-ts/ScopedSlots.stories.ts b/code/renderers/vue3/template/stories_vue3-vite-default-ts/ScopedSlots.stories.ts index 1d338dc24f9e..95266e452711 100644 --- a/code/renderers/vue3/template/stories_vue3-vite-default-ts/ScopedSlots.stories.ts +++ b/code/renderers/vue3/template/stories_vue3-vite-default-ts/ScopedSlots.stories.ts @@ -60,7 +60,7 @@ export const CustomRender: Story = { setup() { return { args }; }, - template: ` + template: ` {{ slotProps.text }}, {{ slotProps.year }} `, }), @@ -73,7 +73,7 @@ export const CustomRenderUsingFunctionSlot: Story = { setup() { return { args }; }, - template: ` + template: ` {{args.default(slotProps)}} `, }),