XGitHub

Value Types

Numora always works with strings. onChange emits a string on every change. Two modes control which string you receive.

Default: formatted string

By default onChange receives the display value - the same string shown in the input, including thousand separators.

typescript
import { NumoraInput } from 'numora'

const numoraInput = new NumoraInput(container, {
  thousandSeparator: ',',
  onChange: (value) => {
    console.log(value) // "1,234.56"
  },
})

rawValueMode: raw string

Set rawValueMode: true and onChange receives the plain numeric string with thousand separators stripped. The input still displays the formatted value. instance.value also returns the raw string in this mode.

typescript
import { NumoraInput } from 'numora'

const numoraInput = new NumoraInput(container, {
  thousandSeparator: ',',
  rawValueMode: true,
  onChange: (value) => {
    console.log(value)                    // "1234.56" ← no separators
    console.log(numoraInput.getElement().value) // "1,234.56" ← display value
  },
})

valueAsNumber

valueAsNumber converts the current value to a JavaScript number via parseFloat. Use it as an escape hatch when you need a number type, not as the primary way to read the value.

typescript
const num = numoraInput.valueAsNumber
console.log(typeof num) // "number"
console.log(num)        // 1234.56
console.log(isNaN(numoraInput.valueAsNumber)) // true when input is empty

Precision warning: parseFloat is subject to IEEE 754 limits. Integers above Number.MAX_SAFE_INTEGER and long decimals may silently lose precision. For financial arithmetic, keep working with the string from onChange and use a decimal library such as decimal.js.