@validationcloud/fractal-ui 1.60.0 → 1.61.0
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.
|
@@ -1,41 +1,76 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
function a(t) {
|
|
2
|
+
return t.includes(".") ? t.replace(/\.?0+$/, "") : t;
|
|
3
|
+
}
|
|
4
|
+
function d(t) {
|
|
5
|
+
const o = t.toString().split("."), e = o[0] ?? "0", r = o[1], c = e.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
6
|
+
return r !== void 0 ? `${c}.${r}` : c;
|
|
7
|
+
}
|
|
8
|
+
function n(t, o) {
|
|
9
|
+
const r = t.toFixed(o).split("."), c = r[0] ?? "0", i = r[1], s = c.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
10
|
+
return i !== void 0 ? `${s}.${i}` : s;
|
|
11
|
+
}
|
|
12
|
+
function _(t, o) {
|
|
13
|
+
const e = Math.abs(t), r = t < 0 ? "-" : "";
|
|
14
|
+
return e >= 1e12 ? `${r}${(e / 1e12).toFixed(o)}T` : e >= 1e9 ? `${r}${(e / 1e9).toFixed(o)}B` : e >= 1e6 ? `${r}${(e / 1e6).toFixed(o)}M` : e >= 1e3 ? `${r}${(e / 1e3).toFixed(o)}k` : a(n(t, o));
|
|
15
|
+
}
|
|
16
|
+
function I(t, o) {
|
|
17
|
+
if (t === 0) return 0;
|
|
18
|
+
const e = Math.floor(Math.log10(Math.abs(t))), r = Math.pow(10, o - e - 1);
|
|
19
|
+
return Math.round(t * r) / r;
|
|
20
|
+
}
|
|
21
|
+
function u(t, o) {
|
|
22
|
+
const e = Math.abs(t), r = t < 0 ? "-" : "", c = [
|
|
23
|
+
{ threshold: 1e12, divisor: 1e12, suffix: "T" },
|
|
24
|
+
{ threshold: 1e9, divisor: 1e9, suffix: "B" },
|
|
25
|
+
{ threshold: 1e6, divisor: 1e6, suffix: "M" },
|
|
26
|
+
{ threshold: 1e3, divisor: 1e3, suffix: "k" }
|
|
27
|
+
];
|
|
28
|
+
for (const s of c)
|
|
29
|
+
if (e >= s.threshold) {
|
|
30
|
+
const C = `${r}${d(e)}`, m = e / s.divisor, f = I(m, o), N = Math.floor(Math.log10(f)) + 1, $ = Math.max(0, o - N), l = `${r}${f.toFixed($)}${s.suffix}`, b = `${r}${a(f.toFixed($))}${s.suffix}`;
|
|
31
|
+
return l.length < C.length ? b : C;
|
|
32
|
+
}
|
|
33
|
+
const i = I(e, o);
|
|
34
|
+
if (i >= 1e3) {
|
|
35
|
+
const s = `${r}${d(i)}`, C = i / 1e3, m = Math.floor(Math.log10(C)) + 1, f = Math.max(0, o - m), N = `${r}${a(C.toFixed(f))}k`;
|
|
36
|
+
return N.length < s.length ? N : s;
|
|
37
|
+
}
|
|
38
|
+
return `${r}${a(d(i))}`;
|
|
39
|
+
}
|
|
40
|
+
const h = {
|
|
41
|
+
// Fixed decimal places with thousand separators
|
|
42
|
+
VC_PRECISION_0: (t) => n(Number(t), 0),
|
|
43
|
+
VC_PRECISION_1: (t) => n(Number(t), 1),
|
|
44
|
+
VC_PRECISION_2: (t) => n(Number(t), 2),
|
|
45
|
+
VC_PRECISION_3: (t) => n(Number(t), 3),
|
|
46
|
+
VC_PRECISION_4: (t) => n(Number(t), 4),
|
|
47
|
+
VC_PRECISION_5: (t) => n(Number(t), 5),
|
|
48
|
+
VC_PRECISION_6: (t) => n(Number(t), 6),
|
|
49
|
+
// Significant digits with compact notation (k/M/B/T) when shorter
|
|
50
|
+
VC_SIGNIFICANT_1: (t) => u(Number(t), 1),
|
|
51
|
+
VC_SIGNIFICANT_2: (t) => u(Number(t), 2),
|
|
52
|
+
VC_SIGNIFICANT_3: (t) => u(Number(t), 3),
|
|
53
|
+
VC_SIGNIFICANT_4: (t) => u(Number(t), 4),
|
|
54
|
+
VC_SIGNIFICANT_5: (t) => u(Number(t), 5),
|
|
55
|
+
VC_SIGNIFICANT_6: (t) => u(Number(t), 6),
|
|
21
56
|
// Compact notation
|
|
22
|
-
VC_COMPACT_0: (
|
|
23
|
-
VC_COMPACT_1: (
|
|
24
|
-
VC_COMPACT_2: (
|
|
25
|
-
// Percentage formatting (multiplies by 100)
|
|
26
|
-
VC_PERCENT_0: (
|
|
27
|
-
VC_PERCENT_1: (
|
|
28
|
-
VC_PERCENT_2: (
|
|
57
|
+
VC_COMPACT_0: (t) => _(Number(t), 0),
|
|
58
|
+
VC_COMPACT_1: (t) => _(Number(t), 1),
|
|
59
|
+
VC_COMPACT_2: (t) => _(Number(t), 2),
|
|
60
|
+
// Percentage formatting (multiplies by 100) with thousand separators, trailing zeros stripped
|
|
61
|
+
VC_PERCENT_0: (t) => `${n(Number(t) * 100, 0)}%`,
|
|
62
|
+
VC_PERCENT_1: (t) => `${a(n(Number(t) * 100, 1))}%`,
|
|
63
|
+
VC_PERCENT_2: (t) => `${a(n(Number(t) * 100, 2))}%`
|
|
29
64
|
};
|
|
30
|
-
function
|
|
31
|
-
return
|
|
65
|
+
function x(t) {
|
|
66
|
+
return h[t];
|
|
32
67
|
}
|
|
33
|
-
function
|
|
34
|
-
const
|
|
35
|
-
return (
|
|
68
|
+
function V(t) {
|
|
69
|
+
const o = h[t.token];
|
|
70
|
+
return (e) => `${t.prefix}${o(e)}${t.suffix}`;
|
|
36
71
|
}
|
|
37
72
|
export {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
73
|
+
V as createTemplateFormatter,
|
|
74
|
+
h as formatterRegistry,
|
|
75
|
+
x as getFormatter
|
|
41
76
|
};
|