@enerjisaformlibrary/formbuilder-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 +0 -48
- package/index.cjs +41 -5
- package/index.cjs.map +1 -1
- package/index.js +41 -5
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/types/lib/FormBuilder.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -36,19 +36,6 @@ function App() {
|
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
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
|
-
|
|
52
39
|
## Features
|
|
53
40
|
|
|
54
41
|
- 20+ field types (input, textarea, dropdown, checkbox, radio, date, file, signature, rating, etc.)
|
|
@@ -61,41 +48,6 @@ function App() {
|
|
|
61
48
|
- Responsive grid system (12-column)
|
|
62
49
|
- Dark/Light theme support
|
|
63
50
|
|
|
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
|
-
```
|
|
98
|
-
|
|
99
51
|
## License
|
|
100
52
|
|
|
101
53
|
MIT
|
package/index.cjs
CHANGED
|
@@ -28550,24 +28550,54 @@ function FormBuilder({ initialForm, onSave, onChange, className = '', theme = 'l
|
|
|
28550
28550
|
}));
|
|
28551
28551
|
const handleDragStart = (event) => {
|
|
28552
28552
|
const { active } = event;
|
|
28553
|
+
console.log('[FormBuilder] Drag started:', {
|
|
28554
|
+
id: active.id,
|
|
28555
|
+
data: active.data.current
|
|
28556
|
+
});
|
|
28553
28557
|
setActiveId(active.id);
|
|
28554
28558
|
if (active.data.current?.type) {
|
|
28555
28559
|
setActiveType(active.data.current.type);
|
|
28556
28560
|
}
|
|
28557
28561
|
};
|
|
28558
|
-
const handleDragOver = (
|
|
28562
|
+
const handleDragOver = (event) => {
|
|
28563
|
+
console.log('[FormBuilder] Drag over:', {
|
|
28564
|
+
activeId: event.active.id,
|
|
28565
|
+
overId: event.over?.id,
|
|
28566
|
+
overData: event.over?.data.current
|
|
28567
|
+
});
|
|
28559
28568
|
};
|
|
28560
28569
|
const handleDragEnd = (event) => {
|
|
28561
28570
|
const { active, over } = event;
|
|
28571
|
+
console.log('[FormBuilder] Drag ended:', {
|
|
28572
|
+
activeId: active.id,
|
|
28573
|
+
activeData: active.data.current,
|
|
28574
|
+
overId: over?.id,
|
|
28575
|
+
overData: over?.data.current
|
|
28576
|
+
});
|
|
28562
28577
|
setActiveId(null);
|
|
28563
28578
|
setActiveType(null);
|
|
28564
|
-
if (!over)
|
|
28579
|
+
if (!over) {
|
|
28580
|
+
console.log('[FormBuilder] No drop target (over is null)');
|
|
28565
28581
|
return;
|
|
28582
|
+
}
|
|
28566
28583
|
const activeData = active.data.current;
|
|
28567
28584
|
const overData = over.data.current;
|
|
28568
|
-
|
|
28569
|
-
|
|
28570
|
-
|
|
28585
|
+
// Check for library item (using actual data structure from ComponentLibrary)
|
|
28586
|
+
const isLibraryItem = activeData?.isLibraryItem;
|
|
28587
|
+
const fieldType = activeData?.componentType || activeData?.type;
|
|
28588
|
+
const isCanvas = overData?.type === 'canvas';
|
|
28589
|
+
const isColumn = overData?.type === 'column' || overData?.columnId;
|
|
28590
|
+
console.log('[FormBuilder] Checking conditions:', {
|
|
28591
|
+
isLibraryItem,
|
|
28592
|
+
fieldType,
|
|
28593
|
+
isCanvas,
|
|
28594
|
+
isColumn,
|
|
28595
|
+
activeData,
|
|
28596
|
+
overData
|
|
28597
|
+
});
|
|
28598
|
+
if (isLibraryItem && fieldType) {
|
|
28599
|
+
if (isCanvas || isColumn) {
|
|
28600
|
+
console.log('[FormBuilder] Adding field:', fieldType);
|
|
28571
28601
|
addRowWithField({
|
|
28572
28602
|
type: fieldType,
|
|
28573
28603
|
props: {
|
|
@@ -28579,6 +28609,12 @@ function FormBuilder({ initialForm, onSave, onChange, className = '', theme = 'l
|
|
|
28579
28609
|
customStyle: {},
|
|
28580
28610
|
});
|
|
28581
28611
|
}
|
|
28612
|
+
else {
|
|
28613
|
+
console.log('[FormBuilder] Drop target not canvas or column');
|
|
28614
|
+
}
|
|
28615
|
+
}
|
|
28616
|
+
else {
|
|
28617
|
+
console.log('[FormBuilder] Not a library item drag');
|
|
28582
28618
|
}
|
|
28583
28619
|
};
|
|
28584
28620
|
return (jsxRuntime.jsx(TooltipProvider, { children: jsxRuntime.jsxs("div", { className: `formbuilder-container ${theme} ${className}`, children: [jsxRuntime.jsxs(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragStart: handleDragStart, onDragOver: handleDragOver, onDragEnd: handleDragEnd, children: [jsxRuntime.jsxs("div", { className: "flex flex-col h-full", children: [showToolbar && (jsxRuntime.jsx(Toolbar, { onOpenJsonViewer: () => setJsonViewerOpen(true) })), jsxRuntime.jsxs("div", { className: "flex flex-1 overflow-hidden", children: [showComponentLibrary && (jsxRuntime.jsx(ComponentLibrary, {})), jsxRuntime.jsx("div", { className: "flex-1 overflow-auto", children: jsxRuntime.jsx(FormCanvas, {}) }), showPropertiesPanel && (jsxRuntime.jsx(PropertiesPanel, {}))] })] }), jsxRuntime.jsx(DragOverlay, { children: activeId && activeType && (jsxRuntime.jsx(DragOverlayContent, { type: activeType })) })] }), jsxRuntime.jsx(JsonViewerModal, { isOpen: jsonViewerOpen, onClose: () => setJsonViewerOpen(false), schema: form })] }) }));
|