This React App generates form by JSON config.
export enum ItemType {
NUMBER = 'number', // number input
TEXT = 'text', // text input
TEXTAREA = 'textarea', // textarea
CHECKBOX = 'checkbox', // checkbox
DATE = 'date', // built in datepicker
RADIO = 'radio', // radio buttons
BUTTON = 'button', // button
}
export interface IItem {
label: string;
type: ItemType;
options?: Array<{ label: string; value: any }>;
}
export interface IControl {
text: string;
variant: 'contained' | 'outlined';
}
export interface IJsonForm {
items: IItem[]; // inputs
controls: IControl[]; // buttons
title: string; // title
}
src/components
- UI Components (Button, Checkbox, Datepicker, etc.)src/pages
- Content pages (JsonEditor, Form)src/utils
- Helper functionssrc/test
- Tests
In the project directory, you can run:
Install all dependencies
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
Launches the test runner in the interactive watch mode.\
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
{
"items": [
{
"label": "Text",
"type": "text"
},
{
"label": "Number",
"type": "number"
},
{
"label": "Checkbox",
"type": "checkbox"
},
{
"label": "Textarea",
"type": "textarea"
},
{
"label": "Date",
"type": "date"
},
{
"label": "Radio",
"type": "radio",
"options": [
{
"label": "One",
"value": 1
},
{
"label": "Two",
"value": 2
},
{
"label": "Three",
"value": 3
}
]
}
],
"controls": [
{
"text": "Cancel",
"variant": "outlined"
},
{
"text": "Ok"
}
],
"title": "Title"
}