pace-table-lib 1.0.37 → 1.0.40
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.
- package/dist/components/StaticTable/StaticTableTypeDec.types.d.ts +2 -2
- package/dist/pace-table-lib.es.js +38 -23
- package/dist/pace-table-lib.es.js.map +1 -1
- package/dist/pace-table-lib.umd.js +38 -23
- package/dist/pace-table-lib.umd.js.map +1 -1
- package/dist/stats.html +1 -1
- package/package.json +1 -1
|
@@ -55,8 +55,6 @@ type TableDataTypes = {
|
|
|
55
55
|
minValueInRow: number;
|
|
56
56
|
}[];
|
|
57
57
|
totalNumberOfRows: number;
|
|
58
|
-
rowDateFormatObj?: any;
|
|
59
|
-
columnDateFormatObj?: any;
|
|
60
58
|
};
|
|
61
59
|
type TableStyleConfig = {
|
|
62
60
|
ToolTip: {
|
|
@@ -233,6 +231,8 @@ type TableStyleConfig = {
|
|
|
233
231
|
Styles: {
|
|
234
232
|
idOfAppliedStyle: string;
|
|
235
233
|
};
|
|
234
|
+
ColumnDateFormat: any;
|
|
235
|
+
RowDateFormat: any;
|
|
236
236
|
};
|
|
237
237
|
export declare enum CONDITIONAL_FORMAT_FOR {
|
|
238
238
|
VALUE = 0,
|
|
@@ -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
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
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
|
|
17473
|
-
const
|
|
17474
|
-
|
|
17475
|
-
|
|
17476
|
-
|
|
17477
|
-
|
|
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),
|
|
@@ -17792,8 +17796,8 @@ function StaticTable({
|
|
|
17792
17796
|
if (isFirstOccurrence(dimensionMarks, i, level)) {
|
|
17793
17797
|
const span = getSpan(dimensionMarks, i, level);
|
|
17794
17798
|
let colLabel = getCleanString(dimensionMarks[i][level]);
|
|
17795
|
-
if (
|
|
17796
|
-
const dFormat =
|
|
17799
|
+
if (tableStyleProps?.ColumnDateFormat) {
|
|
17800
|
+
const dFormat = tableStyleProps?.ColumnDateFormat[level];
|
|
17797
17801
|
if (dFormat) {
|
|
17798
17802
|
colLabel = formatValue(colLabel, dFormat);
|
|
17799
17803
|
}
|
|
@@ -17899,7 +17903,6 @@ function StaticTable({
|
|
|
17899
17903
|
// data
|
|
17900
17904
|
dimensionMarks,
|
|
17901
17905
|
columnTotalRow,
|
|
17902
|
-
tableData.columnDateFormatObj,
|
|
17903
17906
|
// layout
|
|
17904
17907
|
fixedRowCount,
|
|
17905
17908
|
fixedColCount,
|
|
@@ -17935,6 +17938,17 @@ function StaticTable({
|
|
|
17935
17938
|
const renderMergedColHeaders = useMemo(() => colHeadersBase?.map(
|
|
17936
17939
|
(h) => renderDataCell(h.label, h, "col_header_cell_div", h.childClassName, h.label, h.dataBarColor)
|
|
17937
17940
|
), [colHeadersBase]);
|
|
17941
|
+
const rowHeaderBandColorMap = useMemo(() => {
|
|
17942
|
+
const map = {};
|
|
17943
|
+
const uniqueParents = [
|
|
17944
|
+
...new Set(measuresBySlice.map((m) => m.sliceMark[0] ?? ""))
|
|
17945
|
+
];
|
|
17946
|
+
const additionFactor = isColTotalOn && headerAtStart ? 0 : 1;
|
|
17947
|
+
uniqueParents.forEach((parent, index) => {
|
|
17948
|
+
map[parent] = getBgColorForCell(index + additionFactor, rowColors);
|
|
17949
|
+
});
|
|
17950
|
+
return map;
|
|
17951
|
+
}, [measuresBySlice, rowColors]);
|
|
17938
17952
|
const rowHeadersBase = useMemo(() => {
|
|
17939
17953
|
const headers = [];
|
|
17940
17954
|
const marks = measuresBySlice.map((m) => m.sliceMark);
|
|
@@ -17992,14 +18006,13 @@ function StaticTable({
|
|
|
17992
18006
|
if (isFirstOccurrence(marks, i, level)) {
|
|
17993
18007
|
const span = getSpan(marks, i, level);
|
|
17994
18008
|
let rowLabel = marks[i][level];
|
|
17995
|
-
if (
|
|
17996
|
-
const dFormat =
|
|
18009
|
+
if (tableStyleProps?.RowDateFormat) {
|
|
18010
|
+
const dFormat = tableStyleProps?.RowDateFormat[level];
|
|
17997
18011
|
if (dFormat) {
|
|
17998
18012
|
rowLabel = formatValue(rowLabel, dFormat);
|
|
17999
18013
|
}
|
|
18000
18014
|
}
|
|
18001
|
-
const
|
|
18002
|
-
const finalStyleForRow = getFinalStyleObj(STYLE_FOR.ROW, baseStyleObj, rowLabel, level, newIndex);
|
|
18015
|
+
const finalStyleForRow = getFinalStyleObj(STYLE_FOR.ROW, baseStyleObj, rowLabel, level, parent);
|
|
18003
18016
|
const tooltipValue = formatValue(marks[i][level], ToolTipNumberFormat, ToolTipDecimalPrecision);
|
|
18004
18017
|
headers.push({
|
|
18005
18018
|
...finalStyleForRow,
|
|
@@ -18108,6 +18121,7 @@ function StaticTable({
|
|
|
18108
18121
|
DataFieldDecimalPrecision,
|
|
18109
18122
|
DisplayUnits,
|
|
18110
18123
|
ShowHeatMap,
|
|
18124
|
+
rowHeaderBandColorMap,
|
|
18111
18125
|
parentBandColorMap,
|
|
18112
18126
|
rowColors,
|
|
18113
18127
|
dataBarMatrix,
|
|
@@ -18164,6 +18178,7 @@ function StaticTable({
|
|
|
18164
18178
|
const typeKey = ConFormattingTypeMap[formatFor];
|
|
18165
18179
|
const obj = {};
|
|
18166
18180
|
const arr = conditionalFormatsByType[typeKey] || [];
|
|
18181
|
+
if (arr.length <= 0) return;
|
|
18167
18182
|
for (const format of arr) {
|
|
18168
18183
|
if (shouldApplyFormat(value, format, formatFor, level)) {
|
|
18169
18184
|
applyFormat(obj, format);
|
|
@@ -18208,7 +18223,7 @@ function StaticTable({
|
|
|
18208
18223
|
}
|
|
18209
18224
|
return false;
|
|
18210
18225
|
}
|
|
18211
|
-
function getFinalStyleObj(styleFor, baseStyle, label, index,
|
|
18226
|
+
function getFinalStyleObj(styleFor, baseStyle, label, index, parentLabel) {
|
|
18212
18227
|
let style = { ...baseStyle };
|
|
18213
18228
|
switch (styleFor) {
|
|
18214
18229
|
// Priority 1: Conditional Formatting overrides everything
|
|
@@ -18219,7 +18234,7 @@ function StaticTable({
|
|
|
18219
18234
|
}
|
|
18220
18235
|
case STYLE_FOR.ROW: {
|
|
18221
18236
|
const conFormatForRow = index > 0 && getConditionalFormat(label, CONDITIONAL_FORMAT_FOR.ROW, index);
|
|
18222
|
-
style.background =
|
|
18237
|
+
style.background = rowHeaderBandColorMap[parentLabel];
|
|
18223
18238
|
style = applyConditionalFormatting(style, conFormatForRow);
|
|
18224
18239
|
return style;
|
|
18225
18240
|
}
|