"use client"; import { useWatch } from "react-hook-form"; import { Slider } from "../../shadcnui"; import { FormFieldWrapper } from "./FormFieldWrapper"; export function FormSlider({ form, id, name, disabled, showPercentage, description, }: { form: any; id: string; name?: string; placeholder?: string; disabled?: boolean; showPercentage?: boolean; description?: string; }) { const value = useWatch({ control: form.control, name: id }); return (
{() => (
{showPercentage && (
{`${value}%`}
)} { const newValue = Array.isArray(val) ? val[0] : val; form.setValue(id, newValue); }} value={[value]} max={100} step={5} disabled={disabled === true || form.formState.isSubmitting} />
)}
); }