UNPKG

2.93 kBTypeScriptView Raw
1import React, { ComponentProps } from 'react';
2import PrettyPropType from 'storybook-pretty-props';
3declare type StyleSheet = Record<string, React.CSSProperties>;
4export declare type ComponentMap = Record<string, {
5 /** The description of the component */
6 description?: string;
7 /** The display name of the component */
8 displayName: string;
9 /** The children of the component */
10 children: (Node | string)[];
11 /** The props of the component */
12 props?: Record<string, {
13 /** Whether the prop is required */
14 required?: boolean;
15 /** The description of the prop */
16 description?: string;
17 /** The type of the prop */
18 type: ComponentProps<typeof PrettyPropType>['propType'];
19 }>;
20}>;
21interface Node {
22 /** The type of node */
23 type: string;
24 /** The HTML tag to use to render the node */
25 tagName: string;
26 /** Properties of the HTML node to create */
27 properties: {
28 /** The classNames to put on the node */
29 className: string[];
30 /** The style object to put on the node */
31 style?: React.CSSProperties;
32 };
33 /** The children of the HTML node to create */
34 children: React.ReactNode;
35 /** The value of the node to create */
36 value?: string;
37}
38interface RenderRows {
39 /** A row to render in the highlighted output */
40 rows: Node[];
41 /** The stylesheet to use to style the highlighted output */
42 stylesheet: StyleSheet;
43 /** Whether to inline all of the styles in the highlighted output */
44 useInlineStyles?: boolean;
45}
46/** Render a row from the react-syntax-highlighter output */
47declare const jsxRenderer: (components: Record<string, {
48 /** The description of the component */
49 description?: string | undefined;
50 /** The display name of the component */
51 displayName: string;
52 /** The children of the component */
53 children: (string | Node)[];
54 /** The props of the component */
55 props?: Record<string, {
56 /** Whether the prop is required */
57 required?: boolean | undefined;
58 /** The description of the prop */
59 description?: string | undefined;
60 /** The type of the prop */
61 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;
62 }> | undefined;
63}>) => ({ rows, stylesheet, useInlineStyles }: RenderRows) => (string | JSX.Element | undefined)[];
64export default jsxRenderer;