@storybook/api

  • Version 6.5.13
  • Published
  • 458 kB
  • 17 dependencies
  • MIT license

Install

npm i @storybook/api
yarn add @storybook/api
pnpm add @storybook/api

Overview

Core Storybook API & Context

Index

Variables

variable ActiveTabs

const ActiveTabs: { SIDEBAR: 'sidebar'; CANVAS: 'canvas'; ADDONS: 'addons' };

    Functions

    function combineParameters

    combineParameters: (...parameterSets: Parameters[]) => any;

      function Consumer

      Consumer: <P = Combo>({
      filter,
      children,
      }: ManagerConsumerProps<P>) => ReactElement;

        function isGroup

        isGroup: (item: Item) => item is Group;

          function isRoot

          isRoot: (item: Item) => item is Root;

            function isStory

            isStory: (item: Item) => item is Story;

              function merge

              merge: (a: any, b: any) => any;

                function useAddonState

                useAddonState: <S>(
                addonId: string,
                defaultState?: S
                ) => [S, (newStateOrMerger: S | StateMerger<S>, options?: Options) => void];

                  function useArgs

                  useArgs: () => [Args, (newArgs: Args) => void, (argNames?: string[]) => void];

                    function useArgTypes

                    useArgTypes: () => ArgTypes;

                      function useChannel

                      useChannel: (
                      eventMap: EventMap,
                      deps?: any[]
                      ) => (type: string, ...args: any[]) => void;

                        function useGlobals

                        useGlobals: () => [Args, (newGlobals: Args) => void];

                          function useGlobalTypes

                          useGlobalTypes: () => ArgTypes;

                            function useParameter

                            useParameter: <S>(parameterKey: string, defaultValue?: S) => S;

                              function useSharedState

                              useSharedState: <S>(
                              stateId: string,
                              defaultState?: S
                              ) => [S, (newStateOrMerger: S | StateMerger<S>, options?: Options) => void];

                                function useStorybookApi

                                useStorybookApi: () => API;

                                  function useStorybookState

                                  useStorybookState: () => State;

                                    function useStoryPrepared

                                    useStoryPrepared: (storyId?: StoryId) => boolean;

                                      Classes

                                      class Provider

                                      class ManagerProvider extends Component<ManagerProviderProps, State> {}

                                        constructor

                                        constructor(props: any);

                                          property api

                                          api: API;

                                            property displayName

                                            static displayName: string;

                                              property initModules

                                              initModules: () => void;

                                                property modules

                                                modules: Module[];

                                                  method getDerivedStateFromProps

                                                  static getDerivedStateFromProps: (
                                                  props: ManagerProviderProps,
                                                  state: State
                                                  ) => {
                                                  location: Partial<Location>;
                                                  path: string;
                                                  refId: string;
                                                  viewMode: string;
                                                  storyId: string;
                                                  layout: layout.Layout;
                                                  ui: layout.UI;
                                                  selectedPanel: string;
                                                  theme: any;
                                                  storiesHash: StoriesHash;
                                                  storiesConfigured: boolean;
                                                  storiesFailed?: Error;
                                                  refs: Record<string, ComposedRef>;
                                                  notifications: notifications.Notification[];
                                                  versions: version.Versions & version.UnknownEntries;
                                                  lastVersionCheck: number;
                                                  dismissedVersionNotification: string;
                                                  customQueryParams: url.QueryParams;
                                                  shortcuts: shortcuts.Shortcuts;
                                                  releaseNotesViewed: string[];
                                                  settings: settings.Settings;
                                                  globals?: any;
                                                  globalTypes?: any;
                                                  navigate: (to: string | number, { plain, ...options }?: any) => void;
                                                  singleStory?: boolean;
                                                  };

                                                    method render

                                                    render: () => JSX.Element;

                                                      method shouldComponentUpdate

                                                      shouldComponentUpdate: (
                                                      nextProps: ManagerProviderProps,
                                                      nextState: State
                                                      ) => boolean;

                                                        Interfaces

                                                        interface Args

                                                        interface Args {}

                                                          index signature

                                                          [key: string]: any;

                                                            interface ArgType

                                                            interface ArgType {}

                                                              property defaultValue

                                                              defaultValue?: any;

                                                                property description

                                                                description?: string;

                                                                  property if

                                                                  if?: Conditional;

                                                                    property name

                                                                    name?: string;

                                                                      index signature

                                                                      [key: string]: any;

                                                                        interface ArgTypes

                                                                        interface ArgTypes {}

                                                                          index signature

                                                                          [key: string]: ArgType;

                                                                            interface Combo

                                                                            interface Combo {}

                                                                              property api

                                                                              api: API;

                                                                                property state

                                                                                state: State;

                                                                                  interface ComposedRef

                                                                                  interface ComposedRef {}

                                                                                    property error

                                                                                    error?: any;

                                                                                      property expanded

                                                                                      expanded?: boolean;

                                                                                        property id

                                                                                        id: string;

                                                                                          property loginUrl

                                                                                          loginUrl?: string;

                                                                                            property ready

                                                                                            ready?: boolean;

                                                                                              property stories

                                                                                              stories: StoriesHash;

                                                                                                property title

                                                                                                title?: string;

                                                                                                  property type

                                                                                                  type?: 'auto-inject' | 'unknown' | 'lazy' | 'server-checked';

                                                                                                    property url

                                                                                                    url: string;

                                                                                                      property version

                                                                                                      version?: string;

                                                                                                        property versions

                                                                                                        versions?: Versions;

                                                                                                          interface EventMap

                                                                                                          interface EventMap {}

                                                                                                            index signature

                                                                                                            [eventId: string]: Listener;

                                                                                                              interface Group

                                                                                                              interface Group {}

                                                                                                                property children

                                                                                                                children: StoryId[];

                                                                                                                  property depth

                                                                                                                  depth: number;

                                                                                                                    property id

                                                                                                                    id: StoryId;

                                                                                                                      property isComponent

                                                                                                                      isComponent: boolean;

                                                                                                                        property isLeaf

                                                                                                                        isLeaf: false;

                                                                                                                          property isRoot

                                                                                                                          isRoot: false;

                                                                                                                            property name

                                                                                                                            name: string;

                                                                                                                              property parameters

                                                                                                                              parameters?: {
                                                                                                                              docsOnly?: boolean;
                                                                                                                              viewMode?: ViewMode;
                                                                                                                              };

                                                                                                                                property parent

                                                                                                                                parent?: StoryId;

                                                                                                                                  property refId

                                                                                                                                  refId?: string;

                                                                                                                                    property renderLabel

                                                                                                                                    renderLabel?: (item: Group) => React.ReactNode;

                                                                                                                                      property type

                                                                                                                                      type: 'group' | 'component';

                                                                                                                                        interface Parameters

                                                                                                                                        interface Parameters {}

                                                                                                                                          index signature

                                                                                                                                          [key: string]: any;

                                                                                                                                            interface Root

                                                                                                                                            interface Root {}

                                                                                                                                              property children

                                                                                                                                              children: StoryId[];

                                                                                                                                                property depth

                                                                                                                                                depth: 0;

                                                                                                                                                  property id

                                                                                                                                                  id: StoryId;

                                                                                                                                                    property isComponent

                                                                                                                                                    isComponent: false;

                                                                                                                                                      property isLeaf

                                                                                                                                                      isLeaf: false;

                                                                                                                                                        property isRoot

                                                                                                                                                        isRoot: true;

                                                                                                                                                          property name

                                                                                                                                                          name: string;

                                                                                                                                                            property refId

                                                                                                                                                            refId?: string;

                                                                                                                                                              property renderLabel

                                                                                                                                                              renderLabel?: (item: Root) => React.ReactNode;

                                                                                                                                                                property startCollapsed

                                                                                                                                                                startCollapsed?: boolean;

                                                                                                                                                                  property type

                                                                                                                                                                  type: 'root';

                                                                                                                                                                    interface StoreOptions

                                                                                                                                                                    interface Options {}

                                                                                                                                                                      property persistence

                                                                                                                                                                      persistence: 'none' | 'session' | string;

                                                                                                                                                                        interface StoriesHash

                                                                                                                                                                        interface StoriesHash {}

                                                                                                                                                                          index signature

                                                                                                                                                                          [id: string]: Root | Group | Story;

                                                                                                                                                                            interface Story

                                                                                                                                                                            interface Story {}

                                                                                                                                                                              property args

                                                                                                                                                                              args?: Args;

                                                                                                                                                                                property argTypes

                                                                                                                                                                                argTypes?: ArgTypes;

                                                                                                                                                                                  property children

                                                                                                                                                                                  children?: StoryId[];

                                                                                                                                                                                    property depth

                                                                                                                                                                                    depth: number;

                                                                                                                                                                                      property id

                                                                                                                                                                                      id: StoryId;

                                                                                                                                                                                        property initialArgs

                                                                                                                                                                                        initialArgs?: Args;

                                                                                                                                                                                          property isComponent

                                                                                                                                                                                          isComponent: boolean;

                                                                                                                                                                                            property isLeaf

                                                                                                                                                                                            isLeaf: true;

                                                                                                                                                                                              property isRoot

                                                                                                                                                                                              isRoot: false;

                                                                                                                                                                                                property kind

                                                                                                                                                                                                kind: StoryKind;

                                                                                                                                                                                                  property name

                                                                                                                                                                                                  name: string;

                                                                                                                                                                                                    property parameters

                                                                                                                                                                                                    parameters?: {
                                                                                                                                                                                                    fileName: string;
                                                                                                                                                                                                    options: {
                                                                                                                                                                                                    [optionName: string]: any;
                                                                                                                                                                                                    };
                                                                                                                                                                                                    docsOnly?: boolean;
                                                                                                                                                                                                    viewMode?: ViewMode;
                                                                                                                                                                                                    [parameterName: string]: any;
                                                                                                                                                                                                    };

                                                                                                                                                                                                      property parent

                                                                                                                                                                                                      parent: StoryId;

                                                                                                                                                                                                        property prepared

                                                                                                                                                                                                        prepared: boolean;

                                                                                                                                                                                                          property refId

                                                                                                                                                                                                          refId?: string;

                                                                                                                                                                                                            property renderLabel

                                                                                                                                                                                                            renderLabel?: (item: Story) => React.ReactNode;

                                                                                                                                                                                                              property type

                                                                                                                                                                                                              type: 'story' | 'docs';

                                                                                                                                                                                                                Type Aliases

                                                                                                                                                                                                                type API

                                                                                                                                                                                                                type API = addons.SubAPI &
                                                                                                                                                                                                                channel.SubAPI &
                                                                                                                                                                                                                provider.SubAPI &
                                                                                                                                                                                                                stories.SubAPI &
                                                                                                                                                                                                                refs.SubAPI &
                                                                                                                                                                                                                globals.SubAPI &
                                                                                                                                                                                                                layout.SubAPI &
                                                                                                                                                                                                                notifications.SubAPI &
                                                                                                                                                                                                                shortcuts.SubAPI &
                                                                                                                                                                                                                releaseNotes.SubAPI &
                                                                                                                                                                                                                settings.SubAPI &
                                                                                                                                                                                                                version.SubAPI &
                                                                                                                                                                                                                url.SubAPI &
                                                                                                                                                                                                                Other;

                                                                                                                                                                                                                  type ManagerProviderProps

                                                                                                                                                                                                                  type ManagerProviderProps = RouterData &
                                                                                                                                                                                                                  ProviderData & {
                                                                                                                                                                                                                  docsMode: boolean;
                                                                                                                                                                                                                  children: ReactNode | ((props: Combo) => ReactNode);
                                                                                                                                                                                                                  };

                                                                                                                                                                                                                    type ModuleArgs

                                                                                                                                                                                                                    type ModuleArgs = RouterData &
                                                                                                                                                                                                                    ProviderData & {
                                                                                                                                                                                                                    mode?: 'production' | 'development';
                                                                                                                                                                                                                    state: State;
                                                                                                                                                                                                                    fullAPI: API;
                                                                                                                                                                                                                    store: Store;
                                                                                                                                                                                                                    };

                                                                                                                                                                                                                      type ModuleFn

                                                                                                                                                                                                                      type ModuleFn = (m: ModuleArgs) => Module;

                                                                                                                                                                                                                        type Refs

                                                                                                                                                                                                                        type Refs = Record<string, ComposedRef>;

                                                                                                                                                                                                                          type State

                                                                                                                                                                                                                          type State = layout.SubState &
                                                                                                                                                                                                                          stories.SubState &
                                                                                                                                                                                                                          refs.SubState &
                                                                                                                                                                                                                          notifications.SubState &
                                                                                                                                                                                                                          version.SubState &
                                                                                                                                                                                                                          url.SubState &
                                                                                                                                                                                                                          shortcuts.SubState &
                                                                                                                                                                                                                          releaseNotes.SubState &
                                                                                                                                                                                                                          settings.SubState &
                                                                                                                                                                                                                          globals.SubState &
                                                                                                                                                                                                                          RouterData &
                                                                                                                                                                                                                          Other;

                                                                                                                                                                                                                            type StoryId

                                                                                                                                                                                                                            type StoryId = string;

                                                                                                                                                                                                                              type StoryKind

                                                                                                                                                                                                                              type StoryKind = string;

                                                                                                                                                                                                                                Package Files (5)

                                                                                                                                                                                                                                Dependencies (17)

                                                                                                                                                                                                                                Dev Dependencies (6)

                                                                                                                                                                                                                                Peer Dependencies (2)

                                                                                                                                                                                                                                Badge

                                                                                                                                                                                                                                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@storybook/api.

                                                                                                                                                                                                                                • Markdown
                                                                                                                                                                                                                                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@storybook/api)
                                                                                                                                                                                                                                • HTML
                                                                                                                                                                                                                                  <a href="https://www.jsdocs.io/package/@storybook/api"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>