@megha-ui/react 1.2.67 → 1.2.69
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.
|
@@ -210,8 +210,6 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
210
210
|
new Date(value).getTime() < end);
|
|
211
211
|
}
|
|
212
212
|
else if (start && end) {
|
|
213
|
-
console.log(start, end, value, parseFloat(start.trim()) < parseFloat(value) &&
|
|
214
|
-
parseFloat(value) < parseFloat(end.trim()));
|
|
215
213
|
return (parseFloat(start.trim()) < parseFloat(value) &&
|
|
216
214
|
parseFloat(value) < parseFloat(end.trim()));
|
|
217
215
|
}
|
|
@@ -112,11 +112,13 @@ const GridRow = ({ item, rowStyle, cellStyle, rowHeight, bulkSelect, selectedRow
|
|
|
112
112
|
const cellData = item[column.key];
|
|
113
113
|
const cellValue = cellData && Object.keys(cellData).includes("html")
|
|
114
114
|
? cellData === null || cellData === void 0 ? void 0 : cellData.html
|
|
115
|
-
: cellData && Object.keys(cellData).includes("
|
|
116
|
-
? cellData === null || cellData === void 0 ? void 0 : cellData.
|
|
117
|
-
: cellData
|
|
118
|
-
? cellData
|
|
119
|
-
:
|
|
115
|
+
: cellData && Object.keys(cellData).includes("displayValue")
|
|
116
|
+
? cellData === null || cellData === void 0 ? void 0 : cellData.displayValue
|
|
117
|
+
: cellData && Object.keys(cellData).includes("value")
|
|
118
|
+
? cellData === null || cellData === void 0 ? void 0 : cellData.value
|
|
119
|
+
: cellData
|
|
120
|
+
? cellData
|
|
121
|
+
: "";
|
|
120
122
|
const cellUrl = cellData === null || cellData === void 0 ? void 0 : cellData.url;
|
|
121
123
|
const isHidden = column.overflowHidden;
|
|
122
124
|
if (!column.hidden && groupBy !== column.key) {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatValue = void 0;
|
|
4
|
+
// Function to format numbers
|
|
5
|
+
const formatNumber = (value, locale = "en-US", options = {}) => {
|
|
6
|
+
const formatter = new Intl.NumberFormat(locale, options);
|
|
7
|
+
return formatter.format(value);
|
|
8
|
+
};
|
|
9
|
+
// Function to format dates
|
|
10
|
+
const formatDate = (date, locale = "en-US", options = {}) => {
|
|
11
|
+
const formatter = new Intl.DateTimeFormat(locale, options);
|
|
12
|
+
return formatter.format(date);
|
|
13
|
+
};
|
|
14
|
+
// Function to format currency
|
|
15
|
+
const formatCurrency = (value, locale = "en-US", currency = "USD", options = {}) => {
|
|
16
|
+
const formatter = new Intl.NumberFormat(locale, Object.assign({ style: "currency", currency: currency }, options));
|
|
17
|
+
return formatter.format(value);
|
|
18
|
+
};
|
|
19
|
+
// Dynamic formatter function
|
|
20
|
+
const formatValue = (value, type = "number", locale = "sv-SE", options = {
|
|
21
|
+
currency: "SEK",
|
|
22
|
+
}) => {
|
|
23
|
+
if (type === "number") {
|
|
24
|
+
const num = parseFloat(value.toString());
|
|
25
|
+
return formatNumber(num, locale, options);
|
|
26
|
+
}
|
|
27
|
+
else if (type === "date") {
|
|
28
|
+
const date = new Date(value);
|
|
29
|
+
return formatDate(date, locale, options);
|
|
30
|
+
}
|
|
31
|
+
else if (type === "currency" && typeof value === "number") {
|
|
32
|
+
return formatCurrency(value, locale, options.currency, options);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.formatValue = formatValue;
|
package/package.json
CHANGED