@pagamio/frontend-commons-lib 0.8.297 → 0.8.298
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.
|
@@ -123,12 +123,16 @@ const formatUrlString = (value) => {
|
|
|
123
123
|
const formatNumberValue = (value, columnKey) => {
|
|
124
124
|
if (columnKey && (columnKey.toLowerCase().includes('amount') || columnKey.toLowerCase().includes('price'))) {
|
|
125
125
|
// Format as currency with proper symbol
|
|
126
|
+
// Replace non-breaking spaces (U+00A0) with regular spaces to prevent
|
|
127
|
+
// encoding corruption when CSV is opened in Excel with non-UTF-8 encoding
|
|
126
128
|
return new Intl.NumberFormat('en-ZA', {
|
|
127
129
|
style: 'currency',
|
|
128
130
|
currency: 'ZAR',
|
|
129
131
|
minimumFractionDigits: 2,
|
|
130
132
|
maximumFractionDigits: 2,
|
|
131
|
-
})
|
|
133
|
+
})
|
|
134
|
+
.format(value)
|
|
135
|
+
.replace(/\u00A0/g, ' ');
|
|
132
136
|
}
|
|
133
137
|
return value.toString();
|
|
134
138
|
};
|
|
@@ -276,8 +280,8 @@ export const exportToCsv = (data, columns, options = {}) => {
|
|
|
276
280
|
}
|
|
277
281
|
// Combine metadata comments with CSV content
|
|
278
282
|
const finalContent = csvRows.length > 0 ? csvRows.join('\n') + '\n' + csvContent : csvContent;
|
|
279
|
-
// Create and download file
|
|
280
|
-
const blob = new Blob([finalContent], { type: 'text/csv;charset=utf-8;' });
|
|
283
|
+
// Create and download file — prepend UTF-8 BOM so Excel detects encoding correctly
|
|
284
|
+
const blob = new Blob(['\uFEFF' + finalContent], { type: 'text/csv;charset=utf-8;' });
|
|
281
285
|
const link = document.createElement('a');
|
|
282
286
|
link.href = URL.createObjectURL(blob);
|
|
283
287
|
// Generate filename with timestamp if not provided
|
|
@@ -839,7 +843,7 @@ export const generateExportAsFile = async (data, columns, format, options) => {
|
|
|
839
843
|
return value !== null && value !== undefined ? String(value) : '';
|
|
840
844
|
}));
|
|
841
845
|
const csvContent = Papa.unparse({ fields: headers, data: rows });
|
|
842
|
-
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
|
|
846
|
+
const blob = new Blob(['\uFEFF' + csvContent], { type: 'text/csv;charset=utf-8;' });
|
|
843
847
|
return new File([blob], `${baseFilename}.csv`, { type: 'text/csv' });
|
|
844
848
|
}
|
|
845
849
|
if (format === 'xlsx') {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagamio/frontend-commons-lib",
|
|
3
3
|
"description": "Pagamio library for Frontend reusable components like the form engine and table container",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.298",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": false
|