pace-table-lib 1.0.61 → 1.0.62

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.
@@ -7897,7 +7897,7 @@
7897
7897
  const TOTAL = "Total";
7898
7898
  const MONTHS_SHORT = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
7899
7899
  const MONTHS_FULL = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
7900
- const DATE_FORMATS$1 = [
7900
+ const DATE_FORMATS = [
7901
7901
  "MMM-YY",
7902
7902
  "DD-MM-YYYY",
7903
7903
  "MM-DD-YYYY",
@@ -8149,15 +8149,15 @@
8149
8149
  return value;
8150
8150
  }
8151
8151
  function formatValue(value, format, decimalValues = 2, displayUnit = DISPLAY_UNITS_OBJ.NONE) {
8152
+ let safeDecimalValues = Number(decimalValues);
8152
8153
  try {
8153
- let safeDecimalValues = Number(decimalValues);
8154
8154
  if (!Number.isFinite(safeDecimalValues) && safeDecimalValues !== 0) {
8155
8155
  safeDecimalValues = 2;
8156
8156
  }
8157
8157
  safeDecimalValues = Math.min(20, Math.max(0, Math.floor(safeDecimalValues)));
8158
8158
  let floatValue = Number(value);
8159
8159
  if (isNaN(floatValue)) return value;
8160
- if (DATE_FORMATS$1.includes(format)) {
8160
+ if (DATE_FORMATS.includes(format)) {
8161
8161
  if (floatValue > 2958465 || floatValue <= 0) return value;
8162
8162
  return formatDate(floatValue, format);
8163
8163
  }
@@ -8187,13 +8187,22 @@
8187
8187
  [VALUE_FORMAT_OBJ.CURRENCY_GBP_SHORT]: { currency: "GBP", locale: "en-GB" },
8188
8188
  [VALUE_FORMAT_OBJ.CURRENCY_EUR]: { currency: "EUR", locale: "en-US" },
8189
8189
  [VALUE_FORMAT_OBJ.CURRENCY_EUR_SHORT]: { currency: "EUR", locale: "en-US" },
8190
- [VALUE_FORMAT_OBJ.CURRENCY_CAD]: { currency: "CAD", locale: "en-CA" },
8191
- [VALUE_FORMAT_OBJ.CURRENCY_CAD_SHORT]: { currency: "CAD", locale: "en-CA" },
8190
+ [VALUE_FORMAT_OBJ.CURRENCY_CAD]: { currency: "CAD", locale: "en-US" },
8191
+ [VALUE_FORMAT_OBJ.CURRENCY_CAD_SHORT]: { currency: "CAD", locale: "en-US" },
8192
8192
  [VALUE_FORMAT_OBJ.CURRENCY_CHF]: { currency: "CHF", locale: "de-CH" },
8193
8193
  [VALUE_FORMAT_OBJ.CURRENCY_CHF_SHORT]: { currency: "CHF", locale: "de-CH" }
8194
8194
  };
8195
8195
  if (currencyMap[format]) {
8196
8196
  const { currency, locale } = currencyMap[format];
8197
+ if (currency === "CAD") {
8198
+ const isNegative = floatValue < 0;
8199
+ let formattedCad = new Intl.NumberFormat(locale, {
8200
+ minimumFractionDigits: safeDecimalValues,
8201
+ maximumFractionDigits: safeDecimalValues
8202
+ }).format(Math.abs(floatValue));
8203
+ formattedCad = (isNegative ? "-" : "") + "C$" + formattedCad;
8204
+ return formattedCad + displayUnitsPostFix;
8205
+ }
8197
8206
  const formatted = new Intl.NumberFormat(locale, {
8198
8207
  style: "currency",
8199
8208
  currency,
@@ -8217,6 +8226,7 @@
8217
8226
  case VALUE_FORMAT_OBJ.GENERAL_EMPTY:
8218
8227
  return floatFixedVal + displayUnitsPostFix;
8219
8228
  }
8229
+ return value?.toFixed(safeDecimalValues);
8220
8230
  } catch (error) {
8221
8231
  console.error("Error in formatValue:", error);
8222
8232
  return value;
@@ -17368,9 +17378,9 @@
17368
17378
  RowTotal,
17369
17379
  ColumnTotal,
17370
17380
  TotalHeaderPosition,
17371
- NumberFormat: NumberFormat2,
17381
+ NumberFormat,
17372
17382
  DataFieldDecimalPrecision,
17373
- DisplayUnits: DisplayUnits2,
17383
+ DisplayUnits,
17374
17384
  DataFieldFontFamily,
17375
17385
  DataFieldFontSize,
17376
17386
  Textalign,
@@ -17416,6 +17426,16 @@
17416
17426
  document.removeEventListener("scroll", hide);
17417
17427
  };
17418
17428
  }, []);
17429
+ React.useEffect(() => {
17430
+ scrollLeftRef.current = 0;
17431
+ scrollTopRef.current = 0;
17432
+ if (colHeaderWrapperRef.current) {
17433
+ colHeaderWrapperRef.current.style.left = `0px`;
17434
+ }
17435
+ if (rowHeaderWrapperRef.current) {
17436
+ rowHeaderWrapperRef.current.style.top = `0px`;
17437
+ }
17438
+ }, [isFitTableOn]);
17419
17439
  const rowHeaderFont = React.useMemo(() => ({
17420
17440
  color: RowHeader.RowHeaderColor,
17421
17441
  fontFamily: RowHeader.RowHeaderFontFamily,
@@ -17715,9 +17735,9 @@
17715
17735
  }
17716
17736
  let label = formatValue(
17717
17737
  grandTotal,
17718
- NumberFormat2,
17738
+ NumberFormat,
17719
17739
  DataFieldDecimalPrecision,
17720
- DisplayUnits2
17740
+ DisplayUnits
17721
17741
  );
17722
17742
  const toolTipVal = formatValue(grandTotal, ToolTipNumberFormat, ToolTipDecimalPrecision);
17723
17743
  if (DataField.hasOwnProperty("percentageBy") && DataField.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
@@ -17832,9 +17852,9 @@
17832
17852
  rowHeaderFont,
17833
17853
  dataCellFont,
17834
17854
  grandTotal,
17835
- NumberFormat2,
17855
+ NumberFormat,
17836
17856
  DataFieldDecimalPrecision,
17837
- DisplayUnits2,
17857
+ DisplayUnits,
17838
17858
  isFitTableOn
17839
17859
  ]);
17840
17860
  const renderLeftFixedHeaders = React.useMemo(
@@ -17919,7 +17939,7 @@
17919
17939
  }
17920
17940
  } else {
17921
17941
  columnTotalRow.forEach((item, idx) => {
17922
- let label = formatValue(item.columnTotal, NumberFormat2, DataFieldDecimalPrecision, DisplayUnits2);
17942
+ let label = formatValue(item.columnTotal, NumberFormat, DataFieldDecimalPrecision, DisplayUnits);
17923
17943
  const innerBg = getBgColorForDataBar(0, idx);
17924
17944
  if (DataField.hasOwnProperty("percentageBy") && DataField.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
17925
17945
  label = formatValue(1, VALUE_FORMAT_OBJ.PERCENT_SHORT);
@@ -18038,9 +18058,9 @@
18038
18058
  dataCellFont,
18039
18059
  dataColors,
18040
18060
  // formatting
18041
- NumberFormat2,
18061
+ NumberFormat,
18042
18062
  DataFieldDecimalPrecision,
18043
- DisplayUnits2,
18063
+ DisplayUnits,
18044
18064
  rowCellHeight,
18045
18065
  fixedColWidth,
18046
18066
  // handlers
@@ -18095,7 +18115,7 @@
18095
18115
  if (lastP !== null) groupIndex++;
18096
18116
  lastP = parent;
18097
18117
  }
18098
- let label = formatValue(row.rowTotal, NumberFormat2, DataFieldDecimalPrecision, DisplayUnits2);
18118
+ let label = formatValue(row.rowTotal, NumberFormat, DataFieldDecimalPrecision, DisplayUnits);
18099
18119
  if (DataField.hasOwnProperty("percentageBy") && DataField.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
18100
18120
  label = formatValue(1, VALUE_FORMAT_OBJ.PERCENT_SHORT);
18101
18121
  }
@@ -18289,9 +18309,9 @@
18289
18309
  leftFixedCellNameList,
18290
18310
  isSparkLineVisible,
18291
18311
  isSlAtStart,
18292
- NumberFormat2,
18312
+ NumberFormat,
18293
18313
  DataFieldDecimalPrecision,
18294
- DisplayUnits2,
18314
+ DisplayUnits,
18295
18315
  ShowHeatMap,
18296
18316
  rowHeaderBandColorMap,
18297
18317
  parentBandColorMap,
@@ -18329,9 +18349,9 @@
18329
18349
  }
18330
18350
  function getMeasureFormattingObj(givenMeasureName) {
18331
18351
  const defaultFormat = {
18332
- numberFormat: NumberFormat2,
18352
+ numberFormat: NumberFormat,
18333
18353
  decimalPrecision: DataFieldDecimalPrecision,
18334
- displayUnits: DisplayUnits2
18354
+ displayUnits: DisplayUnits
18335
18355
  };
18336
18356
  if (!givenMeasureName || !measureFormatConfigs?.length) {
18337
18357
  return defaultFormat;
@@ -18388,7 +18408,8 @@
18388
18408
  }
18389
18409
  return false;
18390
18410
  }
18391
- return compareVal(value, format.operator, format.checkValue);
18411
+ const formattedValue = formatValue(value, void 0, DataFieldDecimalPrecision);
18412
+ return compareVal(formattedValue, format.operator, format.checkValue);
18392
18413
  } catch {
18393
18414
  return false;
18394
18415
  }
@@ -18783,43 +18804,7 @@
18783
18804
  )
18784
18805
  ] });
