UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

45 lines (44 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCurrencySymbol = getCurrencySymbol; exports.getDecimalSeparator = getDecimalSeparator; exports.getThousandsSeparator = getThousandsSeparator; var _formatNumberCore = require("./formatNumberCore.js"); var _currencyDisplay = require("./currencyDisplay.js"); function getDecimalSeparator(locale = null) { const separator = (0, _formatNumberCore.formatToParts)({ number: 1.1, locale }).find(({ type }) => type === 'decimal')?.value || ','; return separator; } function getThousandsSeparator(locale = null) { return (0, _formatNumberCore.formatToParts)({ number: 1000, locale }).find(({ type }) => type === 'group')?.value || ' '; } function getCurrencySymbol(locale = null, currency = null, display = null, number = 2) { if (!currency || currency === true) { currency = _currencyDisplay.CURRENCY; } const currencyDisplay = (0, _currencyDisplay.getFallbackCurrencyDisplay)(locale, display); return (0, _formatNumberCore.alignCurrencySymbol)((0, _formatNumberCore.formatToParts)({ number, locale, options: { style: 'currency', currency, currencyDisplay } }).find(({ type }) => type === 'currency')?.value || currency, currencyDisplay); } //# sourceMappingURL=separators.js.map