UNPKG

@kubit-ui-web/react-components

Version:

Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience

13 lines 732 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.truncatedValue = void 0; const formatNumber_1 = require("../../input/utils/formatNumber"); const truncatedValue = (value, maxDecimals, locale) => { const decimalSeparator = (0, formatNumber_1.getDecimalSeparator)(locale); const numberOfDecimals = (value.split(decimalSeparator)[1] || '').length; const decimalIndex = maxDecimals > 0 ? value.indexOf(decimalSeparator) : value.indexOf(decimalSeparator) - 1; const truncatedValue = value.slice(0, decimalIndex + 1 + maxDecimals); return numberOfDecimals > maxDecimals ? truncatedValue : value; }; exports.truncatedValue = truncatedValue; //# sourceMappingURL=truncatedValue.js.map