@inventreedb/ui 0.3.0 → 0.3.1

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.
@@ -22,13 +22,19 @@ export function formatDecimal(
22
22
  return value;
23
23
  }
24
24
 
25
- const formatter = new Intl.NumberFormat(locale, {
26
- style: 'decimal',
27
- maximumFractionDigits: options.digits ?? 6,
28
- minimumFractionDigits: options.minDigits ?? 0
29
- });
30
-
31
- return formatter.format(value);
25
+ try {
26
+ const formatter = new Intl.NumberFormat(locale, {
27
+ style: 'decimal',
28
+ maximumFractionDigits: options.digits ?? 6,
29
+ minimumFractionDigits: options.minDigits ?? 0
30
+ });
31
+
32
+ return formatter.format(value);
33
+ } catch (e) {
34
+ console.error('Error formatting decimal:', e);
35
+ // Return the unformatted value if formatting fails
36
+ return value;
37
+ }
32
38
  }
33
39
 
34
40
  /*
@@ -61,14 +67,20 @@ export function formatCurrencyValue(
61
67
  const minDigits = options.minDigits ?? 0;
62
68
  const maxDigits = options.digits ?? 6;
63
69
 
64
- const formatter = new Intl.NumberFormat(locale, {
65
- style: 'currency',
66
- currency: options.currency,
67
- maximumFractionDigits: Math.max(minDigits, maxDigits),
68
- minimumFractionDigits: Math.min(minDigits, maxDigits)
69
- });
70
-
71
- return formatter.format(value);
70
+ try {
71
+ const formatter = new Intl.NumberFormat(locale, {
72
+ style: 'currency',
73
+ currency: options.currency || 'USD',
74
+ maximumFractionDigits: Math.max(minDigits, maxDigits),
75
+ minimumFractionDigits: Math.min(minDigits, maxDigits)
76
+ });
77
+
78
+ return formatter.format(value);
79
+ } catch (e) {
80
+ console.error('Error formatting currency:', e);
81
+ // Return the unformatted value if formatting fails
82
+ return value;
83
+ }
72
84
  }
73
85
 
74
86
  /*
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inventreedb/ui",
3
3
  "description": "UI components for the InvenTree project",
4
- "version": "0.3.0",
4
+ "version": "0.3.1",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "license": "MIT",