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