UNPKG

storybook-addon-jsx

Version:
65 lines (64 loc) 2.93 kB
import React, { ComponentProps } from 'react'; import PrettyPropType from 'storybook-pretty-props'; declare type StyleSheet = Record<string, React.CSSProperties>; export declare type ComponentMap = Record<string, { /** The description of the component */ description?: string; /** The display name of the component */ displayName: string; /** The children of the component */ children: (Node | string)[]; /** The props of the component */ props?: Record<string, { /** Whether the prop is required */ required?: boolean; /** The description of the prop */ description?: string; /** The type of the prop */ type: ComponentProps<typeof PrettyPropType>['propType']; }>; }>; interface Node { /** The type of node */ type: string; /** The HTML tag to use to render the node */ tagName: string; /** Properties of the HTML node to create */ properties: { /** The classNames to put on the node */ className: string[]; /** The style object to put on the node */ style?: React.CSSProperties; }; /** The children of the HTML node to create */ children: React.ReactNode; /** The value of the node to create */ value?: string; } interface RenderRows { /** A row to render in the highlighted output */ rows: Node[]; /** The stylesheet to use to style the highlighted output */ stylesheet: StyleSheet; /** Whether to inline all of the styles in the highlighted output */ useInlineStyles?: boolean; } /** Render a row from the react-syntax-highlighter output */ declare const jsxRenderer: (components: Record<string, { /** The description of the component */ description?: string | undefined; /** The display name of the component */ displayName: string; /** The children of the component */ children: (string | Node)[]; /** The props of the component */ props?: Record<string, { /** Whether the prop is required */ required?: boolean | undefined; /** The description of the prop */ description?: string | undefined; /** The type of the prop */ type: import("storybook-pretty-props/dist/types/types").PropTypeBase | import("storybook-pretty-props/dist/types/types").LiteralType | import("storybook-pretty-props/dist/types/types").EnumType | import("storybook-pretty-props/dist/types/types").InstanceofType | import("storybook-pretty-props/dist/types/types").SignatureType | import("storybook-pretty-props/dist/types/types").ShapeType | import("storybook-pretty-props/dist/types/types").UnionType | import("storybook-pretty-props/dist/types/types").ArrayOfType | import("storybook-pretty-props/dist/types/types").ObjectOfType | undefined; }> | undefined; }>) => ({ rows, stylesheet, useInlineStyles }: RenderRows) => (string | JSX.Element | undefined)[]; export default jsxRenderer;