18785
18806
  }
18786
- var NumberFormat = /* @__PURE__ */ ((NumberFormat2) => {
18787
- NumberFormat2["General"] = "General";
18788
- NumberFormat2["CommaSeparated"] = "Comma Separated";
18789
- NumberFormat2["Percentage"] = "Percentage";
18790
- NumberFormat2["Scientific"] = "Scientific";
18791
- NumberFormat2["CurrencyUSD"] = "Currency-USD";
18792
- NumberFormat2["CurrencyCAD"] = "Currency-CAD";
18793
- NumberFormat2["CurrencyEUR"] = "Currency-EUR";
18794
- NumberFormat2["CurrencyCHF"] = "Currency-CHF";
18795
- NumberFormat2["CurrencyUK"] = "Currency-UK";
18796
- NumberFormat2["CurrencyINR"] = "Currency-INR";
18797
- return NumberFormat2;
18798
- })(NumberFormat || {});
18799
- var DisplayUnits = /* @__PURE__ */ ((DisplayUnits2) => {
18800
- DisplayUnits2["Thousands"] = "Thousands";
18801
- DisplayUnits2["Millions"] = "Millions";
18802
- DisplayUnits2["Billions"] = "Billions";
18803
- return DisplayUnits2;
18804
- })(DisplayUnits || {});
18805
18807
  const NO_ENTRY_TOKENS = ["nolegendentryrow", "nocolentry"];
