@enerjisaformlibrary/formbuilder-react 1.0.1 → 1.0.3

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,6 +1,6 @@
1
1
  # @enerjisaformlibrary/formbuilder-react
2
2
 
3
- Dynamic drag-and-drop form builder React components with 20+ field types, conditional logic, multi-step forms, and custom styling.
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
- FormCanvas,
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 FormBuilder() {
32
- const { form, setForm } = useFormStore();
17
+ function App() {
18
+ const handleChange = (form) => {
19
+ console.log('Form changed:', form);
20
+ };
33
21
 
34
- const handleSave = () => {
35
- const formJson = JSON.stringify(form);
36
- // Save to your database
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 className="flex h-screen">
41
- <ComponentLibrary />
42
- <FormCanvas />
43
- <PropertiesPanel />
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 with dnd-kit
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
- - Unified sizing system (compact, normal, comfortable)
60
-
61
- ## Exports
62
-
63
- ### Components
64
- - `FormCanvas` - Main canvas for form editing
65
- - `CanvasField` - Individual field renderer
66
- - `PropertiesPanel` - Field properties editor
67
- - `ComponentLibrary` - Draggable component palette
68
- - `Toolbar` - Save, preview, settings toolbar
69
- - `JsonViewerModal` - JSON export viewer
70
-
71
- ### Store
72
- - `useFormStore` - Zustand store for form state
73
-
74
- ### Types
75
- - `FormSchema` - Form schema type
76
- - `FormField` - Field type
77
- - `FormRow` - Row type
78
- - `FormColumn` - Column type
79
- - All validation and conditional logic types
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