mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +00:00
Fix number format for monetary device class (#15693)
This commit is contained in:
parent
1741b051fc
commit
9bb36e38e6
@ -71,6 +71,11 @@ export const computeStateDisplayFromEntityAttributes = (
|
|||||||
style: "currency",
|
style: "currency",
|
||||||
currency: attributes.unit_of_measurement,
|
currency: attributes.unit_of_measurement,
|
||||||
minimumFractionDigits: 2,
|
minimumFractionDigits: 2,
|
||||||
|
// Override monetary options with number format
|
||||||
|
...getNumberFormatOptions(
|
||||||
|
{ state, attributes } as HassEntity,
|
||||||
|
entity
|
||||||
|
),
|
||||||
});
|
});
|
||||||
} catch (_err) {
|
} catch (_err) {
|
||||||
// fallback to default
|
// fallback to default
|
||||||
|
@ -82,17 +82,14 @@ export const formatNumber = (
|
|||||||
!Number.isNaN(Number(num)) &&
|
!Number.isNaN(Number(num)) &&
|
||||||
num !== "" &&
|
num !== "" &&
|
||||||
localeOptions?.number_format === NumberFormat.none &&
|
localeOptions?.number_format === NumberFormat.none &&
|
||||||
Intl &&
|
Intl
|
||||||
(options?.maximumFractionDigits != null ||
|
|
||||||
options?.minimumFractionDigits != null)
|
|
||||||
) {
|
) {
|
||||||
// If NumberFormat is none, just set the digits options for precision and use en-US format without grouping.
|
// If NumberFormat is none, use en-US format without grouping.
|
||||||
return new Intl.NumberFormat(
|
return new Intl.NumberFormat(
|
||||||
"en-US",
|
"en-US",
|
||||||
getDefaultFormatOptions(num, {
|
getDefaultFormatOptions(num, {
|
||||||
|
...options,
|
||||||
useGrouping: false,
|
useGrouping: false,
|
||||||
maximumFractionDigits: options?.maximumFractionDigits,
|
|
||||||
minimumFractionDigits: options?.minimumFractionDigits,
|
|
||||||
})
|
})
|
||||||
).format(Number(num));
|
).format(Number(num));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user