Files
Wand-Enhancer/web-panel/src/trainer/controls/NumberControl.tsx
T
kitbyte a0b3968d33 refactor(web-panel): update architecture + cheat i18n
Reorganize the panel around product capabilities and integrate the
remote i18n feature from origin/master into the new structure.

- Restructure src into capability features (app, trainer, library,
  remote-session, appearance, shared); move the bridge to bridge/src.
- Add lingui-based UI localization and wrap remaining user-facing
  strings (Trans / msg macros); fix the 'END В·' mojibake.
- Port WeMod cheat-metadata i18n: capture the access token from the
  snapshot's renderer in the bridge and fetch localized trainer_meta
  in remote-session.i18n; guarantee snapshot sync on token failure.
- Wire vitest to the app's lingui/preact pipeline (mergeConfig).
2026-06-15 00:10:49 +03:00

31 lines
1.5 KiB
TypeScript

import { type FormEvent } from 'react';
import { cn } from '@/shared/lib/ui';
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<HTMLInputElement>) => 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 (
<div className={cn('grid h-[38px] w-full items-stretch overflow-hidden rounded-[10px] border border-white/10 bg-white/[0.055] shadow-[inset_0_1px_0_rgba(255,255,255,0.05)] backdrop-blur-xl', NUMBER_STEP_GRID)}>
<StepButton border="right" disabled={disabled} icon="minus" onClick={decrement} />
<input
type="text"
value={formatInputNumber(value)}
disabled={disabled}
className="min-w-0 bg-transparent px-2 text-center font-mono text-[15px] font-semibold tabular-nums text-(--deck-fg) outline-none disabled:opacity-50"
onInput={handleInput}
/>
<StepButton border="left" disabled={disabled} icon="plus" onClick={increment} />
</div>
);
};