Skip to content

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 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. 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

  • 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 to decimalMinLength. Options: Formatting, Decimals.
  • Cursor restoration: puts the cursor back after Numora writes the formatted value. Every write goes through setRangeText, which fires no input event. Numora never assigns input.value.
  • Value output: values are always strings. onValueChange gets both the raw value (canonical in every locale: ASCII digits, . decimal, no grouping) and the formattedValue. See Value types.