import React from "react"; import { FormLayout, Label, type LayoutType } from "../../ui"; import { PresetsInput } from "../../ui"; import { useDialSchema } from "../DialProvider"; import { IconRenderer } from "../IconRenderer"; import { LabelPositionT } from "../types"; const DialInputWrapper: React.FC<{ label?: string; labelPosition?: LabelPositionT; icon?: string; children: React.ReactElement; }> = ({ label, labelPosition = "top", icon, children }) => { if (!label) { return <>{children}; } return ( {children} ); }; export const DialPresetsInput: React.FC<{ name: string; label?: string; size?: "sm" | "md" | "lg"; labelPosition?: LabelPositionT; icon?: string; options: Array; }> = ({ name, label, size = "sm", labelPosition = "top", icon, options }) => { const { getValue, setValue } = useDialSchema(); const value = (getValue(name) ?? 0) as number; // Extract preset values from options const presets = options.slice(0, 3).map((opt) => { if (typeof opt === "number") return opt; if (typeof opt === "string") return parseFloat(opt); return typeof opt.value === "number" ? opt.value : parseFloat(opt.value as string); }) as [number, number, number]; // Pad with zeros if less than 3 presets while (presets.length < 3) { presets.push(0); } if (labelPosition === "inline") { // this is suspicious - Ge return (
{label && } setValue(name, val)} size={size} presets={presets} />
); } else { return ( setValue(name, val)} size={size} presets={presets} /> ); } };