@storybook/types 7.4.0-alpha.0 → 7.4.0-alpha.2

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/index.d.ts CHANGED
@@ -1430,6 +1430,65 @@ interface ThemeVarsColors {
1430
1430
  gridCellSize?: number;
1431
1431
  }
1432
1432
 
1433
+ type ChannelHandler = (event: ChannelEvent) => void;
1434
+ interface ChannelTransport {
1435
+ send(event: ChannelEvent, options?: any): void;
1436
+ setHandler(handler: ChannelHandler): void;
1437
+ }
1438
+ interface ChannelEvent {
1439
+ type: string;
1440
+ from: string;
1441
+ args: any[];
1442
+ }
1443
+ interface Listener {
1444
+ (...args: any[]): void;
1445
+ }
1446
+ interface ChannelArgsSingle {
1447
+ transport?: ChannelTransport;
1448
+ async?: boolean;
1449
+ }
1450
+ interface ChannelArgsMulti {
1451
+ transports: ChannelTransport[];
1452
+ async?: boolean;
1453
+ }
1454
+
1455
+ declare class Channel {
1456
+ readonly isAsync: boolean;
1457
+ private sender;
1458
+ private events;
1459
+ private data;
1460
+ private readonly transports;
1461
+ constructor(input: ChannelArgsMulti);
1462
+ constructor(input: ChannelArgsSingle);
1463
+ get hasTransport(): boolean;
1464
+ addListener(eventName: string, listener: Listener): void;
1465
+ emit(eventName: string, ...args: any): void;
1466
+ last(eventName: string): any;
1467
+ eventNames(): string[];
1468
+ listenerCount(eventName: string): number;
1469
+ listeners(eventName: string): Listener[] | undefined;
1470
+ once(eventName: string, listener: Listener): void;
1471
+ removeAllListeners(eventName?: string): void;
1472
+ removeListener(eventName: string, listener: Listener): void;
1473
+ on(eventName: string, listener: Listener): void;
1474
+ off(eventName: string, listener: Listener): void;
1475
+ private handleEvent;
1476
+ private onceListener;
1477
+ }
1478
+
1479
+ interface Options$1 {
1480
+ allowRegExp: boolean;
1481
+ allowFunction: boolean;
1482
+ allowSymbol: boolean;
1483
+ allowDate: boolean;
1484
+ allowUndefined: boolean;
1485
+ allowClass: boolean;
1486
+ allowError: boolean;
1487
+ maxDepth: number;
1488
+ space: number | undefined;
1489
+ lazyEval: boolean;
1490
+ }
1491
+
1433
1492
  type ExportName = string;
1434
1493
  type MetaId = string;
