pace-table-lib 1.0.36 → 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,14 +17474,12 @@ function StaticTable({
17469
17474
  rowCellH = newRowHeight;
17470
17475
  }
17471
17476
  if (isFitTableOn) {
17472
- const baseColWidth = Math.floor(tableWidth / columnCount);
17473
- const extraWidth = tableWidth - baseColWidth * columnCount;
17474
- nonFixColCellW = baseColWidth;
17475
- fixedColCellW = baseColWidth + extraWidth;
17476
- const baseRowHeight = Math.floor(tableHeight / rowCount);
17477
- const extraHeight = tableHeight - baseRowHeight * rowCount;
17478
- rowCellH = baseRowHeight;
17479
- colCellH = baseRowHeight + extraHeight;
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;
17480
17483
  }
17481
17484
  return {
17482
17485
  colCellHeight: Number(colCellH),
@@ -17936,6 +17939,17 @@ function StaticTable({
17936
17939
  const renderMergedColHeaders = useMemo(() => colHeadersBase?.map(
17937
17940
  (h) => renderDataCell(h.label, h, "col_header_cell_div", h.childClassName, h.label, h.dataBarColor)
17938
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]);
17939
17953
  const rowHeadersBase = useMemo(() => {
17940
17954
  const headers = [];
17941
17955
  const marks = measuresBySlice.map((m) => m.sliceMark);
@@ -17999,8 +18013,7 @@ function StaticTable({
17999
18013
  rowLabel = formatValue(rowLabel, dFormat);
18000
18014
  }
18001
18015
  }
18002
- const newIndex = isColTotalOn && headerAtStart ? groupIndex - 1 : groupIndex;
18003
- const finalStyleForRow = getFinalStyleObj(STYLE_FOR.ROW, baseStyleObj, rowLabel, level, newIndex);
18016
+ const finalStyleForRow = getFinalStyleObj(STYLE_FOR.ROW, baseStyleObj, rowLabel, level, parent);
18004
18017
  const tooltipValue = formatValue(marks[i][level], ToolTipNumberFormat, ToolTipDecimalPrecision);
18005
18018
  headers.push({
18006
18019
  ...finalStyleForRow,
@@ -18109,6 +18122,7 @@ function StaticTable({
18109
18122
  DataFieldDecimalPrecision,
18110
18123
  DisplayUnits,
18111
18124
  ShowHeatMap,
18125
+ rowHeaderBandColorMap,
18112
18126
  parentBandColorMap,
18113
18127
  rowColors,
18114
18128
  dataBarMatrix,
@@ -18165,6 +18179,7 @@ function StaticTable({
18165
18179
  const typeKey = ConFormattingTypeMap[formatFor];
18166
18180
  const obj = {};
18167
18181
  const arr = conditionalFormatsByType[typeKey] || [];
18182
+ if (arr.length <= 0) return;
18168
18183
  for (const format of arr) {
18169
18184
  if (shouldApplyFormat(value, format, formatFor, level)) {
18170
18185
  applyFormat(obj, format);
@@ -18209,7 +18224,7 @@ function StaticTable({
18209
18224
  }
18210
18225
  return false;
18211
18226
  }
18212
- function getFinalStyleObj(styleFor, baseStyle, label, index, groupIndex) {
18227
+ function getFinalStyleObj(styleFor, baseStyle, label, index, parentLabel) {
18213
18228
  let style = { ...baseStyle };
18214
18229
  switch (styleFor) {
18215
18230
  // Priority 1: Conditional Formatting overrides everything
@@ -18220,7 +18235,7 @@ function StaticTable({
18220
18235
  }
18221
18236
  case STYLE_FOR.ROW: {
18222
18237
  const conFormatForRow = index > 0 && getConditionalFormat(label, CONDITIONAL_FORMAT_FOR.ROW, index);
18223
- style.background = getBgColorForCell(groupIndex, rowColors);
18238
+ style.background = rowHeaderBandColorMap[parentLabel];
18224
18239
  style = applyConditionalFormatting(style, conFormatForRow);
18225
18240
  return style;
18226
18241
  }