pace-table-lib 1.0.29 → 1.0.31

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.
@@ -8020,9 +8020,16 @@ function getSpan(arr, index, level) {
8020
8020
  return span;
8021
8021
  }
8022
8022
  function getCleanString(dimensionMark) {
8023
- if (!dimensionMark) return dimensionMark;
8024
- const parts = dimensionMark.split("~$~");
8025
- return parts.length > 1 ? parts[1] : dimensionMark;
8023
+ try {
8024
+ if (!dimensionMark) return dimensionMark;
8025
+ if (dimensionMark.includes("~$~")) {
8026
+ const parts = dimensionMark.split("~$~");
8027
+ return parts[1] ?? dimensionMark;
8028
+ }
8029
+ } catch (error) {
8030
+ console.log(error);
8031
+ }
8032
+ return dimensionMark;
8026
8033
  }
8027
8034
  function isFirstOccurrence(arr, index, level) {
8028
8035
  return index === 0 || arr[index].slice(0, level + 1).join("~$~") !== arr[index - 1].slice(0, level + 1).join("~$~");
@@ -8112,6 +8119,11 @@ function formatDate(value, formatKey) {
8112
8119
  }
8113
8120
  function formatValue(value, format, decimalValues = 2, displayUnit = DISPLAY_UNITS_OBJ.NONE) {
8114
8121
  try {
8122
+ let safeDecimalValues = Number(decimalValues);
8123
+ if (!Number.isFinite(safeDecimalValues)) {
8124
+ safeDecimalValues = 2;
8125
+ }
8126
+ safeDecimalValues = Math.min(20, Math.max(0, Math.floor(safeDecimalValues)));
8115
8127
  let floatValue = Number(value);
8116
8128
  if (isNaN(floatValue)) return value;
8117
8129
  if (DATE_FORMATS.includes(format)) {
@@ -8131,8 +8143,8 @@ function formatValue(value, format, decimalValues = 2, displayUnit = DISPLAY_UNI
8131
8143
  }
8132
8144
  if (format === VALUE_FORMAT_OBJ.PERCENT || format === VALUE_FORMAT_OBJ.PERCENT_SHORT) {
8133
8145
  return new Intl.NumberFormat(void 0, {
8134
- minimumFractionDigits: decimalValues,
8135
- maximumFractionDigits: decimalValues
8146
+ minimumFractionDigits: safeDecimalValues,
8147
+ maximumFractionDigits: safeDecimalValues
8136
8148
  }).format(floatValue * 100) + "%";
8137
8149
  }
8138
8150
  const currencyMap = {
@@ -8154,21 +8166,21 @@ function formatValue(value, format, decimalValues = 2, displayUnit = DISPLAY_UNI
8154
8166
  const formatted = new Intl.NumberFormat(locale, {
8155
8167
  style: "currency",
8156
8168
  currency,
8157
- minimumFractionDigits: decimalValues,
8158
- maximumFractionDigits: decimalValues
8169
+ minimumFractionDigits: safeDecimalValues,
8170
+ maximumFractionDigits: safeDecimalValues
8159
8171
  }).format(floatValue);
8160
8172
  return formatted + displayUnitsPostFix;
8161
8173
  }
8162
8174
  if (format === VALUE_FORMAT_OBJ.SCIENTIFIC || format === VALUE_FORMAT_OBJ.SCIENTIFIC_SHORT) {
8163
- return floatValue.toExponential(decimalValues) + displayUnitsPostFix;
8175
+ return floatValue.toExponential(safeDecimalValues) + displayUnitsPostFix;
8164
8176
  }
8165
8177
  if (format === VALUE_FORMAT_OBJ.COMMA || format === VALUE_FORMAT_OBJ.COMMA_SHORT || format === VALUE_FORMAT_OBJ.GENERAL || format === VALUE_FORMAT_OBJ.GENERAL_EMPTY) {
8166
8178
  return new Intl.NumberFormat(void 0, {
8167
- minimumFractionDigits: decimalValues,
8168
- maximumFractionDigits: decimalValues
8179
+ minimumFractionDigits: safeDecimalValues,
8180
+ maximumFractionDigits: safeDecimalValues
8169
8181
  }).format(floatValue) + displayUnitsPostFix;
8170
8182
  }
8171
- return floatValue.toFixed(decimalValues) + displayUnitsPostFix;
8183
+ return floatValue.toFixed(safeDecimalValues) + displayUnitsPostFix;
8172
8184
  } catch (error) {
8173
8185
  console.error("Error in formatValue:", error);
8174
8186
  return value;
@@ -17430,7 +17442,7 @@ function StaticTable({
17430
17442
  const textArr = measuresBySlice?.map((item) => item.sliceMark)?.flat();
17431
17443
  if (textArr === void 0 || textArr.length === 0) return Table2?.RowHeight;
17432
17444
  const longest = textArr?.reduce(
17433
- (a, b) => b.length > a.length ? b : a
17445
+ (a, b) => b?.length > a?.length ? b : a
17434
17446
  );
17435
17447
  const finalHeight = calculateWidthHeightDynamically(longest, Number(rowHeaderFont.fontSize), rowHeaderFont.fontFamily, Table2.FixHeaderWidth);
17436
17448
  return finalHeight;
@@ -17452,8 +17464,8 @@ function StaticTable({
17452
17464
  rowCellH = newRowHeight;
17453
17465
  }
17454
17466
  if (isFitTableOn) {
17455
- const sharedWidth = tableWidth / columnCount;
17456
- const sharedHeight = tableHeight / rowCount;
17467
+ const sharedWidth = Math.floor(tableWidth / columnCount);
17468
+ const sharedHeight = Math.floor(tableHeight / rowCount);
17457
17469
  colCellH = sharedHeight;
17458
17470
  rowCellH = sharedHeight;
17459
17471
  nonFixColCellW = sharedWidth;