@claritylabs/cl-sdk 3.1.8 → 3.1.9
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/index.js +32 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -10893,6 +10893,33 @@ function findCellForContinuation(params) {
|
|
|
10893
10893
|
}
|
|
10894
10894
|
return params.cells[1] ?? params.cells[params.cells.length - 1];
|
|
10895
10895
|
}
|
|
10896
|
+
function columnLabelStartIndex(rows) {
|
|
10897
|
+
const headerIndex = rows.findIndex(
|
|
10898
|
+
({ row, cells }) => isSourceTreeHeaderRow(row) && cells.length > 1
|
|
10899
|
+
);
|
|
10900
|
+
return headerIndex >= 0 ? headerIndex : 0;
|
|
10901
|
+
}
|
|
10902
|
+
function metadataWithColumnLabel(metadata, label) {
|
|
10903
|
+
const next = {
|
|
10904
|
+
...metadata ?? {},
|
|
10905
|
+
columnName: label,
|
|
10906
|
+
visualTableRepairColumnLabel: label
|
|
10907
|
+
};
|
|
10908
|
+
if (metadata?.table && typeof metadata.table === "object" && !Array.isArray(metadata.table)) {
|
|
10909
|
+
next.table = {
|
|
10910
|
+
...metadata.table,
|
|
10911
|
+
columnName: label
|
|
10912
|
+
};
|
|
10913
|
+
}
|
|
10914
|
+
return next;
|
|
10915
|
+
}
|
|
10916
|
+
function tableCellDescription(cell, label) {
|
|
10917
|
+
const text = tableCellText(cell);
|
|
10918
|
+
return cleanText(
|
|
10919
|
+
text && text.toLowerCase() !== label.toLowerCase() ? `${label} | ${text}` : label,
|
|
10920
|
+
cell.description
|
|
10921
|
+
);
|
|
10922
|
+
}
|
|
10896
10923
|
function applyVisualTableRepair(sourceTree, repair) {
|
|
10897
10924
|
if (repair.tables.length === 0) return sourceTree;
|
|
10898
10925
|
const byId = new Map(sourceTree.map((node) => [node.id, node]));
|
|
@@ -10912,8 +10939,10 @@ function applyVisualTableRepair(sourceTree, repair) {
|
|
|
10912
10939
|
if (normalized) columnLabels.set(label.columnIndex, normalized);
|
|
10913
10940
|
}
|
|
10914
10941
|
if (columnLabels.size > 0) {
|
|
10915
|
-
|
|
10942
|
+
const firstLabelRowIndex = columnLabelStartIndex(rows);
|
|
10943
|
+
for (const [rowIndex, { row, cells }] of rows.entries()) {
|
|
10916
10944
|
if (removeIds.has(row.id)) continue;
|
|
10945
|
+
if (rowIndex < firstLabelRowIndex) continue;
|
|
10917
10946
|
for (const [fallbackIndex, cell] of cells.entries()) {
|
|
10918
10947
|
const columnIndex = tableCellColumnIndex(cell, fallbackIndex);
|
|
10919
10948
|
const label = columnLabels.get(columnIndex);
|
|
@@ -10921,10 +10950,8 @@ function applyVisualTableRepair(sourceTree, repair) {
|
|
|
10921
10950
|
updates.set(cell.id, {
|
|
10922
10951
|
...currentNode(cell.id) ?? cell,
|
|
10923
10952
|
title: label,
|
|
10924
|
-
|
|
10925
|
-
|
|
10926
|
-
visualTableRepairColumnLabel: label
|
|
10927
|
-
}
|
|
10953
|
+
description: tableCellDescription(cell, label),
|
|
10954
|
+
metadata: metadataWithColumnLabel(cell.metadata, label)
|
|
10928
10955
|
});
|
|
10929
10956
|
}
|
|
10930
10957
|
}
|