@arudovwen/form-builder-react 1.0.5 → 1.0.6

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,163 @@
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
+ ## Demo
24
+
25
+ Check out the live demo of the Form Builder Package: [Form Builder Demo](https://form-builder-inky-nine.vercel.app/),
26
+ To view after saving : [Form Viewer ](https://form-builder-inky-nine.vercel.app/viewer)
27
+
28
+ ## Usage
29
+
30
+ Here’s a quick example of how to use the Form Builder Package:
31
+
32
+ ```tsx
33
+ import React, { useState, useEffect } from "react";
34
+ import { FormBuilder, FormViewer } from "@arudovwen/form-builder-react";
35
+ import "@arudovwen/form-builder-react/dist/index.css";
36
+
37
+
38
+ function App() {
39
+ const [formData, setFormData] = useState(null);
40
+ const [loading, setLoading] = useState(true);
41
+
42
+ useEffect(() => {
43
+ try {
44
+ const storedData = localStorage.getItem("formData");
45
+ setFormData(storedData ? JSON.parse(storedData) : null);
46
+ } catch (error) {
47
+ console.error("Error parsing formData from localStorage:", error);
48
+ setFormData(null);
49
+ }
50
+
51
+ const timer = setTimeout(() => {
52
+ setLoading(false);
53
+ }, 4000);
54
+
55
+ return () => clearTimeout(timer); // Cleanup timeout on unmount
56
+ }, []);
57
+
58
+ const config = {
59
+ buttonColor: "#333",
60
+ loaderColor: "#333",
61
+ };
62
+
63
+ return (
64
+
65
+ <>
66
+ <FormBuilder
67
+ onSubmit={(form_data: any) => console.log(form_data)}
68
+ config={config}
69
+ />
70
+
71
+
72
+ <FormViewer
73
+ onSubmit={(e: any) => console.log(e)}
74
+ form_data={formData}
75
+ anwserData={answerData}
76
+ config={config}
77
+ loading={loading}
78
+ />
79
+ </>
80
+
81
+ );
82
+ }
83
+
84
+ export default App;
85
+
86
+ ```
87
+
88
+ ### Props for `FormBuilder`
89
+
90
+ | Prop | Type | Description |
91
+ |--------------|--------------------|--------------------------------------------------|
92
+ | `form_data` | `FormElement[]` | Array of form elements to render in the form. |
93
+ | `anwserData` | `any[]` | Array of user-provided answers to the form. |
94
+ | `config` | `object` | Configuration object (e.g., `buttonColor`, `loaderColor`). |
95
+ | `onSubmit` | `(data: any) => void` | Callback function triggered when the form is submitted. |
96
+ | `loading` | `boolean` | Indicates whether the form is in a loading state. |
97
+ | `isReadOnly` | `boolean` | Determines if the form is rendered in read-only mode. |
98
+
99
+ ### Form Element Types
100
+
101
+ The `FormElement` type supports the following fields:
102
+
103
+ | Field | Type | Description |
104
+ |---------------|------------|------------------------------------------|
105
+ | `id` | `string` | Unique identifier for the form element. |
106
+ | `type` | `string` | Type of the input (e.g., `text`, `email`). |
107
+ | `label` | `string` | Label for the form element. |
108
+ | `placeholder` | `string` | Placeholder text for the input. |
109
+
110
+ ## Development
111
+
112
+ To contribute or modify the package:
113
+
114
+ 1. Clone the repository:
115
+
116
+ ```bash
117
+ git clone https://github.com/your-username/form-builder.git
118
+ cd form-builder
119
+ ```
120
+
121
+ 2. Install dependencies:
122
+
123
+ ```bash
124
+ npm install
125
+ ```
126
+
127
+ 3. Build the package:
128
+
129
+ ```bash
130
+ npm run build
131
+ ```
132
+
133
+ 4. Run tests:
134
+
135
+ ```bash
136
+ npm test
137
+ ```
138
+
139
+ ## Scripts
140
+
141
+ - `npm run build`: Build the package for production.
142
+ - `npm test`: Run unit tests.
143
+ - `npm run lint`: Check code quality with ESLint.
144
+
145
+ ## License
146
+
147
+ This package is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
148
+
149
+ ## Acknowledgments
150
+
151
+ - [React](https://reactjs.org/)
152
+ - [TypeScript](https://www.typescriptlang.org/)
153
+ - [Vite](https://vitejs.dev/)
154
+ - [TailwindCSS](https://tailwindcss.com/)
155
+
156
+ ## Contributing
157
+
158
+ Contributions are welcome! Please fork the repository, create a feature branch, and submit a pull request.
159
+
160
+ ---
161
+
162
+ Happy form building!
163
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arudovwen/form-builder-react",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A React-based form builder component library.",
5
5
  "type": "module",
6
6
  "main": "./dist/form-builder.umd.js",
package/types/App.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import "./App.css";
2
- import "./assets/scss/style.scss";
3
- declare function App(): import("react/jsx-runtime").JSX.Element;
4
- export default App;
1
+ import "./assets/scss/style.scss";
2
+ declare function App(): import("react/jsx-runtime").JSX.Element;
3
+ export default App;