import clsx from "clsx"; import { ReactNode } from "react"; import { useTranslation } from "react-i18next"; import EntityIcon from "~/components/layouts/icons/EntityIcon"; import HintTooltip from "~/components/ui/tooltips/HintTooltip"; import { Input } from "../../input"; interface Props { name?: string; title?: string; withLabel?: boolean; valueMin?: number | null; defaultValueMin?: number | undefined; onChangeMin?: (value: number) => void; valueMax?: number | null; defaultValueMax?: number | undefined; onChangeMax?: (value: number) => void; className?: string; help?: string; min?: number; max?: number; disabled?: boolean; readOnly?: boolean; required?: boolean; hint?: ReactNode; step?: string; placeholder?: string; icon?: string; borderless?: boolean; autoFocus?: boolean; } export default function InputRangeNumber({ name, title, withLabel = true, valueMin, defaultValueMin, onChangeMin, valueMax, defaultValueMax, onChangeMax, className, hint, help, disabled = false, readOnly = false, required = false, min = 0, max, step, placeholder, icon, borderless, autoFocus, }: Props) { const { t } = useTranslation(); // useImperativeHandle(ref, () => ({ inputMin, inputMax })); // const inputMin = useRef(null); // const inputMax = useRef(null); return (
{withLabel && ( )}
{icon && (
)}
(onChangeMin ? onChangeMin(Number(e.currentTarget.value)) : null)} step={step} placeholder={placeholder ?? t("shared.from") + "..."} disabled={disabled} readOnly={readOnly} autoFocus={autoFocus} className={clsx( icon && "pl-10" // "focus:border-border focus:ring-ring block w-full min-w-0 flex-1 rounded-md border-border sm:text-sm", // className, // disabled || readOnly ? "cursor-not-allowed bg-secondary/90" : "hover:bg-secondary focus:bg-secondary", // icon && "pl-10", // borderless && "border-transparent" )} /> - (onChangeMax ? onChangeMax(Number(e.currentTarget.value)) : null)} step={step} placeholder={placeholder ?? t("shared.to") + "..."} disabled={disabled} readOnly={readOnly} className={clsx( icon && "pl-10" // "focus:border-border focus:ring-ring block w-full min-w-0 flex-1 rounded-md border-border sm:text-sm", // className, // disabled || readOnly ? "cursor-not-allowed bg-secondary/90" : "hover:bg-secondary focus:bg-secondary", // borderless && "border-transparent" )} />
); }