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.umd.js
CHANGED
@@ -1945,7 +1945,8 @@
|
|
1945
1945
|
_onChange = column.onChange,
|
1946
1946
|
format = column.format,
|
1947
1947
|
options = column.options,
|
1948
|
-
action = column.action
|
1948
|
+
action = column.action,
|
1949
|
+
maxDecimals = column.maxDecimals;
|
1949
1950
|
|
1950
1951
|
if (id === "checked") {
|
1951
1952
|
return /*#__PURE__*/React__default["default"].createElement(CheckBox, {
|
@@ -2077,7 +2078,8 @@
|
|
2077
2078
|
return /*#__PURE__*/React__default["default"].createElement(NumberCellViewer, {
|
2078
2079
|
id: id,
|
2079
2080
|
value: cell,
|
2080
|
-
format: format
|
2081
|
+
format: format,
|
2082
|
+
maxDecimals: maxDecimals
|
2081
2083
|
});
|
2082
2084
|
|
2083
2085
|
default:
|
@@ -2184,11 +2186,27 @@
|
|
2184
2186
|
format = _ref7.format,
|
2185
2187
|
maxDecimals = _ref7.maxDecimals;
|
2186
2188
|
|
2187
|
-
|
2188
|
-
|
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
|
+
|
2189
2208
|
if (number === null) return "null";
|
2190
|
-
var
|
2191
|
-
var result = number2.toLocaleString('es-ES', {
|
2209
|
+
var result = number.toLocaleString('es-ES', {
|
2192
2210
|
minimumFractionDigits: 2,
|
2193
2211
|
maximumFractionDigits: 2
|
2194
2212
|
}); // thousands separator is a dot
|
@@ -2196,8 +2214,10 @@
|
|
2196
2214
|
var parts = result.toString().split(",");
|
2197
2215
|
var numberPart = parts[0];
|
2198
2216
|
var decimalPart = parts[1];
|
2199
|
-
var thousands = /\B(?=(\d{3})+(?!\d))/g;
|
2200
|
-
|
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 : "");
|
2201
2221
|
}
|
2202
2222
|
|
2203
2223
|
if (format) {
|
@@ -2218,11 +2238,9 @@
|
|
2218
2238
|
// convert value to number
|
2219
2239
|
var number = Number(value); // if value is not a number, return value
|
2220
2240
|
|
2221
|
-
if (isNaN(number)) return value; //
|
2222
|
-
|
2223
|
-
if (maxDecimals) number = number.toFixed(maxDecimals); // format number
|
2241
|
+
if (isNaN(number)) return value; // format number
|
2224
2242
|
|
2225
|
-
return /*#__PURE__*/React__default["default"].createElement("span", null, formatNumber(number));
|
2243
|
+
return /*#__PURE__*/React__default["default"].createElement("span", null, formatNumber(number, maxDecimals));
|
2226
2244
|
|
2227
2245
|
default:
|
2228
2246
|
return /*#__PURE__*/React__default["default"].createElement("span", null, value);
|