@vitus-labs/rocketstories
Version:
Rocketstyle is ultra powerful and extensible styling system for building React components blazingly fast, easily and make them easily extensible and reusable.
192 lines (148 loc) • 7.69 kB
TypeScript
import type { ComponentType } from 'react';
import type { FC } from 'react';
import type { ForwardRefExoticComponent } from 'react';
import type { ListProps } from '@vitus-labs/elements';
import type { ReactNode } from 'react';
import type { RocketComponentType } from '@vitus-labs/rocketstyle';
import { StoryConfiguration as StoryConfiguration_2 } from '../../types';
export declare type Configuration = {
component: RocketType | ElementType;
attrs: Record<string, any>;
prefix?: string;
name: string;
storyOptions: Partial<{
direction: 'inline' | 'rows';
alignX: 'left' | 'center' | 'right' | 'spaceBetween';
alignY: 'top' | 'center' | 'bottom' | 'spaceBetween';
gap: number;
pseudo: boolean | null | undefined;
}>;
controls: Record<string, Control>;
decorators: Decorator[];
};
export declare type Control = ControlConfiguration;
declare const CONTROL_TYPES: readonly ["tag", "text", "number", "range", "boolean", "color", "select", "multi-select", "object", "array", "radio", "inline-radio", "check", "inline-check", "function", "component"];
declare type ControlConfiguration = {
type?: T_CONTROL_TYPES;
value?: any;
valueType?: string;
description?: string;
group?: string;
options?: ArrayLike<any>;
disable?: boolean;
};
export declare type Controls = Record<string, Control>;
export declare type ControlTypes = T_CONTROL_TYPES;
declare type Decorator = (Story: any) => ReactNode;
declare const _default: (list: any) => (params: RocketStoryConfiguration) => StoryComponent<{}>;
declare const _default_2: (params: RocketStoryConfiguration) => StoryComponent<{}>;
declare const _default_3: (render: any) => (params: RocketStoryConfiguration) => StoryComponent<{}>;
declare const _default_4: (list: any) => (params: StoryConfiguration_2) => StoryComponent<{}>;
declare const _default_5: (params: StoryConfiguration_2) => StoryComponent<{}>;
declare const _default_6: (render: any) => (params: StoryConfiguration_2) => StoryComponent<{}>;
export declare type ElementType<T extends TObj | unknown = any> = ComponentType<T> | ForwardRefExoticComponent<T>;
export declare type ExtractDimensions<C extends RocketType> = keyof C['$$rocketstyle'];
export declare type ExtractProps<TComponentOrTProps> = TComponentOrTProps extends ComponentType<infer TProps> ? TProps : TComponentOrTProps;
export declare type Init = <P extends Partial<Omit<Configuration, 'component' | 'attrs'>>>(params: P) => <T extends Configuration['component']>(component: T) => T extends RocketType ? IRocketStories<ExtractProps<T>, T['$$rocketstyle'], true> : IRocketStories<ExtractProps<T>, unknown, false>;
declare const init: Init;
export default init;
export { init }
export declare interface IRocketStories<OA extends TObj = {}, RA extends TObj | unknown = unknown, ISRS extends boolean = false> {
CONFIG: Configuration;
main: () => ISRS extends true ? ReturnType<rocketstory.RenderMain<OA>> : ReturnType<simplestory.RenderMain<OA>>;
dimension: <P extends keyof RA>(dimension: ISRS extends true ? P : never, options?: Partial<{
ignore: Array<RA[P]>;
}>) => ReturnType<rocketstory.RenderDimension<OA>> | null;
render: (params: RenderStoryOptions<OA>) => ISRS extends true ? ReturnType<rocketstory.RenderRender<OA>> : ReturnType<simplestory.RenderRender<OA>>;
list: (params: ListStoryOptions) => ISRS extends true ? ReturnType<rocketstory.RenderList<OA>> : ReturnType<simplestory.RenderList<OA>>;
init: () => {
component: Configuration['component'];
title: Configuration['name'];
decorators: Configuration['decorators'];
};
storyOptions: (options: Configuration['storyOptions']) => IRocketStories<OA, RA, ISRS>;
controls: (options: Partial<{
[I in keyof OA]: Control;
}>) => IRocketStories<OA, RA, ISRS>;
config: <P extends Partial<Omit<Configuration, 'attrs'>>>(params: P) => IRocketStories<OA, RA, ISRS>;
attrs: <P extends Partial<OA>>(params: P) => IRocketStories<OA, RA, ISRS>;
replaceComponent: <P extends Configuration['component']>(param: P) => P extends RocketType ? IRocketStories<ExtractProps<P>, P['$$rocketstyle'], true> : IRocketStories<ExtractProps<P>, unknown, false>;
decorators: <P extends Configuration['decorators']>(param: P) => IRocketStories<OA, RA, ISRS>;
}
declare type ListStoryOptions = Pick<ListProps, 'itemKey' | 'itemProps' | 'wrapComponent' | 'wrapProps' | 'valueName'> & {
data: ListProps['data'];
};
export declare type PartialControls = Record<string, Partial<Control>>;
declare type RenderDimension<P = {}> = (dimension: RocketDimensions, params: RocketStoryConfiguration & {
ignore: any;
}) => StoryComponent<P>;
declare const renderDimension: RenderDimension;
declare type RenderList<P = {}> = (render: ListStoryOptions, params: RocketStoryConfiguration) => StoryComponent<P>;
declare type RenderList_2<P = {}> = (render: ListStoryOptions, params: RocketStoryConfiguration) => StoryComponent<P>;
declare type RenderMain<P = {}> = (params: RocketStoryConfiguration) => StoryComponent<P>;
declare type RenderMain_2<P = {}> = (params: RocketStoryConfiguration) => StoryComponent<P>;
declare type RenderRender<P = {}> = (render: any, params: RocketStoryConfiguration) => StoryComponent<P>;
declare type RenderRender_2<P = {}> = (render: any, params: RocketStoryConfiguration) => StoryComponent<P>;
declare type RenderStoryOptions<P extends TObj = {}> = (props: P) => ReactNode;
declare type RocketDimensions = keyof RocketType['$$rocketstyle'];
export declare type Rocketstories = <C extends Configuration['component']>(component: C, options?: Partial<Omit<Configuration, 'component' | 'attrs'>>) => C extends RocketType ? IRocketStories<ExtractProps<C>, C['$$rocketstyle'], true> : IRocketStories<ExtractProps<C>, unknown, false>;
export declare const rocketstories: Rocketstories;
declare namespace rocketstory {
export {
RenderDimension,
RenderList,
RenderRender,
RenderMain,
renderDimension,
_default as renderList,
_default_2 as renderMain,
_default_3 as renderRender
}
}
export declare type RocketStoryConfiguration = Omit<Configuration, 'component'> & {
component: RocketType;
};
export declare type RocketType = RocketComponentType & {
VITUS_LABS__COMPONENT?: string;
getStaticDimensions: any;
getDefaultAttrs: any;
displayName?: string;
};
declare namespace simplestory {
export {
RenderList_2 as RenderList,
RenderRender_2 as RenderRender,
RenderMain_2 as RenderMain,
_default_4 as renderList,
_default_5 as renderMain,
_default_6 as renderRender
}
}
export declare type StorybookControl = {
control: {
type: string;
};
description?: string;
options?: any[];
table: {
disable?: boolean;
category?: string;
defaultValue?: {
summary: any;
};
type?: {
summary?: string;
};
};
};
export declare type StoryComponent<P = {}> = FC<P> & Partial<{
args: Record<string, unknown>;
argTypes: Record<string, unknown>;
parameters: Record<string, unknown>;
}>;
export declare type StoryConfiguration = Omit<Configuration, 'component'> & {
component: ElementType;
};
declare type T_CONTROL_TYPES = typeof CONTROL_TYPES[number];
declare type TObj = Record<string, unknown>;
export { }