@enerjisaformlibrary/formbuilder-react 1.0.0 → 1.0.2
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 +66 -48
- package/index.cjs +26186 -3990
- package/index.cjs.map +1 -0
- package/index.js +25873 -3663
- package/index.js.map +1 -0
- package/package.json +10 -18
- package/styles.css +1 -0
- package/types/lib/FormBuilder.d.ts +14 -0
- package/types/lib/FormBuilder.d.ts.map +1 -0
- package/types/lib/index.d.ts +2 -0
- package/types/lib/index.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @enerjisaformlibrary/formbuilder-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Standalone drag-and-drop form builder React component with CSS included. No additional dependencies required!
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,75 +8,93 @@ Dynamic drag-and-drop form builder React components with 20+ field types, condit
|
|
|
8
8
|
npm install @enerjisaformlibrary/formbuilder-react
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
## Peer Dependencies
|
|
12
|
-
|
|
13
|
-
This package requires the following peer dependencies:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install react react-dom @dnd-kit/core @dnd-kit/sortable @dnd-kit/utilities zustand zod lucide-react nanoid framer-motion class-variance-authority clsx tailwind-merge date-fns qrcode.react
|
|
17
|
-
```
|
|
18
|
-
|
|
19
11
|
## Usage
|
|
20
12
|
|
|
21
13
|
```tsx
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
PropertiesPanel,
|
|
25
|
-
ComponentLibrary,
|
|
26
|
-
Toolbar,
|
|
27
|
-
useFormStore,
|
|
28
|
-
FormSchema
|
|
29
|
-
} from '@enerjisaformlibrary/formbuilder-react';
|
|
14
|
+
import { FormBuilder, useFormStore } from '@enerjisaformlibrary/formbuilder-react';
|
|
15
|
+
import '@enerjisaformlibrary/formbuilder-react/styles.css';
|
|
30
16
|
|
|
31
|
-
function
|
|
32
|
-
const
|
|
17
|
+
function App() {
|
|
18
|
+
const handleChange = (form) => {
|
|
19
|
+
console.log('Form changed:', form);
|
|
20
|
+
};
|
|
33
21
|
|
|
34
|
-
const handleSave = () => {
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
const handleSave = (form) => {
|
|
23
|
+
// Save form JSON to your database
|
|
24
|
+
console.log('Save form:', JSON.stringify(form));
|
|
37
25
|
};
|
|
38
26
|
|
|
39
27
|
return (
|
|
40
|
-
<div
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
<div style={{ height: '100vh' }}>
|
|
29
|
+
<FormBuilder
|
|
30
|
+
onChange={handleChange}
|
|
31
|
+
onSave={handleSave}
|
|
32
|
+
theme="light"
|
|
33
|
+
/>
|
|
44
34
|
</div>
|
|
45
35
|
);
|
|
46
36
|
}
|
|
47
37
|
```
|
|
48
38
|
|
|
39
|
+
## Props
|
|
40
|
+
|
|
41
|
+
| Prop | Type | Default | Description |
|
|
42
|
+
|------|------|---------|-------------|
|
|
43
|
+
| `initialForm` | `FormSchema` | - | Initial form data to load |
|
|
44
|
+
| `onChange` | `(form: FormSchema) => void` | - | Called when form changes |
|
|
45
|
+
| `onSave` | `(form: FormSchema) => void` | - | Called when save is triggered |
|
|
46
|
+
| `theme` | `'light' \| 'dark'` | `'light'` | Color theme |
|
|
47
|
+
| `showToolbar` | `boolean` | `true` | Show/hide toolbar |
|
|
48
|
+
| `showComponentLibrary` | `boolean` | `true` | Show/hide component library |
|
|
49
|
+
| `showPropertiesPanel` | `boolean` | `true` | Show/hide properties panel |
|
|
50
|
+
| `className` | `string` | - | Additional CSS class |
|
|
51
|
+
|
|
49
52
|
## Features
|
|
50
53
|
|
|
51
54
|
- 20+ field types (input, textarea, dropdown, checkbox, radio, date, file, signature, rating, etc.)
|
|
52
|
-
- Drag-and-drop interface
|
|
55
|
+
- Drag-and-drop interface
|
|
53
56
|
- Multi-step wizard forms
|
|
54
57
|
- Conditional logic (show/hide/enable/disable fields)
|
|
55
58
|
- Custom styling per field
|
|
56
59
|
- Form versioning
|
|
57
60
|
- JSON export/import
|
|
58
61
|
- Responsive grid system (12-column)
|
|
59
|
-
-
|
|
60
|
-
|
|
61
|
-
##
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
62
|
+
- Dark/Light theme support
|
|
63
|
+
|
|
64
|
+
## Individual Components
|
|
65
|
+
|
|
66
|
+
You can also import individual components:
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import {
|
|
70
|
+
FormCanvas,
|
|
71
|
+
PropertiesPanel,
|
|
72
|
+
ComponentLibrary,
|
|
73
|
+
Toolbar,
|
|
74
|
+
useFormStore
|
|
75
|
+
} from '@enerjisaformlibrary/formbuilder-react';
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Getting Form JSON
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { useFormStore } from '@enerjisaformlibrary/formbuilder-react';
|
|
82
|
+
|
|
83
|
+
function SaveButton() {
|
|
84
|
+
const form = useFormStore((state) => state.form);
|
|
85
|
+
|
|
86
|
+
const handleSave = () => {
|
|
87
|
+
const formJson = JSON.stringify(form, null, 2);
|
|
88
|
+
// Send to your API
|
|
89
|
+
fetch('/api/forms', {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
body: formJson
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
return <button onClick={handleSave}>Save Form</button>;
|
|
96
|
+
}
|
|
97
|
+
```
|
|
80
98
|
|
|
81
99
|
## License
|
|
82
100
|
|