import { useRef, useState } from "react"; import { Select } from "@/components/ui/base/select"; type CanvasSizePickerProps = { value: string; className?: string; onChange: (value: string) => void }; const presets = ["auto", "1:1", "3:2", "2:3", "4:3", "3:4", "16:9", "9:16"]; export function CanvasSizePicker({ value, className, onChange }: CanvasSizePickerProps) { const [query, setQuery] = useState(""); const [expanded, setExpanded] = useState(false); const draft = useRef(""); const options = [...new Set([...presets, value, query.trim()].filter(Boolean))].map((option) => ({ label: option, value: option })); const commit = (text: string) => { const next = text.trim(); draft.current = ""; setQuery(""); setExpanded(false); if (next && next !== value) onChange(next); }; return (
event.stopPropagation()}>