@arudovwen/form-builder-react 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1 +1,162 @@
1
- # Form Builder
1
+
2
+ # React Form Builder
3
+
4
+ The **Form Builder Package** is a reusable library designed to simplify the creation and management of dynamic forms in web applications. It provides a robust API and customizable components to streamline form-building workflows.
5
+
6
+ **This package is still in development**
7
+
8
+ ## Features
9
+
10
+ - **Drag-and-Drop Support**: Easily add and arrange form elements.
11
+ - **Customizable Components**: Modify form elements to suit your needs.
12
+ - **Dynamic Rendering**: Automatically update forms based on user input or configuration.
13
+ - **TypeScript Support**: Fully typed for better developer experience.
14
+ - **Lightweight and Fast**: Built with modern tools for optimal performance.
15
+
16
+ ## Installation
17
+
18
+ Install the package via npm:
19
+
20
+ ```bash
21
+ npm install @arudovwen/form-builder-react
22
+ ```
23
+
24
+ ## Demo
25
+
26
+ Check out the live demo of the Form Builder Package: [Form Builder Demo](https://form-builder-inky-nine.vercel.app/),
27
+ To view after saving: [Form Viewer](https://form-builder-inky-nine.vercel.app/viewer)
28
+
29
+ ## GitHub Repository
30
+
31
+ Find the source code and contribute to the project on GitHub: [Form Builder GitHub Repository](https://github.com/arudovwen/Form.Builder)
32
+
33
+ ## Usage
34
+
35
+ Here’s a quick example of how to use the Form Builder Package:
36
+
37
+ ```tsx
38
+ import React, { useState, useEffect } from "react";
39
+ import { FormBuilder, FormViewer } from "@arudovwen/form-builder-react";
40
+ import "@arudovwen/form-builder-react/dist/index.css";
41
+
42
+ function App() {
43
+ const [formData, setFormData] = useState(null);
44
+ const [loading, setLoading] = useState(true);
45
+
46
+ useEffect(() => {
47
+ try {
48
+ const storedData = localStorage.getItem("formData");
49
+ setFormData(storedData ? JSON.parse(storedData) : null);
50
+ } catch (error) {
51
+ console.error("Error parsing formData from localStorage:", error);
52
+ setFormData(null);
53
+ }
54
+
55
+ const timer = setTimeout(() => {
56
+ setLoading(false);
57
+ }, 4000);
58
+
59
+ return () => clearTimeout(timer); // Cleanup timeout on unmount
60
+ }, []);
61
+
62
+ const config = {
63
+ buttonColor: "#333",
64
+ loaderColor: "#333",
65
+ };
66
+
67
+ return (
68
+ <>
69
+ <FormBuilder
70
+ onSubmit={(form_data: any) => console.log(form_data)}
71
+ config={config}
72
+ />
73
+ <FormViewer
74
+ onSubmit={(e: any) => console.log(e)}
75
+ form_data={formData}
76
+ anwserData={answerData}
77
+ config={config}
78
+ loading={loading}
79
+ />
80
+ </>
81
+ );
82
+ }
83
+
84
+ export default App;
85
+ ```
86
+
87
+ ### Props for `FormBuilder`
88
+
89
+ | Prop | Type | Description |
90
+ |--------------|--------------------|--------------------------------------------------|
91
+ | `form_data` | `FormElement[]` | Array of form elements to render in the form. |
92
+ | `anwserData` | `any[]` | Array of user-provided answers to the form. |
93
+ | `config` | `object` | Configuration object (e.g., `buttonColor`, `loaderColor`). |
94
+ | `onSubmit` | `(data: any) => void` | Callback function triggered when the form is submitted. |
95
+ | `loading` | `boolean` | Indicates whether the form is in a loading state. |
96
+ | `isReadOnly` | `boolean` | Determines if the form is rendered in read-only mode. |
97
+
98
+ ### Form Element Types
99
+
100
+ The `FormElement` type supports the following fields:
101
+
102
+ | Field | Type | Description |
103
+ |---------------|------------|------------------------------------------|
104
+ | `id` | `string` | Unique identifier for the form element. |
105
+ | `type` | `string` | Type of the input (e.g., `text`, `email`). |
106
+ | `label` | `string` | Label for the form element. |
107
+ | `placeholder` | `string` | Placeholder text for the input. |
108
+
109
+ ## Development
110
+
111
+ To contribute or modify the package:
112
+
113
+ 1. Clone the repository:
114
+
115
+ ```bash
116
+ git clone https://github.com/your-username/form-builder.git
117
+ cd form-builder
118
+ ```
119
+
120
+ 2. Install dependencies:
121
+
122
+ ```bash
123
+ npm install
124
+ ```
125
+
126
+ 3. Build the package:
127
+
128
+ ```bash
129
+ npm run build
130
+ ```
131
+
132
+ 4. Run tests:
133
+
134
+ ```bash
135
+ npm test
136
+ ```
137
+
138
+ ## Scripts
139
+
140
+ - `npm run build`: Build the package for production.
141
+ - `npm test`: Run unit tests.
142
+ - `npm run lint`: Check code quality with ESLint.
143
+
144
+ ## License
145
+
146
+ This package is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
147
+
148
+ ## Acknowledgments
149
+
150
+ - [React](https://reactjs.org/)
151
+ - [TypeScript](https://www.typescriptlang.org/)
152
+ - [Vite](https://vitejs.dev/)
153
+ - [TailwindCSS](https://tailwindcss.com/)
154
+
155
+ ## Contributing
156
+
157
+ Contributions are welcome! Please fork the repository, create a feature branch, and submit a pull request.
158
+
159
+ ---
160
+
161
+ Happy form building!
162
+