;
/**
* Defines parameters for Storybook stories, combining built-in parameters with custom ones.
*
* @param parameters - Configuration object containing both built-in Storybook parameters and custom parameters
* @returns The combined parameters object
*
* @example
* ```ts
* import { defineParameters } from '@repobuddy/storybook'
*
* export default {
* parameters: defineParameters({
* // Built-in parameters
* layout: 'centered',
* backgrounds: {
* default: 'light',
* values: [
* { name: 'light', value: '#ffffff' },
* { name: 'dark', value: '#333333' }
* ]
* },
* // Custom parameters
* myCustomParam: {
* someValue: true
* }
* })
* }
* ```
*/
export declare function defineParameters>(param: P & StorybookBuiltInParams, ...rest: Array): StorybookBuiltInParams;
//#endregion
//#region src/parameters/define_story_card_param.d.ts
export interface StoryCardParam {
storyCard: {
/**
* Optional title displayed as a heading in the card.
* Can be any React node (string, JSX, etc.).
*/
title?: ReactNode | undefined;
/**
* @deprecated Use `appearance` instead.
*/
status?: StoryCardStatus;
/**
* Appearance of the card (error | warn | info | source | output). Default: `'info'`.
*/
appearance?: StoryCardAppearance | undefined;
/**
* Additional CSS classes or a function to compute classes.
*
* If a string is provided, it will be merged with the default classes.
* If a function is provided, it receives the card state and default className,
* and should return the final className string.
*/
className?: ((state: Pick & {
defaultClassName: string;
}) => string) | string | undefined;
/**
* Content to display in the card body.
* Can be any React node (string, JSX, etc.).
*
* If not provided, the decorator will automatically use:
* 1. Story description (`parameters.docs.description.story`)
* 2. Component description (`parameters.docs.description.component`)
* 3. Nothing (card won't render if no content and no title)
*/
content?: ReactNode | undefined;
};
}
/**
* Defines story card parameters for Storybook stories.
*
* These parameters can be consumed by the `withStoryCard` decorator
* to automatically configure story cards without passing props directly.
*
* @param storyCard - Configuration for story card parameters
* @returns An object containing the story card parameter configuration
*
* @example
* ```tsx
* import { defineStoryCard, withStoryCard } from '@repobuddy/storybook'
*
* export const MyStory: Story = {
* parameters: defineStoryCard({
* title: 'Important Notice',
* status: 'warn',
* content: Please review this carefully.
* }),
* decorators: [withStoryCard()]
* }
* ```
*
* @example
* With automatic content from story description:
* ```tsx
* export const MyStory: Story = {
* parameters: {
* ...defineDocsParam({
* description: {
* story: 'This description will be shown in the card'
* }
* }),
* ...defineStoryCard({
* title: 'Story Information',
* status: 'info'
* })
* },
* decorators: [withStoryCard()]
* }
* ```
*/
export declare function defineStoryCardParam(storyCard: StoryCardParam['storyCard']): StoryCardParam;
//#endregion
//#region src/testing/decorators/when_running_in_test.d.ts
/**
* executes the specified decorator or handler if the code is running in test.
*/
export declare function whenRunningInTest(decoratorOrHandler: ((...args: Parameters>) => ReturnType> | undefined | void) | (() => ReturnType> | undefined | void)): Decorator;
//#endregion
//#region src/types/_extract_string_literals.d.ts
type ExtractStringLiterals = T extends any ? (string extends T ? never : T) : never;
//#endregion
//#region src/types/_is_string_literal.d.ts
/**
* Is `T` a string literal (or a union of string literals)?
*
* A local alias rather than a re-export of `type-plus`'s `IsStringLiteral`,
* so the published tag types keep this exact meaning independent of which
* `type-plus` version resolves: `never` and `string` are `false`, literals and
* template literals are `true`.
*/
type IsStringLiteral = [T] extends [never] ? false : T extends string ? string extends T ? false : true : false;
//#endregion
//#region src/types/extends_meta.d.ts
/**
* Extends the Storybook Meta type with custom tag types.
*
* This utility type allows you to extend the `tags` property of a Storybook Meta type
* with custom string literal types while preserving existing tag types from the base Meta.
*
* @template M - The base Meta type to extend
* @template E - The extension type containing a `tag` property with the custom tag types
*
* @example
* ```ts
* import type { ExtendsMeta } from '@repobuddy/storybook'
* import type { Args, Meta as M } from '@storybook/your-framework'
*
* // Create a generic Meta type for your project
* type Meta = ExtendsMeta<
* M,
* { tag: 'new' | 'beta' | 'deprecated' | 'remove:next' }
* >
*
* // Use in component stories
* const meta: Meta = {
* tags: ['new'], // <--- gets auto-completion for 'new' | 'beta' | 'deprecated' | 'remove:next'
* // ...
* }
* ```
*/
export type ExtendsMeta = Omit & {
tags?: ExtractStringLiterals[number]> extends (infer MT) ? IsStringLiteral extends true ? Array<(string & {}) | MT | E['tag']> | undefined : Array<(string & {}) | E['tag']> | undefined : never;
};
//#endregion
//#region src/types/extends_story_obj.d.ts
/**
* Extends the Storybook StoryObj type with custom tag types.
*
* This utility type allows you to extend the `tags` property of a Storybook StoryObj type
* with custom string literal types while preserving existing tag types from the base StoryObj.
*
* @template S - The base StoryObj type to extend (must have an optional `tags` property)
* @template E - The extension type containing a `tag` property with the custom tag types
*
* @example
* ```ts
* import type { ExtendsStoryObj } from '@repobuddy/storybook'
* import type { Args, StoryObj as S } from '@storybook/your-framework'
*
* // Create a generic StoryObj type for your project
* type StoryObj = ExtendsStoryObj<
* S,
* { tag: 'new' | 'beta' | 'deprecated' | 'remove:next' }
* >
*
* // Use in component stories
* const story: StoryObj = {
* tags: ['new'], // <--- gets auto-completion for 'new' | 'beta' | 'deprecated' | 'remove:next'
* // ...
* }
* ```
*/
export type ExtendsStoryObj = Omit & {
tags?: ExtractStringLiterals[number]> extends (infer MT) ? IsStringLiteral extends true ? Array<(string & {}) | MT | E['tag']> | undefined : Array<(string & {}) | E['tag']> | undefined : never;
};
//#endregion
//#region src/types.d.ts
/**
* Extends the Storybook Meta type with custom tag types
* @template TCmpOrArgs - The component or args type
* @template M - The base Meta type
* @template E - The extension type containing tagType
*
* @deprecated use `import { ExtendsMeta } from '@repobuddy/storybook'` instead.
*
* @example
* ```ts
* // Create a generic Meta type for a project
* type Meta = ExtendMeta, { tagType: 'tag1' | 'tag2' }>
*
* // Create a specific Meta type for a component
* type Meta = ExtendMeta, { tagType: 'tag1' | 'tag2' }>
* ```
*/
type ExtendMeta, E extends {
tag: string;
}> = Omit & {
tags?: Array | undefined;
};
/**
* Extends the Storybook StoryObj type with custom tag types
* @template TMetaOrCmpOrArgs - The meta, component or args type
* @template S - The base StoryObj type
* @template E - The extension type containing tagType
*
* @deprecated use `import { ExtendsStoryObj } from '@repobuddy/storybook'` instead.
*
* @example
* ```ts
* // Create a generic StoryObj type for a project
* type StoryObj = ExtendStoryObj, { tagType: 'tag1' | 'tag2' }>
*
* // Create a specific StoryObj type for a component
* type StoryObj = ExtendStoryObj, { tagType: 'tag1' | 'tag2' }>
* ```
*/
type ExtendStoryObj, E extends {
tag: string;
}> = Omit & {
tags?: Array | undefined;
};
//#endregion
export type { ExtendMeta, ExtendStoryObj, FnToArgTypes };