import useEditorStore from "./useEditorStore";
import { useState } from "react";
import { DndContext, closestCenter, PointerSensor, useSensor, useSensors } from "@dnd-kit/core";
import { arrayMove, SortableContext, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
function SortableColumnItem({ column, elementId, updateColumnWidth, updateColumnLabel, toggleColumnVisibility }) {
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id: column.key });
const style = {
transform: CSS.Transform.toString(transform),
transition,
};
return (
Properties
{selected.type.toUpperCase()}
{/* POSITION */}
{/* ROTATION */}
{selected.rotation !== undefined && (
updateElement(selected.id, { rotation: Number(e.target.value) })
}
style={styles.input}
placeholder="Degrees"
/>
)}
{/* TEXT PROPERTIES */}
{selected.type === "text" && (
<>
updateElement(selected.id, {
fontSize: Number(e.target.value),
})
}
style={styles.input}
/>
updateElement(selected.id, { color: e.target.value })
}
style={{ ...styles.input, height: 40 }}
/>
>
)}
{/* IMAGE PROPERTIES */}
{selected.type === "image" && (
<>
{selected.src ? (
) : (
)}
>
)}
{/* QRCODE PROPERTIES */}
{selected.type === "qrcode" && (
<>
updateElement(selected.id, {
size: Number(e.target.value),
})
}
style={styles.input}
/>
>
)}
{/* LINE PROPERTIES */}
{selected.type === "line" && (
<>
updateElement(selected.id, {
width: Number(e.target.value),
})
}
style={styles.input}
/>
updateElement(selected.id, {
thickness: Number(e.target.value),
})
}
style={styles.input}
/>
updateElement(selected.id, { color: e.target.value })
}
style={{ ...styles.input, height: 40 }}
/>
>
)}
{/* RECTANGLE PROPERTIES */}
{selected.type === "rectangle" && (
<>
updateElement(selected.id, { fill: e.target.value })
}
style={{ ...styles.input, height: 40 }}
/>
updateElement(selected.id, { stroke: e.target.value })
}
style={{ ...styles.input, height: 40 }}
/>
updateElement(selected.id, {
strokeWidth: Number(e.target.value),
})
}
style={styles.input}
/>
updateElement(selected.id, {
cornerRadius: Number(e.target.value),
})
}
style={styles.input}
/>
>
)}
{/* SUMMARY PROPERTIES */}
{selected.type === "summary" && (
<>
updateElement(selected.id, {
fontSize: Number(e.target.value),
})
}
style={styles.input}
/>
updateElement(selected.id, {
spacing: Number(e.target.value),
})
}
style={styles.input}
/>
updateElement(selected.id, { labelColor: e.target.value })
}
style={{ ...styles.input, height: 40 }}
/>
updateElement(selected.id, { valueColor: e.target.value })
}
style={{ ...styles.input, height: 40 }}
/>
>
)}
{/* TABLE PROPERTIES */}
{selected.type === "table" && (
<>
updateElement(selected.id, {
rowHeight: Number(e.target.value),
})
}
style={styles.input}
/>
col.key)}
strategy={verticalListSortingStrategy}
>
{selected.columns.map((col) => (
))}
updateElement(selected.id, { headerBg: e.target.value })
}
style={{ ...styles.input, height: 40 }}
/>
updateElement(selected.id, { borderColor: e.target.value })
}
style={{ ...styles.input, height: 40 }}
/>
>
)}
);
}
const styles = {
panel: {
width: 280,
background: "#fff",
borderLeft: "1px solid #ddd",
padding: 16,
overflowY: "auto",
},
header: {
display: "flex",
justifyContent: "space-between",
alignItems: "center",
marginBottom: 16,
},
title: {
margin: 0,
fontSize: 16,
fontWeight: 600,
},
actions: {
display: "flex",
gap: 4,
},
iconBtn: {
background: "none",
border: "1px solid #ddd",
borderRadius: 4,
padding: "4px 8px",
cursor: "pointer",
fontSize: 14,
},
emptyState: {
textAlign: "center",
color: "#999",
marginTop: 40,
},
section: {
marginBottom: 16,
},
label: {
display: "block",
fontSize: 12,
fontWeight: 600,
marginBottom: 6,
color: "#333",
},
input: {
width: "100%",
padding: 8,
border: "1px solid #ddd",
borderRadius: 4,
fontSize: 13,
boxSizing: "border-box",
},
row: {
display: "flex",
gap: 8,
},
inputGroup: {
flex: 1,
display: "flex",
flexDirection: "column",
},
inputLabel: {
fontSize: 11,
color: "#666",
marginBottom: 4,
},
checkbox: {
display: "flex",
alignItems: "center",
gap: 6,
fontSize: 13,
cursor: "pointer",
},
badge: {
display: "inline-block",
padding: "4px 8px",
background: "#e3f2fd",
color: "#1976d2",
borderRadius: 4,
fontSize: 11,
fontWeight: 600,
},
columnItem: {
display: "flex",
justifyContent: "space-between",
alignItems: "center",
padding: "6px 0",
borderBottom: "1px solid #f0f0f0",
},
};