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.
@@ -5,7 +5,7 @@ export declare function getCleanString(dimensionMark: string): string;
5
5
  export declare function isFirstOccurrence(arr: string[][], index: number, level: number): boolean;
6
6
  export declare function getBgColorForCell(dataIndex: number, colorObj: BgColorObj): string;
7
7
  export declare function getBgColor(obj: any, type: "row" | "dataField" | "column"): BgColorObj;
8
- export declare function formatValue(value: any, format: string, decimalValues?: number, displayUnit?: DisplayUnitsType): any;
8
+ export declare function formatValue(value: any, format: any, decimalValues?: number, displayUnit?: DisplayUnitsType): any;
9
9
  export declare function getFontStyleObj(stylePayload: any): CSSProperties;
10
10
  export declare function interpolateColor(minColor: string, maxColor: string, ratio: number): string;
11
11
  export declare function computeMatrix<T>(rawDataMatrix: number[][], mode: "All" | "Column-wise" | "Row-wise", transformFn: (v: number, min: number, max: number) => T): T[][];
@@ -7879,7 +7879,7 @@ var STYLE_FOR = /* @__PURE__ */ ((STYLE_FOR2) => {
7879
7879
  const TOTAL = "Total";
7880
7880
  const MONTHS_SHORT = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
7881
7881
  const MONTHS_FULL = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
7882
- const DATE_FORMATS$1 = [
7882
+ const DATE_FORMATS = [
7883
7883
  "MMM-YY",
7884
7884
  "DD-MM-YYYY",
7885
7885
  "MM-DD-YYYY",
@@ -8131,15 +8131,15 @@ function formatDate(value, formatKey) {
8131
8131
  return value;
8132
8132
  }
8133
8133
  function formatValue(value, format, decimalValues = 2, displayUnit = DISPLAY_UNITS_OBJ.NONE) {
8134
+ let safeDecimalValues = Number(decimalValues);
8134
8135
  try {
8135
- let safeDecimalValues = Number(decimalValues);
8136
8136
  if (!Number.isFinite(safeDecimalValues) && safeDecimalValues !== 0) {
8137
8137
  safeDecimalValues = 2;
8138
8138
  }
8139
8139
  safeDecimalValues = Math.min(20, Math.max(0, Math.floor(safeDecimalValues)));
8140
8140
  let floatValue = Number(value);
8141
8141
  if (isNaN(floatValue)) return value;
8142
- if (DATE_FORMATS$1.includes(format)) {
8142
+ if (DATE_FORMATS.includes(format)) {
8143
8143
  if (floatValue > 2958465 || floatValue <= 0) return value;
8144
8144
  return formatDate(floatValue, format);
8145
8145
  }
@@ -8169,13 +8169,22 @@ function formatValue(value, format, decimalValues = 2, displayUnit = DISPLAY_UNI
8169
8169
  [VALUE_FORMAT_OBJ.CURRENCY_GBP_SHORT]: { currency: "GBP", locale: "en-GB" },
8170
8170
  [VALUE_FORMAT_OBJ.CURRENCY_EUR]: { currency: "EUR", locale: "en-US" },
8171
8171
  [VALUE_FORMAT_OBJ.CURRENCY_EUR_SHORT]: { currency: "EUR", locale: "en-US" },
8172
- [VALUE_FORMAT_OBJ.CURRENCY_CAD]: { currency: "CAD", locale: "en-CA" },
8173
- [VALUE_FORMAT_OBJ.CURRENCY_CAD_SHORT]: { currency: "CAD", locale: "en-CA" },
8172
+ [VALUE_FORMAT_OBJ.CURRENCY_CAD]: { currency: "CAD", locale: "en-US" },
8173
+ [VALUE_FORMAT_OBJ.CURRENCY_CAD_SHORT]: { currency: "CAD", locale: "en-US" },
8174
8174
  [VALUE_FORMAT_OBJ.CURRENCY_CHF]: { currency: "CHF", locale: "de-CH" },
8175
8175
  [VALUE_FORMAT_OBJ.CURRENCY_CHF_SHORT]: { currency: "CHF", locale: "de-CH" }
8176
8176
  };
8177
8177
  if (currencyMap[format]) {
8178
8178
  const { currency, locale } = currencyMap[format];
8179
+ if (currency === "CAD") {
8180
+ const isNegative = floatValue < 0;
8181
+ let formattedCad = new Intl.NumberFormat(locale, {
8182
+ minimumFractionDigits: safeDecimalValues,
8183
+ maximumFractionDigits: safeDecimalValues
8184
+ }).format(Math.abs(floatValue));
8185
+ formattedCad = (isNegative ? "-" : "") + "C$" + formattedCad;
8186
+ return formattedCad + displayUnitsPostFix;
8187
+ }
8179
8188
  const formatted = new Intl.NumberFormat(locale, {
8180
8189
  style: "currency",
8181
8190
  currency,
@@ -8199,6 +8208,7 @@ function formatValue(value, format, decimalValues = 2, displayUnit = DISPLAY_UNI
8199
8208
  case VALUE_FORMAT_OBJ.GENERAL_EMPTY:
8200
8209
  return floatFixedVal + displayUnitsPostFix;
8201
8210
  }
8211
+ return value?.toFixed(safeDecimalValues);
8202
8212
  } catch (error) {
8203
8213
  console.error("Error in formatValue:", error);
8204
8214
  return value;
@@ -17350,9 +17360,9 @@ function StaticTable({
17350
17360
  RowTotal,
17351
17361
  ColumnTotal,
17352
17362
  TotalHeaderPosition,
17353
- NumberFormat: NumberFormat2,
17363
+ NumberFormat,
17354
17364
  DataFieldDecimalPrecision,
17355
- DisplayUnits: DisplayUnits2,
17365
+ DisplayUnits,
17356
17366
  DataFieldFontFamily,
17357
17367
  DataFieldFontSize,
17358
17368
  Textalign,
@@ -17398,6 +17408,16 @@ function StaticTable({
17398
17408
  document.removeEventListener("scroll", hide);
17399
17409
  };
17400
17410
  }, []);
17411
+ useEffect(() => {
17412
+ scrollLeftRef.current = 0;
17413
+ scrollTopRef.current = 0;
17414
+ if (colHeaderWrapperRef.current) {
17415
+ colHeaderWrapperRef.current.style.left = `0px`;
17416
+ }
17417
+ if (rowHeaderWrapperRef.current) {
17418
+ rowHeaderWrapperRef.current.style.top = `0px`;
17419
+ }
17420
+ }, [isFitTableOn]);
17401
17421
  const rowHeaderFont = useMemo(() => ({
17402
17422
  color: RowHeader.RowHeaderColor,
17403
17423
  fontFamily: RowHeader.RowHeaderFontFamily,
@@ -17697,9 +17717,9 @@ function StaticTable({
17697
17717
  }
17698
17718
  let label = formatValue(
17699
17719
  grandTotal,
17700
- NumberFormat2,
17720
+ NumberFormat,
17701
17721
  DataFieldDecimalPrecision,
17702
- DisplayUnits2
17722
+ DisplayUnits
17703
17723
  );
17704
17724
  const toolTipVal = formatValue(grandTotal, ToolTipNumberFormat, ToolTipDecimalPrecision);
17705
17725
  if (DataField.hasOwnProperty("percentageBy") && DataField.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
@@ -17814,9 +17834,9 @@ function StaticTable({
17814
17834
  rowHeaderFont,
17815
17835
  dataCellFont,
17816
17836
  grandTotal,
17817
- NumberFormat2,
17837
+ NumberFormat,
17818
17838
  DataFieldDecimalPrecision,
17819
- DisplayUnits2,
17839
+ DisplayUnits,
17820
17840
  isFitTableOn
17821
17841
  ]);
17822
17842
  const renderLeftFixedHeaders = useMemo(
@@ -17901,7 +17921,7 @@ function StaticTable({
17901
17921
  }
17902
17922
  } else {
17903
17923
  columnTotalRow.forEach((item, idx) => {
17904
- let label = formatValue(item.columnTotal, NumberFormat2, DataFieldDecimalPrecision, DisplayUnits2);
17924
+ let label = formatValue(item.columnTotal, NumberFormat, DataFieldDecimalPrecision, DisplayUnits);
17905
17925
  const innerBg = getBgColorForDataBar(0, idx);
17906
17926
  if (DataField.hasOwnProperty("percentageBy") && DataField.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
17907
17927
  label = formatValue(1, VALUE_FORMAT_OBJ.PERCENT_SHORT);
@@ -18020,9 +18040,9 @@ function StaticTable({
18020
18040
  dataCellFont,
18021
18041
  dataColors,
18022
18042
  // formatting
18023
- NumberFormat2,
18043
+ NumberFormat,
18024
18044
  DataFieldDecimalPrecision,
18025
- DisplayUnits2,
18045
+ DisplayUnits,
18026
18046
  rowCellHeight,
18027
18047
  fixedColWidth,
18028
18048
  // handlers
@@ -18077,7 +18097,7 @@ function StaticTable({
18077
18097
  if (lastP !== null) groupIndex++;
18078
18098
  lastP = parent;
18079
18099
  }
18080
- let label = formatValue(row.rowTotal, NumberFormat2, DataFieldDecimalPrecision, DisplayUnits2);
18100
+ let label = formatValue(row.rowTotal, NumberFormat, DataFieldDecimalPrecision, DisplayUnits);
18081
18101
  if (DataField.hasOwnProperty("percentageBy") && DataField.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
18082
18102
  label = formatValue(1, VALUE_FORMAT_OBJ.PERCENT_SHORT);
18083
18103
  }
@@ -18271,9 +18291,9 @@ function StaticTable({
18271
18291
  leftFixedCellNameList,
18272
18292
  isSparkLineVisible,
18273
18293
  isSlAtStart,
18274
- NumberFormat2,
18294
+ NumberFormat,
18275
18295
  DataFieldDecimalPrecision,
18276
- DisplayUnits2,
18296
+ DisplayUnits,
18277
18297
  ShowHeatMap,
18278
18298
  rowHeaderBandColorMap,
18279
18299
  parentBandColorMap,
@@ -18311,9 +18331,9 @@ function StaticTable({
18311
18331
  }
18312
18332
  function getMeasureFormattingObj(givenMeasureName) {
18313
18333
  const defaultFormat = {
18314
- numberFormat: NumberFormat2,
18334
+ numberFormat: NumberFormat,
18315
18335
  decimalPrecision: DataFieldDecimalPrecision,
18316
- displayUnits: DisplayUnits2
18336
+ displayUnits: DisplayUnits
18317
18337
  };
18318
18338
  if (!givenMeasureName || !measureFormatConfigs?.length) {
18319
18339
  return defaultFormat;
@@ -18370,7 +18390,8 @@ function StaticTable({
18370
18390
  }
18371
18391
  return false;
18372
18392
  }
18373
- return compareVal(value, format.operator, format.checkValue);
18393
+ const formattedValue = formatValue(value, void 0, DataFieldDecimalPrecision);
18394
+ return compareVal(formattedValue, format.operator, format.checkValue);
18374
18395
  } catch {
18375
18396
  return false;
18376
18397
  }
@@ -18765,43 +18786,7 @@ function StaticTable({
18765
18786
  )
18766
18787
  ] });
18767
18788
  }
18768
- var NumberFormat = /* @__PURE__ */ ((NumberFormat2) => {
18769
- NumberFormat2["General"] = "General";
18770
- NumberFormat2["CommaSeparated"] = "Comma Separated";
18771
- NumberFormat2["Percentage"] = "Percentage";
18772
- NumberFormat2["Scientific"] = "Scientific";
18773
- NumberFormat2["CurrencyUSD"] = "Currency-USD";
18774
- NumberFormat2["CurrencyCAD"] = "Currency-CAD";
18775
- NumberFormat2["CurrencyEUR"] = "Currency-EUR";
18776
- NumberFormat2["CurrencyCHF"] = "Currency-CHF";
18777
- NumberFormat2["CurrencyUK"] = "Currency-UK";
18778
- NumberFormat2["CurrencyINR"] = "Currency-INR";
18779
- return NumberFormat2;
18780
- })(NumberFormat || {});
18781
- var DisplayUnits = /* @__PURE__ */ ((DisplayUnits2) => {
18782
- DisplayUnits2["Thousands"] = "Thousands";
18783
- DisplayUnits2["Millions"] = "Millions";
18784
- DisplayUnits2["Billions"] = "Billions";
18785
- return DisplayUnits2;
18786
- })(DisplayUnits || {});
18787
18789
  const NO_ENTRY_TOKENS = ["nolegendentryrow", "nocolentry"];
18788
- const DATE_FORMATS = [
18789
- "DD-MM-YYYY",
18790
- "MM-DD-YYYY",
18791
- "YYYY-MM-DD",
18792
- "YYYY",
18793
- "DD-MM",
18794
- "MMM-YY",
18795
- "MMM-YYYY",
18796
- "YY-MMM",
18797
- "MM-YYYY",
18798
- "YYYY-MM",
18799
- "MMMM-YYYY",
18800
- "MMMM-YY",
18801
- "DD-MMM",
18802
- "DD-MMM-YY",
18803
- "DD-MMM-YYYY"
18804
- ];
18805
18790
  function hexToRgb(hex) {
18806
18791
  const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
18807
18792
  return result ? {
@@ -18847,91 +18832,6 @@ function getRowDisplayName(segments, measureValue) {
18847
18832
  }
18848
18833
  return "";
18849
18834
  }
18850
- function formatCellValue(value, formatConfig) {
18851
- if (value === null || value === void 0 || value === "") return "-";
18852
- if (formatConfig?.numberFormat && DATE_FORMATS.includes(formatConfig.numberFormat) && (value === 0 || value === "0" || value === "" || Number(value) === 0)) {
18853
- return "0";
18854
- }
18855
- if (formatConfig?.numberFormat && DATE_FORMATS.includes(formatConfig.numberFormat)) {
18856
- return applyDateFormat(String(value), formatConfig.numberFormat);
18857
- }
18858
- const num = typeof value === "string" ? parseFloat(value) : value;
18859
- if (isNaN(num)) return String(value);
18860
- let formatted = num;
18861
- let suffix = "";
18862
- switch (formatConfig?.displayUnits) {
18863
- case DisplayUnits.Thousands:
18864
- formatted = num / 1e3;
18865
- suffix = "K";
18866
- break;
18867
- case DisplayUnits.Millions:
18868
- formatted = num / 1e6;
18869
- suffix = "M";
18870
- break;
18871
- case DisplayUnits.Billions:
18872
- formatted = num / 1e9;
18873
- suffix = "B";
18874
- break;
18875
- }
18876
- const precision = formatConfig?.decimalPrecision ?? 0;
18877
- switch (formatConfig?.numberFormat) {
18878
- case NumberFormat.General:
18879
- return formatted.toString() + suffix;
18880
- case NumberFormat.CommaSeparated:
18881
- return formatted.toLocaleString(void 0, {
18882
- minimumFractionDigits: precision,
18883
- maximumFractionDigits: precision
18884
- }) + suffix;
18885
- case NumberFormat.Percentage:
18886
- return `${(formatted * 100).toFixed(precision)}%`;
18887
- case NumberFormat.Scientific:
18888
- return formatted.toExponential(precision);
18889
- case NumberFormat.CurrencyUSD:
18890
- return formatted.toLocaleString("en-US", {
18891
- style: "currency",
18892
- currency: "USD",
18893
- minimumFractionDigits: precision,
18894
- maximumFractionDigits: precision
18895
- });
18896
- case NumberFormat.CurrencyCAD:
18897
- return formatted.toLocaleString("en-CA", {
18898
- style: "currency",
18899
- currency: "CAD",
18900
- minimumFractionDigits: precision,
18901
- maximumFractionDigits: precision
18902
- });
18903
- case NumberFormat.CurrencyEUR:
18904
- return formatted.toLocaleString("de-DE", {
18905
- style: "currency",
18906
- currency: "EUR",
18907
- minimumFractionDigits: precision,
18908
- maximumFractionDigits: precision
18909
- });
18910
- case NumberFormat.CurrencyCHF:
18911
- return formatted.toLocaleString("de-CH", {
18912
- style: "currency",
18913
- currency: "CHF",
18914
- minimumFractionDigits: precision,
18915
- maximumFractionDigits: precision
18916
- });
18917
- case NumberFormat.CurrencyUK:
18918
- return formatted.toLocaleString("en-GB", {
18919
- style: "currency",
18920
- currency: "GBP",
18921
- minimumFractionDigits: precision,
18922
- maximumFractionDigits: precision
18923
- });
18924
- case NumberFormat.CurrencyINR:
18925
- return formatted.toLocaleString("en-IN", {
18926
- style: "currency",
18927
- currency: "INR",
18928
- minimumFractionDigits: precision,
18929
- maximumFractionDigits: precision
18930
- });
18931
- default:
18932
- return formatted.toString() + suffix;
18933
- }
18934
- }
18935
18835
  function getCellBackgroundColor(isEven, _ribbon, styleProps, isRowHeader = false) {
18936
18836
  if (isRowHeader) {
18937
18837
  if (styleProps.RowHeader.RowHeaderBackgroundcolor === "Alternating")
@@ -19928,7 +19828,7 @@ const PivotTable = ({
19928
19828
  decimalPrecision: conditionalFormatObj?.decimalPrecision ?? measureFmt.decimalPrecision,
19929
19829
  displayUnits: conditionalFormatObj?.displayUnits ?? measureFmt.displayUnits
19930
19830
  };
19931
- const formattedValue = isPercentageMode ? `${(Number(rawValue) * 100).toFixed(resolvedFormat.decimalPrecision ?? 2)}%` : formatCellValue(String(rawValue), resolvedFormat);
19831
+ const formattedValue = isPercentageMode ? `${(Number(rawValue) * 100).toFixed(resolvedFormat.decimalPrecision ?? 2)}%` : formatValue(rawValue, resolvedFormat.numberFormat, resolvedFormat.decimalPrecision, resolvedFormat.displayUnits);
19932
19832
  const isSubtotalCell = row.isSubtotal || col.isSubtotal;
19933
19833
  const bi = rowBandMap[row.segments[0]] ?? 0;
19934
19834
  const cbi = colBandMap[col.year] ?? 0;
@@ -19985,12 +19885,7 @@ const PivotTable = ({
19985
19885
  }
19986
19886
  tooltipValue = total !== 0 ? `${(Number(rawValue) / total * 100).toFixed(2)}%` : "0.00%";
19987
19887
  } else {
19988
- tooltipValue = formatCellValue(String(rawValue), {
19989
- measureIndex: activeFormat?.measureIndex ?? 0,
19990
- numberFormat: tableStyleProps.ToolTip.ToolTipNumberFormat,
19991
- decimalPrecision: tableStyleProps.ToolTip.ToolTipDecimalPrecision,
19992
- displayUnits: measureFmt.displayUnits ?? "None"
19993
- });
19888
+ tooltipValue = formatValue(rawValue, tableStyleProps.ToolTip.ToolTipNumberFormat, tableStyleProps.ToolTip.ToolTipDecimalPrecision);
19994
19889
  }
19995
19890
  }
19996
19891
  let percentage = 0;