@crossworks/content-core 0.712.10 → 0.712.15
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/package.json +2 -2
- package/src/table-model.ts +18 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crossworks/content-core",
|
|
3
|
-
"version": "0.712.
|
|
3
|
+
"version": "0.712.15",
|
|
4
4
|
"description": "Browser-safe content logic — markdown, blocks, pages, tables, formulas — shared by the server and any client. Zero server deps by design: nothing here may reach @mantle/db, node-only APIs, or the network (the jackdaw-repo-split P0 boundary).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"./tree": "./src/tree.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@mantle/client-types": "npm:@crossworks/client-types@0.712.
|
|
41
|
+
"@mantle/client-types": "npm:@crossworks/client-types@0.712.15",
|
|
42
42
|
"marked": "^18.1.2",
|
|
43
43
|
"mathjs": "15.2.0"
|
|
44
44
|
},
|
package/src/table-model.ts
CHANGED
|
@@ -209,17 +209,27 @@ export function tableDocFromGrid(input: GridInput): TableDoc {
|
|
|
209
209
|
name: c.name?.trim() || 'Column',
|
|
210
210
|
type: COLUMN_TYPES.includes(c.type as ColumnType) ? (c.type as ColumnType) : 'text',
|
|
211
211
|
}));
|
|
212
|
-
const rows: Row[] = input.rows.map((values) =>
|
|
213
|
-
const cells: Record<string, CellValue> = {};
|
|
214
|
-
columns.forEach((col, i) => {
|
|
215
|
-
const v = coerceCell(values[i] ?? null, storageType(col));
|
|
216
|
-
if (v !== null) cells[col.id] = v;
|
|
217
|
-
});
|
|
218
|
-
return { id: randomUUID(), cells };
|
|
219
|
-
});
|
|
212
|
+
const rows: Row[] = input.rows.map((values) => rowFromGrid(columns, values));
|
|
220
213
|
return { columns, rows, aggregates: {}, views: [] };
|
|
221
214
|
}
|
|
222
215
|
|
|
216
|
+
/** One grid row as a table row, as tableDocFromGrid makes it: a stable id
|
|
217
|
+
* (a random UUID unless the caller gives one), each cell coerced to its
|
|
218
|
+
* column's type. A file database's rows read as
|
|
219
|
+
* they come take this one at a time (packages/content file-database.ts). */
|
|
220
|
+
export function rowFromGrid(
|
|
221
|
+
columns: readonly Column[],
|
|
222
|
+
values: readonly (string | number | boolean | null)[],
|
|
223
|
+
id: string = randomUUID(),
|
|
224
|
+
): Row {
|
|
225
|
+
const cells: Record<string, CellValue> = {};
|
|
226
|
+
columns.forEach((col, i) => {
|
|
227
|
+
const v = coerceCell(values[i] ?? null, storageType(col));
|
|
228
|
+
if (v !== null) cells[col.id] = v;
|
|
229
|
+
});
|
|
230
|
+
return { id, cells };
|
|
231
|
+
}
|
|
232
|
+
|
|
223
233
|
/** Coerce an unknown/partial value into a well-formed TableDoc. Tolerant of
|
|
224
234
|
* legacy / hand-authored shapes — missing arrays become empty, every column
|
|
225
235
|
* and row gets a stable id, and cells are pruned to known columns. Returns the
|