@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.js
CHANGED
|
@@ -11261,6 +11261,33 @@ function findCellForContinuation(params) {
|
|
|
11261
11261
|
}
|
|
11262
11262
|
return params.cells[1] ?? params.cells[params.cells.length - 1];
|
|
11263
11263
|
}
|
|
11264
|
+
function columnLabelStartIndex(rows) {
|
|
11265
|
+
const headerIndex = rows.findIndex(
|
|
11266
|
+
({ row, cells }) => isSourceTreeHeaderRow(row) && cells.length > 1
|
|
11267
|
+
);
|
|
11268
|
+
return headerIndex >= 0 ? headerIndex : 0;
|
|
11269
|
+
}
|
|
11270
|
+
function metadataWithColumnLabel(metadata, label) {
|
|
11271
|
+
const next = {
|
|
11272
|
+
...metadata ?? {},
|
|
11273
|
+
columnName: label,
|
|
11274
|
+
visualTableRepairColumnLabel: label
|
|
11275
|
+
};
|
|
11276
|
+
if (metadata?.table && typeof metadata.table === "object" && !Array.isArray(metadata.table)) {
|
|
11277
|
+
next.table = {
|
|
11278
|
+
...metadata.table,
|
|
11279
|
+
columnName: label
|
|
11280
|
+
};
|
|
11281
|
+
}
|
|
11282
|
+
return next;
|
|
11283
|
+
}
|
|
11284
|
+
function tableCellDescription(cell, label) {
|
|
11285
|
+
const text = tableCellText(cell);
|
|
11286
|
+
return cleanText(
|
|
11287
|
+
text && text.toLowerCase() !== label.toLowerCase() ? `${label} | ${text}` : label,
|
|
11288
|
+
cell.description
|
|
11289
|
+
);
|
|
11290
|
+
}
|
|
11264
11291
|
function applyVisualTableRepair(sourceTree, repair) {
|
|
11265
11292
|
if (repair.tables.length === 0) return sourceTree;
|
|
11266
11293
|
const byId = new Map(sourceTree.map((node) => [node.id, node]));
|
|
@@ -11280,8 +11307,10 @@ function applyVisualTableRepair(sourceTree, repair) {
|
|
|
11280
11307
|
if (normalized) columnLabels.set(label.columnIndex, normalized);
|
|
11281
11308
|
}
|
|
11282
11309
|
if (columnLabels.size > 0) {
|
|
11283
|
-
|
|
11310
|
+
const firstLabelRowIndex = columnLabelStartIndex(rows);
|
|
11311
|
+
for (const [rowIndex, { row, cells }] of rows.entries()) {
|
|
11284
11312
|
if (removeIds.has(row.id)) continue;
|
|
11313
|
+
if (rowIndex < firstLabelRowIndex) continue;
|
|
11285
11314
|
for (const [fallbackIndex, cell] of cells.entries()) {
|
|
11286
11315
|
const columnIndex = tableCellColumnIndex(cell, fallbackIndex);
|
|
11287
11316
|
const label = columnLabels.get(columnIndex);
|
|
@@ -11289,10 +11318,8 @@ function applyVisualTableRepair(sourceTree, repair) {
|
|
|
11289
11318
|
updates.set(cell.id, {
|
|
11290
11319
|
...currentNode(cell.id) ?? cell,
|
|
11291
11320
|
title: label,
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
visualTableRepairColumnLabel: label
|
|
11295
|
-
}
|
|
11321
|
+
description: tableCellDescription(cell, label),
|
|
11322
|
+
metadata: metadataWithColumnLabel(cell.metadata, label)
|
|
11296
11323
|
});
|
|
11297
11324
|
}
|
|
11298
11325
|
}
|