pace-table-lib 1.0.29 → 1.0.30

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.
@@ -8112,6 +8112,11 @@ function formatDate(value, formatKey) {
8112
8112
  }
8113
8113
  function formatValue(value, format, decimalValues = 2, displayUnit = DISPLAY_UNITS_OBJ.NONE) {
8114
8114
  try {
8115
+ let safeDecimalValues = Number(decimalValues);
8116
+ if (!Number.isFinite(safeDecimalValues)) {
8117
+ safeDecimalValues = 2;
8118
+ }
8119
+ safeDecimalValues = Math.min(20, Math.max(0, Math.floor(safeDecimalValues)));
8115
8120
  let floatValue = Number(value);
8116
8121
  if (isNaN(floatValue)) return value;
8117
8122
  if (DATE_FORMATS.includes(format)) {
@@ -8131,8 +8136,8 @@ function formatValue(value, format, decimalValues = 2, displayUnit = DISPLAY_UNI
8131
8136
  }
8132
8137
  if (format === VALUE_FORMAT_OBJ.PERCENT || format === VALUE_FORMAT_OBJ.PERCENT_SHORT) {
8133
8138
  return new Intl.NumberFormat(void 0, {
8134
- minimumFractionDigits: decimalValues,
8135
- maximumFractionDigits: decimalValues
8139
+ minimumFractionDigits: safeDecimalValues,
8140
+ maximumFractionDigits: safeDecimalValues
8136
8141
  }).format(floatValue * 100) + "%";
8137
8142
  }
8138
8143
  const currencyMap = {
@@ -8154,21 +8159,21 @@ function formatValue(value, format, decimalValues = 2, displayUnit = DISPLAY_UNI
8154
8159
  const formatted = new Intl.NumberFormat(locale, {
8155
8160
  style: "currency",
8156
8161
  currency,
8157
- minimumFractionDigits: decimalValues,
8158
- maximumFractionDigits: decimalValues
8162
+ minimumFractionDigits: safeDecimalValues,
8163
+ maximumFractionDigits: safeDecimalValues
8159
8164
  }).format(floatValue);
8160
8165
  return formatted + displayUnitsPostFix;
8161
8166
  }
8162
8167
  if (format === VALUE_FORMAT_OBJ.SCIENTIFIC || format === VALUE_FORMAT_OBJ.SCIENTIFIC_SHORT) {
8163
- return floatValue.toExponential(decimalValues) + displayUnitsPostFix;
8168
+ return floatValue.toExponential(safeDecimalValues) + displayUnitsPostFix;
8164
8169
  }
8165
8170
  if (format === VALUE_FORMAT_OBJ.COMMA || format === VALUE_FORMAT_OBJ.COMMA_SHORT || format === VALUE_FORMAT_OBJ.GENERAL || format === VALUE_FORMAT_OBJ.GENERAL_EMPTY) {
8166
8171
  return new Intl.NumberFormat(void 0, {
8167
- minimumFractionDigits: decimalValues,
8168
- maximumFractionDigits: decimalValues
8172
+ minimumFractionDigits: safeDecimalValues,
8173
+ maximumFractionDigits: safeDecimalValues
8169
8174
  }).format(floatValue) + displayUnitsPostFix;
8170
8175
  }
8171
- return floatValue.toFixed(decimalValues) + displayUnitsPostFix;
8176
+ return floatValue.toFixed(safeDecimalValues) + displayUnitsPostFix;
8172
8177
  } catch (error) {
8173
8178
  console.error("Error in formatValue:", error);
8174
8179
  return value;
@@ -17430,7 +17435,7 @@ function StaticTable({
17430
17435
  const textArr = measuresBySlice?.map((item) => item.sliceMark)?.flat();
17431
17436
  if (textArr === void 0 || textArr.length === 0) return Table2?.RowHeight;
17432
17437
  const longest = textArr?.reduce(
17433
- (a, b) => b.length > a.length ? b : a
17438
+ (a, b) => b?.length > a?.length ? b : a
17434
17439
  );
17435
17440
  const finalHeight = calculateWidthHeightDynamically(longest, Number(rowHeaderFont.fontSize), rowHeaderFont.fontFamily, Table2.FixHeaderWidth);
17436
17441
  return finalHeight;
@@ -17452,8 +17457,8 @@ function StaticTable({
17452
17457
  rowCellH = newRowHeight;
17453
17458
  }
17454
17459
  if (isFitTableOn) {
17455
- const sharedWidth = tableWidth / columnCount;
17456
- const sharedHeight = tableHeight / rowCount;
17460
+ const sharedWidth = Math.floor(tableWidth / columnCount);
17461
+ const sharedHeight = Math.floor(tableHeight / rowCount);
17457
17462
  colCellH = sharedHeight;
17458
17463
  rowCellH = sharedHeight;
17459
17464
  nonFixColCellW = sharedWidth;