UNPKG

@storybook/react-native

Version:

A better way to develop React Native Components for your app

127 lines (122 loc) 4.85 kB
import * as storybook_internal_types from 'storybook/internal/types'; import { StoryIndex, PreparedStory, NormalizedStoriesSpecifier, Addon_StorySortParameterV7, StorybookConfig as StorybookConfig$1 } from 'storybook/internal/types'; import { ReactRenderer } from '@storybook/react'; export { ArgTypes, Args, Decorator, Loader, Meta, Parameters, Preview, StoryFn, StoryObj } from '@storybook/react'; import * as react_jsx_runtime from 'react/jsx-runtime'; import { StoryContext } from 'storybook/internal/csf'; import { Theme } from '@storybook/react-native-theming'; export { Theme, darkTheme, theme } from '@storybook/react-native-theming'; import { SBUI } from '@storybook/react-native-ui-common'; import { Channel } from 'storybook/internal/channels'; import { PreviewWithSelection } from 'storybook/internal/preview-api'; interface Storage { getItem: (key: string) => Promise<string | null>; setItem: (key: string, value: string) => Promise<void>; } type StoryKind = string; type StoryName = string; type InitialSelection = `${StoryKind}--${StoryName}` | { /** * Kind is the default export name or the storiesOf("name") name */ kind: StoryKind; /** * Name is the named export or the .add("name") name */ name: StoryName; }; type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]>; } : T; type ThemePartial = DeepPartial<Theme>; type Params = { onDeviceUI?: boolean; /** * Set as false to disable the wrapper around the story view. * NOTE We may remove this in the future for a better solution. * default: true */ hasStoryWrapper?: boolean; /** * Enable websockets for the storybook server to remotely control the storybook * default: false */ enableWebsockets?: boolean; query?: string; /** The host for the websocket server. default: localhost */ host?: string; /** The port for the websocket server. default: 7007 */ port?: number; secured?: boolean; /** The initial story */ initialSelection?: InitialSelection; /** Whether to persist story selection. default: true */ shouldPersistSelection?: boolean; theme: ThemePartial; /** Used for persisting story selection. required. */ storage?: Storage; /** The custom UI component to use instead of the default UI */ CustomUIComponent?: SBUI; }; declare class View { _storyIndex: StoryIndex; _setStory: (story: StoryContext<ReactRenderer>) => void; _forceRerender: () => void; _ready: boolean; _preview: PreviewWithSelection<ReactRenderer>; _asyncStorageStoryId: string; _webUrl: string; _storage: Storage; _channel: Channel; _idToPrepared: Record<string, PreparedStory<ReactRenderer>>; constructor(preview: PreviewWithSelection<ReactRenderer>, channel: Channel); _storyIdExists: (storyId: string) => boolean; _getInitialStory: ({ initialSelection, shouldPersistSelection, }?: Partial<Params>) => Promise<{ storySpecifier: string; viewMode: string; }>; _getServerChannel: (params?: Partial<Params>) => Channel; createPreparedStoryMapping: () => Promise<void>; getStorybookUI: (params?: Partial<Params>) => () => react_jsx_runtime.JSX.Element; } /** Configuration options that are needed at startup, only serialisable values are possible */ interface ReactNativeOptions { /** * Note that this is for future and play functions are not yet fully supported on native. */ playFn?: boolean; } declare function prepareStories({ storyEntries, options, storySort, }: { storyEntries: (NormalizedStoriesSpecifier & { req: any; })[]; options?: ReactNativeOptions; storySort?: Addon_StorySortParameterV7; }): { index: { v: number; entries: Record<string, storybook_internal_types.IndexEntry>; }; importMap: Record<string, any>; }; declare const getProjectAnnotations: (view: View, annotations: any[]) => () => Promise<storybook_internal_types.NormalizedProjectAnnotations<ReactRenderer>>; declare function start({ annotations, storyEntries, options, }: { storyEntries: (NormalizedStoriesSpecifier & { req: any; })[]; annotations: any[]; options?: ReactNativeOptions; }): View; declare function updateView(viewInstance: View, annotations: any[], normalizedStories: (NormalizedStoriesSpecifier & { req: any; })[], options?: ReactNativeOptions): void; interface StorybookConfig { stories: StorybookConfig$1['stories']; addons: Array<string | { name: string; options?: Record<string, any>; }>; reactNative?: ReactNativeOptions; framework?: '@storybook/react-native'; } export { InitialSelection, Params, Storage, StorybookConfig, ThemePartial, View, getProjectAnnotations, prepareStories, start, updateView };