fui-material 2.2.13 → 2.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/f-ui-kit.es.js
CHANGED
|
@@ -50094,32 +50094,55 @@ function fDownloadBlobFile(blob, fileName) {
|
|
|
50094
50094
|
window.URL.revokeObjectURL(url);
|
|
50095
50095
|
}
|
|
50096
50096
|
function fBankRound(value, decimals = 2) {
|
|
50097
|
-
const str =
|
|
50098
|
-
if (!/^[-+]?\d+(\.\d+)?$/.test(str))
|
|
50099
|
-
|
|
50100
|
-
|
|
50101
|
-
|
|
50102
|
-
const
|
|
50103
|
-
|
|
50104
|
-
const
|
|
50105
|
-
const
|
|
50106
|
-
const
|
|
50107
|
-
const
|
|
50108
|
-
let
|
|
50097
|
+
const str = String(value).trim();
|
|
50098
|
+
if (!/^[-+]?\d+(\.\d+)?$/.test(str)) return NaN;
|
|
50099
|
+
if (decimals < 0) return NaN;
|
|
50100
|
+
const sign = str.startsWith("-") ? -1 : 1;
|
|
50101
|
+
const abs = str.replace(/^[-+]/, "");
|
|
50102
|
+
const [intPart, fracPart = ""] = abs.split(".");
|
|
50103
|
+
if (fracPart.length <= decimals) return Number(str);
|
|
50104
|
+
const roundPos = decimals;
|
|
50105
|
+
const roundingDigit = Number(fracPart[roundPos]);
|
|
50106
|
+
const tail = fracPart.slice(roundPos + 1);
|
|
50107
|
+
const hasTail = tail.length > 0 && /[1-9]/.test(tail);
|
|
50108
|
+
let lastKept;
|
|
50109
|
+
if (roundPos > 0) {
|
|
50110
|
+
lastKept = Number(fracPart[roundPos - 1]);
|
|
50111
|
+
} else {
|
|
50112
|
+
lastKept = intPart.length > 0 ? Number(intPart[intPart.length - 1]) : 0;
|
|
50113
|
+
}
|
|
50114
|
+
const isNegative = sign < 0;
|
|
50109
50115
|
let carry = 0;
|
|
50110
|
-
if (roundingDigit > 5
|
|
50111
|
-
|
|
50112
|
-
|
|
50113
|
-
if (
|
|
50116
|
+
if (roundingDigit > 5) {
|
|
50117
|
+
carry = 1;
|
|
50118
|
+
} else if (roundingDigit === 5) {
|
|
50119
|
+
if (hasTail || isNegative || lastKept % 2 === 1) {
|
|
50114
50120
|
carry = 1;
|
|
50115
|
-
|
|
50121
|
+
}
|
|
50122
|
+
}
|
|
50123
|
+
let frac = fracPart.slice(0, roundPos).padEnd(decimals, "0");
|
|
50124
|
+
let int = intPart || "0";
|
|
50125
|
+
if (carry) {
|
|
50126
|
+
if (decimals === 0) {
|
|
50127
|
+
int = (Number(int) + 1).toString();
|
|
50116
50128
|
} else {
|
|
50117
|
-
|
|
50129
|
+
let i = decimals - 1;
|
|
50130
|
+
while (i >= 0) {
|
|
50131
|
+
if (frac[i] !== "9") {
|
|
50132
|
+
frac = frac.slice(0, i) + (Number(frac[i]) + 1) + frac.slice(i + 1);
|
|
50133
|
+
break;
|
|
50134
|
+
}
|
|
50135
|
+
frac = frac.slice(0, i) + "0" + frac.slice(i + 1);
|
|
50136
|
+
i--;
|
|
50137
|
+
}
|
|
50138
|
+
if (i < 0) {
|
|
50139
|
+
int = (Number(int) + 1).toString();
|
|
50140
|
+
frac = "0".repeat(decimals);
|
|
50141
|
+
}
|
|
50118
50142
|
}
|
|
50119
50143
|
}
|
|
50120
|
-
const
|
|
50121
|
-
|
|
50122
|
-
return Number(result2);
|
|
50144
|
+
const resultStr = int + (decimals > 0 ? "." + frac : "");
|
|
50145
|
+
return sign * Number(resultStr);
|
|
50123
50146
|
}
|
|
50124
50147
|
const fFormatRuNumber = (a, options) => {
|
|
50125
50148
|
if (typeof a !== "number" || isNaN(a)) return (options == null ? void 0 : options.returnNumber) ? NaN : "";
|