UNPKG

@storybook/react

Version:
85 lines (84 loc) 4.86 kB
import { _ as ReactRenderer, a as AddMocks, c as Decorator, d as Parameters, f as Preview, g as StrictArgs, h as StoryObj, i as __definePreview, l as Loader, m as StoryFn, n as ReactPreview, o as ArgTypes, p as StoryContext, r as ReactStory, s as Args, t as ReactMeta, u as Meta, v as ReactTypes } from "./chunk-ojHmM-yX.js"; import { Args as Args$1, ComposedStoryFn, NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, ProjectAnnotations, Store_CSFExports, StoriesWithPartialProps, StoryAnnotationsOrFn } from "storybook/internal/types"; //#region code/renderers/react/.dts-emit/code/renderers/react/src/portable-stories.d.ts /** * Function that sets the globalConfig of your storybook. The global config is the preview module of * your .storybook folder. * * It should be run a single time, so that your global config (e.g. decorators) is applied to your * stories when using `composeStories` or `composeStory`. * * Example: * * ```jsx * // setup-file.js * import { setProjectAnnotations } from '@storybook/react'; * import projectAnnotations from './.storybook/preview'; * * setProjectAnnotations(projectAnnotations); * ``` * * @param projectAnnotations - E.g. (import * as projectAnnotations from '../.storybook/preview') */ declare function setProjectAnnotations(projectAnnotations: NamedOrDefaultProjectAnnotations<any> | NamedOrDefaultProjectAnnotations<any>[]): NormalizedProjectAnnotations<ReactRenderer>; declare const INTERNAL_DEFAULT_PROJECT_ANNOTATIONS: ProjectAnnotations<ReactRenderer>; /** * Function that will receive a story along with meta (e.g. a default export from a .stories file) * and optionally projectAnnotations e.g. (import * as projectAnnotations from * '../.storybook/preview) and will return a composed component that has all * args/parameters/decorators/etc combined and applied to it. * * It's very useful for reusing a story in scenarios outside of Storybook like unit testing. * * Example: * * ```jsx * import { render } from '@testing-library/react'; * import { composeStory } from '@storybook/react'; * import Meta, { Primary as PrimaryStory } from './Button.stories'; * * const Primary = composeStory(PrimaryStory, Meta); * * test('renders primary button with Hello World', () => { * const { getByText } = render(<Primary>Hello world</Primary>); * expect(getByText(/Hello world/i)).not.toBeNull(); * }); * ``` * * @param story * @param componentAnnotations - E.g. (import Meta from './Button.stories') * @param [projectAnnotations] - E.g. (import * as projectAnnotations from '../.storybook/preview') * this can be applied automatically if you use `setProjectAnnotations` in your setup files. * @param [exportsName] - In case your story does not contain a name and you want it to have a name. */ declare function composeStory<TArgs extends Args$1 = Args$1>(story: StoryAnnotationsOrFn<ReactRenderer, TArgs>, componentAnnotations: Meta<TArgs | any>, projectAnnotations?: ProjectAnnotations<ReactRenderer>, exportsName?: string): ComposedStoryFn<ReactRenderer, Partial<TArgs>>; /** * Function that will receive a stories import (e.g. `import * as stories from './Button.stories'`) * and optionally projectAnnotations (e.g. `import * as projectAnnotations from * '../.storybook/preview`) and will return an object containing all the stories passed, but now as * a composed component that has all args/parameters/decorators/etc combined and applied to it. * * It's very useful for reusing stories in scenarios outside of Storybook like unit testing. * * Example: * * ```jsx * import { render } from '@testing-library/react'; * import { composeStories } from '@storybook/react'; * import * as stories from './Button.stories'; * * const { Primary, Secondary } = composeStories(stories); * * test('renders primary button with Hello World', () => { * const { getByText } = render(<Primary>Hello world</Primary>); * expect(getByText(/Hello world/i)).not.toBeNull(); * }); * ``` * * @param csfExports - E.g. (import * as stories from './Button.stories') * @param [projectAnnotations] - E.g. (import * as projectAnnotations from '../.storybook/preview') * this can be applied automatically if you use `setProjectAnnotations` in your setup files. */ declare function composeStories<TModule extends Store_CSFExports<ReactRenderer, any>>(csfExports: TModule, projectAnnotations?: ProjectAnnotations<ReactRenderer>): Omit<StoriesWithPartialProps<ReactRenderer, TModule>, keyof Store_CSFExports>; //#endregion export { AddMocks, type ArgTypes, type Args, Decorator, INTERNAL_DEFAULT_PROJECT_ANNOTATIONS, Loader, Meta, type Parameters, Preview, ReactMeta, ReactPreview, type ReactRenderer, ReactStory, type ReactTypes, StoryContext, StoryFn, StoryObj, type StrictArgs, __definePreview, composeStories, composeStory, setProjectAnnotations };