@lotics/app-sdk 0.131.1 → 0.131.2
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/index.js +30 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2852,7 +2852,7 @@ __export(expression_string_exports, {
|
|
|
2852
2852
|
contains: () => contains,
|
|
2853
2853
|
endsWith: () => endsWith,
|
|
2854
2854
|
formatDecimal: () => formatDecimal,
|
|
2855
|
-
formatNumber: () =>
|
|
2855
|
+
formatNumber: () => formatNumber2,
|
|
2856
2856
|
join: () => join,
|
|
2857
2857
|
length: () => length,
|
|
2858
2858
|
localeCompare: () => localeCompare,
|
|
@@ -3241,6 +3241,27 @@ function uuidV5(name, namespace) {
|
|
|
3241
3241
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
3242
3242
|
}
|
|
3243
3243
|
|
|
3244
|
+
// ../shared/src/format_unit.ts
|
|
3245
|
+
function signed(format2, n) {
|
|
3246
|
+
return n < 0 ? `\u2212${format2(-n)}` : format2(n + 0);
|
|
3247
|
+
}
|
|
3248
|
+
|
|
3249
|
+
// ../shared/src/format_money.ts
|
|
3250
|
+
function numberFormatter(locale, maximumFractionDigits) {
|
|
3251
|
+
const key = `${locale}\0${maximumFractionDigits}`;
|
|
3252
|
+
let format2 = numberFormatters.get(key);
|
|
3253
|
+
if (format2 === void 0) {
|
|
3254
|
+
format2 = new Intl.NumberFormat(locale, { maximumFractionDigits });
|
|
3255
|
+
numberFormatters.set(key, format2);
|
|
3256
|
+
}
|
|
3257
|
+
return format2;
|
|
3258
|
+
}
|
|
3259
|
+
var numberFormatters = /* @__PURE__ */ new Map();
|
|
3260
|
+
function formatNumber(value, options = {}) {
|
|
3261
|
+
const { locale = "vi-VN", maxFractionDigits = 2 } = options;
|
|
3262
|
+
return signed((magnitude) => numberFormatter(locale, maxFractionDigits).format(magnitude), value);
|
|
3263
|
+
}
|
|
3264
|
+
|
|
3244
3265
|
// ../shared/src/expression_string.ts
|
|
3245
3266
|
function join(arr, separator = ",") {
|
|
3246
3267
|
if (arr == null) return "";
|
|
@@ -3625,7 +3646,7 @@ function enNumberToWords(n, negative) {
|
|
|
3625
3646
|
const result = parts.join(" ");
|
|
3626
3647
|
return negative ? "minus " + result : result;
|
|
3627
3648
|
}
|
|
3628
|
-
function
|
|
3649
|
+
function formatNumber2(value, decimals) {
|
|
3629
3650
|
if (value == null) return "";
|
|
3630
3651
|
if (typeof value !== "number" || Number.isNaN(value)) {
|
|
3631
3652
|
throw new ExpressionArgumentError("formatNumber: expected number, got " + typeof value);
|
|
@@ -3638,6 +3659,13 @@ function formatDecimal(value, decimals, locale) {
|
|
|
3638
3659
|
if (typeof value !== "number" || Number.isNaN(value)) {
|
|
3639
3660
|
throw new ExpressionArgumentError("formatDecimal: expected number, got " + typeof value);
|
|
3640
3661
|
}
|
|
3662
|
+
if (typeof decimals === "string" && locale === void 0) {
|
|
3663
|
+
if (!isUsableLocale(decimals)) {
|
|
3664
|
+
throw new ExpressionArgumentError(`formatDecimal(value, locale) requires a locale tag, got "${decimals}". Example: formatDecimal(2.5, "vi-VN").`);
|
|
3665
|
+
}
|
|
3666
|
+
return formatNumber(value, { locale: decimals });
|
|
3667
|
+
}
|
|
3668
|
+
if (typeof decimals !== "number") throw new ExpressionArgumentError("formatDecimal: decimals must be an integer between 0 and 100");
|
|
3641
3669
|
assertDecimals(decimals, "formatDecimal");
|
|
3642
3670
|
if (typeof locale !== "string" || locale === "" || !isUsableLocale(locale)) {
|
|
3643
3671
|
throw new ExpressionArgumentError(
|
package/package.json
CHANGED