@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 C(e, t) {
2
- const r = Math.abs(e), o = e < 0 ? "-" : "";
3
- return r >= 1e12 ? `${o}${(r / 1e12).toFixed(t)}T` : r >= 1e9 ? `${o}${(r / 1e9).toFixed(t)}B` : r >= 1e6 ? `${o}${(r / 1e6).toFixed(t)}M` : r >= 1e3 ? `${o}${(r / 1e3).toFixed(t)}k` : e.toFixed(t);
4
- }
5
- const N = {
6
- // Fixed decimal places
7
- VC_PRECISION_0: (e) => Number(e).toFixed(0),
8
- VC_PRECISION_1: (e) => Number(e).toFixed(1),
9
- VC_PRECISION_2: (e) => Number(e).toFixed(2),
10
- VC_PRECISION_3: (e) => Number(e).toFixed(3),
11
- VC_PRECISION_4: (e) => Number(e).toFixed(4),
12
- VC_PRECISION_5: (e) => Number(e).toFixed(5),
13
- VC_PRECISION_6: (e) => Number(e).toFixed(6),
14
- // Significant digits
15
- VC_SIGNIFICANT_1: (e) => Number(e).toPrecision(1),
16
- VC_SIGNIFICANT_2: (e) => Number(e).toPrecision(2),
17
- VC_SIGNIFICANT_3: (e) => Number(e).toPrecision(3),
18
- VC_SIGNIFICANT_4: (e) => Number(e).toPrecision(4),
19
- VC_SIGNIFICANT_5: (e) => Number(e).toPrecision(5),
20
- VC_SIGNIFICANT_6: (e) => Number(e).toPrecision(6),
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: (e) => C(Number(e), 0),
23
- VC_COMPACT_1: (e) => C(Number(e), 1),
24
- VC_COMPACT_2: (e) => C(Number(e), 2),
25
- // Percentage formatting (multiplies by 100)
26
- VC_PERCENT_0: (e) => `${(Number(e) * 100).toFixed(0)}%`,
27
- VC_PERCENT_1: (e) => `${(Number(e) * 100).toFixed(1)}%`,
28
- VC_PERCENT_2: (e) => `${(Number(e) * 100).toFixed(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 _(e) {
31
- return N[e];
65
+ function x(t) {
66
+ return h[t];
32
67
  }
33
- function i(e) {
34
- const t = N[e.token];
35
- return (r) => `${e.prefix}${t(r)}${e.suffix}`;
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
- i as createTemplateFormatter,
39
- N as formatterRegistry,
40
- _ as getFormatter
73
+ V as createTemplateFormatter,
74
+ h as formatterRegistry,
75
+ x as getFormatter
41
76
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@validationcloud/fractal-ui",
3
3
  "private": false,
4
- "version": "1.60.0",
4
+ "version": "1.61.0",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",
7
7
  "files": [