import { type FormEvent } from 'react'; import { cn } from '@/lib/utils'; import { formatInputNumber, numericValue, stripNumberGrouping } from './format-number'; import { StepButton, type ControlInternalProps } from './shared'; const NUMBER_STEP_GRID = 'grid-cols-[48px_minmax(0,1fr)_48px]'; export const NumberControl = ({ cheat, value, disabled, onChange }: ControlInternalProps) => { const step = cheat.args.step ?? 1; const currentValue = numericValue(value, 0); const handleInput = (event: FormEvent) => onChange(stripNumberGrouping(event.currentTarget.value)); const decrement = () => onChange(Math.max(cheat.args.min ?? Number.NEGATIVE_INFINITY, currentValue - step)); const increment = () => onChange(Math.min(cheat.args.max ?? Number.POSITIVE_INFINITY, currentValue + step)); return (
); };