ywana-core8 0.0.780 → 0.0.782
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.
- package/dist/index.cjs +36 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +36 -13
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +36 -13
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/table.js +24 -7
- package/src/html/table.test.js +11 -11
package/dist/index.cjs
CHANGED
@@ -1764,7 +1764,12 @@ var DataTable = function DataTable(props) {
|
|
1764
1764
|
}
|
1765
1765
|
|
1766
1766
|
var keySort = function keySort(a, b, direction) {
|
1767
|
-
direction = direction !== null ? direction : 1;
|
1767
|
+
direction = direction !== null ? direction : 1; // check if a and b are numbers and compare as numbers
|
1768
|
+
|
1769
|
+
if (!isNaN(a) && !isNaN(b)) {
|
1770
|
+
a = Number(a);
|
1771
|
+
b = Number(b);
|
1772
|
+
}
|
1768
1773
|
|
1769
1774
|
if (a === b) {
|
1770
1775
|
// If the values are the same, do not switch positions.
|
@@ -1946,7 +1951,8 @@ var DataTableCell = function DataTableCell(_ref4) {
|
|
1946
1951
|
_onChange = column.onChange,
|
1947
1952
|
format = column.format,
|
1948
1953
|
options = column.options,
|
1949
|
-
action = column.action
|
1954
|
+
action = column.action,
|
1955
|
+
maxDecimals = column.maxDecimals;
|
1950
1956
|
|
1951
1957
|
if (id === "checked") {
|
1952
1958
|
return /*#__PURE__*/React__default["default"].createElement(CheckBox, {
|
@@ -2078,7 +2084,8 @@ var DataTableCell = function DataTableCell(_ref4) {
|
|
2078
2084
|
return /*#__PURE__*/React__default["default"].createElement(NumberCellViewer, {
|
2079
2085
|
id: id,
|
2080
2086
|
value: cell,
|
2081
|
-
format: format
|
2087
|
+
format: format,
|
2088
|
+
maxDecimals: maxDecimals
|
2082
2089
|
});
|
2083
2090
|
|
2084
2091
|
default:
|
@@ -2185,11 +2192,27 @@ var NumberCellViewer = function NumberCellViewer(_ref7) {
|
|
2185
2192
|
format = _ref7.format,
|
2186
2193
|
maxDecimals = _ref7.maxDecimals;
|
2187
2194
|
|
2188
|
-
|
2189
|
-
|
2195
|
+
/*
|
2196
|
+
function formatNumber(number) {
|
2197
|
+
// convert number to numeric
|
2198
|
+
if (number === null) return "null"
|
2199
|
+
const number2 = Number(number)
|
2200
|
+
let result = number2.toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
2201
|
+
// thousands separator is a dot
|
2202
|
+
var parts = result.toString().split(",");
|
2203
|
+
const numberPart = parts[0];
|
2204
|
+
const decimalPart = parts[1];
|
2205
|
+
const thousands = /\B(?=(\d{3})+(?!\d))/g;
|
2206
|
+
return numberPart.replace(thousands, ".") + (decimalPart ? "," + decimalPart : "");
|
2207
|
+
}
|
2208
|
+
*/
|
2209
|
+
function formatNumber(number, maxDecimals) {
|
2210
|
+
if (maxDecimals === void 0) {
|
2211
|
+
maxDecimals = 0;
|
2212
|
+
}
|
2213
|
+
|
2190
2214
|
if (number === null) return "null";
|
2191
|
-
var
|
2192
|
-
var result = number2.toLocaleString('es-ES', {
|
2215
|
+
var result = number.toLocaleString('es-ES', {
|
2193
2216
|
minimumFractionDigits: 2,
|
2194
2217
|
maximumFractionDigits: 2
|
2195
2218
|
}); // thousands separator is a dot
|
@@ -2197,8 +2220,10 @@ var NumberCellViewer = function NumberCellViewer(_ref7) {
|
|
2197
2220
|
var parts = result.toString().split(",");
|
2198
2221
|
var numberPart = parts[0];
|
2199
2222
|
var decimalPart = parts[1];
|
2200
|
-
var thousands = /\B(?=(\d{3})+(?!\d))/g;
|
2201
|
-
|
2223
|
+
var thousands = /\B(?=(\d{3})+(?!\d))/g; // limit decimal part to maxdecimals
|
2224
|
+
|
2225
|
+
var decimal = decimalPart ? decimalPart.substring(0, maxDecimals) : null;
|
2226
|
+
return numberPart.replace(thousands, ".") + (decimal ? "," + decimal : "");
|
2202
2227
|
}
|
2203
2228
|
|
2204
2229
|
if (format) {
|
@@ -2219,11 +2244,9 @@ var NumberCellViewer = function NumberCellViewer(_ref7) {
|
|
2219
2244
|
// convert value to number
|
2220
2245
|
var number = Number(value); // if value is not a number, return value
|
2221
2246
|
|
2222
|
-
if (isNaN(number)) return value; //
|
2223
|
-
|
2224
|
-
if (maxDecimals) number = number.toFixed(maxDecimals); // format number
|
2247
|
+
if (isNaN(number)) return value; // format number
|
2225
2248
|
|
2226
|
-
return /*#__PURE__*/React__default["default"].createElement("span", null, formatNumber(number));
|
2249
|
+
return /*#__PURE__*/React__default["default"].createElement("span", null, formatNumber(number, maxDecimals));
|
2227
2250
|
|
2228
2251
|
default:
|
2229
2252
|
return /*#__PURE__*/React__default["default"].createElement("span", null, value);
|