Bug Fixes
- fix tests & add corresponding formatToParts fns (855e272)
Features
- extend numberformat to unified (#1462) (a7f2104)
Currently this is part of Unified NumberFormat which is stage 3. We've provided a polyfill here andreact-intl
types allow users to pass in a sanctioned unit. For example:
<FormattedNumber
value={1000}
style="unit"
unit="kilobyte"
unitDisplay="narrow"
/>
<span>1,000kB</span>
<FormattedNumber
value={1000}
unit="fahrenheit"
unitDisplay="long"
style="unit"
/>
<span>1,000 degrees Fahrenheit</span>
- add support for formatToParts (e8167f3)
- introduce Parts component (a1b5ff1), closes #1048
This component provides more customization toFormattedNumber/Date/Time
by allowing children function to have access to underlying parts of the formatted date. The available parts are listed here
Props:
props: NumberFormatOptions &
{
value: number,
format: string,
children: (parts: Intl.NumberFormatPart[]) => ReactElement,
};
Example:
<FormattedNumberParts value={1000}>
{parts => (
<>
<b>{parts[0].value}</b>
{parts[1].value}
<small>{parts[2].value}</small>
</>
)}
</FormattedNumberParts>
<b>1</b>,<small>000</small>