json-to-shadcn
Version:
Config-driven UI renderer using ShadCN components
74 lines (70 loc) • 1.61 kB
text/typescript
import * as react_jsx_runtime from 'react/jsx-runtime';
type BaseProps = {
className?: string;
label?: string;
name?: string;
validation?: any;
wrapperClassName?: string;
labelClassName?: string;
errorClassName?: string;
[key: string]: any;
};
type JSONComponent = {
type: "input";
props: BaseProps & {
placeholder?: string;
type?: string;
};
} | {
type: "textarea";
props: BaseProps & {
placeholder?: string;
rows?: number;
};
} | {
type: "select";
props: BaseProps & {
options: {
label: string;
value: string;
}[];
};
} | {
type: "checkbox";
props: BaseProps;
} | {
type: "radio";
props: BaseProps & {
options: {
label: string;
value: string;
}[];
};
} | {
type: "date";
props: BaseProps;
} | {
type: "button";
props: BaseProps & {
text: string;
variant?: "default" | "outline" | "secondary";
};
} | {
type: "text";
props: BaseProps & {
content: string;
};
} | {
type: "card";
props: BaseProps & {
title?: string;
content: JSONComponent[];
};
};
type JsonRendererProps = {
config: JSONComponent | JSONComponent[];
};
declare const JsonFormRenderer: ({ config, onSubmit, }: JsonRendererProps & {
onSubmit?: ((data: any) => void) | undefined;
}) => react_jsx_runtime.JSX.Element;
export { type JSONComponent, JsonFormRenderer, type JsonRendererProps };