pace-table-lib 1.0.68 → 1.0.70

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.
@@ -17214,8 +17214,8 @@ const DEFAULT_SL_STYLE = {
17214
17214
  hideMarkerButton: false
17215
17215
  };
17216
17216
  function JQuerySparkLine({
17217
- width = 76,
17218
- height = 16,
17217
+ width,
17218
+ height,
17219
17219
  slPropData
17220
17220
  }) {
17221
17221
  const sparkRef = useRef(null);
@@ -17238,7 +17238,7 @@ function JQuerySparkLine({
17238
17238
  case SL_TYPE.LINE:
17239
17239
  {
17240
17240
  const sparkOptions = {
17241
- type: "line",
17241
+ type: SL_TYPE.LINE,
17242
17242
  width: `${width}px`,
17243
17243
  height: `${height}px`,
17244
17244
  lineColor: slPropData.slStyle.lineColor,
@@ -17256,12 +17256,12 @@ function JQuerySparkLine({
17256
17256
  case SL_TYPE.BAR:
17257
17257
  {
17258
17258
  $(sparkRef.current).sparkline([...slPropData.dataArr], {
17259
- type: "bar",
17259
+ type: SL_TYPE.BAR,
17260
17260
  width: `${width}px`,
17261
17261
  height: `${height}px`,
17262
- barColor: slPropData.slStyle?.barColor,
17262
+ barColor: slPropData.slStyle?.posBarColor,
17263
17263
  negBarColor: slPropData.slStyle?.negBarColor,
17264
- zeroColor: slPropData.slStyle?.zeroBarColor,
17264
+ zeroColor: slPropData.slStyle?.zeroColor,
17265
17265
  barWidth: slPropData.slStyle?.barWidth,
17266
17266
  barSpacing: slPropData.slStyle?.barSpacing,
17267
17267
  chartRangeMin: 0
@@ -17271,7 +17271,7 @@ function JQuerySparkLine({
17271
17271
  case SL_TYPE.BOX:
17272
17272
  {
17273
17273
  $(sparkRef.current).sparkline([...slPropData.dataArr], {
17274
- type: "box",
17274
+ type: SL_TYPE.BOX,
17275
17275
  width: `${width}px`,
17276
17276
  height: `${height}px`,
17277
17277
  boxLineColor: slPropData.slStyle?.boxLineColor,
@@ -17284,7 +17284,7 @@ function JQuerySparkLine({
17284
17284
  case SL_TYPE.DISCRETE:
17285
17285
  {
17286
17286
  $(sparkRef.current).sparkline([...slPropData.dataArr], {
17287
- type: "discrete",
17287
+ type: SL_TYPE.DISCRETE,
17288
17288
  width: `${width}`,
17289
17289
  height: `${height}px`,
17290
17290
  lineColor: slPropData.slStyle?.lineColor || "#007bff",
@@ -17296,9 +17296,10 @@ function JQuerySparkLine({
17296
17296
  case SL_TYPE.PIE:
17297
17297
  {
17298
17298
  $(sparkRef.current).sparkline([...slPropData.dataArr], {
17299
- type: "pie",
17300
- // width: `${40}px`,
17301
- height: `${height}px`,
17299
+ type: SL_TYPE.PIE,
17300
+ //Why min in order to center align the pie chart , in case of fit table.
17301
+ width: `${Math.min(height, width)}px`,
17302
+ height: `${Math.min(height, width)}px`,
17302
17303
  borderWidth: 0,
17303
17304
  offset: slPropData.slStyle?.offset || 0,
17304
17305
  tooltipFormatter: function(sparkline, options, fields) {
@@ -17314,14 +17315,14 @@ function JQuerySparkLine({
17314
17315
  case SL_TYPE.TRISTATE:
17315
17316
  {
17316
17317
  $(sparkRef.current).sparkline(slPropData.dataArr, {
17317
- type: "tristate",
17318
+ type: SL_TYPE.TRISTATE,
17318
17319
  width: `${width}px`,
17319
17320
  height: `${height}px`,
17320
17321
  posBarColor: slPropData.slStyle?.posBarColor || "#28a745",
17321
17322
  // positive
17322
17323
  negBarColor: slPropData.slStyle?.negBarColor || "#dc3545",
17323
17324
  // negative
17324
- zeroBarColor: slPropData.slStyle?.zeroBarColor || "#bab0ac",
17325
+ zeroBarColor: slPropData.slStyle?.zeroColor || "#bab0ac",
17325
17326
  // neutral
17326
17327
  barWidth: slPropData.slStyle?.barWidth || 4,
17327
17328
  barSpacing: slPropData.slStyle?.barSpacing || 2,
@@ -17349,7 +17350,7 @@ function JQuerySparkLine({
17349
17350
  "span",
17350
17351
  {
17351
17352
  ref: sparkRef,
17352
- style: { display: "inline-block", verticalAlign: "middle" }
17353
+ style: { display: "inline-block", verticalAlign: "middle", zIndex: 10 }
17353
17354
  }
17354
17355
  );
17355
17356
  }
@@ -17416,23 +17417,33 @@ function StaticTable({
17416
17417
  const outsideBorder = isOutsideBorderVisible ? createBorder(Border.LineWidth, Border.LineStyle, Border.LineColor) : null;
17417
17418
  const insideVBorder = isInsideVerticalBVisible ? createBorder(Border.VerticalBorderLineWidth, Border.VerticalBorderLineStyle, Border.VerticalBorderLineColor) : null;
17418
17419
  const insideHBorder = isInsideHorizontalBVisible ? createBorder(Border.HorizontalBorderLineWidth, Border.HorizontalBorderLineStyle, Border.HorizontalBorderLineColor) : null;
17420
+ const {
17421
+ ShowHeatMap,
17422
+ HeatMapView,
17423
+ HeatMapMinColor,
17424
+ HeatMapMaxColor
17425
+ } = HeatMap || {};
17426
+ const gridRef = useRef(null);
17419
17427
  const renderDataCell = (label, styles, className, childClassName, toolTip, dataBarBg) => /* @__PURE__ */ jsxRuntimeExports.jsx(
17420
17428
  "div",
17421
17429
  {
17422
17430
  ...ToolTipVisibility ? { title: getCleanString(toolTip) ?? "" } : {},
17423
17431
  className,
17424
17432
  style: styles,
17433
+ onContextMenu: styles.hasOwnProperty("oncontextmenu") ? styles.oncontextmenu : null,
17425
17434
  children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
17426
17435
  "div",
17427
17436
  {
17428
17437
  className: `${childClassName} cell_inner`,
17429
17438
  style: {
17430
17439
  fontFamily: styles.fontFamily,
17431
- background: dataBarBg ?? "none"
17440
+ background: dataBarBg ?? "none",
17441
+ //Show icon only then align icon to center
17442
+ ...styles?.iconPosition === ICON_POSITION.OIcon ? { justifyContent: "center" } : {}
17432
17443
  },
17433
17444
  children: [
17434
17445
  styles && styles?.iconPosition === ICON_POSITION.Left && styles?.iconUrl && /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: styles?.iconUrl, className: "cell_icon left" }),
17435
- styles && styles?.iconPosition === ICON_POSITION.OIcon && styles?.iconUrl ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: styles?.iconUrl, className: "cell_icon left" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { textAlign: styles.justifyContent }, className: "cell_text", children: label }),
17446
+ styles && styles?.iconPosition === ICON_POSITION.OIcon && styles?.iconUrl ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: styles?.iconUrl, className: "cell_icon" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { textAlign: styles.justifyContent }, className: "cell_text", children: label }),
17436
17447
  styles && styles?.iconPosition === ICON_POSITION.Right && styles?.iconUrl && /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: styles?.iconUrl, className: "cell_icon right" })
17437
17448
  ]
17438
17449
  }
@@ -17479,12 +17490,6 @@ function StaticTable({
17479
17490
  color: DataFieldColor,
17480
17491
  ...getFontStyleObj(DataFieldFontStyle)
17481
17492
  }), [DataField]);
17482
- const {
17483
- ShowHeatMap,
17484
- HeatMapView,
17485
- HeatMapMinColor,
17486
- HeatMapMaxColor
17487
- } = HeatMap || {};
17488
17493
  const fixedRowCount = useMemo(() => {
17489
17494
  if (!isColHeaderVisible) {
17490
17495
  return headerAtStart && isColTotalOn ? 1 : 0;
@@ -17592,7 +17597,6 @@ function StaticTable({
17592
17597
  Table2.TableWidth,
17593
17598
  Table2.FixHeaderWidth
17594
17599
  ]);
17595
- const gridRef = useRef(null);
17596
17600
  useEffect(() => {
17597
17601
  const t = setTimeout(() => {
17598
17602
  if (gridRef.current) {
@@ -18216,7 +18220,7 @@ function StaticTable({
18216
18220
  height: rowCellHeight,
18217
18221
  top: baseTop + measuresBySlice.length * rowCellHeight,
18218
18222
  left: widthForTheTotal,
18219
- background: getBgColorForCell(rowCount - 1, rowColors),
18223
+ background: finalStyleForRow.background ?? getBgColorForCell(getGroupIndex(measuresBySlice), rowColors),
18220
18224
  fontWeight: "bold"
18221
18225
  };
18222
18226
  let measures = [];
@@ -18254,7 +18258,7 @@ function StaticTable({
18254
18258
  top: fixedRowCount * rowCellHeight + rowIdx * rowCellHeight,
18255
18259
  // directly under headers
18256
18260
  left: sparkColIndex * fixedColWidth,
18257
- background: getBgColorForCell(rowIdx - 1, rowColors),
18261
+ background: rowHeaderBandColorMap[item.sliceMark[0]],
18258
18262
  display: "flex",
18259
18263
  justifyContent: "center",
18260
18264
  alignItems: "center"
@@ -18412,10 +18416,12 @@ function StaticTable({
18412
18416
  if (operator === "duplicate") {
18413
18417
  const currentVal = value?.toLowerCase();
18414
18418
  if (type === CONDITIONAL_FORMAT_FOR.ROW) {
18415
- const allChildren = measuresBySlice.map((item) => item.sliceMark[level]?.toLowerCase()).filter((v) => v);
18416
- return allChildren.filter((v) => v === currentVal).length > 1;
18419
+ const marks = measuresBySlice.map((m) => m.sliceMark);
18420
+ const renderedValues = measuresBySlice.map((item, i) => isFirstOccurrence(marks, i, level) ? item.sliceMark[level]?.toLowerCase() : null).filter((v) => v !== null && v !== void 0);
18421
+ return renderedValues.filter((v) => v === currentVal).length > 1;
18417
18422
  } else if (type === CONDITIONAL_FORMAT_FOR.COLUMN) {
18418
- return dimensionMarks.filter((row) => row.some((item) => item?.toLowerCase() === currentVal)).length > 1;
18423
+ const renderedValues = dimensionMarks.map((d, i) => isFirstOccurrence(dimensionMarks, i, level) ? d[level]?.toLowerCase() : null).filter((v) => v !== null && v !== void 0);
18424
+ return renderedValues.filter((v) => v === currentVal).length > 1;
18419
18425
  }
18420
18426
  }
18421
18427
  if (type === CONDITIONAL_FORMAT_FOR.VALUE) {
@@ -18575,55 +18581,38 @@ function StaticTable({
18575
18581
  innerDivBg
18576
18582
  );
18577
18583
  };
18578
- function getSparkLineStyleObj(lineType) {
18584
+ function getSparkLineStyleObj() {
18579
18585
  const slStyle = structuredClone(DEFAULT_SL_STYLE);
18580
- switch (lineType) {
18581
- case SL_TYPE.LINE: {
18582
- if (SparkLine?.SparkLineColor)
18583
- slStyle.lineColor = SparkLine.SparkLineColor;
18584
- if (SparkLine?.SparkLineWidth)
18585
- slStyle.lineWidth = SparkLine.SparkLineWidth;
18586
- if (SparkLine?.HideMarkerButton !== void 0)
18587
- slStyle.hideMarkerButton = SparkLine.HideMarkerButton;
18588
- if (SparkLine?.SparkLineMarkerColor)
18589
- slStyle.spotColor = SparkLine.SparkLineMarkerColor;
18590
- break;
18591
- }
18592
- case SL_TYPE.BAR: {
18593
- if (SparkLine?.PositiveBarChartColor)
18594
- slStyle.posBarColor = SparkLine.PositiveBarChartColor;
18595
- if (SparkLine?.NegativeBarChartColor)
18596
- slStyle.negBarColor = SparkLine.NegativeBarChartColor;
18597
- if (SparkLine?.ZeroBarChartColor)
18598
- slStyle.zeroColor = SparkLine.ZeroBarChartColor;
18599
- if (SparkLine?.BarWidth)
18600
- slStyle.barWidth = SparkLine.BarWidth;
18601
- if (SparkLine?.BarSpacing)
18602
- slStyle.barSpacing = SparkLine.BarSpacing;
18603
- break;
18604
- }
18605
- case SL_TYPE.DISCRETE: {
18606
- if (SparkLine?.ThresholdValue !== void 0)
18607
- slStyle.thresholdValue = SparkLine.ThresholdValue;
18608
- if (SparkLine?.ThresholdColor)
18609
- slStyle.thresholdColor = SparkLine.ThresholdColor;
18610
- break;
18611
- }
18612
- case SL_TYPE.BOX: {
18613
- if (SparkLine?.MedianColor)
18614
- slStyle.medianColor = SparkLine.MedianColor;
18615
- if (SparkLine?.BoxFillColor)
18616
- slStyle.boxFillColor = SparkLine.BoxFillColor;
18617
- if (SparkLine?.BoxBorderColor)
18618
- slStyle.boxLineColor = SparkLine.BoxBorderColor;
18619
- if (SparkLine?.MinMaxLineColor)
18620
- slStyle.whiskerColor = SparkLine.MinMaxLineColor;
18621
- break;
18622
- }
18623
- case SL_TYPE.PIE: {
18624
- break;
18625
- }
18626
- }
18586
+ if (SparkLine?.SparkLineColor)
18587
+ slStyle.lineColor = SparkLine.SparkLineColor;
18588
+ if (SparkLine?.SparkLineWidth)
18589
+ slStyle.lineWidth = SparkLine.SparkLineWidth;
18590
+ if (SparkLine?.HideMarkerButton !== void 0)
18591
+ slStyle.hideMarkerButton = SparkLine.HideMarkerButton;
18592
+ if (SparkLine?.SparkLineMarkerColor)
18593
+ slStyle.spotColor = SparkLine.SparkLineMarkerColor;
18594
+ if (SparkLine?.PositiveBarChartColor)
18595
+ slStyle.posBarColor = SparkLine.PositiveBarChartColor;
18596
+ if (SparkLine?.NegativeBarChartColor)
18597
+ slStyle.negBarColor = SparkLine.NegativeBarChartColor;
18598
+ if (SparkLine?.ZeroBarChartColor)
18599
+ slStyle.zeroColor = SparkLine.ZeroBarChartColor;
18600
+ if (SparkLine?.BarWidth)
18601
+ slStyle.barWidth = SparkLine.BarWidth;
18602
+ if (SparkLine?.BarSpacing)
18603
+ slStyle.barSpacing = SparkLine.BarSpacing;
18604
+ if (SparkLine?.ThresholdValue !== void 0)
18605
+ slStyle.thresholdValue = SparkLine.ThresholdValue;
18606
+ if (SparkLine?.ThresholdColor)
18607
+ slStyle.thresholdColor = SparkLine.ThresholdColor;
18608
+ if (SparkLine?.MedianColor)
18609
+ slStyle.medianColor = SparkLine.MedianColor;
18610
+ if (SparkLine?.BoxFillColor)
18611
+ slStyle.boxFillColor = SparkLine.BoxFillColor;
18612
+ if (SparkLine?.BoxBorderColor)
18613
+ slStyle.boxLineColor = SparkLine.BoxBorderColor;
18614
+ if (SparkLine?.MinMaxLineColor)
18615
+ slStyle.whiskerColor = SparkLine.MinMaxLineColor;
18627
18616
  return slStyle;
18628
18617
  }
18629
18618
  function getSparkLine(dataArr, styleObj) {
@@ -18631,7 +18620,7 @@ function StaticTable({
18631
18620
  const lineType = SPARK_LINE_TYPE_MAPPING[SparkLine.SparkLineType];
18632
18621
  const slPropData = {
18633
18622
  dataArr,
18634
- slStyle: getSparkLineStyleObj(lineType),
18623
+ slStyle: getSparkLineStyleObj(),
18635
18624
  slType: lineType
18636
18625
  };
18637
18626
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "spark_line_div", style: { ...styleObj }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -18842,15 +18831,27 @@ function hexToRgb(hex) {
18842
18831
  const interpolateColor = (minColor, maxColor, factor) => {
18843
18832
  const toRgb = (hex) => {
18844
18833
  const clean = hex.replace("#", "");
18834
+ if (!/^[0-9A-Fa-f]{6}$/.test(clean)) {
18835
+ return { r: 0, g: 0, b: 0 };
18836
+ }
18845
18837
  const n = parseInt(clean, 16);
18846
- return { r: n >> 16 & 255, g: n >> 8 & 255, b: n & 255 };
18838
+ return {
18839
+ r: n >> 16 & 255,
18840
+ g: n >> 8 & 255,
18841
+ b: n & 255
18842
+ };
18847
18843
  };
18848
- const toHex = (r2, g, b) => `#${[r2, g, b]?.map((x) => x.toString(16).padStart(2, "0")).join("")}`;
18849
- const c1 = toRgb(minColor), c2 = toRgb(maxColor);
18844
+ const toHex = (r2, g, b) => `#${[r2, g, b].map((x) => {
18845
+ const safe = Number.isFinite(x) ? x : 0;
18846
+ return safe.toString(16).padStart(2, "0");
18847
+ }).join("")}`;
18848
+ const c1 = toRgb(minColor);
18849
+ const c2 = toRgb(maxColor);
18850
+ const safeFactor = Number.isFinite(factor) ? Math.max(0, Math.min(1, factor)) : 0;
18850
18851
  return toHex(
18851
- Math.round(c1.r + (c2.r - c1.r) * factor),
18852
- Math.round(c1.g + (c2.g - c1.g) * factor),
18853
- Math.round(c1.b + (c2.b - c1.b) * factor)
18852
+ Math.round(c1.r + (c2.r - c1.r) * safeFactor),
18853
+ Math.round(c1.g + (c2.g - c1.g) * safeFactor),
18854
+ Math.round(c1.b + (c2.b - c1.b) * safeFactor)
18854
18855
  );
18855
18856
  };
18856
18857
  function getHeatmapColor(value, minValue, maxValue, minColor, maxColor) {
@@ -19154,6 +19155,18 @@ const PivotTable = ({
19154
19155
  const [showCornerMenu, setShowCornerMenu] = useState(false);
19155
19156
  const [collapsedRows, setCollapsedRows] = useState(/* @__PURE__ */ new Set());
19156
19157
  const [collapsedCols, setCollapsedCols] = useState(/* @__PURE__ */ new Set());
19158
+ const cornerMenuRef = useRef(null);
19159
+ useEffect(() => {
19160
+ const handleOutsideClick = (event) => {
19161
+ if (cornerMenuRef.current && !cornerMenuRef.current.contains(event.target)) {
19162
+ setShowCornerMenu(false);
19163
+ }
19164
+ };
19165
+ document.addEventListener("mousedown", handleOutsideClick);
19166
+ return () => {
19167
+ document.removeEventListener("mousedown", handleOutsideClick);
19168
+ };
19169
+ }, []);
19157
19170
  const visibleRows = useMemo(
19158
19171
  () => flatRows?.filter((row) => {
19159
19172
  const nonSubSegs = row.segments?.filter((s) => s !== "!subtotal");
@@ -19961,6 +19974,7 @@ const PivotTable = ({
19961
19974
  }
19962
19975
  }
19963
19976
  let percentage = 0;
19977
+ let kpiColor = "";
19964
19978
  if (KPI.KPIVisibility) {
19965
19979
  const baseType = tableStyleProps.KPI.KPIBaseFormat;
19966
19980
  const values = baseType === "Column-wise" ? flatRows?.map(
@@ -19977,7 +19991,7 @@ const PivotTable = ({
19977
19991
  0,
19978
19992
  Math.min(100, (Number(rawValue) - min) / (max - min) * 100)
19979
19993
  ) : 0;
19980
- interpolateColor(
19994
+ kpiColor = interpolateColor(
19981
19995
  KPI.KPIMinColor,
19982
19996
  KPI.KPIMaxColor,
19983
19997
  percentage / 100
@@ -20020,7 +20034,7 @@ const PivotTable = ({
20020
20034
  "div",
20021
20035
  {
20022
20036
  className: "kpi-wrapper cell_inner_pivot",
20023
- style: { justifyContent: dataCellFont.justifyContent },
20037
+ style: { justifyContent: dataCellFont.justifyContent, background: kpiColor ?? "none" },
20024
20038
  children: [
20025
20039
  conditionalFormatObj && conditionalFormatObj?.iconPosition === ICON_POSITION.Left && conditionalFormatObj?.iconUrl && /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: conditionalFormatObj?.iconUrl, className: "cell_icon_pivot left" }),
20026
20040
  conditionalFormatObj && conditionalFormatObj?.iconPosition === ICON_POSITION.OIcon && conditionalFormatObj?.iconUrl ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: conditionalFormatObj?.iconUrl, className: "cell_icon_pivot left" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { textAlign: dataCellFont.justifyContent, ...shouldWrap ? { wordBreak: "break-word", whiteSpace: "normal" } : { whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, className: "kpi-text cell_text_pivot_pivot", children: formattedValue }),
@@ -20112,7 +20126,7 @@ const PivotTable = ({
20112
20126
  children: "+/−"
20113
20127
  }
20114
20128
  ),
20115
- showCornerMenu && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "pivot-corner-menu", children: [
20129
+ showCornerMenu && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "pivot-corner-menu", ref: cornerMenuRef, children: [
20116
20130
  hasCollapsibleRows && /* @__PURE__ */ jsxRuntimeExports.jsxs(
20117
20131
  "div",
20118
20132
  {