'use client' import { useState } from "react" import { Slider, Tooltip } from "@heroui/react"; import { InformationCircleIcon } from "@heroicons/react/24/outline"; export function ValueSlider( props: { label: string, description: string, maxValue: number, minValue: number, step: number, defaultValue: number, onChange: (value: number) => void } ) { const [value, setValue] = useState(props.defaultValue); const [inputValue, setInputValue] = useState(props.defaultValue.toString()); const handleChange = (value: number | number[]) => { if (isNaN(Number(value))) return; setValue(value as number); setInputValue(value.toString()); props.onChange(value as number); }; const contentRender = () => { return ( {props.description} ) } return ( ( )} // eslint-disable-next-line @typescript-eslint/no-unused-vars renderValue={({ children, ...props }) => ( { const v = e.target.value; setInputValue(v); }} onKeyDown={(e) => { if (e.key === "Enter" && !isNaN(Number(inputValue))) { handleChange(Number(inputValue)); } }} /> )} // we extract the default children to render the input step={props.step} value={value} onChange={handleChange} /> ); }