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