123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855 |
- import React, { ReactNode, Component, ReactElement, FC } from 'react';
- import { API_ProviderData, API_IframeRenderer, Addon_Types, Addon_TypesEnum, Addon_Collection, Addon_TypesMapping, API_Panels, API_StateMerger, API_Provider, API_Notification, StoryId, API_Settings, API_LoadedRefData, API_PreparedStoryIndex, API_ViewMode, API_StatusState, API_FilterFunction, API_HashEntry, API_LeafEntry, API_StoryEntry, Args, API_IndexHash, API_ComposedRef, API_StatusUpdate, API_DocsEntry, API_Refs, API_SetRefData, API_ComposedRefUpdate, API_Layout, API_UI, API_PanelPositions, API_Versions, API_UnknownEntries, API_Version, Globals, GlobalTypes, Addon_BaseType, Addon_SidebarTopType, Addon_SidebarBottomType, Addon_PageType, Addon_WrapperType, Addon_Config, API_OptionsData, Parameters, ArgTypes } from '@storybook/types';
- export { Addon_Type as Addon, API_ComponentEntry as ComponentEntry, API_ComposedRef as ComposedRef, API_DocsEntry as DocsEntry, API_GroupEntry as GroupEntry, API_HashEntry as HashEntry, API_IndexHash as IndexHash, API_LeafEntry as LeafEntry, API_Refs as Refs, API_RootEntry as RootEntry, API_IndexHash as StoriesHash, API_StoryEntry as StoryEntry } from '@storybook/types';
- import { RouterData, NavigateOptions } from '@storybook/router';
- import { Listener, Channel } from '@storybook/channels';
- export { Listener as ChannelListener } from '@storybook/channels';
- import { toId } from '@storybook/csf';
- import { ThemeVars } from '@storybook/theming';
- import { WhatsNewData } from '@storybook/core-events';
- type GetState = () => State;
- type SetState = (a: any, b: any) => any;
- interface Upstream {
- getState: GetState;
- setState: SetState;
- }
- type Patch = Partial<State>;
- type InputFnPatch = (s: State) => Patch;
- type InputPatch = Patch | InputFnPatch;
- interface Options {
- persistence: 'none' | 'session' | string;
- }
- type CallBack = (s: State) => void;
- declare class Store {
- upstreamGetState: GetState;
- upstreamSetState: SetState;
- constructor({ setState, getState }: Upstream);
- getInitialState(base: State): any;
- getState(): State;
- setState(inputPatch: InputPatch, options?: Options): Promise<State>;
- setState(inputPatch: InputPatch, callback?: CallBack, options?: Options): Promise<State>;
- }
- 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;
- };
- interface SubAPI$c {
- renderPreview?: API_IframeRenderer;
- }
- interface SubAPI$b {
-
- getElements: <T extends Addon_Types | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_SIDEBAR_TOP = Addon_Types>(type: T) => Addon_Collection<Addon_TypesMapping[T]>;
-
- getPanels: () => API_Panels;
-
- getStoryPanels: () => API_Panels;
-
- getSelectedPanel: () => string;
-
- setSelectedPanel: (panelName: string) => void;
-
- setAddonState<S>(addonId: string, newStateOrMerger: S | API_StateMerger<S>, options?: Options): Promise<S>;
-
- getAddonState<S>(addonId: string): S;
- }
- interface SubAPI$a {
-
- getChannel: () => API_Provider<API>['channel'];
-
- on: (type: string, handler: Listener) => () => void;
-
- off: (type: string, handler: Listener) => void;
-
- emit: (type: string, ...args: any[]) => void;
-
- once: (type: string, handler: Listener) => void;
-
- collapseAll: () => void;
-
- expandAll: () => void;
- }
- interface SubState$9 {
- notifications: API_Notification[];
- }
- interface SubAPI$9 {
-
- addNotification: (notification: API_Notification) => void;
-
- clearNotification: (id: string) => void;
- }
- interface SubAPI$8 {
- storeSelection: () => void;
- retrieveSelection: () => StoryId;
-
- changeSettingsTab: (path: string) => void;
-
- closeSettings: () => void;
-
- isSettingsScreenActive: () => boolean;
-
- navigateToSettingsPage: (path: string) => Promise<void>;
- }
- interface SubState$8 {
- settings: API_Settings;
- }
- 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$7 extends API_LoadedRefData {
- storyId: StoryId;
- internal_index?: API_PreparedStoryIndex;
- viewMode: API_ViewMode;
- status: API_StatusState;
- filters: Record<string, API_FilterFunction>;
- }
- interface SubAPI$7 {
-
- storyId: typeof toId;
-
- resolveStory: (storyId: StoryId, refsId?: string) => API_HashEntry;
-
- selectFirstStory: () => void;
-
- selectStory: (kindOrId?: string, story?: StoryId, obj?: {
- ref?: string;
- viewMode?: API_ViewMode;
- }) => void;
-
- getCurrentStoryData: () => API_LeafEntry;
-
- setIndex: (index: API_PreparedStoryIndex) => Promise<void>;
-
- jumpToComponent: (direction: Direction) => void;
-
- jumpToStory: (direction: Direction) => void;
-
- getData: (storyId: StoryId, refId?: string) => API_LeafEntry;
-
- isPrepared: (storyId: StoryId, refId?: string) => boolean;
-
- getParameters: (storyId: StoryId | {
- storyId: StoryId;
- refId: string;
- }, parameterName?: ParameterName) => API_StoryEntry['parameters'] | any;
-
- getCurrentParameter<S>(parameterName?: ParameterName): S;
-
- updateStoryArgs(story: API_StoryEntry, newArgs: Args): void;
-
- resetStoryArgs: (story: API_StoryEntry, argNames?: string[]) => void;
-
- findLeafEntry(index: API_IndexHash, storyId: StoryId): API_LeafEntry;
-
- findLeafStoryId(index: API_IndexHash, storyId: StoryId): StoryId;
-
- findSiblingStoryId(storyId: StoryId, index: API_IndexHash, direction: Direction, toSiblingGroup: boolean): StoryId;
-
- fetchIndex: () => Promise<void>;
-
- updateStory: (storyId: StoryId, update: StoryUpdate, ref?: API_ComposedRef) => Promise<void>;
-
- updateDocs: (storyId: StoryId, update: DocsUpdate, ref?: API_ComposedRef) => Promise<void>;
-
- setPreviewInitialized: (ref?: API_ComposedRef) => Promise<void>;
-
- experimental_updateStatus: (addonId: string, update: API_StatusUpdate | ((state: API_StatusState) => API_StatusUpdate)) => Promise<void>;
-
- experimental_setFilter: (addonId: string, filterFunction: API_FilterFunction) => Promise<void>;
- }
- interface SubState$6 {
- refs: API_Refs;
- }
- interface SubAPI$6 {
-
- findRef: (source: string) => API_ComposedRef;
-
- setRef: (id: string, data: API_SetRefData, ready?: boolean) => void;
-
- updateRef: (id: string, ref: API_ComposedRefUpdate) => void;
-
- getRefs: () => API_Refs;
-
- checkRef: (ref: API_SetRefData) => Promise<void>;
-
- changeRefVersion: (id: string, url: string) => void;
-
- changeRefState: (id: string, previewInitialized: boolean) => void;
- }
- interface SubState$5 {
- layout: API_Layout;
- ui: API_UI;
- selectedPanel: string | undefined;
- theme: ThemeVars;
- }
- interface SubAPI$5 {
-
- toggleFullscreen: (toggled?: boolean) => void;
-
- togglePanel: (toggled?: boolean) => void;
-
- togglePanelPosition: (position?: API_PanelPositions) => void;
-
- toggleNav: (toggled?: boolean) => void;
-
- toggleToolbar: (toggled?: boolean) => void;
-
- setOptions: (options: any) => void;
- }
- declare const isMacLike: () => boolean;
- declare const controlOrMetaSymbol: () => "⌘" | "ctrl";
- declare const controlOrMetaKey: () => "meta" | "control";
- 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;
- declare const keyToSymbol: (key: string) => string;
- declare const shortcutToHumanString: (shortcut: API_KeyCollection) => string;
- interface SubState$4 {
- shortcuts: API_Shortcuts;
- }
- interface SubAPI$4 {
-
- getShortcutKeys(): API_Shortcuts;
-
- getDefaultShortcuts(): API_Shortcuts | API_AddonShortcutDefaults;
-
- getAddonsShortcuts(): API_AddonShortcuts;
-
- getAddonsShortcutLabels(): API_AddonShortcutLabels;
-
- getAddonsShortcutDefaults(): API_AddonShortcutDefaults;
-
- setShortcuts(shortcuts: API_Shortcuts): Promise<API_Shortcuts>;
-
- setShortcut(action: API_Action, value: API_KeyCollection): Promise<API_KeyCollection>;
-
- setAddonShortcut(addon: string, shortcut: API_AddonShortcut): Promise<API_AddonShortcut>;
-
- restoreAllDefaultShortcuts(): Promise<API_Shortcuts>;
-
- restoreDefaultShortcut(action: API_Action): Promise<API_KeyCollection>;
-
- handleKeydownEvent(event: KeyboardEventLike): void;
-
- 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;
- }
- 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>;
- interface SubState$3 {
- customQueryParams: QueryParams;
- }
- interface QueryParams {
- [key: string]: string | null;
- }
- interface SubAPI$3 {
-
- navigateUrl: (url: string, options: NavigateOptions) => void;
-
- getQueryParam: (key: string) => string | undefined;
-
- getUrlState: () => {
- queryParams: QueryParams;
- path: string;
- viewMode?: string;
- storyId?: string;
- url: string;
- };
-
- setQueryParams: (input: QueryParams) => void;
- }
- interface SubState$2 {
- versions: API_Versions & API_UnknownEntries;
- lastVersionCheck: number;
- dismissedVersionNotification: undefined | string;
- }
- interface SubAPI$2 {
-
- getCurrentVersion: () => API_Version;
-
- getLatestVersion: () => API_Version;
-
- versionUpdateAvailable: () => boolean;
- }
- type SubState$1 = {
- whatsNewData?: WhatsNewData;
- };
- type SubAPI$1 = {
- isWhatsNewUnread(): boolean;
- whatsNewHasBeenRead(): void;
- toggleWhatsNewNotifications(): void;
- };
- interface SubState {
- globals?: Globals;
- globalTypes?: GlobalTypes;
- }
- interface SubAPI {
-
- getGlobals: () => Globals;
-
- getGlobalTypes: () => GlobalTypes;
-
- updateGlobals: (newGlobals: Globals) => void;
- }
- declare function mockChannel(): Channel;
- interface DeprecatedAddonWithId {
-
- id?: string;
- }
- declare class AddonStore {
- constructor();
- private loaders;
- private elements;
- private config;
- private channel;
- /**
- * @deprecated will be removed in 8.0
- */
- private serverChannel;
- private promise;
- private resolve;
- getChannel: () => Channel;
- /**
- * @deprecated will be removed in 8.0, use getChannel instead
- */
- getServerChannel: () => Channel;
- ready: () => Promise<Channel>;
- hasChannel: () => boolean;
- /**
- * @deprecated will be removed in 8.0, please use the normal channel instead
- */
- hasServerChannel: () => boolean;
- setChannel: (channel: Channel) => void;
- /**
- * @deprecated will be removed in 8.0, please use the normal channel instead
- */
- setServerChannel: (channel: Channel) => void;
- getElements<T extends Addon_Types | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_SIDEBAR_TOP>(type: T): Addon_Collection<Addon_TypesMapping[T]>;
- /**
- * Adds a panel to the addon store.
- * @param {string} id - The id of the panel.
- * @param {Addon_Type} options - The options for the panel.
- * @returns {void}
- *
- * @deprecated Use the 'add' method instead.
- * @example
- * addons.add('My Panel', {
- * title: 'My Title',
- * type: types.PANEL,
- * render: () => <div>My Content</div>,
- * });
- */
- addPanel: (id: string, options: Omit<Addon_BaseType, 'type' | 'id'> & DeprecatedAddonWithId) => void;
-
- add(id: string, addon: Addon_BaseType | (Omit<Addon_SidebarTopType, 'id'> & DeprecatedAddonWithId) | (Omit<Addon_SidebarBottomType, 'id'> & DeprecatedAddonWithId) | (Omit<Addon_PageType, 'id'> & DeprecatedAddonWithId) | (Omit<Addon_WrapperType, 'id'> & DeprecatedAddonWithId)): void;
- setConfig: (value: Addon_Config) => void;
- getConfig: () => Addon_Config;
-
- register: (id: string, callback: (api: API) => void) => void;
- loadAddons: (api: any) => void;
- }
- declare const addons: AddonStore;
- declare const _default: <TObj = any>(a: TObj, b: Partial<TObj>) => TObj & Partial<TObj>;
- declare const ActiveTabs: {
- SIDEBAR: "sidebar";
- CANVAS: "canvas";
- ADDONS: "addons";
- };
- declare const ManagerContext: React.Context<{
- api: API;
- state: State;
- }>;
- type State = SubState$5 & SubState$7 & SubState$6 & SubState$9 & SubState$2 & SubState$3 & SubState$4 & SubState$8 & SubState & SubState$1 & RouterData & API_OptionsData & DeprecatedState & Other;
- type API = SubAPI$b & SubAPI$a & SubAPI$c & SubAPI$7 & SubAPI$6 & SubAPI & SubAPI$5 & SubAPI$9 & SubAPI$4 & SubAPI$8 & SubAPI$2 & SubAPI$3 & SubAPI$1 & Other;
- interface DeprecatedState {
-
- storiesHash: API_IndexHash;
-
- storiesConfigured: boolean;
-
- storiesFailed?: Error;
- }
- interface Other {
- [key: string]: any;
- }
- interface Combo {
- api: API;
- state: State;
- }
- type ManagerProviderProps = RouterData & API_ProviderData<API> & {
- children: ReactNode | ((props: Combo) => ReactNode);
- };
- declare const combineParameters: (...parameterSets: Parameters[]) => any;
- declare class ManagerProvider extends Component<ManagerProviderProps, State> {
- api: API;
- modules: ReturnType<ModuleFn>[];
- static displayName: string;
- constructor(props: ManagerProviderProps);
- static getDerivedStateFromProps(props: ManagerProviderProps, state: State): State;
- shouldComponentUpdate(nextProps: ManagerProviderProps, nextState: State): boolean;
- initModules: () => void;
- render(): React.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;
- }
- declare const useChannel: (eventMap: API_EventMap, deps?: any[]) => (type: string, ...args: any[]) => void;
- declare function useStoryPrepared(storyId?: StoryId): 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) => void];
- declare function useAddonState<S>(addonId: string, defaultState?: S): [S, (newStateOrMerger: S | API_StateMerger<S>, options?: Options) => void];
- declare function useArgs(): [Args, (newArgs: Args) => void, (argNames?: string[]) => void];
- declare function useGlobals(): [Args, (newGlobals: Args) => void];
- declare function useGlobalTypes(): ArgTypes;
- declare function useArgTypes(): ArgTypes;
- declare const typesX: typeof Addon_TypesEnum;
- export { API, API_EventMap, ActiveTabs, AddonStore, Combo, ManagerConsumer as Consumer, KeyboardEventLike, ManagerContext, ManagerProviderProps, ManagerProvider as Provider, State, Options as StoreOptions, addons, combineParameters, controlOrMetaKey, controlOrMetaSymbol, eventMatchesShortcut, eventToShortcut, isMacLike, isShortcutTaken, keyToSymbol, _default as merge, mockChannel, optionOrAltSymbol, shortcutMatchesShortcut, shortcutToHumanString, typesX as types, useAddonState, useArgTypes, useArgs, useChannel, useGlobalTypes, useGlobals, useParameter, useSharedState, useStoryPrepared, useStorybookApi, useStorybookState };
|