@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
22 lines (21 loc) • 836 B
JavaScript
"use client";
import { getDigitParts } from "./get-digit-parts.mjs";
//#region packages/@mantine/core/src/components/RollingNumber/build-value.ts
function buildValue({ value, prefix, suffix, decimalSeparator = ".", thousandSeparator, decimalScale, fixedDecimalScale }) {
const parts = getDigitParts({
value,
decimalScale,
fixedDecimalScale
});
let intStr = parts.intDigits.join("");
if (thousandSeparator) {
const sep = typeof thousandSeparator === "string" ? thousandSeparator : ",";
intStr = intStr.replace(/\B(?=(\d{3})+(?!\d))/g, sep);
}
let result = parts.negative ? `-${intStr}` : intStr;
if (parts.fracDigits.length > 0) result += `${decimalSeparator}${parts.fracDigits.join("")}`;
return `${prefix || ""}${result}${suffix || ""}`;
}
//#endregion
export { buildValue };
//# sourceMappingURL=build-value.mjs.map