@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/index.js
CHANGED
|
@@ -28530,24 +28530,54 @@ function FormBuilder({ initialForm, onSave, onChange, className = '', theme = 'l
|
|
|
28530
28530
|
}));
|
|
28531
28531
|
const handleDragStart = (event) => {
|
|
28532
28532
|
const { active } = event;
|
|
28533
|
+
console.log('[FormBuilder] Drag started:', {
|
|
28534
|
+
id: active.id,
|
|
28535
|
+
data: active.data.current
|
|
28536
|
+
});
|
|
28533
28537
|
setActiveId(active.id);
|
|
28534
28538
|
if (active.data.current?.type) {
|
|
28535
28539
|
setActiveType(active.data.current.type);
|
|
28536
28540
|
}
|
|
28537
28541
|
};
|
|
28538
|
-
const handleDragOver = (
|
|
28542
|
+
const handleDragOver = (event) => {
|
|
28543
|
+
console.log('[FormBuilder] Drag over:', {
|
|
28544
|
+
activeId: event.active.id,
|
|
28545
|
+
overId: event.over?.id,
|
|
28546
|
+
overData: event.over?.data.current
|
|
28547
|
+
});
|
|
28539
28548
|
};
|
|
28540
28549
|
const handleDragEnd = (event) => {
|
|
28541
28550
|
const { active, over } = event;
|
|
28551
|
+
console.log('[FormBuilder] Drag ended:', {
|
|
28552
|
+
activeId: active.id,
|
|
28553
|
+
activeData: active.data.current,
|
|
28554
|
+
overId: over?.id,
|
|
28555
|
+
overData: over?.data.current
|
|
28556
|
+
});
|
|
28542
28557
|
setActiveId(null);
|
|
28543
28558
|
setActiveType(null);
|
|
28544
|
-
if (!over)
|
|
28559
|
+
if (!over) {
|
|
28560
|
+
console.log('[FormBuilder] No drop target (over is null)');
|
|
28545
28561
|
return;
|
|
28562
|
+
}
|
|
28546
28563
|
const activeData = active.data.current;
|
|
28547
28564
|
const overData = over.data.current;
|
|
28548
|
-
|
|
28549
|
-
|
|
28550
|
-
|
|
28565
|
+
// Check for library item (using actual data structure from ComponentLibrary)
|
|
28566
|
+
const isLibraryItem = activeData?.isLibraryItem;
|
|
28567
|
+
const fieldType = activeData?.componentType || activeData?.type;
|
|
28568
|
+
const isCanvas = overData?.type === 'canvas';
|
|
28569
|
+
const isColumn = overData?.type === 'column' || overData?.columnId;
|
|
28570
|
+
console.log('[FormBuilder] Checking conditions:', {
|
|
28571
|
+
isLibraryItem,
|
|
28572
|
+
fieldType,
|
|
28573
|
+
isCanvas,
|
|
28574
|
+
isColumn,
|
|
28575
|
+
activeData,
|
|
28576
|
+
overData
|
|
28577
|
+
});
|
|
28578
|
+
if (isLibraryItem && fieldType) {
|
|
28579
|
+
if (isCanvas || isColumn) {
|
|
28580
|
+
console.log('[FormBuilder] Adding field:', fieldType);
|
|
28551
28581
|
addRowWithField({
|
|
28552
28582
|
type: fieldType,
|
|
28553
28583
|
props: {
|
|
@@ -28559,6 +28589,12 @@ function FormBuilder({ initialForm, onSave, onChange, className = '', theme = 'l
|
|
|
28559
28589
|
customStyle: {},
|
|
28560
28590
|
});
|
|
28561
28591
|
}
|
|
28592
|
+
else {
|
|
28593
|
+
console.log('[FormBuilder] Drop target not canvas or column');
|
|
28594
|
+
}
|
|
28595
|
+
}
|
|
28596
|
+
else {
|
|
28597
|
+
console.log('[FormBuilder] Not a library item drag');
|
|
28562
28598
|
}
|
|
28563
28599
|
};
|
|
28564
28600
|
return (jsx(TooltipProvider, { children: jsxs("div", { className: `formbuilder-container ${theme} ${className}`, children: [jsxs(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragStart: handleDragStart, onDragOver: handleDragOver, onDragEnd: handleDragEnd, children: [jsxs("div", { className: "flex flex-col h-full", children: [showToolbar && (jsx(Toolbar, { onOpenJsonViewer: () => setJsonViewerOpen(true) })), jsxs("div", { className: "flex flex-1 overflow-hidden", children: [showComponentLibrary && (jsx(ComponentLibrary, {})), jsx("div", { className: "flex-1 overflow-auto", children: jsx(FormCanvas, {}) }), showPropertiesPanel && (jsx(PropertiesPanel, {}))] })] }), jsx(DragOverlay, { children: activeId && activeType && (jsx(DragOverlayContent, { type: activeType })) })] }), jsx(JsonViewerModal, { isOpen: jsonViewerOpen, onClose: () => setJsonViewerOpen(false), schema: form })] }) }));
|