Repository navigation
nitro-input v0.3.8
-
NitroNumbershows what itsformatprints, 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 zerosIntldrops; pass
fractionDigitsto keep a fixed count.
-
valuetakes abigintor a decimal string, andminorDigitsreads 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 a0x/0o/0binteger is
shifted exactly too; a string that is not a number shows as NaN rather than
an unshifted amount. -
The components read their
formatin C++. WhatNitroNumberand
NitroInputtake from aNumberFormat(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. -
NitroNumberkeeps 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
durationof the
last value, as the numeric transition does. A single change from rest rolls
as before. - With