import type { EditorObject } from "../../../store/editorStore";
import Input from "@/components/Input";

type SizeSettingsProps = {
    selectedObject: EditorObject;
    onUpdate: (id: string, updates: Partial<EditorObject>) => void;
    defaultWidth?: number;
    defaultHeight?: number;
};

const SizeSettings = ({ selectedObject, onUpdate, defaultWidth = 100, defaultHeight = 100 }: SizeSettingsProps) => {
    return (
        <>
            <Input
                label="عرض"
                type="number"
                value={selectedObject.width || defaultWidth}
                onChange={(e) =>
                    onUpdate(selectedObject.id, {
                        width: parseInt(e.target.value) || defaultWidth,
                    })
                }
            />
            <Input
                label="ارتفاع"
                type="number"
                value={selectedObject.height || defaultHeight}
                onChange={(e) =>
                    onUpdate(selectedObject.id, {
                        height: parseInt(e.target.value) || defaultHeight,
                    })
                }
            />
            <Input
                label="گردی گوشه"
                type="number"
                value={selectedObject.borderRadius ?? 0}
                onChange={(e) =>
                    onUpdate(selectedObject.id, {
                        borderRadius: Math.max(0, parseInt(e.target.value) || 0),
                    })
                }
                min={0}
            />
        </>
    );
};

export default SizeSettings;

