How it works
A cheat sheet. Each row links to the section of Anatomy that explains it with diagrams and demos.
Events
keydown: moves the cursor over a thousand separator on Delete / Backspace. It deletes nothing. It acts only withformatOn: 'change', a thousand separator set and no text selected.beforeinputthen deletes the digit. Mobile keyboards that send no usablekeydownget the same result, becausebeforeinputdeletes the digit past the separator itself.beforeinput: the main formatting hook. Writes the formatted value withsetRangeText.input: fallback for autofill, drop, IME commits and other changes withoutbeforeinput.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-0into0and empties a field with no digit.
Pipeline
- Sanitization: runs on every value before formatting. Options: Sanitization, Compact notation, Scientific notation (
allowScientificNotation), Leading zeros, Max length. - Formatting: trims the decimals to
decimalMaxLength, then groups the digits. On blur and for values from your code it then drops a trailing decimal separator and pads the decimals todecimalMinLength. Options: Formatting, Decimals. - Cursor restoration: puts the cursor back after Numora writes the formatted value. Every write goes through
setRangeText, which fires noinputevent. Numora never assignsinput.value. - Value output: values are always strings.
onValueChangegets both the rawvalue(canonical in every locale: ASCII digits,.decimal, no grouping) and theformattedValue. See Value types.