UNPKG

storybook

Version:

Storybook: Develop, document, and test UI components in isolation

1,146 lines (1,145 loc) 703 kB
import { a as RenderData } from "./chunk-BxCdsGId.js"; import { c as ThemeVars$1 } from "./chunk-By2eGsW5.js"; import { f as Channel$1 } from "./chunk-DgWlWC_3.js"; import { t as Options$3 } from "./chunk-CB2MeY3U.js"; import { Y as StrictArgTypes$3 } from "./chunk-DEJsEo3q.js"; import { a as StoryStore, i as RenderType, n as StoryRender, r as Render, s as ReporterAPI, u as StorySpecifier } from "./chunk-D4lKaBz7.js"; import { AfterEach, AnnotatedStoryFn, ArgTypes as ArgTypes$2, ArgTypesEnhancer, Args, Args as Args$2, ArgsEnhancer, ArgsFromMeta, ArgsStoryFn, BaseAnnotations, BeforeAll, BeforeEach, Canvas, CleanupCallback, CleanupCallback as CleanupCallback$1, ComponentAnnotations as ComponentAnnotations$1, ComponentId, ComponentTitle as ComponentTitle$1, Conditional, DecoratorApplicator as DecoratorApplicator$1, DecoratorFunction as DecoratorFunction$2, GlobalTypes as GlobalTypes$1, Globals, Globals as Globals$2, IncludeExcludeOptions, InputType, LegacyAnnotatedStoryFn, LegacyStoryAnnotationsOrFn as LegacyStoryAnnotationsOrFn$1, LegacyStoryFn as LegacyStoryFn$1, LoaderFunction, Meta, Parameters as Parameters$2, PartialStoryFn as PartialStoryFn$1, PlayFunction, PlayFunctionContext, ProjectAnnotations, ProjectAnnotations as BaseProjectAnnotations, Renderer, Renderer as Renderer$2, SBArrayType, SBEnumType, SBIntersectionType, SBObjectType, SBOtherType, SBScalarType, SBType as SBType$1, SBUnionType, SeparatorOptions, StepFunction, StepLabel, StepRunner as StepRunner$1, Story, StoryAnnotations as StoryAnnotations$1, StoryAnnotationsOrFn as StoryAnnotationsOrFn$1, StoryContext, StoryContext as StoryContext$2, StoryContextForEnhancers as StoryContextForEnhancers$1, StoryContextForLoaders, StoryContextUpdate as StoryContextUpdate$1, StoryFn, StoryId, StoryId as StoryId$2, StoryIdentifier, StoryKind, StoryName as StoryName$1, StrictArgTypes, StrictArgTypes as StrictArgTypes$2, StrictArgs, StrictInputType, Tag, Tag as Tag$2, TestFunction as TestFunction$1, ViewMode, toId } from "storybook/internal/csf"; import React$1, { Component, FC, PropsWithChildren, ReactElement, ReactNode } from "react"; import { Channel, ChannelLike, Listener, Listener as Listener$2 } from "storybook/internal/channels"; import { NavigateOptions, RouterData } from "storybook/internal/router"; import { API_ComponentEntry as API_ComponentEntry$1, API_ComposedRef, API_ComposedRef as API_ComposedRef$2, API_ComposedRefUpdate, API_DocsEntry, API_DocsEntry as API_DocsEntry$2, API_FilterFunction, API_GroupEntry as API_GroupEntry$1, API_HashEntry, API_HashEntry as API_HashEntry$2, API_IframeRenderer, API_IndexHash, API_IndexHash as API_IndexHash$2, API_Layout, API_LayoutCustomisations, API_LeafEntry, API_LeafEntry as API_LeafEntry$2, API_LoadedRefData, API_Notification, API_OptionsData, API_PanelPositions, API_PreparedStoryIndex, API_Provider, API_ProviderData, API_Refs, API_Refs as API_Refs$2, API_RootEntry as API_RootEntry$1, API_SetRefData, API_Settings, API_StateMerger, API_StoryEntry, API_StoryEntry as API_StoryEntry$2, API_TestEntry, API_UI, API_UnknownEntries, API_Version, API_Versions, API_ViewMode, Addon_BaseType, Addon_Collection, Addon_Config, Addon_PageType, Addon_StorySortParameterV7, Addon_StoryWrapper, Addon_TestProviderType, Addon_Type as Addon_Type$1, Addon_Types, Addon_TypesEnum, Addon_TypesEnum as Addon_TypesEnum$2, Addon_TypesMapping, Addon_WrapperType, ArgTypes as ArgTypes$1, Args as Args$1, CSFFile, ComponentAnnotations, ComposeStoryFn, ComposedStoryFn, DecoratorFunction as DecoratorFunction$1, DocsContextProps, GlobalTypes, Globals as Globals$1, IndexEntry, LegacyStoryAnnotationsOrFn, LegacyStoryFn, ModuleExport, ModuleExports, ModuleImportFn, ModuleResolveConfig as ModuleResolveConfig$1, NamedOrDefaultProjectAnnotations, NormalizedComponentAnnotations, NormalizedProjectAnnotations, NormalizedStoriesSpecifier, NormalizedStoryAnnotations, Parameters as Parameters$1, PartialStoryFn, Path, PreparedStory, ProjectAnnotations as ProjectAnnotations$1, RenderContextCallbacks, RenderToCanvas, Renderer as Renderer$1, ResolvedModuleExportFromType, ResolvedModuleExportType, StatusValue, StepRunner, Store_CSFExports, StoryAnnotationsOrFn, StoryContext as StoryContext$1, StoryContextForEnhancers, StoryContextUpdate, StoryId as StoryId$1, StoryIndex, StoryName, StoryRenderOptions, StrictArgTypes as StrictArgTypes$1, Tag as Tag$1, TagsOptions, ViewMode as ViewMode$1 } from "storybook/internal/types"; import { ThemeVars } from "storybook/theming"; import { ArgTypesRequestPayload, OpenInEditorResponsePayload, RequestData, WhatsNewData } from "storybook/internal/core-events"; import { ImportEdge } from "storybook/internal/oxc-parser"; import { FileSystemCache } from "storybook/internal/common"; import { StoryIndexGenerator } from "storybook/internal/core-server"; import { CsfFile } from "storybook/internal/csf-tools"; import { LogLevel } from "storybook/internal/node-logger"; import { IncomingMessage, Server, ServerResponse } from "http"; import { Server as Server$1 } from "net"; //#region code/core/.dts-emit/code/core/src/channels/mock-channel.d.ts /** In-process channel with no transport — the default for unit tests and manager story mocks. */ declare function mockChannel(): Channel$1; //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/lib/addons.d.ts declare class AddonStore$1 { constructor(); private loaders; private elements; private config; private channel; private promise; private resolve; getChannel: () => Channel; ready: () => Promise<Channel>; hasChannel: () => boolean; setChannel: (channel: Channel) => void; getElements<T extends Addon_Types | Addon_TypesEnum$2.experimental_PAGE | Addon_TypesEnum$2.experimental_TEST_PROVIDER>(type: T): Addon_Collection<Addon_TypesMapping[T]> | any; /** * Adds an addon to the addon store. * * @param {string} id - The id of the addon. * @param {Addon_Type} addon - The addon to add. * @returns {void} */ add(id: string, addon: Addon_BaseType | Omit<Addon_TestProviderType, 'id'> | Omit<Addon_PageType, 'id'> | Omit<Addon_WrapperType, 'id'>): void; setConfig: (value: Addon_Config) => void; getConfig: () => Addon_Config; /** * Registers an addon loader function. * * @param {string} id - The id of the addon loader. * @param {(api: API) => void} callback - The function that will be called to register the addon. * @returns {void} */ register: (id: string, callback: (api: API) => void) => void; loadAddons: (api: any) => void; experimental_getRegisteredAddons<T extends Addon_Types | Addon_TypesEnum$2.experimental_PAGE | Addon_TypesEnum$2.experimental_TEST_PROVIDER>(type?: T): string[]; } declare const addons$1: AddonStore$1; //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/store.d.ts type GetState = () => State; type SetState = (a: any, b: any) => any; interface Upstream { /** * Whether to allow persistence of state to local/sessionStorage. This is used to disable * persistence in Storybook's own tests. True by default. */ allowPersistence?: boolean; getState: GetState; setState: SetState; } type Patch = Partial<State>; type InputFnPatch = (s: State) => Patch; type InputPatch = Patch | InputFnPatch; type PersistenceHandler = (patch: Partial<State>, serialize: ((s: State) => Partial<Record<string, string | null | undefined>>) | undefined) => void | Promise<void>; interface Options$2 { persistence: 'none' | 'session' | 'url' | string; serialize?: (s: State) => Partial<Record<string, string | null | undefined>>; } type CallBack = (s: State) => void; declare class Store { upstreamPersistence: boolean; upstreamGetState: GetState; upstreamSetState: SetState; private persistenceHandlers; constructor({ allowPersistence, setState, getState }: Upstream); registerPersistenceHandler(key: string, handler: PersistenceHandler): void; getInitialState(base: State): any; getState(): State; setState(inputPatch: InputPatch, options?: Options$2): Promise<State>; setState(inputPatch: InputPatch, callback?: CallBack, options?: Options$2): Promise<State>; } //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/lib/types.d.ts type ModuleFn<APIType = unknown, StateType = unknown> = (m: ModuleArgs, options?: any) => { init?: () => void | Promise<void>; api: APIType; state: StateType; }; type ModuleArgs = RouterData & API_ProviderData<API> & { mode?: 'production' | 'development'; state: State; fullAPI: API; store: Store; }; //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/modules/addons.d.ts interface SubAPI$13 { /** * Returns a collection of elements of a specific type. * * @template T - The type of the elements in the collection. * @param {Addon_Types | Addon_TypesEnum.experimental_PAGE} type - The type of the elements to * retrieve. * @returns {Addon_Collection<T>} - A collection of elements of the specified type. * @protected This is used internally in storybook's manager. */ getElements: <T extends Addon_Types | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_TEST_PROVIDER>(type: T) => Addon_Collection<Addon_TypesMapping[T]>; /** * Clears statuses for all registered test providers by calling each provider's `clear` function. */ clearStatuses: () => void; /** * Returns the id of the currently selected panel. * * @returns {string} - The ID of the currently selected panel. */ getSelectedPanel: () => string; /** * Sets the currently selected panel via it's ID. * * @param {string} panelName - The ID of the panel to select. * @returns {void} */ setSelectedPanel: (panelName: string) => void; /** * Sets the state of an addon with the given ID. * * @deprecated This API might get dropped, if you are using this, please file an issue. * @template S - The type of the addon state. * @param {string} addonId - The ID of the addon to set the state for. * @param {S | API_StateMerger<S>} newStateOrMerger - The new state to set, or a function which * receives the current state and returns the new state. * @param {Options} [options] - Optional options for the state update. * @returns {Promise<S>} - A promise that resolves with the new state after it has been set. */ setAddonState<S>(addonId: string, newStateOrMerger: S | API_StateMerger<S>, options?: Options$2): Promise<S>; /** * Returns the state of an addon with the given ID. * * @deprecated This API might get dropped, if you are using this, please file an issue. * @template S - The type of the addon state. * @param {string} addonId - The ID of the addon to get the state for. * @returns {S} - The state of the addon with the given ID. */ getAddonState<S>(addonId: string): S; } //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/modules/channel.d.ts interface SubAPI$12 { /** * Returns the channel object. * * @protected Please do not use, it's for internal use only. */ getChannel: () => API_Provider<API>['channel']; /** * Adds a listener to the channel for the given event type. Returns a function that can be called * to remove the listener. * * @param type - The event type to listen for. If using a core event, import it from * `storybook/internal/core-events`. * @param handler - The callback function to be called when the event is emitted. * @returns A function that can be called to remove the listener. */ on: (type: string, handler: Listener) => () => void; /** * Removes a listener from the channel for the given event type. * * @param type - The event type to remove the listener from. If using a core event, import it from * `storybook/internal/core-events`. * @param handler - The callback function to be removed. */ off: (type: string, handler: Listener) => void; /** * Emits an event on the channel for the given event type. * * @param type - The event type to emit. If using a core event, import it from * `storybook/internal/core-events`. * @param args - The arguments to pass to the event listener. */ emit: (type: string, ...args: any[]) => void; /** * Adds a one-time listener to the channel for the given event type. * * @param type - The event type to listen for. If using a core event, import it from * `storybook/internal/core-events`. * @param handler - The callback function to be called when the event is emitted. */ once: (type: string, handler: Listener) => void; } //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/modules/globals.d.ts interface SubState$9 { globals?: Globals$1; userGlobals?: Globals$1; storyGlobals?: Globals$1; globalTypes?: GlobalTypes; } interface SubAPI$11 { /** * Returns the current globals, which is the user globals overlaid with the story globals * * @returns {Globals} The current globals. */ getGlobals: () => Globals$1; /** * Returns the current globals, as set by the user (a story may have override values) * * @returns {Globals} The current user globals. */ getUserGlobals: () => Globals$1 /** * /** Returns the current globals, as set by the story * * @returns {Globals} The current story globals. */ ; getStoryGlobals: () => Globals$1 /** * Returns the globalTypes, as defined at the project level. * * @returns {GlobalTypes} The globalTypes. */ ; getGlobalTypes: () => GlobalTypes; /** * Updates the current globals with the provided new globals. * * @param {Globals} newGlobals - The new globals to update with. * @returns {void} */ updateGlobals: (newGlobals: Globals$1) => void; } //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/modules/layout.d.ts interface SubState$8 { layout: API_Layout; layoutCustomisations: API_LayoutCustomisations; ui: API_UI; selectedPanel: string | undefined; theme: ThemeVars; } /** * Availability of the sidebar/nav: 'unavailable' means the current route suppresses the nav * entirely (review routes), otherwise it is 'shown' or 'hidden' based on the layout state. */ type NavAvailability = 'shown' | 'hidden' | 'unavailable'; interface SubAPI$10 { /** * Toggles the fullscreen mode of the Storybook UI. * * @param toggled - Optional boolean value to set the fullscreen mode to. If not provided, it will * toggle the current state. */ toggleFullscreen: (toggled?: boolean) => void; /** * Toggles the visibility of the panel in the Storybook UI. * * @param toggled - Optional boolean value to set the panel visibility to. If not provided, it * will toggle the current state. */ togglePanel: (toggled?: boolean) => void; /** * Toggles the position of the panel in the Storybook UI. * * @param position - Optional string value to set the panel position to. If not provided, it will * toggle between 'bottom' and 'right'. */ togglePanelPosition: (position?: API_PanelPositions) => void; /** * Toggles the visibility of the navigation bar in the Storybook UI. * * @param toggled - Optional boolean value to set the navigation bar visibility to. If not * provided, it will toggle the current state. */ toggleNav: (toggled?: boolean) => void; /** * Toggles the visibility of the toolbar in the Storybook UI. * * @param toggled - Optional boolean value to set the toolbar visibility to. If not provided, it * will toggle the current state. */ toggleToolbar: (toggled?: boolean) => void; /** * Sets the options for the Storybook UI. * * @param options - An object containing the options to set. */ setOptions: (options: any) => void; /** Sets the sizes of the resizable elements in the layout. */ setSizes: (options: Partial<Pick<API_Layout, 'navSize' | 'bottomPanelHeight' | 'rightPanelWidth'>>) => void; /** GetIsFullscreen - Returns the current fullscreen mode of the Storybook UI. */ getIsFullscreen: () => boolean; /** GetIsPanelShown - Returns the current visibility of the panel in the Storybook UI. */ getIsPanelShown: () => boolean; /** GetIsNavShown - Returns the current visibility of the navigation bar in the Storybook UI. */ getIsNavShown: () => boolean; /** * GetNavAvailability - Returns whether the sidebar/nav is shown, hidden (but can be shown by the * user), or unavailable because the current route suppresses it entirely (review routes). */ getNavAvailability: () => NavAvailability; /** * GetShowToolbarWithCustomisations - Returns the current visibility of the toolbar, taking into * account customisations requested by the end user via a layoutCustomisations function. */ getShowToolbarWithCustomisations: (showToolbar: boolean) => boolean; /** * GetShowPanelWithCustomisations - Returns the current visibility of the addon panel, taking into * account customisations requested by the end user via a layoutCustomisations function. */ getShowPanelWithCustomisations: (showPanel: boolean) => boolean; /** * GetNavSizeWithCustomisations - Returns the size to apply to the sidebar/nav, taking into * account customisations requested by the end user via a layoutCustomisations function. */ getNavSizeWithCustomisations: (navSize: number) => number; /** * Attempts to focus an element identified by its ID. * * @param elementId - The id of the element to focus. * @param options - Options for focusing the element. * @param options.forceFocus - Whether to make the element focusable even though it wasn't. * @param options.select - Whether to call select() on the element after focusing it. * @param options.poll - Whether to poll for the element if it is not immediately available. * Defaults to true. When true, polls every 50ms for up to 500ms. * @returns Whether the element was successfully focused. Returns a Promise when polling. */ focusOnUIElement: (elementId?: string, options?: boolean | { forceFocus?: boolean; select?: boolean; poll?: boolean; }) => boolean | Promise<boolean>; } //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/modules/notifications.d.ts interface SubState$7 { notifications: API_Notification[]; } /** The API for managing notifications. */ interface SubAPI$9 { /** * Adds a new notification to the list of notifications. If a notification with the same ID * already exists, it will be replaced. * * @param notification - The notification to add. */ addNotification: (notification: API_Notification) => void; /** * Removes a notification from the list of notifications and calls the onClear callback. * * @param id - The ID of the notification to remove. */ clearNotification: (id: string) => void; } //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/modules/open-in-editor.d.ts /** The API for opening files in the editor. */ interface SubAPI$8 { /** * Opens the file in the editor. You can optionally provide a line and column number to open at a * more specific location. */ openInEditor: (payload: { file: string; line?: number; column?: number; }) => Promise<OpenInEditorResponsePayload>; } //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/modules/provider.d.ts interface SubAPI$7 { renderPreview?: API_IframeRenderer; } //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/modules/refs.d.ts interface SubState$6 { refs: API_Refs; } interface SubAPI$6 { /** * Finds a composed ref by its source. * * @param {string} source - The source/URL of the composed ref. * @returns {API_ComposedRef} - The composed ref object. */ findRef: (source: string) => API_ComposedRef; /** * Sets a composed ref by its ID and data. * * @param {string} id - The ID of the composed ref. * @param {API_SetRefData} data - The data to set for the composed ref. * @param {boolean} [ready] - Whether the composed ref is ready. */ setRef: (id: string, data: API_SetRefData, ready?: boolean) => void; /** * Updates a composed ref by its ID and update object. * * @param {string} id - The ID of the composed ref. * @param {API_ComposedRefUpdate} ref - The update object for the composed ref. */ updateRef: (id: string, ref: API_ComposedRefUpdate) => Promise<void>; /** * Gets all composed refs. * * @returns {API_Refs} - The composed refs object. */ getRefs: () => API_Refs; /** * Checks if a composed ref is valid. * * @param {API_SetRefData} ref - The composed ref to check. * @returns {Promise<void>} - A promise that resolves when the check is complete. */ checkRef: (ref: API_SetRefData) => Promise<void>; /** * Changes the version of a composed ref by its ID and URL. * * @param {string} id - The ID of the composed ref. * @param {string} url - The new URL for the composed ref. */ changeRefVersion: (id: string, url: string) => Promise<void>; /** * Changes the state of a composed ref by its ID and previewInitialized flag. * * @param {string} id - The ID of the composed ref. * @param {boolean} previewInitialized - The new previewInitialized flag for the composed ref. */ changeRefState: (id: string, previewInitialized: boolean) => void; } //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/modules/settings.d.ts interface SubAPI$5 { storeSelection: () => void; retrieveSelection: () => StoryId$1; /** * Changes the active settings tab. * * @example * * ```ts * changeSettingsTab(`about`); * ``` * * @param path - The path of the settings page to navigate to. The path NOT should include the * `/settings` prefix. */ changeSettingsTab: (path: string) => void; /** Closes the settings screen and returns to the last tracked story or the first story. */ closeSettings: () => void; /** * Checks if the settings screen is currently active. * * @returns A boolean indicating whether the settings screen is active. */ isSettingsScreenActive: () => boolean; } interface SubState$5 { settings: API_Settings; } //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/lib/shortcut.d.ts declare const controlOrMetaSymbol: () => "ctrl" | "⌘"; declare const controlOrMetaKey: () => "control" | "meta"; declare const optionOrAltSymbol: () => "alt" | "⌥"; declare const isShortcutTaken: (arr1: string[], arr2: string[]) => boolean; type KeyboardEventLike = Pick<KeyboardEvent, 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey' | 'key' | 'code' | 'keyCode' | 'preventDefault'>; declare const eventToShortcut: (e: KeyboardEventLike) => (string | string[])[] | null; declare const shortcutMatchesShortcut: (inputShortcut: (string | string[])[], shortcut: API_KeyCollection) => boolean; declare const eventMatchesShortcut: (e: KeyboardEventLike, shortcut: API_KeyCollection) => boolean; /** * Returns a human-readable symbol for a keyboard key. * * @param key The key to convert to a symbol. * @returns A string that a human could understand as that keyboard key. */ declare const keyToSymbol: (key: string) => string; declare const shortcutToHumanString: (shortcut: API_KeyCollection) => string; declare const shortcutToAriaKeyshortcuts: (shortcut: API_KeyCollection) => string; //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/modules/shortcuts.d.ts interface SubState$4 { shortcuts: API_Shortcuts; } interface SubAPI$4 { /** Returns the current shortcuts. */ getShortcutKeys(): API_Shortcuts; /** Returns the default shortcuts. */ getDefaultShortcuts(): API_Shortcuts | API_AddonShortcutDefaults; /** Returns the shortcuts for addons. */ getAddonsShortcuts(): API_AddonShortcuts; /** Returns the labels for addon shortcuts. */ getAddonsShortcutLabels(): API_AddonShortcutLabels; /** Returns the default shortcuts for addons. */ getAddonsShortcutDefaults(): API_AddonShortcutDefaults; /** * Sets the shortcuts to the given value. * * @param shortcuts The new shortcuts to set. * @returns A promise that resolves to the new shortcuts. */ setShortcuts(update: API_Shortcuts | ((shortcuts: API_Shortcuts) => API_Shortcuts)): Promise<API_Shortcuts>; /** * Sets the shortcut for the given action to the given value. * * @param action The action to set the shortcut for. * @param value The new shortcut to set. * @returns A promise that resolves to the new shortcut. */ setShortcut(action: API_Action, value: API_KeyCollection): Promise<API_KeyCollection>; /** * Sets the shortcut for the given addon to the given value. * * @param addon The addon to set the shortcut for. * @param shortcut The new shortcut to set. * @returns A promise that resolves to the new addon shortcut. */ setAddonShortcut(addon: string, shortcut: API_AddonShortcut): Promise<API_AddonShortcut>; /** * Restores all default shortcuts. * * @returns A promise that resolves to the new shortcuts. */ restoreAllDefaultShortcuts(): Promise<API_Shortcuts>; /** * Restores the default shortcut for the given action. * * @param action The action to restore the default shortcut for. * @returns A promise that resolves to the new shortcut. */ restoreDefaultShortcut(action: API_Action): Promise<API_KeyCollection>; /** * Handles a keydown event. * * @param event The event to handle. */ handleKeydownEvent(event: KeyboardEventLike): void; /** * Handles a shortcut feature. * * @param feature The feature to handle. * @param event The event to handle. */ handleShortcutFeature(feature: API_Action, event: KeyboardEventLike): void; } type API_KeyCollection = string[]; interface API_Shortcuts { fullScreen: API_KeyCollection; togglePanel: API_KeyCollection; panelPosition: API_KeyCollection; toggleNav: API_KeyCollection; toolbar: API_KeyCollection; search: API_KeyCollection; focusNav: API_KeyCollection; focusIframe: API_KeyCollection; focusPanel: API_KeyCollection; prevComponent: API_KeyCollection; nextComponent: API_KeyCollection; prevStory: API_KeyCollection; nextStory: API_KeyCollection; shortcutsPage: API_KeyCollection; aboutPage: API_KeyCollection; escape: API_KeyCollection; collapseAll: API_KeyCollection; expandAll: API_KeyCollection; remount: API_KeyCollection; openInEditor: API_KeyCollection; openInIsolation: API_KeyCollection; copyStoryLink: API_KeyCollection; goToPreviousLandmark: API_KeyCollection; goToNextLandmark: API_KeyCollection; } type API_Action = keyof API_Shortcuts; interface API_AddonShortcut { label: string; defaultShortcut: API_KeyCollection; actionName: string; showInMenu?: boolean; action: (...args: any[]) => any; } type API_AddonShortcuts = Record<string, API_AddonShortcut>; type API_AddonShortcutLabels = Record<string, string>; type API_AddonShortcutDefaults = Record<string, API_KeyCollection>; //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/modules/stories.d.ts type Direction = -1 | 1; type ParameterName = string; type StoryUpdate = Partial<Pick<API_StoryEntry, 'prepared' | 'parameters' | 'initialArgs' | 'argTypes' | 'args'>>; type DocsUpdate = Partial<Pick<API_DocsEntry, 'prepared' | 'parameters'>>; interface SubState$3 extends API_LoadedRefData { storyId: StoryId$1; internal_index?: API_PreparedStoryIndex; viewMode: API_ViewMode; filters: Record<string, API_FilterFunction>; tagPresets: TagsOptions; defaultIncludedTagFilters: Tag$1[]; defaultExcludedTagFilters: Tag$1[]; includedTagFilters: Tag$1[]; excludedTagFilters: Tag$1[]; includedStatusFilters: StatusValue[]; excludedStatusFilters: StatusValue[]; } interface SubAPI$3 { /** * The `storyId` method is a reference to the `toId` function from `@storybook/csf`, which is used * to generate a unique ID for a story. This ID is used to identify a specific story in the * Storybook index. * * @type {typeof toId} */ storyId: typeof toId; /** * Resolves a story, docs, component or group ID to its corresponding hash entry in the index. * * @param {StoryId} storyId - The ID of the story to resolve. * @param {string} [refsId] - The ID of the refs to use for resolving the story. * @returns {API_HashEntry} - The hash entry corresponding to the given story ID. */ resolveStory: (storyId: StoryId$1, refsId?: string) => API_HashEntry | undefined; /** * Selects the first story to display in the Storybook UI. * * @returns {void} */ selectFirstStory: () => void; /** * Selects a story to display in the Storybook UI. * * @param {string} [kindOrId] - The kind or ID of the story to select. * @param {StoryId} [story] - The ID of the story to select. * @param {Object} [obj] - An optional object containing additional options. * @param {string} [obj.ref] - The ref ID of the story to select. * @param {API_ViewMode} [obj.viewMode] - The view mode to display the story in. * @returns {void} */ selectStory: (kindOrId?: string, story?: StoryId$1, obj?: { ref?: string; viewMode?: API_ViewMode; }) => void; /** * Returns the current story's data, including its ID, kind, name, and parameters. * * @returns {API_LeafEntry} The current story's data. */ getCurrentStoryData: () => API_LeafEntry; /** * Returns the current story index. * * @returns {API_PreparedStoryIndex | undefined} The current story index, or undefined if not yet * loaded. */ getIndex: () => API_PreparedStoryIndex | undefined; /** * Sets the prepared story index to the given value. * * @param {API_PreparedStoryIndex} index - The prepared story index to set. * @returns {Promise<void>} A promise that resolves when the prepared story index has been set. */ setIndex: (index: API_PreparedStoryIndex) => Promise<void>; /** * Jumps to the next or previous component in the index. * * @param {Direction} direction - The direction to jump. Use -1 to jump to the previous component, * and 1 to jump to the next component. * @returns {void} */ jumpToComponent: (direction: Direction) => void; /** * Jumps to the next or previous story in the story index. * * @param {Direction} direction - The direction to jump. Use -1 to jump to the previous story, and * 1 to jump to the next story. * @returns {void} */ jumpToStory: (direction: Direction) => void; /** * Returns the data for the given story ID and optional ref ID. * * @param {StoryId} storyId - The ID of the story to retrieve data for. * @param {string} [refId] - The ID of the ref to retrieve data for. If not provided, retrieves * data for the default ref. * @returns {API_LeafEntry} The data for the given story ID and optional ref ID. */ getData: (storyId: StoryId$1, refId?: string) => API_LeafEntry; /** * Returns a boolean indicating whether the given story ID and optional ref ID have been prepared. * * @param {StoryId} storyId - The ID of the story to check. * @param {string} [refId] - The ID of the ref to check. If not provided, checks all refs for the * given story ID. * @returns {boolean} A boolean indicating whether the given story ID and optional ref ID have * been prepared. */ isPrepared: (storyId: StoryId$1, refId?: string) => boolean; /** * Returns the parameters for the given story ID and optional ref ID. * * @param {StoryId | { storyId: StoryId; refId: string }} storyId - The ID of the story to * retrieve parameters for, or an object containing the story ID and ref ID. * @param {ParameterName} [parameterName] - The name of the parameter to retrieve. If not * provided, returns all parameters. * @returns {API_StoryEntry['parameters'] | any} The parameters for the given story ID and * optional ref ID. */ getParameters: (storyId: StoryId$1 | { storyId: StoryId$1; refId: string; }, parameterName?: ParameterName) => API_StoryEntry['parameters'] | any; /** * Returns the current value of the specified parameter for the currently selected story. * * @template S - The type of the parameter value. * @param {ParameterName} [parameterName] - The name of the parameter to retrieve. If not * provided, returns all parameters. * @returns {S} The value of the specified parameter for the currently selected story. */ getCurrentParameter<S>(parameterName?: ParameterName): S; /** * Updates the arguments for the given story with the provided new arguments. * * @param {API_StoryEntry | API_TestEntry} story - The story to update the arguments for. * @param {Args} newArgs - The new arguments to set for the story. * @returns {void} */ updateStoryArgs(story: API_StoryEntry | API_TestEntry, newArgs: Args$1): void; /** * Resets the arguments for the given story to their initial values. * * @param {API_StoryEntry | API_TestEntry} story - The story to reset the arguments for. * @param {string[]} [argNames] - An optional array of argument names to reset. If not provided, * all arguments will be reset. * @returns {void} */ resetStoryArgs: (story: API_StoryEntry | API_TestEntry, argNames?: string[]) => void; /** * Finds the leaf entry for the given story ID in the given story index. * * @param {API_IndexHash} index - The story index to search for the leaf entry in. * @param {StoryId} storyId - The ID of the story to find the leaf entry for. * @returns {API_LeafEntry | undefined} The leaf entry for the given story ID, or undefined if no * leaf entry was found. */ findLeafEntry(index: API_IndexHash, storyId: StoryId$1): API_LeafEntry | undefined; /** * Finds the leaf story ID for the given component or group ID in the given index. * * @param {API_IndexHash} index - The story index to search for the leaf story ID in. * @param {StoryId} storyId - The ID of the story to find the leaf story ID for. * @returns {StoryId | undefined} The ID of the leaf story, or undefined if no leaf story was * found. */ findLeafStoryId(index: API_IndexHash, storyId: StoryId$1): StoryId$1 | undefined; /** * Finds all the leaf story IDs for the given entry ID in the given index. * * @param {StoryId} entryId - The ID of the entry to find the leaf story IDs for. * @returns {StoryId[]} The IDs of all the leaf stories, or an empty array if no leaf stories were * found. */ findAllLeafStoryIds(entryId: string): StoryId$1[]; /** * Finds the ID of the sibling story in the given direction for the given story ID in the given * story index. * * @param {StoryId} storyId - The ID of the story to find the sibling of. * @param {API_IndexHash} index - The story index to search for the sibling in. * @param {Direction} direction - The direction to search for the sibling in. * @param {boolean} toSiblingGroup - When true, skips over leafs within the same group. * @returns {StoryId} The ID of the sibling story, or null if no sibling was found. */ findSiblingStoryId(storyId: StoryId$1, index: API_IndexHash, direction: Direction, toSiblingGroup: boolean): StoryId$1; /** * Fetches the story index from the server. * * @returns {Promise<void>} A promise that resolves when the index has been fetched. */ fetchIndex: () => Promise<void>; /** * Updates the story with the given ID with the provided update object. * * @param {StoryId} storyId - The ID of the story to update. * @param {StoryUpdate} update - An object containing the updated story information. * @param {API_ComposedRef} [ref] - The composed ref of the story to update. * @returns {Promise<void>} A promise that resolves when the story has been updated. */ updateStory: (storyId: StoryId$1, update: StoryUpdate, ref?: API_ComposedRef) => Promise<void>; /** * Updates the documentation for the given story ID with the given update object. * * @param {StoryId} storyId - The ID of the story to update. * @param {DocsUpdate} update - An object containing the updated documentation information. * @param {API_ComposedRef} [ref] - The composed ref of the story to update. * @returns {Promise<void>} A promise that resolves when the documentation has been updated. */ updateDocs: (storyId: StoryId$1, update: DocsUpdate, ref?: API_ComposedRef) => Promise<void>; /** * Sets the preview as initialized. * * @param {ComposedRef} [ref] - The composed ref of the story to set as initialized. * @returns {Promise<void>} A promise that resolves when the preview has been set as initialized. */ setPreviewInitialized: (ref?: API_ComposedRef$2) => Promise<void>; /** * Updates the filtering of the index. * * @param {string} addonId - The ID of the addon to update. * @param {API_FilterFunction} filterFunction - A function that returns a boolean based on the * story, index and status. * @returns {Promise<void>} A promise that resolves when the state has been updated. */ experimental_setFilter: (addonId: string, filterFunction: API_FilterFunction) => Promise<void>; /** Resets tag filters in the sidebar to the default filters. */ resetTagFilters(): Promise<void>; /** * Replaces all tag filters in the sidebar with the provided included and excluded lists. * * @param included The tags to include in the filtered stories list * @param excluded The tags to filter out (exclude) from the stories list */ setAllTagFilters(included: Tag$1[], excluded: Tag$1[]): Promise<void>; /** * Adds tag filters to the included or excluded filter lists. Included filters are included in the * stories list, whereas excluded filters are filtered out. * * @param tags The tags to add as filters. * @param excluded Whether to add the tags to the include or exclude filter list. */ addTagFilters(tags: Tag$1[], excluded: boolean): Promise<void>; /** * Removes tag filters from both the included and excluded filter lists. * * @param tags The tags to remove from filters. */ removeTagFilters(tags: Tag$1[]): Promise<void>; /** Resets status filters in the sidebar (clears both included and excluded). */ resetStatusFilters(): Promise<void>; /** * Replaces all status filters in the sidebar with the provided included and excluded lists. * * @param included The status values to include in the filtered stories list * @param excluded The status values to filter out (exclude) from the stories list */ setAllStatusFilters(included: StatusValue[], excluded: StatusValue[]): Promise<void>; /** * Adds status filters to the included or excluded filter lists. * * @param statuses The status values to add as filters. * @param excluded Whether to add to the include or exclude filter list. */ addStatusFilters(statuses: StatusValue[], excluded: boolean): Promise<void>; /** * Removes status filters from both the included and excluded filter lists. * * @param statuses The status values to remove from filters. */ removeStatusFilters(statuses: StatusValue[]): Promise<void>; } //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/modules/url.d.ts interface SubState$2 { customQueryParams: QueryParams; } interface QueryParams { [key: string]: string | undefined; } interface QueryParamInput { [key: string]: string | undefined | null; } /** SubAPI for managing URL navigation and state. */ interface SubAPI$2 { /** * Navigate to a new URL. * * @param {string} url - The URL to navigate to. * @param {NavigateOptions} options - Options for the navigation. * @returns {void} */ navigateUrl: (url: string, options: NavigateOptions) => void; /** * Get the manager and preview hrefs for a story. * * @param {string} storyId - The ID of the story to get the URL for. * @param {Object} options - Options for the URL. * @param {string} [options.base] - Return an absolute href based on the current origin or network * address. * @param {boolean} [options.inheritArgs] - Inherit args from the current URL. If storyId matches * current story, inheritArgs defaults to true. * @param {boolean} [options.inheritGlobals] - Inherit globals from the current URL. Defaults to * true. * @param {QueryParams} [options.queryParams] - Query params to add to the URL. * @param {string} [options.refId] - ID of the ref to get the URL for (for composed Storybooks) * @param {string} [options.viewMode] - The view mode to use, defaults to 'story'. * @param {boolean} [options.embed] - Append `embed=true` so the preview broadcasts * content dimensions to an embedding parent via `iframe.resize` postMessage. Affects * `previewHref` only. * @param {boolean} [options.freeze] - Append the `freeze=finished` preview contract so the * preview settles to a static end frame and blocks interaction. Affects `previewHref` only. * @returns {Object} Manager and preview hrefs for the story. */ getStoryHrefs(storyId: string, options?: { base?: 'origin' | 'network'; inheritArgs?: boolean; inheritGlobals?: boolean; queryParams?: QueryParams; refId?: string; viewMode?: API_ViewMode; embed?: boolean; freeze?: boolean; }): { managerHref: string; previewHref: string; }; /** * Get the value of a query parameter from the current URL. * * @param {string} key - The key of the query parameter to get. * @returns {string | undefined} The value of the query parameter, or undefined if it does not * exist. */ getQueryParam: (key: string) => string | undefined; /** * Returns an object containing the current state of the URL. * * @returns {{ * queryParams: QueryParams; * path: string; * viewMode?: string; * storyId?: string; * url: string; * }} * An object containing the current state of the URL. */ getUrlState: () => { queryParams: QueryParams; path: string; hash: string; viewMode?: string; storyId?: string; url: string; }; /** * Set the query parameters for the current URL. * * @param {QueryParams} input - An object containing the query parameters to set. * @returns {void} */ setQueryParams: (input: QueryParamInput) => void; /** * Set the query parameters for the current URL & navigates. * * @param {QueryParams} input - An object containing the query parameters to set. * @param {NavigateOptions} options - Options for the navigation. * @returns {void} */ applyQueryParams: (input: QueryParamInput, options?: NavigateOptions) => void; } //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/modules/versions.d.ts interface SubState$1 { versions: API_Versions & API_UnknownEntries; lastVersionCheck: number; dismissedVersionNotification: undefined | string; } interface SubAPI$1 { /** * Returns the current version of the Storybook Manager. * * @returns {API_Version} The current version of the Storybook Manager. */ getCurrentVersion: () => API_Version; /** * Returns the latest version of the Storybook Manager. * * @returns {API_Version} The latest version of the Storybook Manager. */ getLatestVersion: () => API_Version; /** * Returns the URL of the Storybook documentation for the current version. * * @param options - The options for the documentation URL. * @param options.asset - Like subpath, but links to the docs-assets directory. * @param options.subpath - The subpath of the documentation URL. * @param options.versioned - Whether to include the versioned path. * @param options.renderer - Whether to include the renderer path. * @param options.ref - Tracking reference for the docs site. E.g. 'ui', 'error', 'upgrade', etc. * @returns {string} The URL of the Storybook Manager documentation. */ getDocsUrl: (options: { asset?: string; subpath?: string; versioned?: boolean; renderer?: boolean; ref?: string; }) => string; /** * Checks if an update is available for the Storybook Manager. * * @returns {boolean} True if an update is available, false otherwise. */ versionUpdateAvailable: () => boolean; } //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/modules/whatsnew.d.ts type SubState = { whatsNewData?: WhatsNewData; }; type SubAPI = { isWhatsNewUnread(): boolean; whatsNewHasBeenRead(): void; toggleWhatsNewNotifications(): void; }; //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/lib/request-response.d.ts declare class RequestResponseError<Payload extends Record<string, any> | void> extends Error { payload: Payload | undefined; constructor(message: string, payload?: Payload); } declare const experimental_requestResponse: <RequestPayload, ResponsePayload = void, CreateNewStoryErrorPayload extends Record<string, any> | void = void>(channel: Channel, requestEvent: string, responseEvent: string, payload: RequestPayload, timeout?: number) => Promise<ResponsePayload>; //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/lib/platform.d.ts declare const isMacLike: () => boolean; //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/lib/merge.d.ts declare function _default<TObj = any>(a: TObj, ...b: Partial<TObj>[]): TObj; //#endregion //#region code/core/.dts-emit/code/core/src/manager-api/root.d.ts declare const ActiveTabs: { SIDEBAR: 'sidebar'; CANVAS: 'canvas'; ADDONS: 'addons'; }; declare const ManagerContext: React$1.Context<{ api: API; state: State; }>; type State = SubState$8 & SubState$3 & SubState$6 & SubState$7 & SubState$1 & SubState$2 & SubState$4 & SubState$5 & SubState$9 & SubState & RouterData & API_OptionsData & Other; type API = SubAPI$13 & SubAPI$12 & SubAPI$7 & SubAPI$3 & SubAPI$6 & SubAPI$11 & SubAPI$10 & SubAPI$9 & SubAPI$4 & SubAPI$5 & SubAPI$1 & SubAPI$2 & SubAPI & SubAPI$8 & Other; interface Other { [key: string]: any; } interface Combo { api: API; state: State; } type ManagerProviderProps = RouterData & API_ProviderData<API> & { children: ReactNode | FC<Combo>; }; declare const combineParameters$1: (...parameterSets: Parameters$1[]) => {}; declare class ManagerProvider extends Component<ManagerProviderProps, State> { api: API; modules: ReturnType<ModuleFn>[]; mounted: boolean; static displayName: string; constructor(props: ManagerProviderProps); componentDidMount(): void; static getDerivedStateFromProps(props: ManagerProviderProps, state: State): State; shouldComponentUpdate(nextProps: ManagerProviderProps, nextState: State): boolean; initModules: () => void; render(): React$1.JSX.Element; } interface ManagerConsumerProps<P = unknown> { filter?: (combo: Combo) => P; children: FC<P> | ReactNode; } declare function ManagerConsumer<P = Combo>({ filter, children }: ManagerConsumerProps<P>): ReactElement; declare function useStorybookState(): State; declare function useStorybookApi(): API; interface API_EventMap { [eventId: string]: Listener$2; } declare const useChannel: (eventMap: API_EventMap, deps?: any[]) => (type: string, ...args: any[]) => void; declare function useStoryPrepared(storyId?: StoryId$1): boolean; declare function useParameter<S>(parameterKey: string, defaultValue?: S): S; declare function useSharedState<S>(stateId: string, defaultState?: S): [S, (newStateOrMerger: S | API_StateMerger<S>, options?: Options$2) => void]; declare function useAddonState<S>(addonId: string, defaultState?: S): [S, (newStateOrMerger: S | API_StateMerger<S>, options?: Options$2) => void]; declare function useArgs(): [Args$1, (newArgs: Args$1) => void, (argNames?: string[]) => void, Args$1]; declare function useGlobals(): [globals: Globals$1, updateGlobals: (newGlobals: Globals$1) => void, storyGlobals: Globals$1, userGlobals: Globals$1]; declare function useGlobalTypes(): GlobalTypes; declare function useArgTypes(): ArgTypes$1; declare const typesX: typeof Addon_TypesEnum$2; //#endregion //#region code/core/.dts-emit/code/core/src/shared/universal-store/types.d.ts type EnvironmentType = (typeof UniversalStore.Environment)[keyof typeof UniversalStore.Environment]; type StatusType = (typeof UniversalStore.Status)[keyof typeof UniversalStore.Status]; type StateUpdater<TState> = (prevState: TState) => TState; type Actor = { id: string; type: (typeof UniversalStore.ActorType)[keyof typeof UniversalStore.ActorType]; environment: EnvironmentType; }; type EventInfo = { actor: Actor; forwardingActor?: Actor; }; type Listener$1<TEvent> = (event: TEvent, eventInfo: EventInfo) => void; type BaseEvent = { type: string; payload?: any; }; interface SetStateEvent<TState> extends BaseEvent { type: typeof UniversalStore.InternalEventType.SET_STATE; payload: { state: TState; previousState: TState; }; } interface ExistingStateRequestEvent extends BaseEvent { type: typeof UniversalStore.InternalEventType.EXISTING_STATE_REQUEST; payload: never; } interface ExistingStateResponseEvent<TState> extends BaseEvent { type: typeof UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE; payload: TState; } interface LeaderCreatedEvent extends BaseEvent { type: typeof UniversalStore.InternalEventType.LEADER_CREATED; payload: never; } interface FollowerCreatedEvent extends BaseEvent { type: typeof UniversalStore.InternalEventType.FOLLOWER_CREATED; payload: never; } type InternalEvent<TState> = SetStateEvent<TState> | ExistingStateRequestEvent | ExistingStateResponseEvent<TState> | FollowerCreatedEvent | LeaderCreatedEvent; type Event<TState, TEvent extends BaseEvent> = TEvent | InternalEvent<TState>; type ChannelLike$1 = Pick<Channel, 'on' | 'o