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.umd.js CHANGED
@@ -1758,7 +1758,12 @@
1758
1758
  }
1759
1759
 
1760
1760
  var keySort = function keySort(a, b, direction) {
1761
- direction = direction !== null ? direction : 1;
1761
+ direction = direction !== null ? direction : 1; // check if a and b are numbers and compare as numbers
1762
+
1763
+ if (!isNaN(a) && !isNaN(b)) {
1764
+ a = Number(a);
1765
+ b = Number(b);
1766
+ }
1762
1767
 
1763
1768
  if (a === b) {
1764
1769
  // If the values are the same, do not switch positions.
@@ -1940,7 +1945,8 @@
1940
1945
  _onChange = column.onChange,
1941
1946
  format = column.format,
1942
1947
  options = column.options,
1943
- action = column.action;
1948
+ action = column.action,
1949
+ maxDecimals = column.maxDecimals;
1944
1950
 
1945
1951
  if (id === "checked") {
1946
1952
  return /*#__PURE__*/React__default["default"].createElement(CheckBox, {
@@ -2072,7 +2078,8 @@
2072
2078
  return /*#__PURE__*/React__default["default"].createElement(NumberCellViewer, {
2073
2079
  id: id,
2074
2080
  value: cell,
2075
- format: format
2081
+ format: format,
2082
+ maxDecimals: maxDecimals
2076
2083
  });
2077
2084
 
2078
2085
  default:
@@ -2179,11 +2186,27 @@
2179
2186
  format = _ref7.format,
2180
2187
  maxDecimals = _ref7.maxDecimals;
2181
2188
 
2182
- function formatNumber(number) {
2183
- // convert number to numeric
2189
+ /*
2190
+ function formatNumber(number) {
2191
+ // convert number to numeric
2192
+ if (number === null) return "null"
2193
+ const number2 = Number(number)
2194
+ let result = number2.toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
2195
+ // thousands separator is a dot
2196
+ var parts = result.toString().split(",");
2197
+ const numberPart = parts[0];
2198
+ const decimalPart = parts[1];
2199
+ const thousands = /\B(?=(\d{3})+(?!\d))/g;
2200
+ return numberPart.replace(thousands, ".") + (decimalPart ? "," + decimalPart : "");
2201
+ }
2202
+ */
2203
+ function formatNumber(number, maxDecimals) {
2204
+ if (maxDecimals === void 0) {
2205
+ maxDecimals = 0;
2206
+ }
2207
+
2184
2208
  if (number === null) return "null";
2185
- var number2 = Number(number);
2186
- var result = number2.toLocaleString('es-ES', {
2209
+ var result = number.toLocaleString('es-ES', {
2187
2210
  minimumFractionDigits: 2,
2188
2211
  maximumFractionDigits: 2
2189
2212
  }); // thousands separator is a dot
@@ -2191,8 +2214,10 @@
2191
2214
  var parts = result.toString().split(",");
2192
2215
  var numberPart = parts[0];
2193
2216
  var decimalPart = parts[1];
2194
- var thousands = /\B(?=(\d{3})+(?!\d))/g;
2195
- return numberPart.replace(thousands, ".") + (decimalPart ? "," + decimalPart : "");
2217
+ var thousands = /\B(?=(\d{3})+(?!\d))/g; // limit decimal part to maxdecimals
2218
+
2219
+ var decimal = decimalPart ? decimalPart.substring(0, maxDecimals) : null;
2220
+ return numberPart.replace(thousands, ".") + (decimal ? "," + decimal : "");
2196
2221
  }
2197
2222
 
2198
2223
  if (format) {
@@ -2213,11 +2238,9 @@
2213
2238
  // convert value to number
2214
2239
  var number = Number(value); // if value is not a number, return value
2215
2240
 
2216
- if (isNaN(number)) return value; // if maxDecimals is defined, round number
2217
-
2218
- if (maxDecimals) number = number.toFixed(maxDecimals); // format number
2241
+ if (isNaN(number)) return value; // format number
2219
2242
 
2220
- return /*#__PURE__*/React__default["default"].createElement("span", null, formatNumber(number));
2243
+ return /*#__PURE__*/React__default["default"].createElement("span", null, formatNumber(number, maxDecimals));
2221
2244
 
2222
2245
  default:
2223
2246
  return /*#__PURE__*/React__default["default"].createElement("span", null, value);