18806
- const DATE_FORMATS = [
18807
- "DD-MM-YYYY",
18808
- "MM-DD-YYYY",
18809
- "YYYY-MM-DD",
18810
- "YYYY",
18811
- "DD-MM",
18812
- "MMM-YY",
18813
- "MMM-YYYY",
18814
- "YY-MMM",
18815
- "MM-YYYY",
18816
- "YYYY-MM",
18817
- "MMMM-YYYY",
18818
- "MMMM-YY",
18819
- "DD-MMM",
18820
- "DD-MMM-YY",
18821
- "DD-MMM-YYYY"
18822
- ];
18823
18808
  function hexToRgb(hex) {
18824
18809
  const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
18825
18810
  return result ? {
@@ -18865,91 +18850,6 @@
18865
18850
  }
18866
18851
  return "";
18867
18852
  }
18868
- function formatCellValue(value, formatConfig) {
18869
- if (value === null || value === void 0 || value === "") return "-";
18870
- if (formatConfig?.numberFormat && DATE_FORMATS.includes(formatConfig.numberFormat) && (value === 0 || value === "0" || value === "" || Number(value) === 0)) {
18871
- return "0";
18872
- }
18873
- if (formatConfig?.numberFormat && DATE_FORMATS.includes(formatConfig.numberFormat)) {
18874
- return applyDateFormat(String(value), formatConfig.numberFormat);
18875
- }
18876
- const num = typeof value === "string" ? parseFloat(value) : value;
18877
- if (isNaN(num)) return String(value);
18878
- let formatted = num;
18879
- let suffix = "";
18880
- switch (formatConfig?.displayUnits) {
18881
- case DisplayUnits.Thousands:
18882
- formatted = num / 1e3;
18883
- suffix = "K";
18884
- break;
18885
- case DisplayUnits.Millions:
18886
- formatted = num / 1e6;
18887
- suffix = "M";
18888
- break;
18889
- case DisplayUnits.Billions:
18890
- formatted = num / 1e9;
18891
- suffix = "B";
18892
- break;
18893
- }
18894
- const precision = formatConfig?.decimalPrecision ?? 0;
18895
- switch (formatConfig?.numberFormat) {
18896
- case NumberFormat.General:
18897
- return formatted.toString() + suffix;
18898
- case NumberFormat.CommaSeparated:
18899
- return formatted.toLocaleString(void 0, {
18900
- minimumFractionDigits: precision,
18901
- maximumFractionDigits: precision
18902
- }) + suffix;
18903
- case NumberFormat.Percentage:
18904
- return `${(formatted * 100).toFixed(precision)}%`;
18905
- case NumberFormat.Scientific:
18906
- return formatted.toExponential(precision);
18907
- case NumberFormat.CurrencyUSD:
18908
- return formatted.toLocaleString("en-US", {
18909
- style: "currency",
18910
- currency: "USD",
18911
- minimumFractionDigits: precision,
18912
- maximumFractionDigits: precision
18913
- });
18914
- case NumberFormat.CurrencyCAD:
18915
- return formatted.toLocaleString("en-CA", {
18916
- style: "currency",
18917
- currency: "CAD",
18918
- minimumFractionDigits: precision,
18919
- maximumFractionDigits: precision
18920
- });
18921
- case NumberFormat.CurrencyEUR:
18922
- return formatted.toLocaleString("de-DE", {
18923
- style: "currency",
18924
- currency: "EUR",
18925
- minimumFractionDigits: precision,
18926
- maximumFractionDigits: precision
18927
- });
18928
- case NumberFormat.CurrencyCHF:
18929
- return formatted.toLocaleString("de-CH", {
18930
- style: "currency",
18931
- currency: "CHF",
18932
- minimumFractionDigits: precision,
18933
- maximumFractionDigits: precision
18934
- });
18935
- case NumberFormat.CurrencyUK:
18936
- return formatted.toLocaleString("en-GB", {
18937
- style: "currency",
18938
- currency: "GBP",
18939
- minimumFractionDigits: precision,
18940
- maximumFractionDigits: precision
18941
- });
18942
- case NumberFormat.CurrencyINR:
18943
- return formatted.toLocaleString("en-IN", {
18944
- style: "currency",
18945
- currency: "INR",
18946
- minimumFractionDigits: precision,
18947
- maximumFractionDigits: precision
18948
- });
18949
- default:
18950
- return formatted.toString() + suffix;
18951
- }
18952
- }
18953
18853
  function getCellBackgroundColor(isEven, _ribbon, styleProps, isRowHeader = false) {
18954
18854
  if (isRowHeader) {
18955
18855
  if (styleProps.RowHeader.RowHeaderBackgroundcolor === "Alternating")
@@ -19946,7 +19846,7 @@
19946
19846
  decimalPrecision: conditionalFormatObj?.decimalPrecision ?? measureFmt.decimalPrecision,
19947
19847
  displayUnits: conditionalFormatObj?.displayUnits ?? measureFmt.displayUnits
19948
19848
  };
19949
- const formattedValue = isPercentageMode ? `${(Number(rawValue) * 100).toFixed(resolvedFormat.decimalPrecision ?? 2)}%` : formatCellValue(String(rawValue), resolvedFormat);
19849
+ const formattedValue = isPercentageMode ? `${(Number(rawValue) * 100).toFixed(resolvedFormat.decimalPrecision ?? 2)}%` : formatValue(rawValue, resolvedFormat.numberFormat, resolvedFormat.decimalPrecision, resolvedFormat.displayUnits);
19950
19850
  const isSubtotalCell = row.isSubtotal || col.isSubtotal;
19951
19851
  const bi = rowBandMap[row.segments[0]] ?? 0;
19952
19852
  const cbi = colBandMap[col.year] ?? 0;
@@ -20003,12 +19903,7 @@
20003
19903
  }
20004
19904
  tooltipValue = total !== 0 ? `${(Number(rawValue) / total * 100).toFixed(2)}%` : "0.00%";
20005
19905
  } else {
20006
- tooltipValue = formatCellValue(String(rawValue), {
20007
- measureIndex: activeFormat?.measureIndex ?? 0,
20008
- numberFormat: tableStyleProps.ToolTip.ToolTipNumberFormat,
20009
- decimalPrecision: tableStyleProps.ToolTip.ToolTipDecimalPrecision,
20010
- displayUnits: measureFmt.displayUnits ?? "None"
20011
- });
19906
+ tooltipValue = formatValue(rawValue, tableStyleProps.ToolTip.ToolTipNumberFormat, tableStyleProps.ToolTip.ToolTipDecimalPrecision);
20012
19907
  }
20013
19908
  }
20014
19909
  let percentage = 0;