ywana-core8 0.0.781 → 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 +30 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +30 -12
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +30 -12
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/table.js +18 -7
- package/src/html/table.test.js +10 -10
package/dist/index.cjs
CHANGED
@@ -1951,7 +1951,8 @@ var DataTableCell = function DataTableCell(_ref4) {
|
|
1951
1951
|
_onChange = column.onChange,
|
1952
1952
|
format = column.format,
|
1953
1953
|
options = column.options,
|
1954
|
-
action = column.action
|
1954
|
+
action = column.action,
|
1955
|
+
maxDecimals = column.maxDecimals;
|
1955
1956
|
|
1956
1957
|
if (id === "checked") {
|
1957
1958
|
return /*#__PURE__*/React__default["default"].createElement(CheckBox, {
|
@@ -2083,7 +2084,8 @@ var DataTableCell = function DataTableCell(_ref4) {
|
|
2083
2084
|
return /*#__PURE__*/React__default["default"].createElement(NumberCellViewer, {
|
2084
2085
|
id: id,
|
2085
2086
|
value: cell,
|
2086
|
-
format: format
|
2087
|
+
format: format,
|
2088
|
+
maxDecimals: maxDecimals
|
2087
2089
|
});
|
2088
2090
|
|
2089
2091
|
default:
|
@@ -2190,11 +2192,27 @@ var NumberCellViewer = function NumberCellViewer(_ref7) {
|
|
2190
2192
|
format = _ref7.format,
|
2191
2193
|
maxDecimals = _ref7.maxDecimals;
|
2192
2194
|
|
2193
|
-
|
2194
|
-
|
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
|
+
|
2195
2214
|
if (number === null) return "null";
|
2196
|
-
var
|
2197
|
-
var result = number2.toLocaleString('es-ES', {
|
2215
|
+
var result = number.toLocaleString('es-ES', {
|
2198
2216
|
minimumFractionDigits: 2,
|
2199
2217
|
maximumFractionDigits: 2
|
2200
2218
|
}); // thousands separator is a dot
|
@@ -2202,8 +2220,10 @@ var NumberCellViewer = function NumberCellViewer(_ref7) {
|
|
2202
2220
|
var parts = result.toString().split(",");
|
2203
2221
|
var numberPart = parts[0];
|
2204
2222
|
var decimalPart = parts[1];
|
2205
|
-
var thousands = /\B(?=(\d{3})+(?!\d))/g;
|
2206
|
-
|
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 : "");
|
2207
2227
|
}
|
2208
2228
|
|
2209
2229
|
if (format) {
|
@@ -2224,11 +2244,9 @@ var NumberCellViewer = function NumberCellViewer(_ref7) {
|
|
2224
2244
|
// convert value to number
|
2225
2245
|
var number = Number(value); // if value is not a number, return value
|
2226
2246
|
|
2227
|
-
if (isNaN(number)) return value; //
|
2228
|
-
|
2229
|
-
if (maxDecimals) number = number.toFixed(maxDecimals); // format number
|
2247
|
+
if (isNaN(number)) return value; // format number
|
2230
2248
|
|
2231
|
-
return /*#__PURE__*/React__default["default"].createElement("span", null, formatNumber(number));
|
2249
|
+
return /*#__PURE__*/React__default["default"].createElement("span", null, formatNumber(number, maxDecimals));
|
2232
2250
|
|
2233
2251
|
default:
|
2234
2252
|
return /*#__PURE__*/React__default["default"].createElement("span", null, value);
|