UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

48 lines (47 loc) 1.74 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) { var _formatToParts$find; const separator = ((_formatToParts$find = (0, _formatNumberCore.formatToParts)({ number: 1.1, locale }).find(({ type }) => type === 'decimal')) === null || _formatToParts$find === void 0 ? void 0 : _formatToParts$find.value) || ','; return separator; } function getThousandsSeparator(locale = null) { var _formatToParts$find2; return ((_formatToParts$find2 = (0, _formatNumberCore.formatToParts)({ number: 1000, locale }).find(({ type }) => type === 'group')) === null || _formatToParts$find2 === void 0 ? void 0 : _formatToParts$find2.value) || ' '; } function getCurrencySymbol(locale = null, currency = null, display = null, number = 2) { var _formatToParts$find3; if (!currency || currency === true) { currency = _currencyDisplay.CURRENCY; } const currencyDisplay = (0, _currencyDisplay.getFallbackCurrencyDisplay)(locale, display); return (0, _formatNumberCore.alignCurrencySymbol)(((_formatToParts$find3 = (0, _formatNumberCore.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