1435
1494
  interface StoriesSpecifier {
@@ -1580,1078 +1639,539 @@ interface StoryIndex {
1580
1639
  entries: Record<StoryId, IndexEntry>;
1581
1640
  }
1582
1641
 
1583
- type Addon_Types = Exclude<Addon_TypesEnum, Addon_TypesEnum.experimental_PAGE>;
1584
- interface Addon_ArgType<TArg = unknown> extends InputType {
1585
- defaultValue?: TArg;
1586
- }
1587
- type Addons_ArgTypes<TArgs = Args> = {
1588
- [key in keyof Partial<TArgs>]: Addon_ArgType<TArgs[key]>;
1589
- } & {
1590
- [key in string]: Addon_ArgType<unknown>;
1591
- };
1592
- type Addon_Comparator<T> = ((a: T, b: T) => boolean) | ((a: T, b: T) => number);
1593
- type Addon_StorySortMethod = 'configure' | 'alphabetical';
1594
- interface Addon_StorySortObjectParameter {
1595
- method?: Addon_StorySortMethod;
1596
- order?: any[];
1597
- locales?: string;
1598
- includeNames?: boolean;
1599
- }
1600
- type IndexEntryLegacy = [StoryId, any, Parameters, Parameters];
1601
- type Addon_StorySortComparator = Addon_Comparator<IndexEntryLegacy>;
1602
- type Addon_StorySortParameter = Addon_StorySortComparator | Addon_StorySortObjectParameter;
1603
- type Addon_StorySortComparatorV7 = Addon_Comparator<IndexEntry>;
1604
- type Addon_StorySortParameterV7 = Addon_StorySortComparatorV7 | Addon_StorySortObjectParameter;
1605
- interface Addon_OptionsParameter extends Object {
1606
- storySort?: Addon_StorySortParameter;
1607
- theme?: {
1608
- base: string;
1609
- brandTitle?: string;
1610
- };
1611
- [key: string]: any;
1612
- }
1613
- interface Addon_OptionsParameterV7 extends Object {
1614
- storySort?: Addon_StorySortParameterV7;
1615
- theme?: {
1616
- base: string;
1617
- brandTitle?: string;
1618
- };
1619
- [key: string]: any;
1642
+ /**
1643
+ * ⚠️ This file contains internal WIP types they MUST NOT be exported outside this package for now!
1644
+ */
1645
+ type BuilderName = 'webpack5' | '@storybook/builder-webpack5' | string;
1646
+ type RendererName = string;
1647
+ interface ServerChannel {
1648
+ emit(type: string, args?: any): void;
1620
1649
  }
1621
- type Addon_StoryContext<TRenderer extends Renderer = Renderer> = StoryContext<TRenderer>;
1622
- type Addon_StoryContextUpdate = Partial<Addon_StoryContext>;
1623
- type Addon_ReturnTypeFramework<ReturnType> = {
1624
- component: any;
1625
- storyResult: ReturnType;
1626
- canvasElement: any;
1627
- };
1628
- type Addon_PartialStoryFn<ReturnType = unknown> = PartialStoryFn<Addon_ReturnTypeFramework<ReturnType>>;
1629
- type Addon_LegacyStoryFn<ReturnType = unknown> = LegacyStoryFn<Addon_ReturnTypeFramework<ReturnType>>;
1630
- type Addon_ArgsStoryFn<ReturnType = unknown> = ArgsStoryFn<Addon_ReturnTypeFramework<ReturnType>>;
1631
- type Addon_StoryFn<ReturnType = unknown> = StoryFn<Addon_ReturnTypeFramework<ReturnType>>;
1632
- type Addon_DecoratorFunction<StoryFnReturnType = unknown> = DecoratorFunction<Addon_ReturnTypeFramework<StoryFnReturnType>>;
1633
- type Addon_LoaderFunction = LoaderFunction<Addon_ReturnTypeFramework<unknown>>;
1634
- interface Addon_WrapperSettings {
1635
- options: object;
1636
- parameters: {
1637
- [key: string]: any;
1650
+ interface CoreConfig {
1651
+ builder?: BuilderName | {
1652
+ name: BuilderName;
1653
+ options?: Record<string, any>;
1638
1654
  };
1639
- }
1640
- type Addon_StoryWrapper = (storyFn: Addon_LegacyStoryFn, context: Addon_StoryContext, settings: Addon_WrapperSettings) => any;
1641
- type Addon_MakeDecoratorResult = (...args: any) => any;
1642
- interface Addon_AddStoryArgs<StoryFnReturnType = unknown> {
1643
- id: StoryId;
1644
- kind: StoryKind;
1645
- name: StoryName;
1646
- storyFn: Addon_StoryFn<StoryFnReturnType>;
1647
- parameters: Parameters;
1648
- }
1649
- type Addon_ClientApiAddon<StoryFnReturnType = unknown> = Addon_Type & {
1650
- apply: (a: Addon_StoryApi<StoryFnReturnType>, b: any[]) => any;
1651
- };
1652
- interface Addon_ClientApiAddons<StoryFnReturnType> {
1653
- [key: string]: Addon_ClientApiAddon<StoryFnReturnType>;
1654
- }
1655
- type Addon_ClientApiReturnFn<StoryFnReturnType = unknown> = (...args: any[]) => Addon_StoryApi<StoryFnReturnType>;
1656
- interface Addon_StoryApi<StoryFnReturnType = unknown> {
1657
- kind: StoryKind;
1658
- add: (storyName: StoryName, storyFn: Addon_StoryFn<StoryFnReturnType>, parameters?: Parameters) => Addon_StoryApi<StoryFnReturnType>;
1659
- addDecorator: (decorator: Addon_DecoratorFunction<StoryFnReturnType>) => Addon_StoryApi<StoryFnReturnType>;
1660
- addLoader: (decorator: Addon_LoaderFunction) => Addon_StoryApi<StoryFnReturnType>;
1661
- addParameters: (parameters: Parameters) => Addon_StoryApi<StoryFnReturnType>;
1662
- [k: string]: string | Addon_ClientApiReturnFn<StoryFnReturnType>;
1663
- }
1664
- interface Addon_ClientStoryApi<StoryFnReturnType = unknown> {
1665
- storiesOf(kind: StoryKind, module: any): Addon_StoryApi<StoryFnReturnType>;
1666
- }
1667
- type Addon_LoadFn = () => any;
1668
- type Addon_RequireContext = any;
1669
- type Addon_Loadable = Addon_RequireContext | [Addon_RequireContext] | Addon_LoadFn;
1670
- type Addon_BaseDecorators<StoryFnReturnType> = Array<(story: () => StoryFnReturnType, context: Addon_StoryContext) => StoryFnReturnType>;
1671
- interface Addon_BaseAnnotations<TArgs, StoryFnReturnType, TRenderer extends Renderer = Renderer> {
1672
- /**
1673
- * Dynamic data that are provided (and possibly updated by) Storybook and its addons.
1674
- * @see [Arg story inputs](https://storybook.js.org/docs/react/api/csf#args-story-inputs)
1675
- */
1676
- args?: Partial<TArgs>;
1655
+ renderer?: RendererName;
1656
+ disableWebpackDefaults?: boolean;
1657
+ channelOptions?: Partial<Options$1>;
1677
1658
  /**
1678
- * ArgTypes encode basic metadata for args, such as `name`, `description`, `defaultValue` for an arg. These get automatically filled in by Storybook Docs.
1679
- * @see [Arg types](https://storybook.js.org/docs/react/api/arg-types)
1659
+ * Disables the generation of project.json, a file containing Storybook metadata
1680
1660
  */
1681
- argTypes?: Addons_ArgTypes<TArgs>;
1661
+ disableProjectJson?: boolean;
1682
1662
  /**
1683
- * Custom metadata for a story.
1684
- * @see [Parameters](https://storybook.js.org/docs/basics/writing-stories/#parameters)
1663
+ * Disables Storybook telemetry
1664
+ * @see https://storybook.js.org/telemetry
1685
1665
  */
1686
- parameters?: Parameters;
1666
+ disableTelemetry?: boolean;
1687
1667
  /**
1688
- * Wrapper components or Storybook decorators that wrap a story.
1689
- *
1690
- * Decorators defined in Meta will be applied to every story variation.
1691
- * @see [Decorators](https://storybook.js.org/docs/addons/introduction/#1-decorators)
1668
+ * Disables notifications for Storybook updates.
1692
1669
  */
1693
- decorators?: Addon_BaseDecorators<StoryFnReturnType>;
1670
+ disableWhatsNewNotifications?: boolean;
1694
1671
  /**
1695
- * Define a custom render function for the story(ies). If not passed, a default render function by the framework will be used.
1672
+ * Enable crash reports to be sent to Storybook telemetry
1673
+ * @see https://storybook.js.org/telemetry
1696
1674
  */
1697
- render?: (args: TArgs, context: Addon_StoryContext<TRenderer>) => StoryFnReturnType;
1675
+ enableCrashReports?: boolean;
1698
1676
  /**
1699
- * Function that is executed after the story is rendered.
1677
+ * enable CORS headings to run document in a "secure context"
1678
+ * see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements
1679
+ * This enables these headers in development-mode:
1680
+ * Cross-Origin-Opener-Policy: same-origin
1681
+ * Cross-Origin-Embedder-Policy: require-corp
1700
1682
  */
1701
- play?: (context: Addon_StoryContext<TRenderer>) => Promise<void> | void;
1683
+ crossOriginIsolated?: boolean;
1702
1684
  }
1703
- interface Addon_Annotations<TArgs, StoryFnReturnType> extends Addon_BaseAnnotations<TArgs, StoryFnReturnType> {
1704
- /**
1705
- * Used to only include certain named exports as stories. Useful when you want to have non-story exports such as mock data or ignore a few stories.
1706
- * @example
1707
- * includeStories: ['SimpleStory', 'ComplexStory']
1708
- * includeStories: /.*Story$/
1709
- *
1710
- * @see [Non-story exports](https://storybook.js.org/docs/formats/component-story-format/#non-story-exports)
1711
- */
1712
- includeStories?: string[] | RegExp;
1713
- /**
1714
- * Used to exclude certain named exports. Useful when you want to have non-story exports such as mock data or ignore a few stories.
1715
- * @example
1716
- * excludeStories: ['simpleData', 'complexData']
1717
- * excludeStories: /.*Data$/
1718
- *
1719
- * @see [Non-story exports](https://storybook.js.org/docs/formats/component-story-format/#non-story-exports)
1720
- */
1721
- excludeStories?: string[] | RegExp;
1685
+ interface DirectoryMapping {
1686
+ from: string;
1687
+ to: string;
1722
1688
  }
1723
- interface Addon_BaseMeta<ComponentType> {
1724
- /**
1725
- * Title of the story which will be presented in the navigation. **Should be unique.**
1726
- *
1727
- * Stories can be organized in a nested structure using "/" as a separator.
1728
- *
1729
- * Since CSF 3.0 this property is optional.
1730
- *
1731
- * @example
1732
- * export default {
1733
- * ...
1734
- * title: 'Design System/Atoms/Button'
1735
- * }
1736
- *
1737
- * @see [Story Hierarchy](https://storybook.js.org/docs/basics/writing-stories/#story-hierarchy)
1738
- */
1739
- title?: string;
1740
- /**
1741
- * Manually set the id of a story, which in particular is useful if you want to rename stories without breaking permalinks.
1742
- *
1743
- * Storybook will prioritize the id over the title for ID generation, if provided, and will prioritize the story.storyName over the export key for display.
1744
- *
1745
- * @see [Sidebar and URLs](https://storybook.js.org/docs/react/configure/sidebar-and-urls#permalinking-to-stories)
1746
- */
1747
- id?: string;
1748
- /**
1749
- * The primary component for your story.
1750
- *
1751
- * Used by addons for automatic prop table generation and display of other component metadata.
1752
- */
1753
- component?: ComponentType;
1754
- /**
1755
- * Auxiliary subcomponents that are part of the stories.
1756
- *
1757
- * Used by addons for automatic prop table generation and display of other component metadata.
1758
- *
1759
- * @example
1760
- * import { Button, ButtonGroup } from './components';
1761
- *
1762
- * export default {
1763
- * ...
1764
- * subcomponents: { Button, ButtonGroup }
1765
- * }
1766
- *
1767
- * By defining them each component will have its tab in the args table.
1768
- *
1769
- * @deprecated
1770
- */
1771
- subcomponents?: Record<string, ComponentType>;
1689
+ interface Presets {
1690
+ apply(extension: 'typescript', config: TypescriptOptions, args?: Options): Promise<TypescriptOptions>;
1691
+ apply(extension: 'framework', config?: {}, args?: any): Promise<Preset>;
1692
+ apply(extension: 'babel', config?: {}, args?: any): Promise<TransformOptions>;
1693
+ apply(extension: 'entries', config?: [], args?: any): Promise<unknown>;
1694
+ apply(extension: 'stories', config?: [], args?: any): Promise<StoriesEntry[]>;
1695
+ apply(extension: 'managerEntries', config: [], args?: any): Promise<string[]>;
1696
+ apply(extension: 'refs', config?: [], args?: any): Promise<unknown>;
1697
+ apply(extension: 'core', config?: {}, args?: any): Promise<CoreConfig>;
1698
+ apply<T>(extension: string, config?: T, args?: unknown): Promise<T>;
1772
1699
  }
1773
- type Addon_BaseStoryObject<TArgs, StoryFnReturnType> = {
1774
- /**
1775
- * Override the display name in the UI
1776
- */
1777
- storyName?: string;
1700
+ interface LoadedPreset {
1701
+ name: string;
1702
+ preset: any;
1703
+ options: any;
1704
+ }
1705
+ type PresetConfig = string | {
1706
+ name: string;
1707
+ options?: unknown;
1778
1708
  };
1779
- type Addon_BaseStoryFn<TArgs, StoryFnReturnType> = {
1780
- (args: TArgs, context: Addon_StoryContext): StoryFnReturnType;
1781
- } & Addon_BaseStoryObject<TArgs, StoryFnReturnType>;
1782
- type BaseStory<TArgs, StoryFnReturnType> = Addon_BaseStoryFn<TArgs, StoryFnReturnType> | Addon_BaseStoryObject<TArgs, StoryFnReturnType>;
1783
- interface Addon_RenderOptions {
1784
- active: boolean;
1709
+ interface Ref {
1710
+ id: string;
1711
+ url: string;
1712
+ title: string;
1713
+ version: string;
1714
+ type?: string;
1715
+ disable?: boolean;
1716
+ }
1717
+ interface VersionCheck {
1718
+ success: boolean;
1719
+ cached: boolean;
1720
+ data?: any;
1721
+ error?: any;
1722
+ time: number;
1723
+ }
1724
+ interface Stats {
1725
+ toJson: () => any;
1726
+ }
1727
+ interface BuilderResult {
1728
+ totalTime?: ReturnType<typeof process.hrtime>;
1729
+ stats?: Stats;
1730
+ }
1731
+ type PackageJson = PackageJson$1 & Record<string, any>;
1732
+ interface LoadOptions {
1733
+ packageJson: PackageJson;
1734
+ outputDir?: string;
1735
+ configDir?: string;
1736
+ ignorePreview?: boolean;
1737
+ extendServer?: (server: Server) => void;
1738
+ }
1739
+ interface CLIOptions {
1740
+ port?: number;
1741
+ ignorePreview?: boolean;
1742
+ previewUrl?: string;
1743
+ forceBuildPreview?: boolean;
1744
+ disableTelemetry?: boolean;
1745
+ enableCrashReports?: boolean;
1746
+ host?: string;
1747
+ initialPath?: string;
1785
1748
  /**
1786
- * @deprecated You should not use key anymore as of Storybook 7.2 this render method is invoked as a React component.
1787
- * This property will be removed in 8.0.
1788
- * */
1789
- key?: unknown;
1749
+ * @deprecated Use 'staticDirs' Storybook Configuration option instead
1750
+ */
1751
+ staticDir?: string[];
1752
+ configDir?: string;
1753
+ https?: boolean;
1754
+ sslCa?: string[];
1755
+ sslCert?: string;
1756
+ sslKey?: string;
1757
+ smokeTest?: boolean;
1758
+ managerCache?: boolean;
1759
+ open?: boolean;
1760
+ ci?: boolean;
1761
+ loglevel?: string;
1762
+ quiet?: boolean;
1763
+ versionUpdates?: boolean;
1764
+ docs?: boolean;
1765
+ debugWebpack?: boolean;
1766
+ webpackStatsJson?: string | boolean;
1767
+ outputDir?: string;
1768
+ }
1769
+ interface BuilderOptions {
1770
+ configType?: 'DEVELOPMENT' | 'PRODUCTION';
1771
+ ignorePreview?: boolean;
1772
+ cache?: FileSystemCache;
1773
+ configDir: string;
1774
+ docsMode?: boolean;
1775
+ features?: StorybookConfig['features'];
1776
+ versionCheck?: VersionCheck;
1777
+ disableWebpackDefaults?: boolean;
1778
+ serverChannelUrl?: string;
1779
+ }
1780
+ interface StorybookConfigOptions {
1781
+ presets: Presets;
1782
+ presetsList?: LoadedPreset[];
1783
+ }
1784
+ type Options = LoadOptions & StorybookConfigOptions & CLIOptions & BuilderOptions;
1785
+ interface Builder<Config, BuilderStats extends Stats = Stats> {
1786
+ getConfig: (options: Options) => Promise<Config>;
1787
+ start: (args: {
1788
+ options: Options;
1789
+ startTime: ReturnType<typeof process.hrtime>;
1790
+ router: Router;
1791
+ server: Server;
1792
+ channel: ServerChannel;
1793
+ }) => Promise<void | {
1794
+ stats?: BuilderStats;
1795
+ totalTime: ReturnType<typeof process.hrtime>;
1796
+ bail: (e?: Error) => Promise<void>;
1797
+ }>;
1798
+ build: (arg: {
1799
+ options: Options;
1800
+ startTime: ReturnType<typeof process.hrtime>;
1801
+ }) => Promise<void | BuilderStats>;
1802
+ bail: (e?: Error) => Promise<void>;
1803
+ corePresets?: string[];
1804
+ overridePresets?: string[];
1790
1805
  }
1791
1806
  /**
1792
- * @deprecated This type is deprecated and will be removed in 8.0.
1807
+ * Options for TypeScript usage within Storybook.
1793
1808
  */
1794
- type ReactJSXElement = {
1795
- type: any;
1796
- props: any;
1797
- key: any;
1798
- };
1799
- type Addon_Type = Addon_BaseType | Addon_PageType | Addon_WrapperType;
1800
- interface Addon_BaseType {
1801
- /**
1802
- * The title of the addon.
1803
- * This can be a simple string, but it can also be a React.FunctionComponent or a React.ReactElement.
1804
- */
1805
- title: FCWithoutChildren | ReactNode;
1806
- /**
1807
- * The type of the addon.
1808
- * @example Addon_TypesEnum.PANEL
1809
- */
1810
- type: Exclude<Addon_Types, Addon_TypesEnum.PREVIEW>;
1811
- /**
1812
- * The unique id of the addon.
1813
- * @warn This will become non-optional in 8.0
1814
- *
1815
- * This needs to be globally unique, so we recommend prefixing it with your org name or npm package name.
1816
- *
1817
- * Do not prefix with `storybook`, this is reserved for core storybook feature and core addons.
1818
- *
1819
- * @example 'my-org-name/my-addon-name'
1820
- */
1821
- id?: string;
1809
+ interface TypescriptOptions {
1822
1810
  /**
1823
- * This component will wrap your `render` function.
1824
- *
1825
- * With it you can determine if you want your addon to be rendered or not.
1811
+ * Enables type checking within Storybook.
1826
1812
  *
1827
- * This is to facilitate addons keeping state, and keep listening for events even when they are not currently on screen/rendered.
1828
- */
1829
- route?: (routeOptions: RenderData) => string;
1830
- /**
1831
- * This will determine the value of `active` prop of your render function.
1813
+ * @default `false`
1832
1814
  */
1833
- match?: (matchOptions: RenderData) => boolean;
1815
+ check: boolean;
1834
1816
  /**
1835
- * The actual contents of your addon.
1817
+ * Disable parsing typescript files through babel.
1836
1818
  *
1837
- * This is called as a function, so if you want to use hooks,
1838
- * your function needs to return a JSX.Element within which components are rendered
1839
- */
1840
- render: (renderOptions: Partial<Addon_RenderOptions>) => ReactElement<any, any> | null;
1841
- /**
1842
- * @unstable
1843
- */
1844
- paramKey?: string;
1845
- /**
1846
- * @unstable
1847
- */
1848
- disabled?: boolean;
1849
- /**
1850
- * @unstable
1819
+ * @default `false`
1851
1820
  */
1852
- hidden?: boolean;
1821
+ skipBabel: boolean;
1853
1822
  }
1823
+ type Preset = string | {
1824
+ name: string;
1825
+ options?: any;
1826
+ };
1854
1827
  /**
1855
- * This is a copy of FC from react/index.d.ts, but has the PropsWithChildren type removed
1856
- * this is correct and more type strict, and future compatible with React.FC in React 18+
1857
- *
1858
- * @deprecated This type is deprecated and will be removed in 8.0. (assuming the manager uses React 18 is out by then)
1828
+ * An additional script that gets injected into the
1829
+ * preview or the manager,
1859
1830
  */
1860
- interface FCWithoutChildren<P = {}> {
1861
- (props: P, context?: any): ReactElement<any, any> | null;
1862
- propTypes?: WeakValidationMap<P> | undefined;
1863
- contextTypes?: ValidationMap<any> | undefined;
1864
- defaultProps?: Partial<P> | undefined;
1865
- displayName?: string | undefined;
1866
- }
1867
- interface Addon_PageType {
1868
- type: Addon_TypesEnum.experimental_PAGE;
1831
+ type Entry = string;
1832
+ type CoreCommon_StorybookRefs = Record<string, {
1833
+ title: string;
1834
+ url: string;
1835
+ } | {
1836
+ disable: boolean;
1837
+ expanded?: boolean;
1838
+ }>;
1839
+ type DocsOptions = {
1869
1840
  /**
1870
- * The unique id of the page.
1841
+ * What should we call the generated docs entries?
1871
1842
  */
1872
- id: string;
1843
+ defaultName?: string;
1873
1844
  /**
1874
- * The URL to navigate to when Storybook needs to navigate to this page.
1845
+ * Should we generate a docs entry per CSF file?
1846
+ * Set to 'tag' (the default) to generate an entry for every CSF file with the
1847
+ * 'autodocs' tag.
1875
1848
  */
1876
- url: string;
1849
+ autodocs?: boolean | 'tag';
1877
1850
  /**
1878
- * The title is used in mobile mode to represent the page in the navigation.
1851
+ * Only show doc entries in the side bar (usually set with the `--docs` CLI flag)
1879
1852
  */
1880
- title: FCWithoutChildren | string | ReactElement | ReactNode;
1853
+ docsMode?: boolean;
1854
+ };
1855
+ /**
1856
+ * The interface for Storybook configuration in `main.ts` files.
1857
+ */
1858
+ interface StorybookConfig {
1881
1859
  /**
1882
- * The main content of the addon, a function component without any props.
1883
- * Storybook will render your component always.
1860
+ * Sets the addons you want to use with Storybook.
1884
1861
  *
1885
- * If you want to render your component only when the URL matches, use the `Route` component.
1886
- * @example
1887
- * import { Route } from '@storybook/router';
1862
+ * @example `['@storybook/addon-essentials']` or `[{ name: '@storybook/addon-essentials', options: { backgrounds: false } }]`
1863
+ */
1864
+ addons?: Preset[];
1865
+ core?: CoreConfig;
1866
+ /**
1867
+ * Sets a list of directories of static files to be loaded by Storybook server
1888
1868
  *
1889
- * render: () => {
1890
- * return (
1891
- * <Route path="/my-addon">
1892
- * <MyAddonContent />
1893
- * </Route>
1894
- * );
1895
- * };
1896
- */
1897
- render: FCWithoutChildren;
1898
- }
1899
- interface Addon_WrapperType {
1900
- type: Addon_TypesEnum.PREVIEW;
1901
- /**
1902
- * The unique id of the page.
1903
- */
1904
- id: string;
1905
- /**
1906
- * A React.FunctionComponent that wraps the story.
1907
- *
1908
- * This component must accept a children prop, and render it.
1869
+ * @example `['./public']` or `[{from: './public', 'to': '/assets'}]`
1909
1870
  */
1910
- render: FC<PropsWithChildren<{
1911
- index: number;
1912
- children: ReactNode;
1913
- id: string;
1914
- storyId: StoryId;
1915
- active: boolean;
1916
- }>>;
1917
- }
1918
- type Addon_TypeBaseNames = Exclude<Addon_TypesEnum, Addon_TypesEnum.PREVIEW | Addon_TypesEnum.experimental_PAGE>;
1919
- interface Addon_TypesMapping extends Record<Addon_TypeBaseNames, Addon_BaseType> {
1920
- [Addon_TypesEnum.PREVIEW]: Addon_WrapperType;
1921
- [Addon_TypesEnum.experimental_PAGE]: Addon_PageType;
1922
- }
1923
- type Addon_Loader<API> = (api: API) => void;
1924
- interface Addon_Loaders<API> {
1925
- [key: string]: Addon_Loader<API>;
1926
- }
1927
- interface Addon_Collection<T = Addon_Type> {
1928
- [key: string]: T;
1929
- }
1930
- interface Addon_Elements {
1931
- [key: string]: Addon_Collection;
1932
- }
1933
- interface Addon_ToolbarConfig {
1934
- hidden?: boolean;
1935
- }
1936
- interface Addon_Config {
1937
- theme?: ThemeVars;
1938
- toolbar?: {
1939
- [id: string]: Addon_ToolbarConfig;
1871
+ staticDirs?: (DirectoryMapping | string)[];
1872
+ logLevel?: string;
1873
+ features?: {
1874
+ /**
1875
+ * Build stories.json automatically on start/build
1876
+ */
1877
+ buildStoriesJson?: boolean;
1878
+ /**
1879
+ * Activate on demand story store
1880
+ */
1881
+ storyStoreV7?: boolean;
1882
+ /**
1883
+ * Do not throw errors if using `.mdx` files in SSv7
1884
+ * (for internal use in sandboxes)
1885
+ */
1886
+ storyStoreV7MdxErrors?: boolean;
1887
+ /**
1888
+ * Filter args with a "target" on the type from the render function (EXPERIMENTAL)
1889
+ */
1890
+ argTypeTargetsV7?: boolean;
1891
+ /**
1892
+ * Warn when there is a pre-6.0 hierarchy separator ('.' / '|') in the story title.
1893
+ * Will be removed in 7.0.
1894
+ */
1895
+ warnOnLegacyHierarchySeparator?: boolean;
1896
+ /**
1897
+ * Use legacy MDX1, to help smooth migration to 7.0
1898
+ */
1899
+ legacyMdx1?: boolean;
1900
+ /**
1901
+ * Apply decorators from preview.js before decorators from addons or frameworks
1902
+ */
1903
+ legacyDecoratorFileOrder?: boolean;
1940
1904
  };
1941
- [key: string]: any;
1942
- }
1943
- declare enum Addon_TypesEnum {
1944
1905
  /**
1945
- * This API is used to create a tab the toolbar above the canvas, This API might be removed in the future.
1946
- * @unstable
1906
+ * Tells Storybook where to find stories.
1907
+ *
1908
+ * @example `['./src/*.stories.@(j|t)sx?']`
1947
1909
  */
1948
- TAB = "tab",
1910
+ stories: StoriesEntry[];
1949
1911
  /**
1950
- * This adds panels to the addons side panel.
1912
+ * Framework, e.g. '@storybook/react-vite', required in v7
1951
1913
  */
1952
- PANEL = "panel",
1914
+ framework?: Preset;
1953
1915
  /**
1954
- * This adds items in the toolbar above the canvas - on the left side.
1916
+ * Controls how Storybook handles TypeScript files.
1955
1917
  */
1956
- TOOL = "tool",
1918
+ typescript?: Partial<TypescriptOptions>;
1957
1919
  /**
1958
- * This adds items in the toolbar above the canvas - on the right side.
1920
+ * References external Storybooks
1959
1921
  */
1960
- TOOLEXTRA = "toolextra",
1922
+ refs?: PresetValue<CoreCommon_StorybookRefs>;
1961
1923
  /**
1962
- * This adds wrapper components around the canvas/iframe component storybook renders.
1963
- * @unstable this API is not stable yet, and is likely to change in 8.0.
1924
+ * Modify or return babel config.
1964
1925
  */
1965
- PREVIEW = "preview",
1926
+ babel?: (config: TransformOptions, options: Options) => TransformOptions | Promise<TransformOptions>;
1966
1927
  /**
1967
- * This adds pages that render instead of the canvas.
1968
- * @unstable
1928
+ * Modify or return env config.
1969
1929
  */
1970
- experimental_PAGE = "page",
1930
+ env?: PresetValue<Record<string, string>>;
1971
1931
  /**
1972
- * @deprecated This property does nothing, and will be removed in Storybook 8.0.
1932
+ * Modify or return babel config.
1973
1933
  */
1974
- NOTES_ELEMENT = "notes-element"
1975
- }
1976
-
1977
- type OrString$1<T extends string> = T | (string & {});
1978
- type ViewMode = OrString$1<ViewMode$1 | 'settings'> | undefined;
1979
- type Layout = 'centered' | 'fullscreen' | 'padded' | 'none';
1980
- interface StorybookParameters {
1981
- options?: Addon_OptionsParameter;
1934
+ babelDefault?: (config: TransformOptions, options: Options) => TransformOptions | Promise<TransformOptions>;
1982
1935
  /**
1983
- * The layout property defines basic styles added to the preview body where the story is rendered.
1936
+ * Add additional scripts to run in the preview a la `.storybook/preview.js`
1984
1937
  *
1985
- * If you pass `none`, no styles are applied.
1938
+ * @deprecated use `previewAnnotations` or `/preview.js` file instead
1986
1939
  */
1987
- layout?: Layout;
1988
- }
1989
- interface StorybookInternalParameters extends StorybookParameters {
1990
- fileName?: string;
1991
- docsOnly?: true;
1992
- }
1993
- type Path = string;
1994
-
1995
- interface WebRenderer extends Renderer {
1996
- canvasElement: HTMLElement;
1997
- }
1998
- type ModuleExport = any;
1999
- type ModuleExports = Record<string, ModuleExport>;
2000
- type ModuleImportFn = (path: Path) => Promise<ModuleExports>;
2001
- type MaybePromise<T> = Promise<T> | T;
2002
- type TeardownRenderToCanvas = () => MaybePromise<void>;
2003
- type RenderToCanvas<TRenderer extends Renderer> = (context: RenderContext<TRenderer>, element: TRenderer['canvasElement']) => MaybePromise<void | TeardownRenderToCanvas>;
2004
- type ProjectAnnotations<TRenderer extends Renderer> = ProjectAnnotations$1<TRenderer> & {
2005
- renderToCanvas?: RenderToCanvas<TRenderer>;
2006
- renderToDOM?: RenderToCanvas<TRenderer>;
2007
- };
2008
- type NormalizedProjectAnnotations<TRenderer extends Renderer = Renderer> = ProjectAnnotations<TRenderer> & {
2009
- argTypes?: StrictArgTypes;
2010
- globalTypes?: StrictGlobalTypes;
2011
- };
2012
- type NormalizedComponentAnnotations<TRenderer extends Renderer = Renderer> = ComponentAnnotations<TRenderer> & {
2013
- id: ComponentId;
2014
- title: ComponentTitle;
2015
- argTypes?: StrictArgTypes;
2016
- };
2017
- type NormalizedStoryAnnotations<TRenderer extends Renderer = Renderer> = Omit<StoryAnnotations<TRenderer>, 'storyName' | 'story'> & {
2018
- moduleExport: ModuleExport;
2019
- id: StoryId;
2020
- argTypes?: StrictArgTypes;
2021
- name: StoryName;
2022
- userStoryFn?: StoryFn<TRenderer>;
2023
- };
2024
- type CSFFile<TRenderer extends Renderer = Renderer> = {
2025
- meta: NormalizedComponentAnnotations<TRenderer>;
2026
- stories: Record<StoryId, NormalizedStoryAnnotations<TRenderer>>;
2027
- moduleExports: ModuleExports;
2028
- };
2029
- type PreparedStory<TRenderer extends Renderer = Renderer> = StoryContextForEnhancers<TRenderer> & {
2030
- moduleExport: ModuleExport;
2031
- originalStoryFn: StoryFn<TRenderer>;
2032
- undecoratedStoryFn: LegacyStoryFn<TRenderer>;
2033
- unboundStoryFn: LegacyStoryFn<TRenderer>;
2034
- applyLoaders: (context: StoryContextForLoaders<TRenderer>) => Promise<StoryContextForLoaders<TRenderer> & {
2035
- loaded: StoryContext<TRenderer>['loaded'];
2036
- }>;
2037
- playFunction?: (context: StoryContext<TRenderer>) => Promise<void> | void;
2038
- };
2039
- type PreparedMeta<TRenderer extends Renderer = Renderer> = Omit<StoryContextForEnhancers<TRenderer>, 'name' | 'story'> & {
2040
- moduleExport: ModuleExport;
2041
- };
2042
- type BoundStory<TRenderer extends Renderer = Renderer> = PreparedStory<TRenderer> & {
2043
- storyFn: PartialStoryFn<TRenderer>;
2044
- };
2045
- declare type RenderContext<TRenderer extends Renderer = Renderer> = StoryIdentifier & {
2046
- showMain: () => void;
2047
- showError: (error: {
2048
- title: string;
2049
- description: string;
2050
- }) => void;
2051
- showException: (err: Error) => void;
2052
- forceRemount: boolean;
2053
- storyContext: StoryContext<TRenderer>;
2054
- storyFn: PartialStoryFn<TRenderer>;
2055
- unboundStoryFn: LegacyStoryFn<TRenderer>;
2056
- };
2057
-
2058
- interface Options$1 {
2059
- allowRegExp: boolean;
2060
- allowFunction: boolean;
2061
- allowSymbol: boolean;
2062
- allowDate: boolean;
2063
- allowUndefined: boolean;
2064
- allowClass: boolean;
2065
- maxDepth: number;
2066
- space: number | undefined;
2067
- lazyEval: boolean;
2068
- }
2069
-
2070
- /**
2071
- * ⚠️ This file contains internal WIP types they MUST NOT be exported outside this package for now!
2072
- */
2073
- type BuilderName = 'webpack5' | '@storybook/builder-webpack5' | string;
2074
- type RendererName = string;
2075
- interface ServerChannel {
2076
- emit(type: string, args?: any): void;
2077
- }
2078
- interface CoreConfig {
2079
- builder?: BuilderName | {
2080
- name: BuilderName;
2081
- options?: Record<string, any>;
2082
- };
2083
- renderer?: RendererName;
2084
- disableWebpackDefaults?: boolean;
2085
- channelOptions?: Partial<Options$1>;
1940
+ config?: PresetValue<Entry[]>;
2086
1941
  /**
2087
- * Disables the generation of project.json, a file containing Storybook metadata
1942
+ * Add additional scripts to run in the preview a la `.storybook/preview.js`
2088
1943
  */
2089
- disableProjectJson?: boolean;
1944
+ previewAnnotations?: PresetValue<Entry[]>;
2090
1945
  /**
2091
- * Disables Storybook telemetry
2092
- * @see https://storybook.js.org/telemetry
1946
+ * Process CSF files for the story index.
1947
+ * @soonDeprecated use {@link experimental_indexers} instead
2093
1948
  */
2094
- disableTelemetry?: boolean;
1949
+ storyIndexers?: PresetValue<StoryIndexer[]>;
2095
1950
  /**
2096
- * Disables notifications for Storybook updates.
1951
+ * Process CSF files for the story index.
2097
1952
  */
2098
- disableWhatsNewNotifications?: boolean;
1953
+ experimental_indexers?: PresetValue<Indexer[]>;
2099
1954
  /**
2100
- * Enable crash reports to be sent to Storybook telemetry
2101
- * @see https://storybook.js.org/telemetry
1955
+ * Docs related features in index generation
2102
1956
  */
2103
- enableCrashReports?: boolean;
1957
+ docs?: DocsOptions;
2104
1958
  /**
2105
- * enable CORS headings to run document in a "secure context"
2106
- * see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements
2107
- * This enables these headers in development-mode:
2108
- * Cross-Origin-Opener-Policy: same-origin
2109
- * Cross-Origin-Embedder-Policy: require-corp
1959
+ * Programmatically modify the preview head/body HTML.
1960
+ * The previewHead and previewBody functions accept a string,
1961
+ * which is the existing head/body, and return a modified string.
2110
1962
  */
2111
- crossOriginIsolated?: boolean;
2112
- }
2113
- interface DirectoryMapping {
2114
- from: string;
2115
- to: string;
1963
+ previewHead?: PresetValue<string>;
1964
+ previewBody?: PresetValue<string>;
1965
+ /**
1966
+ * Programmatically override the preview's main page template.
1967
+ * This should return a reference to a file containing an `.ejs` template
1968
+ * that will be interpolated with environment variables.
1969
+ *
1970
+ * @example '.storybook/index.ejs'
1971
+ */
1972
+ previewMainTemplate?: string;
1973
+ /**
1974
+ * Programmatically modify the preview head/body HTML.
1975
+ * The managerHead function accept a string,
1976
+ * which is the existing head content, and return a modified string.
1977
+ */
1978
+ managerHead?: PresetValue<string>;
2116
1979
  }
2117
- interface Presets {
2118
- apply(extension: 'typescript', config: TypescriptOptions, args?: Options): Promise<TypescriptOptions>;
2119
- apply(extension: 'framework', config?: {}, args?: any): Promise<Preset>;
2120
- apply(extension: 'babel', config?: {}, args?: any): Promise<TransformOptions>;
2121
- apply(extension: 'entries', config?: [], args?: any): Promise<unknown>;
2122
- apply(extension: 'stories', config?: [], args?: any): Promise<StoriesEntry[]>;
2123
- apply(extension: 'managerEntries', config: [], args?: any): Promise<string[]>;
2124
- apply(extension: 'refs', config?: [], args?: any): Promise<unknown>;
2125
- apply(extension: 'core', config?: {}, args?: any): Promise<CoreConfig>;
2126
- apply<T>(extension: string, config?: T, args?: unknown): Promise<T>;
1980
+ type PresetValue<T> = T | ((config: T, options: Options) => T | Promise<T>);
1981
+ type PresetProperty<K, TStorybookConfig = StorybookConfig> = TStorybookConfig[K extends keyof TStorybookConfig ? K : never] | PresetPropertyFn<K, TStorybookConfig>;
1982
+ type PresetPropertyFn<K, TStorybookConfig = StorybookConfig, TOptions = {}> = (config: TStorybookConfig[K extends keyof TStorybookConfig ? K : never], options: Options & TOptions) => TStorybookConfig[K extends keyof TStorybookConfig ? K : never] | Promise<TStorybookConfig[K extends keyof TStorybookConfig ? K : never]>;
1983
+ interface CoreCommon_ResolvedAddonPreset {
1984
+ type: 'presets';
1985
+ name: string;
2127
1986
  }
2128
- interface LoadedPreset {
1987
+ type PreviewAnnotation = string | {
1988
+ bare: string;
1989
+ absolute: string;
1990
+ };
1991
+ interface CoreCommon_ResolvedAddonVirtual {
1992
+ type: 'virtual';
2129
1993
  name: string;
2130
- preset: any;
2131
- options: any;
1994
+ managerEntries?: string[];
1995
+ previewAnnotations?: PreviewAnnotation[];
1996
+ presets?: (string | {
1997
+ name: string;
1998
+ options?: any;
1999
+ })[];
2132
2000
  }
2133
- type PresetConfig = string | {
2001
+ type CoreCommon_OptionsEntry = {
2134
2002
  name: string;
2135
- options?: unknown;
2136
2003
  };
2137
- interface Ref {
2138
- id: string;
2139
- url: string;
2140
- title: string;
2004
+ type CoreCommon_AddonEntry = string | CoreCommon_OptionsEntry;
2005
+ type CoreCommon_AddonInfo = {
2006
+ name: string;
2007
+ inEssentials: boolean;
2008
+ };
2009
+ interface CoreCommon_StorybookInfo {
2141
2010
  version: string;
2142
- type?: string;
2143
- disable?: boolean;
2144
- }
2145
- interface VersionCheck {
2146
- success: boolean;
2147
- cached: boolean;
2148
- data?: any;
2149
- error?: any;
2150
- time: number;
2151
- }
2152
- interface Stats {
2153
- toJson: () => any;
2011
+ framework: string;
2012
+ frameworkPackage: string;
2013
+ renderer: string;
2014
+ rendererPackage: string;
2015
+ configDir?: string;
2016
+ mainConfig?: string;
2017
+ previewConfig?: string;
2018
+ managerConfig?: string;
2154
2019
  }
2155
- interface BuilderResult {
2156
- totalTime?: ReturnType<typeof process.hrtime>;
2157
- stats?: Stats;
2020
+
2021
+ interface API_BaseEntry {
2022
+ id: StoryId;
2023
+ depth: number;
2024
+ name: string;
2025
+ refId?: string;
2026
+ renderLabel?: (item: API_BaseEntry) => any;
2027
+ /** @deprecated */
2028
+ isRoot: boolean;
2029
+ /** @deprecated */
2030
+ isComponent: boolean;
2031
+ /** @deprecated */
2032
+ isLeaf: boolean;
2158
2033
  }
2159
- type PackageJson = PackageJson$1 & Record<string, any>;
2160
- interface LoadOptions {
2161
- packageJson: PackageJson;
2162
- outputDir?: string;
2163
- configDir?: string;
2164
- ignorePreview?: boolean;
2165
- extendServer?: (server: Server) => void;
2034
+ interface API_RootEntry extends API_BaseEntry {
2035
+ type: 'root';
2036
+ startCollapsed?: boolean;
2037
+ children: StoryId[];
2038
+ /** @deprecated */
2039
+ isRoot: true;
2040
+ /** @deprecated */
2041
+ isComponent: false;
2042
+ /** @deprecated */
2043
+ isLeaf: false;
2166
2044
  }
2167
- interface CLIOptions {
2168
- port?: number;
2169
- ignorePreview?: boolean;
2170
- previewUrl?: string;
2171
- forceBuildPreview?: boolean;
2172
- disableTelemetry?: boolean;
2173
- enableCrashReports?: boolean;
2174
- host?: string;
2175
- initialPath?: string;
2176
- /**
2177
- * @deprecated Use 'staticDirs' Storybook Configuration option instead
2178
- */
2179
- staticDir?: string[];
2180
- configDir?: string;
2181
- https?: boolean;
2182
- sslCa?: string[];
2183
- sslCert?: string;
2184
- sslKey?: string;
2185
- smokeTest?: boolean;
2186
- managerCache?: boolean;
2187
- open?: boolean;
2188
- ci?: boolean;
2189
- loglevel?: string;
2190
- quiet?: boolean;
2191
- versionUpdates?: boolean;
2192
- docs?: boolean;
2193
- debugWebpack?: boolean;
2194
- webpackStatsJson?: string | boolean;
2195
- outputDir?: string;
2045
+ interface API_GroupEntry extends API_BaseEntry {
2046
+ type: 'group';
2047
+ parent?: StoryId;
2048
+ children: StoryId[];
2049
+ /** @deprecated */
2050
+ isRoot: false;
2051
+ /** @deprecated */
2052
+ isComponent: false;
2053
+ /** @deprecated */
2054
+ isLeaf: false;
2196
2055
  }
2197
- interface BuilderOptions {
2198
- configType?: 'DEVELOPMENT' | 'PRODUCTION';
2199
- ignorePreview?: boolean;
2200
- cache?: FileSystemCache;
2201
- configDir: string;
2202
- docsMode?: boolean;
2203
- features?: StorybookConfig['features'];
2204
- versionCheck?: VersionCheck;
2205
- disableWebpackDefaults?: boolean;
2206
- serverChannelUrl?: string;
2056
+ interface API_ComponentEntry extends API_BaseEntry {
2057
+ type: 'component';
2058
+ parent?: StoryId;
2059
+ children: StoryId[];
2060
+ /** @deprecated */
2061
+ isRoot: false;
2062
+ /** @deprecated */
2063
+ isComponent: true;
2064
+ /** @deprecated */
2065
+ isLeaf: false;
2207
2066
  }
2208
- interface StorybookConfigOptions {
2209
- presets: Presets;
2210
- presetsList?: LoadedPreset[];
2067
+ interface API_DocsEntry extends API_BaseEntry {
2068
+ type: 'docs';
2069
+ parent: StoryId;
2070
+ title: ComponentTitle;
2071
+ /** @deprecated */
2072
+ kind: ComponentTitle;
2073
+ importPath: Path;
2074
+ tags: Tag[];
2075
+ prepared: boolean;
2076
+ parameters?: {
2077
+ [parameterName: string]: any;
2078
+ };
2079
+ /** @deprecated */
2080
+ isRoot: false;
2081
+ /** @deprecated */
2082
+ isComponent: false;
2083
+ /** @deprecated */
2084
+ isLeaf: true;
2211
2085
  }
2212
- type Options = LoadOptions & StorybookConfigOptions & CLIOptions & BuilderOptions;
2213
- interface Builder<Config, BuilderStats extends Stats = Stats> {
2214
- getConfig: (options: Options) => Promise<Config>;
2215
- start: (args: {
2216
- options: Options;
2217
- startTime: ReturnType<typeof process.hrtime>;
2218
- router: Router;
2219
- server: Server;
2220
- channel: ServerChannel;
2221
- }) => Promise<void | {
2222
- stats?: BuilderStats;
2223
- totalTime: ReturnType<typeof process.hrtime>;
2224
- bail: (e?: Error) => Promise<void>;
2225
- }>;
2226
- build: (arg: {
2227
- options: Options;
2228
- startTime: ReturnType<typeof process.hrtime>;
2229
- }) => Promise<void | BuilderStats>;
2230
- bail: (e?: Error) => Promise<void>;
2231
- corePresets?: string[];
2232
- overridePresets?: string[];
2086
+ interface API_StoryEntry extends API_BaseEntry {
2087
+ type: 'story';
2088
+ parent: StoryId;
2089
+ title: ComponentTitle;
2090
+ /** @deprecated */
2091
+ kind: ComponentTitle;
2092
+ importPath: Path;
2093
+ tags: Tag[];
2094
+ prepared: boolean;
2095
+ parameters?: {
2096
+ [parameterName: string]: any;
2097
+ };
2098
+ args?: Args;
2099
+ argTypes?: ArgTypes;
2100
+ initialArgs?: Args;
2101
+ /** @deprecated */
2102
+ isRoot: false;
2103
+ /** @deprecated */
2104
+ isComponent: false;
2105
+ /** @deprecated */
2106
+ isLeaf: true;
2233
2107
  }
2108
+ type API_LeafEntry = API_DocsEntry | API_StoryEntry;
2109
+ type API_HashEntry = API_RootEntry | API_GroupEntry | API_ComponentEntry | API_DocsEntry | API_StoryEntry;
2110
+ /** @deprecated */
2111
+ type API_Root = API_RootEntry;
2112
+ /** @deprecated */
2113
+ type API_Group = API_GroupEntry | API_ComponentEntry;
2114
+ /** @deprecated */
2115
+ type API_Story = API_LeafEntry;
2234
2116
  /**
2235
- * Options for TypeScript usage within Storybook.
2117
+ * The `IndexHash` is our manager-side representation of the `StoryIndex`.
2118
+ * We create entries in the hash not only for each story or docs entry, but
2119
+ * also for each "group" of the component (split on '/'), as that's how things
2120
+ * are manipulated in the manager (i.e. in the sidebar)
2236
2121
  */
2237
- interface TypescriptOptions {
2238
- /**
2239
- * Enables type checking within Storybook.
2240
- *
2241
- * @default `false`
2242
- */
2243
- check: boolean;
2244
- /**
2245
- * Disable parsing typescript files through babel.
2246
- *
2247
- * @default `false`
2248
- */
2249
- skipBabel: boolean;
2122
+ interface API_IndexHash {
2123
+ [id: string]: API_HashEntry;
2250
2124
  }
2251
- type Preset = string | {
2252
- name: string;
2253
- options?: any;
2254
- };
2255
- /**
2256
- * An additional script that gets injected into the
2257
- * preview or the manager,
2258
- */
2259
- type Entry = string;
2260
- type CoreCommon_StorybookRefs = Record<string, {
2261
- title: string;
2262
- url: string;
2263
- } | {
2264
- disable: boolean;
2265
- expanded?: boolean;
2266
- }>;
2267
- type DocsOptions = {
2268
- /**
2269
- * What should we call the generated docs entries?
2270
- */
2271
- defaultName?: string;
2272
- /**
2273
- * Should we generate a docs entry per CSF file?
2274
- * Set to 'tag' (the default) to generate an entry for every CSF file with the
2275
- * 'autodocs' tag.
2276
- */
2277
- autodocs?: boolean | 'tag';
2278
- /**
2279
- * Only show doc entries in the side bar (usually set with the `--docs` CLI flag)
2280
- */
2281
- docsMode?: boolean;
2125
+ type API_PreparedIndexEntry = IndexEntry & {
2126
+ parameters?: Parameters;
2127
+ argTypes?: ArgTypes;
2128
+ args?: Args;
2129
+ initialArgs?: Args;
2282
2130
  };
2283
- /**
2284
- * The interface for Storybook configuration in `main.ts` files.
2285
- */
2286
- interface StorybookConfig {
2287
- /**
2288
- * Sets the addons you want to use with Storybook.
2289
- *
2290
- * @example `['@storybook/addon-essentials']` or `[{ name: '@storybook/addon-essentials', options: { backgrounds: false } }]`
2291
- */
2292
- addons?: Preset[];
2293
- core?: CoreConfig;
2294
- /**
2295
- * Sets a list of directories of static files to be loaded by Storybook server
2296
- *
2297
- * @example `['./public']` or `[{from: './public', 'to': '/assets'}]`
2298
- */
2299
- staticDirs?: (DirectoryMapping | string)[];
2300
- logLevel?: string;
2301
- features?: {
2302
- /**
2303
- * Build stories.json automatically on start/build
2304
- */
2305
- buildStoriesJson?: boolean;
2306
- /**
2307
- * Activate on demand story store
2308
- */
2309
- storyStoreV7?: boolean;
2310
- /**
2311
- * Do not throw errors if using `.mdx` files in SSv7
2312
- * (for internal use in sandboxes)
2313
- */
2314
- storyStoreV7MdxErrors?: boolean;
2315
- /**
2316
- * Filter args with a "target" on the type from the render function (EXPERIMENTAL)
2317
- */
2318
- argTypeTargetsV7?: boolean;
2319
- /**
2320
- * Warn when there is a pre-6.0 hierarchy separator ('.' / '|') in the story title.
2321
- * Will be removed in 7.0.
2322
- */
2323
- warnOnLegacyHierarchySeparator?: boolean;
2324
- /**
2325
- * Use legacy MDX1, to help smooth migration to 7.0
2326
- */
2327
- legacyMdx1?: boolean;
2328
- /**
2329
- * Apply decorators from preview.js before decorators from addons or frameworks
2330
- */
2331
- legacyDecoratorFileOrder?: boolean;
2332
- };
2333
- /**
2334
- * Tells Storybook where to find stories.
2335
- *
2336
- * @example `['./src/*.stories.@(j|t)sx?']`
2337
- */
2338
- stories: StoriesEntry[];
2339
- /**
2340
- * Framework, e.g. '@storybook/react-vite', required in v7
2341
- */
2342
- framework?: Preset;
2343
- /**
2344
- * Controls how Storybook handles TypeScript files.
2345
- */
2346
- typescript?: Partial<TypescriptOptions>;
2347
- /**
2348
- * References external Storybooks
2349
- */
2350
- refs?: PresetValue<CoreCommon_StorybookRefs>;
2351
- /**
2352
- * Modify or return babel config.
2353
- */
2354
- babel?: (config: TransformOptions, options: Options) => TransformOptions | Promise<TransformOptions>;
2355
- /**
2356
- * Modify or return env config.
2357
- */
2358
- env?: PresetValue<Record<string, string>>;
2359
- /**
2360
- * Modify or return babel config.
2361
- */
2362
- babelDefault?: (config: TransformOptions, options: Options) => TransformOptions | Promise<TransformOptions>;
2363
- /**
2364
- * Add additional scripts to run in the preview a la `.storybook/preview.js`
2365
- *
2366
- * @deprecated use `previewAnnotations` or `/preview.js` file instead
2367
- */
2368
- config?: PresetValue<Entry[]>;
2369
- /**
2370
- * Add additional scripts to run in the preview a la `.storybook/preview.js`
2371
- */
2372
- previewAnnotations?: PresetValue<Entry[]>;
2373
- /**
2374
- * Process CSF files for the story index.
2375
- * @soonDeprecated use {@link experimental_indexers} instead
2376
- */
2377
- storyIndexers?: PresetValue<StoryIndexer[]>;
2378
- /**
2379
- * Process CSF files for the story index.
2380
- */
2381
- experimental_indexers?: PresetValue<Indexer[]>;
2382
- /**
2383
- * Docs related features in index generation
2384
- */
2385
- docs?: DocsOptions;
2386
- /**
2387
- * Programmatically modify the preview head/body HTML.
2388
- * The previewHead and previewBody functions accept a string,
2389
- * which is the existing head/body, and return a modified string.
2390
- */
2391
- previewHead?: PresetValue<string>;
2392
- previewBody?: PresetValue<string>;
2393
- /**
2394
- * Programmatically override the preview's main page template.
2395
- * This should return a reference to a file containing an `.ejs` template
2396
- * that will be interpolated with environment variables.
2397
- *
2398
- * @example '.storybook/index.ejs'
2399
- */
2400
- previewMainTemplate?: string;
2401
- /**
2402
- * Programmatically modify the preview head/body HTML.
2403
- * The managerHead function accept a string,
2404
- * which is the existing head content, and return a modified string.
2405
- */
2406
- managerHead?: PresetValue<string>;
2407
- }
2408
- type PresetValue<T> = T | ((config: T, options: Options) => T | Promise<T>);
2409
- type PresetProperty<K, TStorybookConfig = StorybookConfig> = TStorybookConfig[K extends keyof TStorybookConfig ? K : never] | PresetPropertyFn<K, TStorybookConfig>;
2410
- type PresetPropertyFn<K, TStorybookConfig = StorybookConfig, TOptions = {}> = (config: TStorybookConfig[K extends keyof TStorybookConfig ? K : never], options: Options & TOptions) => TStorybookConfig[K extends keyof TStorybookConfig ? K : never] | Promise<TStorybookConfig[K extends keyof TStorybookConfig ? K : never]>;
2411
- interface CoreCommon_ResolvedAddonPreset {
2412
- type: 'presets';
2413
- name: string;
2131
+ interface API_PreparedStoryIndex {
2132
+ v: number;
2133
+ entries: Record<StoryId, API_PreparedIndexEntry>;
2414
2134
  }
2415
- type PreviewAnnotation = string | {
2416
- bare: string;
2417
- absolute: string;
2135
+ type API_OptionsData = {
2136
+ docsOptions: DocsOptions;
2418
2137
  };
2419
- interface CoreCommon_ResolvedAddonVirtual {
2420
- type: 'virtual';
2421
- name: string;
2422
- managerEntries?: string[];
2423
- previewAnnotations?: PreviewAnnotation[];
2424
- presets?: (string | {
2425
- name: string;
2426
- options?: any;
2427
- })[];
2138
+ interface API_ReleaseNotes {
2139
+ success?: boolean;
2140
+ currentVersion?: string;
2141
+ showOnFirstLaunch?: boolean;
2428
2142
  }
2429
- type CoreCommon_OptionsEntry = {
2430
- name: string;
2431
- };
2432
- type CoreCommon_AddonEntry = string | CoreCommon_OptionsEntry;
2433
- type CoreCommon_AddonInfo = {
2434
- name: string;
2435
- inEssentials: boolean;
2436
- };
2437
- interface CoreCommon_StorybookInfo {
2143
+ interface API_Settings {
2144
+ lastTrackedStoryId: string;
2145
+ }
2146
+ interface API_Version {
2438
2147
  version: string;
2439
- framework: string;
2440
- frameworkPackage: string;
2441
- renderer: string;
2442
- rendererPackage: string;
2443
- configDir?: string;
2444
- mainConfig?: string;
2445
- previewConfig?: string;
2446
- managerConfig?: string;
2148
+ info?: {
2149
+ plain: string;
2150
+ };
2151
+ [key: string]: any;
2447
2152
  }
2448
-
2449
- interface BuilderStats {
2450
- toJson: () => any;
2153
+ interface API_UnknownEntries {
2154
+ [key: string]: {
2155
+ [key: string]: any;
2156
+ };
2451
2157
  }
2452
- type Builder_WithRequiredProperty<Type, Key extends keyof Type> = Type & {
2453
- [Property in Key]-?: Type[Property];
2454
- };
2455
- type Builder_Unpromise<T extends Promise<any>> = T extends Promise<infer U> ? U : never;
2456
- type Builder_EnvsRaw = Record<string, string>;
2457
-
2458
- type ChannelHandler = (event: ChannelEvent) => void;
2459
- interface ChannelTransport {
2460
- send(event: ChannelEvent, options?: any): void;
2461
- setHandler(handler: ChannelHandler): void;
2158
+ interface API_Versions$1 {
2159
+ latest?: API_Version;
2160
+ next?: API_Version;
2161
+ current?: API_Version;
2462
2162
  }
2463
- interface ChannelEvent {
2464
- type: string;
2465
- from: string;
2466
- args: any[];
2467
- }
2468
- interface Listener {
2469
- (...args: any[]): void;
2470
- }
2471
- interface ChannelArgsSingle {
2472
- transport?: ChannelTransport;
2473
- async?: boolean;
2474
- }
2475
- interface ChannelArgsMulti {
2476
- transports: ChannelTransport[];
2477
- async?: boolean;
2478
- }
2479
-
2480
- declare class Channel {
2481
- readonly isAsync: boolean;
2482
- private sender;
2483
- private events;
2484
- private data;
2485
- private readonly transports;
2486
- constructor(input: ChannelArgsMulti);
2487
- constructor(input: ChannelArgsSingle);
2488
- get hasTransport(): boolean;
2489
- addListener(eventName: string, listener: Listener): void;
2490
- emit(eventName: string, ...args: any): void;
2491
- last(eventName: string): any;
2492
- eventNames(): string[];
2493
- listenerCount(eventName: string): number;
2494
- listeners(eventName: string): Listener[] | undefined;
2495
- once(eventName: string, listener: Listener): void;
2496
- removeAllListeners(eventName?: string): void;
2497
- removeListener(eventName: string, listener: Listener): void;
2498
- on(eventName: string, listener: Listener): void;
2499
- off(eventName: string, listener: Listener): void;
2500
- private handleEvent;
2501
- private onceListener;
2502
- }
2503
-
2504
- interface API_BaseEntry {
2505
- id: StoryId;
2506
- depth: number;
2507
- name: string;
2508
- refId?: string;
2509
- renderLabel?: (item: API_BaseEntry) => any;
2510
- /** @deprecated */
2511
- isRoot: boolean;
2512
- /** @deprecated */
2513
- isComponent: boolean;
2514
- /** @deprecated */
2515
- isLeaf: boolean;
2516
- }
2517
- interface API_RootEntry extends API_BaseEntry {
2518
- type: 'root';
2519
- startCollapsed?: boolean;
2520
- children: StoryId[];
2521
- /** @deprecated */
2522
- isRoot: true;
2523
- /** @deprecated */
2524
- isComponent: false;
2525
- /** @deprecated */
2526
- isLeaf: false;
2527
- }
2528
- interface API_GroupEntry extends API_BaseEntry {
2529
- type: 'group';
2530
- parent?: StoryId;
2531
- children: StoryId[];
2532
- /** @deprecated */
2533
- isRoot: false;
2534
- /** @deprecated */
2535
- isComponent: false;
2536
- /** @deprecated */
2537
- isLeaf: false;
2538
- }
2539
- interface API_ComponentEntry extends API_BaseEntry {
2540
- type: 'component';
2541
- parent?: StoryId;
2542
- children: StoryId[];
2543
- /** @deprecated */
2544
- isRoot: false;
2545
- /** @deprecated */
2546
- isComponent: true;
2547
- /** @deprecated */
2548
- isLeaf: false;
2549
- }
2550
- interface API_DocsEntry extends API_BaseEntry {
2551
- type: 'docs';
2552
- parent: StoryId;
2553
- title: ComponentTitle;
2554
- /** @deprecated */
2555
- kind: ComponentTitle;
2556
- importPath: Path;
2557
- tags: Tag[];
2558
- prepared: boolean;
2559
- parameters?: {
2560
- [parameterName: string]: any;
2561
- };
2562
- /** @deprecated */
2563
- isRoot: false;
2564
- /** @deprecated */
2565
- isComponent: false;
2566
- /** @deprecated */
2567
- isLeaf: true;
2568
- }
2569
- interface API_StoryEntry extends API_BaseEntry {
2570
- type: 'story';
2571
- parent: StoryId;
2572
- title: ComponentTitle;
2573
- /** @deprecated */
2574
- kind: ComponentTitle;
2575
- importPath: Path;
2576
- tags: Tag[];
2577
- prepared: boolean;
2578
- parameters?: {
2579
- [parameterName: string]: any;
2580
- };
2581
- args?: Args;
2582
- argTypes?: ArgTypes;
2583
- initialArgs?: Args;
2584
- /** @deprecated */
2585
- isRoot: false;
2586
- /** @deprecated */
2587
- isComponent: false;
2588
- /** @deprecated */
2589
- isLeaf: true;
2590
- }
2591
- type API_LeafEntry = API_DocsEntry | API_StoryEntry;
2592
- type API_HashEntry = API_RootEntry | API_GroupEntry | API_ComponentEntry | API_DocsEntry | API_StoryEntry;
2593
- /** @deprecated */
2594
- type API_Root = API_RootEntry;
2595
- /** @deprecated */
2596
- type API_Group = API_GroupEntry | API_ComponentEntry;
2597
- /** @deprecated */
2598
- type API_Story = API_LeafEntry;
2599
- /**
2600
- * The `IndexHash` is our manager-side representation of the `StoryIndex`.
2601
- * We create entries in the hash not only for each story or docs entry, but
2602
- * also for each "group" of the component (split on '/'), as that's how things
2603
- * are manipulated in the manager (i.e. in the sidebar)
2604
- */
2605
- interface API_IndexHash {
2606
- [id: string]: API_HashEntry;
2607
- }
2608
- type API_PreparedIndexEntry = IndexEntry & {
2609
- parameters?: Parameters;
2610
- argTypes?: ArgTypes;
2611
- args?: Args;
2612
- initialArgs?: Args;
2613
- };
2614
- interface API_PreparedStoryIndex {
2615
- v: number;
2616
- entries: Record<StoryId, API_PreparedIndexEntry>;
2617
- }
2618
- type API_OptionsData = {
2619
- docsOptions: DocsOptions;
2620
- };
2621
- interface API_ReleaseNotes {
2622
- success?: boolean;
2623
- currentVersion?: string;
2624
- showOnFirstLaunch?: boolean;
2625
- }
2626
- interface API_Settings {
2627
- lastTrackedStoryId: string;
2628
- }
2629
- interface API_Version {
2630
- version: string;
2631
- info?: {
2632
- plain: string;
2633
- };
2634
- [key: string]: any;
2635
- }
2636
- interface API_UnknownEntries {
2637
- [key: string]: {
2638
- [key: string]: any;
2639
- };
2640
- }
2641
- interface API_Versions$1 {
2642
- latest?: API_Version;
2643
- next?: API_Version;
2644
- current?: API_Version;
2645
- }
2646
- type API_StatusValue = 'pending' | 'success' | 'error' | 'warn' | 'unknown';
2647
- interface API_StatusObject {
2648
- status: API_StatusValue;
2649
- title: string;
2650
- description: string;
2651
- data?: any;
2163
+ type API_StatusValue = 'pending' | 'success' | 'error' | 'warn' | 'unknown';
2164
+ interface API_StatusObject {
2165
+ status: API_StatusValue;
2166
+ title: string;
2167
+ description: string;
2168
+ data?: any;
2652
2169
  }
2653
2170
  type API_StatusState = Record<StoryId, Record<string, API_StatusObject>>;
2654
2171
  type API_StatusUpdate = Record<StoryId, API_StatusObject>;
2172
+ type API_FilterFunction = (item: API_PreparedIndexEntry & {
2173
+ status: Record<string, API_StatusObject>;
2174
+ }) => boolean;
2655
2175
 
2656
2176
  interface SetStoriesStory {
2657
2177
  id: StoryId;
@@ -2699,139 +2219,659 @@ interface StoryPreparedPayload {
2699
2219
  initialArgs: Args;
2700
2220
  args: Args;
2701
2221
  }
2702
- interface DocsPreparedPayload {
2703
- id: StoryId;
2704
- parameters: Parameters;
2222
+ interface DocsPreparedPayload {
2223
+ id: StoryId;
2224
+ parameters: Parameters;
2225
+ }
2226
+
2227
+ type OrString$1<T extends string> = T | (string & {});
2228
+ type API_ViewMode = OrString$1<'story' | 'docs' | 'settings'> | undefined;
2229
+ type API_RenderOptions = Addon_RenderOptions;
2230
+ interface API_RouteOptions {
2231
+ storyId: string;
2232
+ viewMode: API_ViewMode;
2233
+ location: RenderData['location'];
2234
+ path: string;
2235
+ }
2236
+ interface API_MatchOptions {
2237
+ storyId: string;
2238
+ viewMode: API_ViewMode;
2239
+ location: RenderData['location'];
2240
+ path: string;
2241
+ }
2242
+ /**
2243
+ * @deprecated this is synonymous with `Addon_Type`. This interface will be removed in 8.0
2244
+ */
2245
+ type API_Addon = Addon_Type;
2246
+ /**
2247
+ * @deprecated this is synonymous with `Addon_Collection`. This interface will be removed in 8.0
2248
+ */
2249
+ type API_Collection<T = Addon_Type> = Addon_Collection<T>;
2250
+ /**
2251
+ * @deprecated This interface will be removed in 8.0
2252
+ */
2253
+ type API_Panels = Addon_Collection<Addon_BaseType>;
2254
+ type API_StateMerger<S> = (input: S) => S;
2255
+ interface API_ProviderData<API> {
2256
+ provider: API_Provider<API>;
2257
+ docsOptions: DocsOptions;
2258
+ }
2259
+ interface API_Provider<API> {
2260
+ channel?: Channel;
2261
+ /**
2262
+ * @deprecated will be removed in 8.0, please use channel instead
2263
+ */
2264
+ serverChannel?: Channel;
2265
+ renderPreview?: API_IframeRenderer;
2266
+ handleAPI(api: API): void;
2267
+ getConfig(): {
2268
+ sidebar?: API_SidebarOptions;
2269
+ theme?: ThemeVars;
2270
+ StoryMapper?: API_StoryMapper;
2271
+ [k: string]: any;
2272
+ } & Partial<API_UIOptions>;
2273
+ [key: string]: any;
2274
+ }
2275
+ type API_IframeRenderer = (storyId: string, viewMode: API_ViewMode, id: string, baseUrl: string, scale: number, queryParams: Record<string, any>) => React.ReactElement<any, any> | null;
2276
+ interface API_UIOptions {
2277
+ name?: string;
2278
+ url?: string;
2279
+ goFullScreen: boolean;
2280
+ showStoriesPanel: boolean;
2281
+ showAddonPanel: boolean;
2282
+ addonPanelInRight: boolean;
2283
+ theme?: ThemeVars;
2284
+ selectedPanel?: string;
2285
+ }
2286
+ interface API_Layout {
2287
+ initialActive: API_ActiveTabsType;
2288
+ isFullscreen: boolean;
2289
+ showPanel: boolean;
2290
+ panelPosition: API_PanelPositions;
2291
+ showNav: boolean;
2292
+ showTabs: boolean;
2293
+ showToolbar: boolean;
2294
+ /**
2295
+ * @deprecated, will be removed in 8.0 - this API no longer works
2296
+ */
2297
+ isToolshown?: boolean;
2298
+ }
2299
+ interface API_UI {
2300
+ name?: string;
2301
+ url?: string;
2302
+ enableShortcuts: boolean;
2303
+ }
2304
+ type API_PanelPositions = 'bottom' | 'right';
2305
+ type API_ActiveTabsType = 'sidebar' | 'canvas' | 'addons';
2306
+ interface API_SidebarOptions {
2307
+ showRoots?: boolean;
2308
+ filters?: Record<string, API_FilterFunction>;
2309
+ collapsedRoots?: string[];
2310
+ renderLabel?: (item: API_HashEntry) => any;
2311
+ }
2312
+ interface OnClearOptions {
2313
+ /**
2314
+ * True when the user dismissed the notification.
2315
+ */
2316
+ dismissed: boolean;
2317
+ }
2318
+ interface API_Notification {
2319
+ id: string;
2320
+ link: string;
2321
+ content: {
2322
+ headline: string;
2323
+ subHeadline?: string | any;
2324
+ };
2325
+ icon?: {
2326
+ name: string;
2327
+ color?: string;
2328
+ };
2329
+ onClear?: (options: OnClearOptions) => void;
2330
+ }
2331
+ type API_Versions = Record<string, string>;
2332
+ type API_SetRefData = Partial<API_ComposedRef & {
2333
+ setStoriesData: SetStoriesStoryData;
2334
+ storyIndex: StoryIndex;
2335
+ }>;
2336
+ type API_StoryMapper = (ref: API_ComposedRef, story: SetStoriesStory) => SetStoriesStory;
2337
+ interface API_LoadedRefData {
2338
+ index?: API_IndexHash;
2339
+ indexError?: Error;
2340
+ previewInitialized: boolean;
2341
+ }
2342
+ interface API_ComposedRef extends API_LoadedRefData {
2343
+ id: string;
2344
+ title?: string;
2345
+ url: string;
2346
+ type?: 'auto-inject' | 'unknown' | 'lazy' | 'server-checked';
2347
+ expanded?: boolean;
2348
+ versions?: API_Versions;
2349
+ loginUrl?: string;
2350
+ version?: string;
2351
+ }
2352
+ type API_ComposedRefUpdate = Partial<Pick<API_ComposedRef, 'title' | 'type' | 'expanded' | 'index' | 'versions' | 'loginUrl' | 'version' | 'indexError' | 'previewInitialized'>>;
2353
+ type API_Refs = Record<string, API_ComposedRef>;
2354
+ type API_RefId = string;
2355
+ type API_RefUrl = string;
2356
+
2357
+ type Addon_Types = Exclude<Addon_TypesEnum, Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_SIDEBAR_TOP>;
2358
+ interface Addon_ArgType<TArg = unknown> extends InputType {
2359
+ defaultValue?: TArg;
2360
+ }
2361
+ type Addons_ArgTypes<TArgs = Args> = {
2362
+ [key in keyof Partial<TArgs>]: Addon_ArgType<TArgs[key]>;
2363
+ } & {
2364
+ [key in string]: Addon_ArgType<unknown>;
2365
+ };
2366
+ type Addon_Comparator<T> = ((a: T, b: T) => boolean) | ((a: T, b: T) => number);
2367
+ type Addon_StorySortMethod = 'configure' | 'alphabetical';
2368
+ interface Addon_StorySortObjectParameter {
2369
+ method?: Addon_StorySortMethod;
2370
+ order?: any[];
2371
+ locales?: string;
2372
+ includeNames?: boolean;
2373
+ }
2374
+ type IndexEntryLegacy = [StoryId, any, Parameters, Parameters];
2375
+ type Addon_StorySortComparator = Addon_Comparator<IndexEntryLegacy>;
2376
+ type Addon_StorySortParameter = Addon_StorySortComparator | Addon_StorySortObjectParameter;
2377
+ type Addon_StorySortComparatorV7 = Addon_Comparator<IndexEntry>;
2378
+ type Addon_StorySortParameterV7 = Addon_StorySortComparatorV7 | Addon_StorySortObjectParameter;
2379
+ interface Addon_OptionsParameter extends Object {
2380
+ storySort?: Addon_StorySortParameter;
2381
+ theme?: {
2382
+ base: string;
2383
+ brandTitle?: string;
2384
+ };
2385
+ [key: string]: any;
2386
+ }
2387
+ interface Addon_OptionsParameterV7 extends Object {
2388
+ storySort?: Addon_StorySortParameterV7;
2389
+ theme?: {
2390
+ base: string;
2391
+ brandTitle?: string;
2392
+ };
2393
+ [key: string]: any;
2394
+ }
2395
+ type Addon_StoryContext<TRenderer extends Renderer = Renderer> = StoryContext<TRenderer>;
2396
+ type Addon_StoryContextUpdate = Partial<Addon_StoryContext>;
2397
+ type Addon_ReturnTypeFramework<ReturnType> = {
2398
+ component: any;
2399
+ storyResult: ReturnType;
2400
+ canvasElement: any;
2401
+ };
2402
+ type Addon_PartialStoryFn<ReturnType = unknown> = PartialStoryFn<Addon_ReturnTypeFramework<ReturnType>>;
2403
+ type Addon_LegacyStoryFn<ReturnType = unknown> = LegacyStoryFn<Addon_ReturnTypeFramework<ReturnType>>;
2404
+ type Addon_ArgsStoryFn<ReturnType = unknown> = ArgsStoryFn<Addon_ReturnTypeFramework<ReturnType>>;
2405
+ type Addon_StoryFn<ReturnType = unknown> = StoryFn<Addon_ReturnTypeFramework<ReturnType>>;
2406
+ type Addon_DecoratorFunction<StoryFnReturnType = unknown> = DecoratorFunction<Addon_ReturnTypeFramework<StoryFnReturnType>>;
2407
+ type Addon_LoaderFunction = LoaderFunction<Addon_ReturnTypeFramework<unknown>>;
2408
+ interface Addon_WrapperSettings {
2409
+ options: object;
2410
+ parameters: {
2411
+ [key: string]: any;
2412
+ };
2413
+ }
2414
+ type Addon_StoryWrapper = (storyFn: Addon_LegacyStoryFn, context: Addon_StoryContext, settings: Addon_WrapperSettings) => any;
2415
+ type Addon_MakeDecoratorResult = (...args: any) => any;
2416
+ interface Addon_AddStoryArgs<StoryFnReturnType = unknown> {
2417
+ id: StoryId;
2418
+ kind: StoryKind;
2419
+ name: StoryName;
2420
+ storyFn: Addon_StoryFn<StoryFnReturnType>;
2421
+ parameters: Parameters;
2422
+ }
2423
+ type Addon_ClientApiAddon<StoryFnReturnType = unknown> = Addon_Type & {
2424
+ apply: (a: Addon_StoryApi<StoryFnReturnType>, b: any[]) => any;
2425
+ };
2426
+ interface Addon_ClientApiAddons<StoryFnReturnType> {
2427
+ [key: string]: Addon_ClientApiAddon<StoryFnReturnType>;
2428
+ }
2429
+ type Addon_ClientApiReturnFn<StoryFnReturnType = unknown> = (...args: any[]) => Addon_StoryApi<StoryFnReturnType>;
2430
+ interface Addon_StoryApi<StoryFnReturnType = unknown> {
2431
+ kind: StoryKind;
2432
+ add: (storyName: StoryName, storyFn: Addon_StoryFn<StoryFnReturnType>, parameters?: Parameters) => Addon_StoryApi<StoryFnReturnType>;
2433
+ addDecorator: (decorator: Addon_DecoratorFunction<StoryFnReturnType>) => Addon_StoryApi<StoryFnReturnType>;
2434
+ addLoader: (decorator: Addon_LoaderFunction) => Addon_StoryApi<StoryFnReturnType>;
2435
+ addParameters: (parameters: Parameters) => Addon_StoryApi<StoryFnReturnType>;
2436
+ [k: string]: string | Addon_ClientApiReturnFn<StoryFnReturnType>;
2437
+ }
2438
+ interface Addon_ClientStoryApi<StoryFnReturnType = unknown> {
2439
+ storiesOf(kind: StoryKind, module: any): Addon_StoryApi<StoryFnReturnType>;
2440
+ }
2441
+ type Addon_LoadFn = () => any;
2442
+ type Addon_RequireContext = any;
2443
+ type Addon_Loadable = Addon_RequireContext | [Addon_RequireContext] | Addon_LoadFn;
2444
+ type Addon_BaseDecorators<StoryFnReturnType> = Array<(story: () => StoryFnReturnType, context: Addon_StoryContext) => StoryFnReturnType>;
2445
+ interface Addon_BaseAnnotations<TArgs, StoryFnReturnType, TRenderer extends Renderer = Renderer> {
2446
+ /**
2447
+ * Dynamic data that are provided (and possibly updated by) Storybook and its addons.
2448
+ * @see [Arg story inputs](https://storybook.js.org/docs/react/api/csf#args-story-inputs)
2449
+ */
2450
+ args?: Partial<TArgs>;
2451
+ /**
2452
+ * ArgTypes encode basic metadata for args, such as `name`, `description`, `defaultValue` for an arg. These get automatically filled in by Storybook Docs.
2453
+ * @see [Arg types](https://storybook.js.org/docs/react/api/arg-types)
2454
+ */
2455
+ argTypes?: Addons_ArgTypes<TArgs>;
2456
+ /**
2457
+ * Custom metadata for a story.
2458
+ * @see [Parameters](https://storybook.js.org/docs/basics/writing-stories/#parameters)
2459
+ */
2460
+ parameters?: Parameters;
2461
+ /**
2462
+ * Wrapper components or Storybook decorators that wrap a story.
2463
+ *
2464
+ * Decorators defined in Meta will be applied to every story variation.
2465
+ * @see [Decorators](https://storybook.js.org/docs/addons/introduction/#1-decorators)
2466
+ */
2467
+ decorators?: Addon_BaseDecorators<StoryFnReturnType>;
2468
+ /**
2469
+ * Define a custom render function for the story(ies). If not passed, a default render function by the framework will be used.
2470
+ */
2471
+ render?: (args: TArgs, context: Addon_StoryContext<TRenderer>) => StoryFnReturnType;
2472
+ /**
2473
+ * Function that is executed after the story is rendered.
2474
+ */
2475
+ play?: (context: Addon_StoryContext<TRenderer>) => Promise<void> | void;
2476
+ }
2477
+ interface Addon_Annotations<TArgs, StoryFnReturnType> extends Addon_BaseAnnotations<TArgs, StoryFnReturnType> {
2478
+ /**
2479
+ * Used to only include certain named exports as stories. Useful when you want to have non-story exports such as mock data or ignore a few stories.
2480
+ * @example
2481
+ * includeStories: ['SimpleStory', 'ComplexStory']
2482
+ * includeStories: /.*Story$/
2483
+ *
2484
+ * @see [Non-story exports](https://storybook.js.org/docs/formats/component-story-format/#non-story-exports)
2485
+ */
2486
+ includeStories?: string[] | RegExp;
2487
+ /**
2488
+ * Used to exclude certain named exports. Useful when you want to have non-story exports such as mock data or ignore a few stories.
2489
+ * @example
2490
+ * excludeStories: ['simpleData', 'complexData']
2491
+ * excludeStories: /.*Data$/
2492
+ *
2493
+ * @see [Non-story exports](https://storybook.js.org/docs/formats/component-story-format/#non-story-exports)
2494
+ */
2495
+ excludeStories?: string[] | RegExp;
2496
+ }
2497
+ interface Addon_BaseMeta<ComponentType> {
2498
+ /**
2499
+ * Title of the story which will be presented in the navigation. **Should be unique.**
2500
+ *
2501
+ * Stories can be organized in a nested structure using "/" as a separator.
2502
+ *
2503
+ * Since CSF 3.0 this property is optional.
2504
+ *
2505
+ * @example
2506
+ * export default {
2507
+ * ...
2508
+ * title: 'Design System/Atoms/Button'
2509
+ * }
2510
+ *
2511
+ * @see [Story Hierarchy](https://storybook.js.org/docs/basics/writing-stories/#story-hierarchy)
2512
+ */
2513
+ title?: string;
2514
+ /**
2515
+ * Manually set the id of a story, which in particular is useful if you want to rename stories without breaking permalinks.
2516
+ *
2517
+ * Storybook will prioritize the id over the title for ID generation, if provided, and will prioritize the story.storyName over the export key for display.
2518
+ *
2519
+ * @see [Sidebar and URLs](https://storybook.js.org/docs/react/configure/sidebar-and-urls#permalinking-to-stories)
2520
+ */
2521
+ id?: string;
2522
+ /**
2523
+ * The primary component for your story.
2524
+ *
2525
+ * Used by addons for automatic prop table generation and display of other component metadata.
2526
+ */
2527
+ component?: ComponentType;
2528
+ /**
2529
+ * Auxiliary subcomponents that are part of the stories.
2530
+ *
2531
+ * Used by addons for automatic prop table generation and display of other component metadata.
2532
+ *
2533
+ * @example
2534
+ * import { Button, ButtonGroup } from './components';
2535
+ *
2536
+ * export default {
2537
+ * ...
2538
+ * subcomponents: { Button, ButtonGroup }
2539
+ * }
2540
+ *
2541
+ * By defining them each component will have its tab in the args table.
2542
+ *
2543
+ * @deprecated
2544
+ */
2545
+ subcomponents?: Record<string, ComponentType>;
2546
+ }
2547
+ type Addon_BaseStoryObject<TArgs, StoryFnReturnType> = {
2548
+ /**
2549
+ * Override the display name in the UI
2550
+ */
2551
+ storyName?: string;
2552
+ };
2553
+ type Addon_BaseStoryFn<TArgs, StoryFnReturnType> = {
2554
+ (args: TArgs, context: Addon_StoryContext): StoryFnReturnType;
2555
+ } & Addon_BaseStoryObject<TArgs, StoryFnReturnType>;
2556
+ type BaseStory<TArgs, StoryFnReturnType> = Addon_BaseStoryFn<TArgs, StoryFnReturnType> | Addon_BaseStoryObject<TArgs, StoryFnReturnType>;
2557
+ interface Addon_RenderOptions {
2558
+ active: boolean;
2559
+ /**
2560
+ * @deprecated You should not use key anymore as of Storybook 7.2 this render method is invoked as a React component.
2561
+ * This property will be removed in 8.0.
2562
+ * */
2563
+ key?: unknown;
2564
+ }
2565
+ /**
2566
+ * @deprecated This type is deprecated and will be removed in 8.0.
2567
+ */
2568
+ type ReactJSXElement = {
2569
+ type: any;
2570
+ props: any;
2571
+ key: any;
2572
+ };
2573
+ type Addon_Type = Addon_BaseType | Addon_PageType | Addon_WrapperType | Addon_SidebarBottomType | Addon_SidebarTopType;
2574
+ interface Addon_BaseType {
2575
+ /**
2576
+ * The title of the addon.
2577
+ * This can be a simple string, but it can also be a React.FunctionComponent or a React.ReactElement.
2578
+ */
2579
+ title: FCWithoutChildren | ReactNode;
2580
+ /**
2581
+ * The type of the addon.
2582
+ * @example Addon_TypesEnum.PANEL
2583
+ */
2584
+ type: Exclude<Addon_Types, Addon_TypesEnum.PREVIEW | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_SIDEBAR_TOP>;
2585
+ /**
2586
+ * The unique id of the addon.
2587
+ * @warn This will become non-optional in 8.0
2588
+ *
2589
+ * This needs to be globally unique, so we recommend prefixing it with your org name or npm package name.
2590
+ *
2591
+ * Do not prefix with `storybook`, this is reserved for core storybook feature and core addons.
2592
+ *
2593
+ * @example 'my-org-name/my-addon-name'
2594
+ */
2595
+ id?: string;
2596
+ /**
2597
+ * This component will wrap your `render` function.
2598
+ *
2599
+ * With it you can determine if you want your addon to be rendered or not.
2600
+ *
2601
+ * This is to facilitate addons keeping state, and keep listening for events even when they are not currently on screen/rendered.
2602
+ */
2603
+ route?: (routeOptions: RenderData) => string;
2604
+ /**
2605
+ * This will determine the value of `active` prop of your render function.
2606
+ */
2607
+ match?: (matchOptions: RenderData) => boolean;
2608
+ /**
2609
+ * The actual contents of your addon.
2610
+ *
2611
+ * This is called as a function, so if you want to use hooks,
2612
+ * your function needs to return a JSX.Element within which components are rendered
2613
+ */
2614
+ render: (renderOptions: Partial<Addon_RenderOptions>) => ReactElement<any, any> | null;
2615
+ /**
2616
+ * @unstable
2617
+ */
2618
+ paramKey?: string;
2619
+ /**
2620
+ * @unstable
2621
+ */
2622
+ disabled?: boolean;
2623
+ /**
2624
+ * @unstable
2625
+ */
2626
+ hidden?: boolean;
2627
+ }
2628
+ /**
2629
+ * This is a copy of FC from react/index.d.ts, but has the PropsWithChildren type removed
2630
+ * this is correct and more type strict, and future compatible with React.FC in React 18+
2631
+ *
2632
+ * @deprecated This type is deprecated and will be removed in 8.0. (assuming the manager uses React 18 is out by then)
2633
+ */
2634
+ interface FCWithoutChildren<P = {}> {
2635
+ (props: P, context?: any): ReactElement<any, any> | null;
2636
+ propTypes?: WeakValidationMap<P> | undefined;
2637
+ contextTypes?: ValidationMap<any> | undefined;
2638
+ defaultProps?: Partial<P> | undefined;
2639
+ displayName?: string | undefined;
2640
+ }
2641
+ interface Addon_PageType {
2642
+ type: Addon_TypesEnum.experimental_PAGE;
2643
+ /**
2644
+ * The unique id of the page.
2645
+ */
2646
+ id: string;
2647
+ /**
2648
+ * The URL to navigate to when Storybook needs to navigate to this page.
2649
+ */
2650
+ url: string;
2651
+ /**
2652
+ * The title is used in mobile mode to represent the page in the navigation.
2653
+ */
2654
+ title: FCWithoutChildren | string | ReactElement | ReactNode;
2655
+ /**
2656
+ * The main content of the addon, a function component without any props.
2657
+ * Storybook will render your component always.
2658
+ *
2659
+ * If you want to render your component only when the URL matches, use the `Route` component.
2660
+ * @example
2661
+ * import { Route } from '@storybook/router';
2662
+ *
2663
+ * render: () => {
2664
+ * return (
2665
+ * <Route path="/my-addon">
2666
+ * <MyAddonContent />
2667
+ * </Route>
2668
+ * );
2669
+ * };
2670
+ */
2671
+ render: FCWithoutChildren;
2672
+ }
2673
+ interface Addon_WrapperType {
2674
+ type: Addon_TypesEnum.PREVIEW;
2675
+ /**
2676
+ * The unique id of the page.
2677
+ */
2678
+ id: string;
2679
+ /**
2680
+ * A React.FunctionComponent that wraps the story.
2681
+ *
2682
+ * This component must accept a children prop, and render it.
2683
+ */
2684
+ render: FC<PropsWithChildren<{
2685
+ index: number;
2686
+ children: ReactNode;
2687
+ id: string;
2688
+ storyId: StoryId;
2689
+ active: boolean;
2690
+ }>>;
2691
+ }
2692
+ interface Addon_SidebarBottomType {
2693
+ type: Addon_TypesEnum.experimental_SIDEBAR_BOTTOM;
2694
+ /**
2695
+ * The unique id of the tool.
2696
+ */
2697
+ id: string;
2698
+ /**
2699
+ * A React.FunctionComponent.
2700
+ */
2701
+ render: FCWithoutChildren;
2702
+ }
2703
+ interface Addon_SidebarTopType {
2704
+ type: Addon_TypesEnum.experimental_SIDEBAR_TOP;
2705
+ /**
2706
+ * The unique id of the tool.
2707
+ */
2708
+ id: string;
2709
+ /**
2710
+ * A React.FunctionComponent.
2711
+ */
2712
+ render: FCWithoutChildren;
2713
+ }
2714
+ type Addon_TypeBaseNames = Exclude<Addon_TypesEnum, Addon_TypesEnum.PREVIEW | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_SIDEBAR_TOP>;
2715
+ interface Addon_TypesMapping extends Record<Addon_TypeBaseNames, Addon_BaseType> {
2716
+ [Addon_TypesEnum.PREVIEW]: Addon_WrapperType;
2717
+ [Addon_TypesEnum.experimental_PAGE]: Addon_PageType;
2718
+ [Addon_TypesEnum.experimental_SIDEBAR_BOTTOM]: Addon_SidebarBottomType;
2719
+ [Addon_TypesEnum.experimental_SIDEBAR_TOP]: Addon_SidebarTopType;
2705
2720
  }
2706
-
2707
- type OrString<T extends string> = T | (string & {});
2708
- type API_ViewMode = OrString<'story' | 'docs' | 'settings'> | undefined;
2709
- type API_RenderOptions = Addon_RenderOptions;
2710
- interface API_RouteOptions {
2711
- storyId: string;
2712
- viewMode: API_ViewMode;
2713
- location: RenderData['location'];
2714
- path: string;
2721
+ type Addon_Loader<API> = (api: API) => void;
2722
+ interface Addon_Loaders<API> {
2723
+ [key: string]: Addon_Loader<API>;
2715
2724
  }
2716
- interface API_MatchOptions {
2717
- storyId: string;
2718
- viewMode: API_ViewMode;
2719
- location: RenderData['location'];
2720
- path: string;
2725
+ interface Addon_Collection<T = Addon_Type> {
2726
+ [key: string]: T;
2721
2727
  }
2722
- /**
2723
- * @deprecated this is synonymous with `Addon_Type`. This interface will be removed in 8.0
2724
- */
2725
- type API_Addon = Addon_Type;
2726
- /**
2727
- * @deprecated this is synonymous with `Addon_Collection`. This interface will be removed in 8.0
2728
- */
2729
- type API_Collection<T = Addon_Type> = Addon_Collection<T>;
2730
- /**
2731
- * @deprecated This interface will be removed in 8.0
2732
- */
2733
- type API_Panels = Addon_Collection<Addon_BaseType>;
2734
- type API_StateMerger<S> = (input: S) => S;
2735
- interface API_ProviderData<API> {
2736
- provider: API_Provider<API>;
2737
- docsOptions: DocsOptions;
2728
+ interface Addon_Elements {
2729
+ [key: string]: Addon_Collection;
2738
2730
  }
2739
- interface API_Provider<API> {
2740
- channel?: Channel;
2741
- /**
2742
- * @deprecated will be removed in 8.0, please use channel instead
2743
- */
2744
- serverChannel?: Channel;
2745
- renderPreview?: API_IframeRenderer;
2746
- handleAPI(api: API): void;
2747
- getConfig(): {
2748
- sidebar?: API_SidebarOptions;
2749
- theme?: ThemeVars;
2750
- StoryMapper?: API_StoryMapper;
2751
- [k: string]: any;
2752
- } & Partial<API_UIOptions>;
2753
- [key: string]: any;
2731
+ interface Addon_ToolbarConfig {
2732
+ hidden?: boolean;
2754
2733
  }
2755
- type API_IframeRenderer = (storyId: string, viewMode: API_ViewMode, id: string, baseUrl: string, scale: number, queryParams: Record<string, any>) => React.ReactElement<any, any> | null;
2756
- interface API_UIOptions {
2757
- name?: string;
2758
- url?: string;
2759
- goFullScreen: boolean;
2760
- showStoriesPanel: boolean;
2761
- showAddonPanel: boolean;
2762
- addonPanelInRight: boolean;
2734
+ interface Addon_Config {
2763
2735
  theme?: ThemeVars;
2764
- selectedPanel?: string;
2736
+ toolbar?: {
2737
+ [id: string]: Addon_ToolbarConfig;
2738
+ };
2739
+ sidebar?: API_SidebarOptions;
2740
+ [key: string]: any;
2765
2741
  }
2766
- interface API_Layout {
2767
- initialActive: API_ActiveTabsType;
2768
- isFullscreen: boolean;
2769
- showPanel: boolean;
2770
- panelPosition: API_PanelPositions;
2771
- showNav: boolean;
2772
- showTabs: boolean;
2773
- showToolbar: boolean;
2742
+ declare enum Addon_TypesEnum {
2774
2743
  /**
2775
- * @deprecated, will be removed in 8.0 - this API no longer works
2744
+ * This API is used to create a tab the toolbar above the canvas, This API might be removed in the future.
2745
+ * @unstable
2776
2746
  */
2777
- isToolshown?: boolean;
2778
- }
2779
- interface API_UI {
2780
- name?: string;
2781
- url?: string;
2782
- enableShortcuts: boolean;
2783
- }
2784
- type API_PanelPositions = 'bottom' | 'right';
2785
- type API_ActiveTabsType = 'sidebar' | 'canvas' | 'addons';
2786
- interface API_SidebarOptions {
2787
- showRoots?: boolean;
2788
- collapsedRoots?: string[];
2789
- renderLabel?: (item: API_HashEntry) => any;
2747
+ TAB = "tab",
2748
+ /**
2749
+ * This adds panels to the addons side panel.
2750
+ */
2751
+ PANEL = "panel",
2752
+ /**
2753
+ * This adds items in the toolbar above the canvas - on the left side.
2754
+ */
2755
+ TOOL = "tool",
2756
+ /**
2757
+ * This adds items in the toolbar above the canvas - on the right side.
2758
+ */
2759
+ TOOLEXTRA = "toolextra",
2760
+ /**
2761
+ * This adds wrapper components around the canvas/iframe component storybook renders.
2762
+ * @unstable this API is not stable yet, and is likely to change in 8.0.
2763
+ */
2764
+ PREVIEW = "preview",
2765
+ /**
2766
+ * This adds pages that render instead of the canvas.
2767
+ * @unstable
2768
+ */
2769
+ experimental_PAGE = "page",
2770
+ /**
2771
+ * This adds items in the bottom of the sidebar.
2772
+ * @unstable
2773
+ */
2774
+ experimental_SIDEBAR_BOTTOM = "sidebar-bottom",
2775
+ /**
2776
+ * This adds items in the top of the sidebar.
2777
+ * @unstable This will get replaced with a new API in 8.0, use at your own risk.
2778
+ */
2779
+ experimental_SIDEBAR_TOP = "sidebar-top",
2780
+ /**
2781
+ * @deprecated This property does nothing, and will be removed in Storybook 8.0.
2782
+ */
2783
+ NOTES_ELEMENT = "notes-element"
2790
2784
  }
2791
- interface OnClearOptions {
2785
+
2786
+ type OrString<T extends string> = T | (string & {});
2787
+ type ViewMode = OrString<ViewMode$1 | 'settings'> | undefined;
2788
+ type Layout = 'centered' | 'fullscreen' | 'padded' | 'none';
2789
+ interface StorybookParameters {
2790
+ options?: Addon_OptionsParameter;
2792
2791
  /**
2793
- * True when the user dismissed the notification.
2792
+ * The layout property defines basic styles added to the preview body where the story is rendered.
2793
+ *
2794
+ * If you pass `none`, no styles are applied.
2794
2795
  */
2795
- dismissed: boolean;
2796
+ layout?: Layout;
2796
2797
  }
2797
- interface API_Notification {
2798
- id: string;
2799
- link: string;
2800
- content: {
2801
- headline: string;
2802
- subHeadline?: string | any;
2803
- };
2804
- icon?: {
2805
- name: string;
2806
- color?: string;
2807
- };
2808
- onClear?: (options: OnClearOptions) => void;
2798
+ interface StorybookInternalParameters extends StorybookParameters {
2799
+ fileName?: string;
2800
+ docsOnly?: true;
2809
2801
  }
2810
- type API_Versions = Record<string, string>;
2811
- type API_SetRefData = Partial<API_ComposedRef & {
2812
- setStoriesData: SetStoriesStoryData;
2813
- storyIndex: StoryIndex;
2814
- }>;
2815
- type API_StoryMapper = (ref: API_ComposedRef, story: SetStoriesStory) => SetStoriesStory;
2816
- interface API_LoadedRefData {
2817
- index?: API_IndexHash;
2818
- indexError?: Error;
2819
- previewInitialized: boolean;
2802
+ type Path = string;
2803
+
2804
+ interface WebRenderer extends Renderer {
2805
+ canvasElement: HTMLElement;
2820
2806
  }
2821
- interface API_ComposedRef extends API_LoadedRefData {
2822
- id: string;
2823
- title?: string;
2824
- url: string;
2825
- type?: 'auto-inject' | 'unknown' | 'lazy' | 'server-checked';
2826
- expanded?: boolean;
2827
- versions?: API_Versions;
2828
- loginUrl?: string;
2829
- version?: string;
2807
+ type ModuleExport = any;
2808
+ type ModuleExports = Record<string, ModuleExport>;
2809
+ type ModuleImportFn = (path: Path) => Promise<ModuleExports>;
2810
+ type MaybePromise<T> = Promise<T> | T;
2811
+ type TeardownRenderToCanvas = () => MaybePromise<void>;
2812
+ type RenderToCanvas<TRenderer extends Renderer> = (context: RenderContext<TRenderer>, element: TRenderer['canvasElement']) => MaybePromise<void | TeardownRenderToCanvas>;
2813
+ type ProjectAnnotations<TRenderer extends Renderer> = ProjectAnnotations$1<TRenderer> & {
2814
+ renderToCanvas?: RenderToCanvas<TRenderer>;
2815
+ renderToDOM?: RenderToCanvas<TRenderer>;
2816
+ };
2817
+ type NormalizedProjectAnnotations<TRenderer extends Renderer = Renderer> = ProjectAnnotations<TRenderer> & {
2818
+ argTypes?: StrictArgTypes;
2819
+ globalTypes?: StrictGlobalTypes;
2820
+ };
2821
+ type NormalizedComponentAnnotations<TRenderer extends Renderer = Renderer> = ComponentAnnotations<TRenderer> & {
2822
+ id: ComponentId;
2823
+ title: ComponentTitle;
2824
+ argTypes?: StrictArgTypes;
2825
+ };
2826
+ type NormalizedStoryAnnotations<TRenderer extends Renderer = Renderer> = Omit<StoryAnnotations<TRenderer>, 'storyName' | 'story'> & {
2827
+ moduleExport: ModuleExport;
2828
+ id: StoryId;
2829
+ argTypes?: StrictArgTypes;
2830
+ name: StoryName;
2831
+ userStoryFn?: StoryFn<TRenderer>;
2832
+ };
2833
+ type CSFFile<TRenderer extends Renderer = Renderer> = {
2834
+ meta: NormalizedComponentAnnotations<TRenderer>;
2835
+ stories: Record<StoryId, NormalizedStoryAnnotations<TRenderer>>;
2836
+ moduleExports: ModuleExports;
2837
+ };
2838
+ type PreparedStory<TRenderer extends Renderer = Renderer> = StoryContextForEnhancers<TRenderer> & {
2839
+ moduleExport: ModuleExport;
2840
+ originalStoryFn: StoryFn<TRenderer>;
2841
+ undecoratedStoryFn: LegacyStoryFn<TRenderer>;
2842
+ unboundStoryFn: LegacyStoryFn<TRenderer>;
2843
+ applyLoaders: (context: StoryContextForLoaders<TRenderer>) => Promise<StoryContextForLoaders<TRenderer> & {
2844
+ loaded: StoryContext<TRenderer>['loaded'];
2845
+ }>;
2846
+ playFunction?: (context: StoryContext<TRenderer>) => Promise<void> | void;
2847
+ };
2848
+ type PreparedMeta<TRenderer extends Renderer = Renderer> = Omit<StoryContextForEnhancers<TRenderer>, 'name' | 'story'> & {
2849
+ moduleExport: ModuleExport;
2850
+ };
2851
+ type BoundStory<TRenderer extends Renderer = Renderer> = PreparedStory<TRenderer> & {
2852
+ storyFn: PartialStoryFn<TRenderer>;
2853
+ };
2854
+ declare type RenderContext<TRenderer extends Renderer = Renderer> = StoryIdentifier & {
2855
+ showMain: () => void;
2856
+ showError: (error: {
2857
+ title: string;
2858
+ description: string;
2859
+ }) => void;
2860
+ showException: (err: Error) => void;
2861
+ forceRemount: boolean;
2862
+ storyContext: StoryContext<TRenderer>;
2863
+ storyFn: PartialStoryFn<TRenderer>;
2864
+ unboundStoryFn: LegacyStoryFn<TRenderer>;
2865
+ };
2866
+
2867
+ interface BuilderStats {
2868
+ toJson: () => any;
2830
2869
  }
2831
- type API_ComposedRefUpdate = Partial<Pick<API_ComposedRef, 'title' | 'type' | 'expanded' | 'index' | 'versions' | 'loginUrl' | 'version' | 'indexError' | 'previewInitialized'>>;
2832
- type API_Refs = Record<string, API_ComposedRef>;
2833
- type API_RefId = string;
2834
- type API_RefUrl = string;
2870
+ type Builder_WithRequiredProperty<Type, Key extends keyof Type> = Type & {
2871
+ [Property in Key]-?: Type[Property];
2872
+ };
2873
+ type Builder_Unpromise<T extends Promise<any>> = T extends Promise<infer U> ? U : never;
2874
+ type Builder_EnvsRaw = Record<string, string>;
2835
2875
 
2836
2876
  type RenderContextCallbacks<TRenderer extends Renderer> = Pick<RenderContext<TRenderer>, 'showMain' | 'showError' | 'showException'>;
2837
2877
  type StoryRenderOptions = {
@@ -2957,4 +2997,4 @@ interface ComposeStoryFn<TRenderer extends Renderer = Renderer, TArgs extends Ar
2957
2997
  (storyAnnotations: AnnotatedStoryFn<TRenderer, TArgs> | StoryAnnotations<TRenderer, TArgs>, componentAnnotations: ComponentAnnotations<TRenderer, TArgs>, projectAnnotations: ProjectAnnotations<TRenderer>, exportsName?: string): ComposedStoryFn;
2958
2998
  }
2959
2999
 
2960
- export { API_ActiveTabsType, API_Addon, API_BaseEntry, API_Collection, API_ComponentEntry, API_ComposedRef, API_ComposedRefUpdate, API_DocsEntry, API_Group, API_GroupEntry, API_HashEntry, API_IframeRenderer, API_IndexHash, API_Layout, API_LeafEntry, API_LoadedRefData, API_MatchOptions, API_Notification, API_OptionsData, API_PanelPositions, API_Panels, API_PreparedStoryIndex, API_Provider, API_ProviderData, API_RefId, API_RefUrl, API_Refs, API_ReleaseNotes, API_RenderOptions, API_Root, API_RootEntry, API_RouteOptions, API_SetRefData, API_Settings, API_SidebarOptions, API_StateMerger, API_StatusObject, API_StatusState, API_StatusUpdate, API_StatusValue, API_Story, API_StoryEntry, API_StoryMapper, API_UI, API_UIOptions, API_UnknownEntries, API_Version, API_Versions$1 as API_Versions, API_ViewMode, Addon_AddStoryArgs, Addon_Annotations, Addon_ArgType, Addon_ArgsStoryFn, Addon_BaseAnnotations, Addon_BaseDecorators, Addon_BaseMeta, Addon_BaseStoryFn, Addon_BaseStoryObject, Addon_BaseType, Addon_ClientApiAddon, Addon_ClientApiAddons, Addon_ClientApiReturnFn, Addon_ClientStoryApi, Addon_Collection, Addon_Comparator, Addon_Config, Addon_DecoratorFunction, Addon_Elements, Addon_LegacyStoryFn, Addon_LoadFn, Addon_Loadable, Addon_Loader, Addon_LoaderFunction, Addon_Loaders, Addon_MakeDecoratorResult, Addon_OptionsParameter, Addon_OptionsParameterV7, Addon_PageType, Addon_PartialStoryFn, Addon_RenderOptions, Addon_RequireContext, Addon_StoryApi, Addon_StoryContext, Addon_StoryContextUpdate, Addon_StoryFn, Addon_StorySortComparator, Addon_StorySortComparatorV7, Addon_StorySortMethod, Addon_StorySortObjectParameter, Addon_StorySortParameter, Addon_StorySortParameterV7, Addon_StoryWrapper, Addon_ToolbarConfig, Addon_Type, Addon_Types, Addon_TypesEnum, Addon_TypesMapping, Addon_WrapperSettings, Addon_WrapperType, Addons_ArgTypes, AnnotatedStoryFn, ArgTypes, ArgTypesEnhancer, Args, ArgsEnhancer, ArgsFromMeta, ArgsStoryFn, BaseAnnotations, BaseIndexEntry, BaseIndexInput, BaseStory, BoundStory, Builder, BuilderName, BuilderOptions, BuilderResult, BuilderStats, Builder_EnvsRaw, Builder_Unpromise, Builder_WithRequiredProperty, CLIOptions, CSFFile, ComponentAnnotations, ComponentId, ComponentTitle, ComposeStoryFn, ComposedStoryFn, ComposedStoryPlayContext, ComposedStoryPlayFn, Conditional, CoreCommon_AddonEntry, CoreCommon_AddonInfo, CoreCommon_OptionsEntry, CoreCommon_ResolvedAddonPreset, CoreCommon_ResolvedAddonVirtual, CoreCommon_StorybookInfo, CoreConfig, DecoratorApplicator, DecoratorFunction, DeprecatedIndexer, DocsContextProps, DocsIndexEntry, DocsIndexInput, DocsOptions, DocsPreparedPayload, DocsRenderFunction, Entry, GlobalTypes, Globals, IncludeExcludeOptions, IndexEntry, IndexEntryLegacy, IndexInput, IndexedCSFFile, IndexedStory, Indexer, IndexerOptions, InputType, LegacyAnnotatedStoryFn, LegacyStoryAnnotationsOrFn, LegacyStoryFn, LoadOptions, LoadedPreset, LoaderFunction, ModuleExport, ModuleExports, ModuleImportFn, NormalizedComponentAnnotations, NormalizedProjectAnnotations, NormalizedStoriesSpecifier, NormalizedStoryAnnotations, Options, PackageJson, Parameters, PartialArgsStoryFn, PartialStoryFn, Path, PlayFunction, PlayFunctionContext, PreparedMeta, PreparedStory, Preset, PresetConfig, PresetProperty, PresetPropertyFn, PresetValue, Presets, PreviewAnnotation, ProjectAnnotations, ReactJSXElement, Ref, RenderContext, RenderContextCallbacks, RenderToCanvas, Renderer, RendererName, ResolvedModuleExport, ResolvedModuleExportFromType, ResolvedModuleExportType, SBArrayType, SBEnumType, SBIntersectionType, SBObjectType, SBOtherType, SBScalarType, SBType, SBUnionType, SeparatorOptions, SetGlobalsPayload, SetStoriesPayload, SetStoriesStory, SetStoriesStoryData, Stats, StepFunction, StepLabel, StepRunner, Store_CSFExports, StoriesEntry, StoriesWithPartialProps, StoryAnnotations, StoryAnnotationsOrFn, StoryContext, StoryContextForEnhancers, StoryContextForLoaders, StoryContextUpdate, StoryFn, StoryId, StoryIdentifier, StoryIndex, StoryIndexEntry, StoryIndexInput, StoryIndexV2, StoryIndexV3, StoryIndexer, StoryKind, StoryName, StoryPreparedPayload, StoryRenderOptions, StorybookConfig, StorybookConfigOptions, StorybookInternalParameters, StorybookParameters, StrictArgTypes, StrictArgs, StrictGlobalTypes, StrictInputType, Tag, TeardownRenderToCanvas, TypescriptOptions, V3CompatIndexEntry, VersionCheck, ViewMode, WebRenderer };
3000
+ export { API_ActiveTabsType, API_Addon, API_BaseEntry, API_Collection, API_ComponentEntry, API_ComposedRef, API_ComposedRefUpdate, API_DocsEntry, API_FilterFunction, API_Group, API_GroupEntry, API_HashEntry, API_IframeRenderer, API_IndexHash, API_Layout, API_LeafEntry, API_LoadedRefData, API_MatchOptions, API_Notification, API_OptionsData, API_PanelPositions, API_Panels, API_PreparedIndexEntry, API_PreparedStoryIndex, API_Provider, API_ProviderData, API_RefId, API_RefUrl, API_Refs, API_ReleaseNotes, API_RenderOptions, API_Root, API_RootEntry, API_RouteOptions, API_SetRefData, API_Settings, API_SidebarOptions, API_StateMerger, API_StatusObject, API_StatusState, API_StatusUpdate, API_StatusValue, API_Story, API_StoryEntry, API_StoryMapper, API_UI, API_UIOptions, API_UnknownEntries, API_Version, API_Versions$1 as API_Versions, API_ViewMode, Addon_AddStoryArgs, Addon_Annotations, Addon_ArgType, Addon_ArgsStoryFn, Addon_BaseAnnotations, Addon_BaseDecorators, Addon_BaseMeta, Addon_BaseStoryFn, Addon_BaseStoryObject, Addon_BaseType, Addon_ClientApiAddon, Addon_ClientApiAddons, Addon_ClientApiReturnFn, Addon_ClientStoryApi, Addon_Collection, Addon_Comparator, Addon_Config, Addon_DecoratorFunction, Addon_Elements, Addon_LegacyStoryFn, Addon_LoadFn, Addon_Loadable, Addon_Loader, Addon_LoaderFunction, Addon_Loaders, Addon_MakeDecoratorResult, Addon_OptionsParameter, Addon_OptionsParameterV7, Addon_PageType, Addon_PartialStoryFn, Addon_RenderOptions, Addon_RequireContext, Addon_SidebarBottomType, Addon_SidebarTopType, Addon_StoryApi, Addon_StoryContext, Addon_StoryContextUpdate, Addon_StoryFn, Addon_StorySortComparator, Addon_StorySortComparatorV7, Addon_StorySortMethod, Addon_StorySortObjectParameter, Addon_StorySortParameter, Addon_StorySortParameterV7, Addon_StoryWrapper, Addon_ToolbarConfig, Addon_Type, Addon_Types, Addon_TypesEnum, Addon_TypesMapping, Addon_WrapperSettings, Addon_WrapperType, Addons_ArgTypes, AnnotatedStoryFn, ArgTypes, ArgTypesEnhancer, Args, ArgsEnhancer, ArgsFromMeta, ArgsStoryFn, BaseAnnotations, BaseIndexEntry, BaseIndexInput, BaseStory, BoundStory, Builder, BuilderName, BuilderOptions, BuilderResult, BuilderStats, Builder_EnvsRaw, Builder_Unpromise, Builder_WithRequiredProperty, CLIOptions, CSFFile, ComponentAnnotations, ComponentId, ComponentTitle, ComposeStoryFn, ComposedStoryFn, ComposedStoryPlayContext, ComposedStoryPlayFn, Conditional, CoreCommon_AddonEntry, CoreCommon_AddonInfo, CoreCommon_OptionsEntry, CoreCommon_ResolvedAddonPreset, CoreCommon_ResolvedAddonVirtual, CoreCommon_StorybookInfo, CoreConfig, DecoratorApplicator, DecoratorFunction, DeprecatedIndexer, DocsContextProps, DocsIndexEntry, DocsIndexInput, DocsOptions, DocsPreparedPayload, DocsRenderFunction, Entry, GlobalTypes, Globals, IncludeExcludeOptions, IndexEntry, IndexEntryLegacy, IndexInput, IndexedCSFFile, IndexedStory, Indexer, IndexerOptions, InputType, LegacyAnnotatedStoryFn, LegacyStoryAnnotationsOrFn, LegacyStoryFn, LoadOptions, LoadedPreset, LoaderFunction, ModuleExport, ModuleExports, ModuleImportFn, NormalizedComponentAnnotations, NormalizedProjectAnnotations, NormalizedStoriesSpecifier, NormalizedStoryAnnotations, Options, PackageJson, Parameters, PartialArgsStoryFn, PartialStoryFn, Path, PlayFunction, PlayFunctionContext, PreparedMeta, PreparedStory, Preset, PresetConfig, PresetProperty, PresetPropertyFn, PresetValue, Presets, PreviewAnnotation, ProjectAnnotations, ReactJSXElement, Ref, RenderContext, RenderContextCallbacks, RenderToCanvas, Renderer, RendererName, ResolvedModuleExport, ResolvedModuleExportFromType, ResolvedModuleExportType, SBArrayType, SBEnumType, SBIntersectionType, SBObjectType, SBOtherType, SBScalarType, SBType, SBUnionType, SeparatorOptions, SetGlobalsPayload, SetStoriesPayload, SetStoriesStory, SetStoriesStoryData, Stats, StepFunction, StepLabel, StepRunner, Store_CSFExports, StoriesEntry, StoriesWithPartialProps, StoryAnnotations, StoryAnnotationsOrFn, StoryContext, StoryContextForEnhancers, StoryContextForLoaders, StoryContextUpdate, StoryFn, StoryId, StoryIdentifier, StoryIndex, StoryIndexEntry, StoryIndexInput, StoryIndexV2, StoryIndexV3, StoryIndexer, StoryKind, StoryName, StoryPreparedPayload, StoryRenderOptions, StorybookConfig, StorybookConfigOptions, StorybookInternalParameters, StorybookParameters, StrictArgTypes, StrictArgs, StrictGlobalTypes, StrictInputType, Tag, TeardownRenderToCanvas, TypescriptOptions, V3CompatIndexEntry, VersionCheck, ViewMode, WebRenderer };