"use client";
import { Button } from "@suphark/ui/components/shared/button/button";
import { useUiText } from "@suphark/ui/components/shared/ui-text";
import { ButtonGroup } from "@suphark/ui/components/ui/button-group";
import { cn } from "@suphark/ui/lib/utils";
import { MinusIcon, PlusIcon } from "lucide-react";
export interface ZoomControlsProps {
/** ระดับซูม (1 = 100%) */
value: number;
onValueChange: (value: number) => void;
/** ค่าเริ่มต้น 0.25 */
min?: number;
/** ค่าเริ่มต้น 4 */
max?: number;
/** ก้าวต่อการกด (ปัดให้ลงก้าว) — ค่าเริ่มต้น 0.25 */
step?: number;
/** ค่าที่ปุ่ม % รีเซ็ตกลับ — ค่าเริ่มต้น 1 */
resetValue?: number;
size?: "sm" | "default";
disabled?: boolean;
className?: string;
}
/** ปัดค่าให้ลงก้าว แล้วจำกัดในช่วง (กันทศนิยมสะสม 0.30000000000000004) */
export function clampZoom(value: number, min: number, max: number, step: number): number {
const snapped = Math.round(value / step) * step;
return Math.min(max, Math.max(min, Number(snapped.toFixed(4))));
}
/**
* ปุ่มซูมพรีวิว − / 100% / + — ปุ่มกลางแสดงระดับปัจจุบัน กดแล้วรีเซ็ต · ถึงขอบ min/max ปุ่มนั้นปิด
* ใช้กับพรีวิวเอกสาร/แม่แบบ/ผืนผ้าใบที่แอปวาดเอง (รูปใช้ `Lightbox` ซึ่งซูมได้ในตัว)
*
* const [zoom, setZoom] = useState(1);
*