@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
40 lines • 1.44 kB
JavaScript
import { formatToParts, alignCurrencySymbol } from "./formatNumberCore.js";
import { getFallbackCurrencyDisplay, CURRENCY } from "./currencyDisplay.js";
export function getDecimalSeparator(locale = null) {
var _formatToParts$find;
const separator = ((_formatToParts$find = formatToParts({
number: 1.1,
locale
}).find(({
type
}) => type === 'decimal')) === null || _formatToParts$find === void 0 ? void 0 : _formatToParts$find.value) || ',';
return separator;
}
export function getThousandsSeparator(locale = null) {
var _formatToParts$find2;
return ((_formatToParts$find2 = formatToParts({
number: 1000,
locale
}).find(({
type
}) => type === 'group')) === null || _formatToParts$find2 === void 0 ? void 0 : _formatToParts$find2.value) || ' ';
}
export function getCurrencySymbol(locale = null, currency = null, display = null, number = 2) {
var _formatToParts$find3;
if (!currency || currency === true) {
currency = CURRENCY;
}
const currencyDisplay = getFallbackCurrencyDisplay(locale, display);
return alignCurrencySymbol(((_formatToParts$find3 = formatToParts({
number,
locale,
options: {
style: 'currency',
currency,
currencyDisplay
}
}).find(({
type
}) => type === 'currency')) === null || _formatToParts$find3 === void 0 ? void 0 : _formatToParts$find3.value) || currency, currencyDisplay);
}
//# sourceMappingURL=separators.js.map