diff --git a/examples/react-ts/src/AccountForm.stories.tsx b/examples/react-ts/src/AccountForm.stories.tsx index 1ba866a24769..4cbc7d48faab 100644 --- a/examples/react-ts/src/AccountForm.stories.tsx +++ b/examples/react-ts/src/AccountForm.stories.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { ComponentMeta } from '@storybook/react'; +import { ComponentStory, ComponentMeta } from '@storybook/react'; import { screen } from '@testing-library/dom'; import userEvent from '@testing-library/user-event'; import { AccountForm, AccountFormProps } from './AccountForm'; @@ -14,7 +14,7 @@ export default { // export const Standard = (args: AccountFormProps) => ; // Standard.args = { passwordVerification: false }; -export const Standard = { +export const Standard: ComponentStory = { // render: (args: AccountFormProps) => , args: { passwordVerification: false }, }; @@ -51,7 +51,7 @@ export const StandardFailHover = { }, }; -export const Verification = { +export const Verification: ComponentStory = { args: { passwordVerification: true }, }; diff --git a/lib/addons/src/types.ts b/lib/addons/src/types.ts index dc1627b0f849..9b25a91c2d05 100644 --- a/lib/addons/src/types.ts +++ b/lib/addons/src/types.ts @@ -197,6 +197,14 @@ export interface BaseAnnotations { * @see [Decorators](https://storybook.js.org/docs/addons/introduction/#1-decorators) */ decorators?: BaseDecorators; + /** + * Define a custom render function for the story(ies). If not passed, a default render function by the framework will be used. + */ + render?: (args: Args, context: StoryContext) => StoryFnReturnType; + /** + * Function that is executed after the story is rendered. + */ + play?: Function; } export interface Annotations @@ -228,6 +236,8 @@ export interface BaseMeta { * * Stories can be organized in a nested structure using "/" as a separator. * + * Since CSF 3.0 this property is optional. + * * @example * export default { * ... @@ -236,7 +246,7 @@ export interface BaseMeta { * * @see [Story Hierarchy](https://storybook.js.org/docs/basics/writing-stories/#story-hierarchy) */ - title: string; + title?: string; /** * The primary component for your story. @@ -263,11 +273,17 @@ export interface BaseMeta { subcomponents?: Record; } -export interface BaseStory { - (args: Args, context: StoryContext): StoryFnReturnType; - +type BaseStoryObject = { /** * Override the display name in the UI */ storyName?: string; -} +}; + +type BaseStoryFn = { + (args: Args, context: StoryContext): StoryFnReturnType; +} & BaseStoryObject; + +export type BaseStory = + | BaseStoryFn + | BaseStoryObject;