@enerjisaformlibrary/formbuilder-react 1.0.4 → 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 +0 -35
- package/index.cjs +32 -2
- package/index.cjs.map +1 -1
- package/index.js +32 -2
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/types/lib/FormBuilder.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -61,41 +61,6 @@ function App() {
|
|
|
61
61
|
- Responsive grid system (12-column)
|
|
62
62
|
- Dark/Light theme support
|
|
63
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
|
-
```
|
|
98
|
-
|
|
99
64
|
## License
|
|
100
65
|
|
|
101
66
|
MIT
|
package/index.cjs
CHANGED
|
@@ -28550,24 +28550,48 @@ 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;
|
|
28585
|
+
console.log('[FormBuilder] Checking conditions:', {
|
|
28586
|
+
isNew: activeData?.isNew,
|
|
28587
|
+
fieldType: activeData?.fieldType,
|
|
28588
|
+
isCanvas: overData?.isCanvas,
|
|
28589
|
+
columnId: overData?.columnId
|
|
28590
|
+
});
|
|
28568
28591
|
if (activeData?.isNew && activeData?.fieldType) {
|
|
28569
28592
|
const fieldType = activeData.fieldType;
|
|
28570
28593
|
if (overData?.isCanvas || overData?.columnId) {
|
|
28594
|
+
console.log('[FormBuilder] Adding field:', fieldType);
|
|
28571
28595
|
addRowWithField({
|
|
28572
28596
|
type: fieldType,
|
|
28573
28597
|
props: {
|
|
@@ -28579,6 +28603,12 @@ function FormBuilder({ initialForm, onSave, onChange, className = '', theme = 'l
|
|
|
28579
28603
|
customStyle: {},
|
|
28580
28604
|
});
|
|
28581
28605
|
}
|
|
28606
|
+
else {
|
|
28607
|
+
console.log('[FormBuilder] Drop target not canvas or column');
|
|
28608
|
+
}
|
|
28609
|
+
}
|
|
28610
|
+
else {
|
|
28611
|
+
console.log('[FormBuilder] Not a new field drag');
|
|
28582
28612
|
}
|
|
28583
28613
|
};
|
|
28584
28614
|
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 })] }) }));
|