pace-table-lib 1.0.37 → 1.0.39

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.
@@ -8120,7 +8120,7 @@ function formatDate(value, formatKey) {
8120
8120
  function formatValue(value, format, decimalValues = 2, displayUnit = DISPLAY_UNITS_OBJ.NONE) {
8121
8121
  try {
8122
8122
  let safeDecimalValues = Number(decimalValues);
8123
- if (!Number.isFinite(safeDecimalValues)) {
8123
+ if (!Number.isFinite(safeDecimalValues) && safeDecimalValues !== 0) {
8124
8124
  safeDecimalValues = 2;
8125
8125
  }
8126
8126
  safeDecimalValues = Math.min(20, Math.max(0, Math.floor(safeDecimalValues)));
@@ -8174,13 +8174,18 @@ function formatValue(value, format, decimalValues = 2, displayUnit = DISPLAY_UNI
8174
8174
  if (format === VALUE_FORMAT_OBJ.SCIENTIFIC || format === VALUE_FORMAT_OBJ.SCIENTIFIC_SHORT) {
8175
8175
  return floatValue.toExponential(safeDecimalValues) + displayUnitsPostFix;
8176
8176
  }
8177
- if (format === VALUE_FORMAT_OBJ.COMMA || format === VALUE_FORMAT_OBJ.COMMA_SHORT || format === VALUE_FORMAT_OBJ.GENERAL || format === VALUE_FORMAT_OBJ.GENERAL_EMPTY) {
8178
- return new Intl.NumberFormat(void 0, {
8179
- minimumFractionDigits: safeDecimalValues,
8180
- maximumFractionDigits: safeDecimalValues
8181
- }).format(floatValue) + displayUnitsPostFix;
8177
+ const floatFixedVal = floatValue.toFixed(safeDecimalValues);
8178
+ switch (format) {
8179
+ case VALUE_FORMAT_OBJ.COMMA:
8180
+ case VALUE_FORMAT_OBJ.COMMA_SHORT:
8181
+ return floatValue.toLocaleString(void 0, {
8182
+ minimumFractionDigits: safeDecimalValues,
8183
+ maximumFractionDigits: safeDecimalValues
8184
+ }) + displayUnitsPostFix;
8185
+ case VALUE_FORMAT_OBJ.GENERAL:
8186
+ case VALUE_FORMAT_OBJ.GENERAL_EMPTY:
8187
+ return floatFixedVal + displayUnitsPostFix;
8182
8188
  }
8183
- return floatValue.toFixed(safeDecimalValues) + displayUnitsPostFix;
8184
8189
  } catch (error) {
8185
8190
  console.error("Error in formatValue:", error);
8186
8191
  return value;
@@ -17469,13 +17474,12 @@ function StaticTable({
17469
17474
  rowCellH = newRowHeight;
17470
17475
  }
17471
17476
  if (isFitTableOn) {
17472
- const baseColWidth = Math.floor((tableWidth - 1) / columnCount);
17473
- const extraWidth = tableWidth - baseColWidth * columnCount;
17474
- nonFixColCellW = baseColWidth;
17475
- fixedColCellW = baseColWidth + extraWidth;
17476
- const baseRowHeight = Math.floor(tableHeight / rowCount);
17477
- rowCellH = baseRowHeight;
17478
- colCellH = baseRowHeight;
17477
+ const sharedWidth = Math.floor((tableWidth - 5) / columnCount);
17478
+ const sharedHeight = Math.floor((tableHeight - 5) / rowCount);
17479
+ colCellH = sharedHeight;
17480
+ rowCellH = sharedHeight;
17481
+ nonFixColCellW = sharedWidth;
17482
+ fixedColCellW = sharedWidth;
17479
17483
  }
17480
17484
  return {
17481
17485
  colCellHeight: Number(colCellH),
@@ -17935,6 +17939,17 @@ function StaticTable({
17935
17939
  const renderMergedColHeaders = useMemo(() => colHeadersBase?.map(
17936
17940
  (h) => renderDataCell(h.label, h, "col_header_cell_div", h.childClassName, h.label, h.dataBarColor)
17937
17941
  ), [colHeadersBase]);
17942
+ const rowHeaderBandColorMap = useMemo(() => {
17943
+ const map = {};
17944
+ const uniqueParents = [
17945
+ ...new Set(measuresBySlice.map((m) => m.sliceMark[0] ?? ""))
17946
+ ];
17947
+ const additionFactor = isColTotalOn && headerAtStart ? 0 : 1;
17948
+ uniqueParents.forEach((parent, index) => {
17949
+ map[parent] = getBgColorForCell(index + additionFactor, rowColors);
17950
+ });
17951
+ return map;
17952
+ }, [measuresBySlice, rowColors]);
17938
17953
  const rowHeadersBase = useMemo(() => {
17939
17954
  const headers = [];
17940
17955
  const marks = measuresBySlice.map((m) => m.sliceMark);
@@ -17998,8 +18013,7 @@ function StaticTable({
17998
18013
  rowLabel = formatValue(rowLabel, dFormat);
17999
18014
  }
18000
18015
  }
18001
- const newIndex = isColTotalOn && headerAtStart ? groupIndex - 1 : groupIndex;
18002
- const finalStyleForRow = getFinalStyleObj(STYLE_FOR.ROW, baseStyleObj, rowLabel, level, newIndex);
18016
+ const finalStyleForRow = getFinalStyleObj(STYLE_FOR.ROW, baseStyleObj, rowLabel, level, parent);
18003
18017
  const tooltipValue = formatValue(marks[i][level], ToolTipNumberFormat, ToolTipDecimalPrecision);
18004
18018
  headers.push({
18005
18019
  ...finalStyleForRow,
@@ -18108,6 +18122,7 @@ function StaticTable({
18108
18122
  DataFieldDecimalPrecision,
18109
18123
  DisplayUnits,
18110
18124
  ShowHeatMap,
18125
+ rowHeaderBandColorMap,
18111
18126
  parentBandColorMap,
18112
18127
  rowColors,
18113
18128
  dataBarMatrix,
@@ -18164,6 +18179,7 @@ function StaticTable({
18164
18179
  const typeKey = ConFormattingTypeMap[formatFor];
18165
18180
  const obj = {};
18166
18181
  const arr = conditionalFormatsByType[typeKey] || [];
18182
+ if (arr.length <= 0) return;
18167
18183
  for (const format of arr) {
18168
18184
  if (shouldApplyFormat(value, format, formatFor, level)) {
18169
18185
  applyFormat(obj, format);
@@ -18208,7 +18224,7 @@ function StaticTable({
18208
18224
  }
18209
18225
  return false;
18210
18226
  }
18211
- function getFinalStyleObj(styleFor, baseStyle, label, index, groupIndex) {
18227
+ function getFinalStyleObj(styleFor, baseStyle, label, index, parentLabel) {
18212
18228
  let style = { ...baseStyle };
18213
18229
  switch (styleFor) {
18214
18230
  // Priority 1: Conditional Formatting overrides everything
@@ -18219,7 +18235,7 @@ function StaticTable({
18219
18235
  }
18220
18236
  case STYLE_FOR.ROW: {
18221
18237
  const conFormatForRow = index > 0 && getConditionalFormat(label, CONDITIONAL_FORMAT_FOR.ROW, index);
18222
- style.background = getBgColorForCell(groupIndex, rowColors);
18238
+ style.background = rowHeaderBandColorMap[parentLabel];
18223
18239
  style = applyConditionalFormatting(style, conFormatForRow);
18224
18240
  return style;
18225
18241
  }