Skip to content

nitro-input v0.3.8

Choose a tag to compare

@ronickg ronickg released this 05 Oct 19:22
· 11 commits to main since this release
  • NitroNumber shows what its format prints, value by value. It read the
    format once and showed every value at its maximum fraction digits, rounded
    by the engine (half away from zero, through a double). Now each value is
    formatted:

    • trailingZeroDisplay: 'stripIfInteger' and a minimum below the maximum
      show the digits the format prints ("$1,234", then "$1,234.50"), and the
      decimal columns roll in and out as the count changes.
    • The figure is rounded with the format's roundingMode (halfEven
      included), on the exact decimal: "1.005" is $1.01.
    • A value that rounds to zero shows no minus.
    • A format whose minimum fraction digits is below its maximum (a plain
      decimal style, say) now drops the trailing zeros Intl drops; pass
      fractionDigits to keep a fixed count.
  • value takes a bigint or a decimal string, and minorDigits reads it in
    minor units
    : <NitroNumber value={123456n} minorDigits={2} format={usd} />
    shows $1,234.56. With a format, nothing goes through a double before it is
    rounded; the rounded figure then rolls as a double, exact to 15 significant
    digits. A string with an exponent ("1e5") or a 0x / 0o / 0b integer is
    shifted exactly too; a string that is not a number shows as NaN rather than
    an unshifted amount.

  • The components read their format in C++. What NitroNumber and
    NitroInput take from a NumberFormat (the figure per value, the prefix
    and suffix, separators, grouping, sign placement, the locale's digits) is
    read off the formatter's own parts natively, instead of formatting sample
    values into JS objects and parsing them back there.

  • NitroNumber keeps rolling while its value keeps changing (a slider, a
    dial, a live price) (#62).

    • With easing="spring", each new value restarted the spring from rest, so
      while a slider moved the figure stood still and only caught up when the
      finger stopped. A wheel now keeps its speed through a new value (the
      spring's response with the speed it had).
    • With any easing, a new value mid-roll sent each wheel to the new digit
      from where it stood, the way the value moved, so a wheel that lagged
      behind or ran past its digit went a whole turn round. A new value now
      moves where the wheel is going, by the step from the digit it was
      heading for (as NumberFlow accumulates), so a stream one way spins it
      faster and a drag that turns back slows it and turns it round.

    Every digit still rolls on its own and lands within one duration of the
    last value, as the numeric transition does. A single change from rest rolls
    as before.