@storybook/react-native
Version:
A better way to develop React Native Components for your app
129 lines (122 loc) • 5.17 kB
TypeScript
import * as react_jsx_runtime from 'react/jsx-runtime';
import { Theme } from '@storybook/react-native-theming';
export { Theme, darkTheme, theme } from '@storybook/react-native-theming';
import * as _storybook_core_client from '@storybook/core-client';
import { StoryApi } from '@storybook/addons';
export { ArgTypes, Args, Parameters, StoryContext } from '@storybook/addons';
import { ClientApi } from '@storybook/client-api';
import { ReactElement, ComponentType, JSXElementConstructor, ComponentProps, ReactNode } from 'react';
import { Args, ComponentAnnotations, AnnotatedStoryFn, StoryAnnotations } from '@storybook/csf';
type StoryFnReactReturnType = ReactElement<unknown>;
type ReactNativeFramework = {
component: ComponentType<any>;
storyResult: StoryFnReactReturnType;
};
/**
* For the common case where a component's stories are simple components that receives args as props:
*
* ```tsx
* export default { ... } as ComponentMeta<typeof Button>;
* ```
*/
type ComponentMeta<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = Meta<ComponentProps<T>>;
/**
* For the common case where a (CSFv2) story is a simple component that receives args as props:
*
* ```tsx
* const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />
* ```
*/
type ComponentStoryFn<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = StoryFn<ComponentProps<T>>;
/**
* For the common case where a (CSFv3) story is a simple component that receives args as props:
*
* ```tsx
* const MyStory: ComponentStory<typeof Button> = {
* args: { buttonArg1: 'val' },
* }
* ```
*/
type ComponentStoryObj<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = StoryObj<ComponentProps<T>>;
/**
* For the common case where a (CSFv2) story is a simple component that receives args as props:
*
* ```tsx
* const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />
* ```
*
* NOTE: this is an alias for `ComponentStoryFn`.
* In Storybook v7, `ComponentStory` will alias `ComponentStoryObj`
*/
type ComponentStory<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = Story<ComponentProps<T>>;
/**
* Metadata to configure the stories for a component.
*
* @see [Default export](https://storybook.js.org/docs/formats/component-story-format/#default-export)
*/
type Meta<TArgs = Args> = ComponentAnnotations<ReactNativeFramework, TArgs>;
/**
* Story function that represents a CSFv2 component example.
*
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
*/
type StoryFn<TArgs = Args> = AnnotatedStoryFn<ReactNativeFramework, TArgs>;
/**
* Story function that represents a CSFv3 component example.
*
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
*/
type StoryObj<TArgs = Args> = StoryAnnotations<ReactNativeFramework, TArgs>;
/**
* Story function that represents a CSFv2 component example.
*
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
*
* NOTE that in Storybook 7.0, this type will be renamed to `StoryFn` and replaced by the current `StoryObj` type.
*
*/
type Story<TArgs = Args> = StoryFn<TArgs>;
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 Params = {
onDeviceUI?: boolean;
enableWebsockets?: boolean;
query?: string;
host?: string;
port?: number;
secured?: boolean;
initialSelection?: InitialSelection;
shouldPersistSelection?: boolean;
tabOpen?: number;
isUIHidden?: boolean;
isSplitPanelVisible?: boolean;
shouldDisableKeyboardAvoidingView?: boolean;
keyboardAvoidingViewVerticalOffset?: number;
theme: DeepPartial<Theme>;
};
declare const configure: (loadable: _storybook_core_client.Loadable, m: NodeModule) => void;
type C = ClientApi<ReactNativeFramework>;
declare const setAddon: C['setAddon'];
declare const addDecorator: C['addDecorator'];
declare const addParameters: C['addParameters'];
declare const addArgsEnhancer: C['addArgsEnhancer'];
declare const addArgTypesEnhancer: C['addArgTypesEnhancer'];
declare const clearDecorators: C['clearDecorators'];
declare const getStorybook: C['getStorybook'];
declare const raw: C['raw'];
declare const storiesOf: (kind: string, _module: NodeModule) => StoryApi<ReactNode>;
declare const getStorybookUI: (params?: Partial<Params>) => () => react_jsx_runtime.JSX.Element;
export { ComponentMeta, ComponentStory, ComponentStoryFn, ComponentStoryObj, Meta, ReactNativeFramework, Story, StoryFn, StoryFnReactReturnType, StoryObj, addArgTypesEnhancer, addArgsEnhancer, addDecorator, addParameters, clearDecorators, configure, getStorybook, getStorybookUI, raw, setAddon, storiesOf };