Skip to content

How it works

A cheat sheet. Each row links to the section of Anatomy that explains it with diagrams and demos.

React integration

NumoraInput is a forwardRef component that calls the core event handlers directly and never instantiates the vanilla class. When an edit changes the raw value, onChange fires with a synthetic event whose target exposes both the raw and formatted values.

Events

  • keydown: moves the cursor over a thousand separator on Delete / Backspace. It deletes nothing. It acts only with formatOn: 'change', a thousand separator set and no text selected. beforeinput then deletes the digit. Mobile keyboards that send no usable keydown get the same result, because beforeinput deletes the digit past the separator itself.
  • beforeinput: the main formatting hook, registered with native addEventListener (why it bypasses React). Writes the formatted value with setRangeText.
  • input: fallback for autofill, drop, IME commits and other changes without beforeinput.
  • paste: splices clipboard text into the selection and runs the full pipeline.
  • focus / blur: strip and re-apply separators in 'blur' mode. Blur also settles the value in both modes: it drops a trailing decimal separator, pads decimals, turns -0 into 0 and empties a field with no digit.

Pipeline

Input value format

value / defaultValue take a string: the canonical raw value, with ASCII digits, . as the decimal mark and no grouping, in every locale. Under locale="de-DE", value="1234.5" displays "1.234,5". A JS number is a TypeScript error, because it may already have lost precision.