@nodii/dev 0.6.153 → 0.6.155

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/README.md CHANGED
@@ -977,6 +977,21 @@ product-page catalog names the Surface by its published component-set key
977
977
  each head and cell declares its column `width` as Figma sizes it (px for
978
978
  FIXED, `"fill"`, `"hug"`; DESIGN-SYSTEM-177) unless its template already
979
979
  does. A table with no hug column gets `layout="fixed"`.
980
+ - Generated tables accept optional `isRowInert(row)` and `getRowOnClick(row)`
981
+ bindings (hub-492). Inert rows receive no click handler. When supplied,
982
+ `getRowOnClick` owns the choice for each row: returning `undefined` leaves
983
+ that row noninteractive. Otherwise the existing `onRowClick(row)` applies.
984
+ Multiple tables have separate bindings named by their list scopes.
985
+ - A table drawn with published `TableTreeBranchRow` and `TableTreeLeafRow`
986
+ instances becomes a DS `Table` with `role="treegrid"`. Both row kinds must
987
+ be drawn, with matching column counts and a consistent template per kind.
988
+ Its `rows` data carries `kind` (`"branch"` or `"leaf"`), `depth`, the template's
989
+ data slots, and controlled `expanded` / `onExpandedChange` bindings. Supply
990
+ visible rows in preorder, removing descendants when a branch collapses.
991
+ The same per-row navigation bindings apply. Character indentation in plain
992
+ cells does not declare hierarchy; change the Surface to published tree rows
993
+ before regenerating it. A standalone branch also receives controlled
994
+ expansion bindings instead of its drawn literal expansion value.
980
995
  - Loose text takes the DS type utility and colour v2 role, and nothing else.
981
996
  A frame that paints its own fill, stroke, radius or effect keeps only its
982
997
  layout. A shape, or a library instance with no template, is a marked gap in
package/dist/core.js CHANGED
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
4
4
  import { homedir, platform } from "node:os";
5
5
  import { dirname, join } from "node:path";
6
6
 
7
- export const VERSION = "0.6.153";
7
+ export const VERSION = "0.6.155";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
package/dist/surface.js CHANGED
@@ -32,7 +32,7 @@ import { CliError, VERSION, devRequest, readConfig } from "./core.js";
32
32
  import { createRenderer } from "./vendor/render-templates.mjs";
33
33
 
34
34
  /** Bumped whenever the emitted code changes shape for the same inputs. */
35
- export const GENERATOR_FORMAT = 18;
35
+ export const GENERATOR_FORMAT = 21;
36
36
  export const TREE_DIR = "docs/figma-ux-ds/figma/surface-trees";
37
37
  export const GENERATED_SUFFIX = ".surface.generated.tsx";
38
38
  /** Where every generated product page lives, as a git glob (NODII-DEV-CLI-77). */
@@ -306,7 +306,7 @@ export function trimTree(entry, { row, version }) {
306
306
  const styles = entry.styles ?? {};
307
307
  const keyOf = (componentId) => components[componentId]?.key ?? null;
308
308
 
309
- const trim = (node, parentBox) => {
309
+ const trim = (node, parentBox, slotOwner = null) => {
310
310
  const out = { type: node.type, name: node.name };
311
311
  if (node.visible === false) return { ...out, visible: false };
312
312
  const box = node.absoluteBoundingBox;
@@ -360,6 +360,19 @@ export function trimTree(entry, { row, version }) {
360
360
  const effects = (node.effects ?? []).filter((e) => e.visible !== false);
361
361
  if (effects.length) out.effects = styles[node.styles?.effect]?.name ?? effects.map((e) => e.type).join(",");
362
362
 
363
+ // A remote component owns its slot container's unmodified paint. Keep the
364
+ // observed values, but distinguish them from Surface-owned overrides. Missing
365
+ // REST provenance stays conservative; the exemption never reaches slot content.
366
+ if (node.type === "SLOT" && Array.isArray(slotOwner?.overrides)) {
367
+ const fields = new Set(slotOwner.overrides.filter(o => o.id === node.id).flatMap(o => o.overriddenFields ?? []));
368
+ if (!fields.has("boundVariables") && !fields.has("styles")) {
369
+ const inherited = Object.entries({ fills: ["fills", "fillStyleId"], strokes: ["strokes", "strokeStyleId", "strokeWeight", "individualStrokeWeights"], radius: ["cornerRadius", "rectangleCornerRadii"], effects: ["effects", "effectStyleId"] })
370
+ .filter(([key, sources]) => out[key] && !sources.some(field => fields.has(field)))
371
+ .map(([key]) => key);
372
+ if (inherited.length) out.inheritedPaint = inherited;
373
+ }
374
+ }
375
+
363
376
  if (node.type === "INSTANCE") {
364
377
  const main = components[node.componentId] ?? {};
365
378
  // An instance's own layers, down to (not into) its slots, which are the Surface's.
@@ -422,7 +435,7 @@ export function trimTree(entry, { row, version }) {
422
435
  }
423
436
  };
424
437
  const children = main.remote ? [...slotsOf(node)] : (node.children ?? []);
425
- if (children.length) out.children = children.map((c) => trim(c, box));
438
+ if (children.length) out.children = children.map((c) => trim(c, box, main.remote ? node : null));
426
439
  return out;
427
440
  }
428
441
  if (node.type === "SLOT") {
@@ -930,6 +943,24 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
930
943
  const lifted = [];
931
944
  const lift = (at, name) => (lifted.push(name), mark(ctx, at, name));
932
945
  let out = liftFieldControls(code, node, ctx, lift, scope);
946
+ // A Tabs Group renders its triggers directly, without tabStrip's sibling assembly.
947
+ // Generic values use the drawn label for a useful name, but keep their routing value.
948
+ // Probes must retain the template's sample until tabStrip assigns each tab its value.
949
+ if (!ctx.tabProbe) {
950
+ out = rewriteTags(out, "TabsTrigger", (attrs, _tag, end) => {
951
+ const value = /\bvalue="([^"]*)"/.exec(attrs)?.[1];
952
+ const body = /\/\s*$/.test(attrs) ? "" : out.slice(end + 1, out.indexOf("</TabsTrigger>", end));
953
+ const label = /\{("(?:[^"\\\n]|\\.)*")\}/.exec(body);
954
+ const name = value && !/^tab(?:-\d+)?$/.test(value) ? camelName(value) : nameOf(label ? JSON.parse(label[1]) : "", value || "tab");
955
+ const own = (prop) => {
956
+ lifted.push(prop);
957
+ return `${prop}={${optionalMark(ctx, `${scope} ${value || name}`, joinName(name, prop))}}`;
958
+ };
959
+ return attrs
960
+ .replace(/\bactionableCount=\{(?:\d+|actionableCount)\}/, () => own("actionableCount"))
961
+ .replace(/\bcountIsFloor(?:=\{(?:true|false|countIsFloor)\})?(?=\s|\/|$)/, () => own("countIsFloor"));
962
+ });
963
+ }
933
964
  // An Alert's title or description that names a record's value: a date, an amount, a code,
934
965
  // or any figure ("running at 4.2% this period", "3 lines still carry a flag"; hub-468).
935
966
  out = out.replace(/<(Alert(Title|Description))>(\{"(?:[^"\\\n]|\\.)*"\})<\/\1>/g, (all, tag, part, lit) =>
@@ -977,6 +1008,12 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
977
1008
  return `<Badge${toned}>{${lift(at, "label")}}</Badge>`;
978
1009
  });
979
1010
  }
1011
+ // hub-492: the page owns disclosure state, not the drawn Expansion variant.
1012
+ out = rewriteTags(out, "TableTreeBranchRow", (attrs) => {
1013
+ let next = attrs.replace(/\bexpanded=\{(?:true|false)\}/, () => `expanded={${lift(scope, "expanded")}}`);
1014
+ if (!/\bonExpandedChange=/.test(next)) next = next.replace(/(expanded=\{[^}]+\})/, `$1 onExpandedChange={${optionalMark(ctx, scope, "onExpandedChange")}}`);
1015
+ return next;
1016
+ });
980
1017
  // Every Checkbox and Switch is controlled by the page and named by the text beside it
981
1018
  // (`pfChecked`, `onPfCheckedChange`): Figma's tick is the sample, never a default, and the
982
1019
  // template's own `checked` / `onCheckedChange` (DESIGN-SYSTEM-508) never shared (hub-468).
@@ -1755,12 +1792,20 @@ function dataProps(views, propsType) {
1755
1792
  entry(o.list).list = true;
1756
1793
  view.uses.add(o.list);
1757
1794
  }
1795
+ for (const m of body.matchAll(/row\.kind === "branch"/g)) {
1796
+ const list = listAt(openers, m.index, "row");
1797
+ if (list) member(entry(list), "kind").set("\u0000kind", { raw: '"branch" | "leaf"' });
1798
+ }
1758
1799
  const itemList = (at, name) => (openers.some((o) => o.param === name) ? listAt(openers, at, name) : null);
1759
- for (const m of body.matchAll(/onClick=\{([a-z][A-Za-z0-9]*) && \(\(\) => \1\(([a-z][A-Za-z0-9]*)\)\)\}/g)) {
1760
- const list = listAt(openers, m.index, m[2]);
1800
+ // hub-492: absence of a handler keeps an inert row noninteractive.
1801
+ for (const m of body.matchAll(/onClick=\{([a-z][A-Za-z0-9]*)\?\.\(row\) \? undefined : ([a-z][A-Za-z0-9]*) \? \2\(row\) : ([a-z][A-Za-z0-9]*) && /g)) {
1802
+ const list = listAt(openers, m.index, "row");
1761
1803
  if (!list) continue;
1762
- own(m[1], `(row: ${propsType}[${JSON.stringify(list)}][number]) => void`);
1763
- view.uses.add(m[1]);
1804
+ const item = `${propsType}[${JSON.stringify(list)}][number]`;
1805
+ own(m[1], `(row: ${item}) => boolean`);
1806
+ own(m[2], `(row: ${item}) => (() => void) | undefined`);
1807
+ own(m[3], `(row: ${item}) => void`);
1808
+ for (const name of m.slice(1)) view.uses.add(name);
1764
1809
  }
1765
1810
  for (const m of body.matchAll(/\bsort=\{([a-z][A-Za-z0-9]*) === ("(?:[^"\\\n]|\\.)*") \? ([a-z][A-Za-z0-9]*) : false\} onSort=\{([a-z][A-Za-z0-9]*) && /g)) {
1766
1811
  const [, by, key, dir, change] = m;
@@ -1799,7 +1844,11 @@ function dataProps(views, propsType) {
1799
1844
  // A lifted row's PII column is PiiText's served pair (cli-140).
1800
1845
  for (const m of body.matchAll(PII_ROW_READ)) {
1801
1846
  const list = itemList(m.index, m[1]);
1802
- if (list) member(entry(list), m[2]).set("\u0000pii", { raw: PII_ROW_FIELD });
1847
+ if (list) {
1848
+ const field = member(entry(list), m[2]);
1849
+ const nullable = / == null \? \("(?:[^"\\]|\\.)*"\) : \($/.test(body.slice(0, m.index)) || field.get("\u0000pii")?.raw.endsWith(" | null");
1850
+ field.set("\u0000pii", { raw: PII_ROW_FIELD + (nullable ? " | null" : "") });
1851
+ }
1803
1852
  }
1804
1853
  for (const m of body.matchAll(/(^|>)\s*\{([a-z][A-Za-z0-9]*)\}/gm)) {
1805
1854
  if (JS_LITERALS.has(m[2])) continue;
@@ -2255,15 +2304,16 @@ function emitNode(node, ctx) {
2255
2304
  return indent(comment(`unmapped: ${node.type.toLowerCase()} ${JSON.stringify(node.name)}`), depth);
2256
2305
  }
2257
2306
 
2258
- const table = tableOf(node, { ...ctx, path });
2307
+ const table = treeTableOf(node, { ...ctx, path }) ?? tableOf(node, { ...ctx, path });
2259
2308
  if (table) return table;
2260
2309
 
2261
2310
  // A frame, group, local component instance or slot: its layout only. A fill,
2262
2311
  // stroke, radius or effect it paints itself is not drawn, which would be a
2263
2312
  // look-alike of a DS part (MW2-37.2); it is reported as a missing DS part.
2264
- const painted = Boolean(node.fills?.length || node.strokes?.length || node.radius || node.effects);
2313
+ const ownPaint = key => !node.inheritedPaint?.includes(key) && node[key];
2314
+ const painted = Boolean(ownPaint("fills")?.length || ownPaint("strokes")?.length || ownPaint("radius") || ownPaint("effects"));
2265
2315
  if (painted)
2266
- note(path, "frame", `${node.instance ? `local component ${describe(node)}` : node.type.toLowerCase()} draws its own ${[node.fills?.length && "fill", node.strokes?.length && "stroke", node.radius && "radius", node.effects && `effect ${node.effects}`].filter(Boolean).join(", ")}`);
2316
+ note(path, "frame", `${node.instance ? `local component ${describe(node)}` : node.type.toLowerCase()} draws its own ${[ownPaint("fills")?.length && "fill", ownPaint("strokes")?.length && "stroke", ownPaint("radius") && "radius", ownPaint("effects") && `effect ${node.effects}`].filter(Boolean).join(", ")}`);
2267
2317
  // A frame that holds layers without auto layout has no flex or grid to
2268
2318
  // become: it is refused and reported, never drawn by absolute positions.
2269
2319
  if (!node.layout && (node.children ?? []).some((c) => c.visible !== false && !c.absolute)) {
@@ -2457,17 +2507,36 @@ function settlePiiColumns(views, unmapped) {
2457
2507
  const id = `${list}.${key}`;
2458
2508
  const r = reads.get(id) ?? reads.set(id, { list, key, pii: 0, node: 0, variant: view.variant }).get(id);
2459
2509
  r[how]++;
2510
+ return r;
2460
2511
  };
2461
2512
  for (const view of views) {
2462
2513
  const openers = listOpeners(view.body);
2463
- for (const m of view.body.matchAll(PII_ROW_READ)) count(view, openers, m.index, m[1], m[2], "pii");
2514
+ for (const m of view.body.matchAll(PII_ROW_READ)) {
2515
+ const r = count(view, openers, m.index, m[1], m[2], "pii");
2516
+ const empty = / == null \? \(("(?:[^"\\]|\\.)*")\) : \($/.exec(view.body.slice(0, m.index));
2517
+ if (r && empty) r.empty = empty[1];
2518
+ }
2464
2519
  for (const m of view.body.matchAll(NODE_READ)) count(view, openers, m.index, m[2], m[3], "node");
2465
2520
  }
2466
2521
  const mixed = new Map([...reads].filter(([, r]) => r.pii && r.node));
2522
+ // All views share the row type. Once nullable, every view must guard its read.
2523
+ for (const view of views) {
2524
+ const openers = listOpeners(view.body);
2525
+ view.body = view.body.replace(PII_CELL, (all, param, key, at) => {
2526
+ const r = reads.get(`${listAt(openers, at, param)}.${key}`);
2527
+ if (r?.empty === undefined || r.node) return all;
2528
+ const pii = /<PiiText[^\n]*\/>/.exec(all)[0];
2529
+ return all.replace(pii, `{${param}.${key} == null ? (${r.empty}) : (${pii})}`);
2530
+ });
2531
+ }
2467
2532
  if (!mixed.size) return;
2468
2533
  for (const view of views) {
2469
2534
  const openers = listOpeners(view.body);
2470
2535
  view.body = view.body.replace(PII_CELL, (all, param, key, at) => (mixed.has(`${listAt(openers, at, param)}.${key}`) ? `>{${param}.${key}}</TableCell>` : all));
2536
+ // Nullable cells also participate in the cross-view contract. A genuinely
2537
+ // different cell kind must not leave an object read behind a ReactNode type.
2538
+ const nullableOpeners = listOpeners(view.body);
2539
+ view.body = view.body.replace(/>\n[ \t]*\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*) == null \? \("(?:[^"\\]|\\.)*"\) : \(<PiiText[^\n]*\/>\)\}\n[ \t]*<\/TableCell>/g, (all, param, key, at) => (mixed.has(`${listAt(nullableOpeners, at, param)}.${key}`) ? `>{${param}.${key}}</TableCell>` : all));
2471
2540
  }
2472
2541
  for (const r of mixed.values()) {
2473
2542
  unmapped.push({ variant: r.variant, path: r.list, kind: LIFTED, detail: `column ${r.key} of ${r.list} is PiiText in ${r.pii} of the ${r.pii + r.node} tables that share its rows: it stays a ReactNode, and the page must draw its people through PiiText itself (U05; cli-140)` });
@@ -2483,6 +2552,24 @@ function piiCellAttrs({ code, held }) {
2483
2552
  }
2484
2553
 
2485
2554
  function piiTreeKind(cell) {
2555
+ // Rich cells render the Surface-owned content slot, not an exposed instance.
2556
+ // Resolve only that slot's visible PiiText; unrelated slots and hidden samples
2557
+ // must not supply a missing kind, and ambiguous content stays unmapped.
2558
+ if (cell.instance?.set === "Table Rich Cell") {
2559
+ const kinds = [];
2560
+ const visit = (node) => {
2561
+ if (node.visible === false || node.absolute) return;
2562
+ if (node.instance) {
2563
+ if (node.instance.remote && node.instance.set === "PiiText") kinds.push(node.instance.props?.kind);
2564
+ return;
2565
+ }
2566
+ for (const child of node.children ?? []) visit(child);
2567
+ };
2568
+ for (const slot of cell.children ?? []) {
2569
+ if (slot.type === "SLOT" && slot.slot === "content") visit(slot);
2570
+ }
2571
+ return kinds.length === 1 ? kinds[0] : undefined;
2572
+ }
2486
2573
  const exposed = Object.entries(cell.instance?.exposed ?? {}).find(([name]) => name.toLowerCase() === "piitext")?.[1];
2487
2574
  return exposed?.props?.kind;
2488
2575
  }
@@ -2495,6 +2582,16 @@ function piiCellText({ cell, code }, ref) {
2495
2582
  return `<PiiText value={${ref}.value} kind="${kind}" model={${ref}.model} relation={${ref}.relation} maskHint={${ref}.maskHint}${size} />`;
2496
2583
  }
2497
2584
 
2585
+ /** Only a plain literal empty cell is compatible with a nullable person. */
2586
+ function emptyPiiCell(part) {
2587
+ if (part.held || !/^<TableCell\b/.test(part.code ?? "")) return null;
2588
+ const inner = part.code.slice(openTagEnd(part.code) + 1).replace(/<\/TableCell>$/, "").trim();
2589
+ const literal = /^\{("(?:[^"\\]|\\.)*")\}$/.exec(inner);
2590
+ if (!literal) return null;
2591
+ const value = JSON.parse(literal[1]);
2592
+ return /^(?:\s*|\s*[-–—]\s*|\s*(?:unassigned|none|system)\s*)$/i.test(value) ? literal[1] : null;
2593
+ }
2594
+
2498
2595
  /**
2499
2596
  * A table a Surface draws as frames: rows of Table-part instances (what the
2500
2597
  * templates emit as TableHead or TableCell). Those parts are valid only inside
@@ -2562,6 +2659,77 @@ const HEAD_PLACEHOLDER_CHILD = /(<Table(?:Sort)?Head\b[^\n]*>\s*)\{"\s*[Tt]able
2562
2659
  /** A head whose copy is a figure (a year, "Zone 2"): the record's, lifted as its column's heading (hub-468). */
2563
2660
  const HEAD_FIGURE_CHILD = /(<Table(?:Sort)?Head\b[^\n]*>\s*)\{"(?:[^"\\\n]|\\.)*\d(?:[^"\\\n]|\\.)*"\}/;
2564
2661
 
2662
+ // hub-492: only published tree-row instances declare hierarchy. The caller supplies
2663
+ // the visible preorder rows, so collapsing a branch removes its descendants.
2664
+ function treeTableOf(node, ctx) {
2665
+ const shown = (node.children ?? []).filter((c) => c.visible !== false);
2666
+ const rendered = shown.map((child) => {
2667
+ if (!child.instance?.remote) return null;
2668
+ const imports = [];
2669
+ const code = emitNode(child, { ...ctx, depth: 0, parent: null, root: false, bare: true, inTable: true, scopes: null, imports, note: () => {} });
2670
+ const tag = /^<(TableTree(?:Branch|Leaf)Row)\b/.exec(code ?? "")?.[1];
2671
+ return tag ? { child, code, tag, imports } : null;
2672
+ });
2673
+ const first = rendered.findIndex(Boolean);
2674
+ if (first < 0 || rendered.slice(first).some((r) => !r)) return null;
2675
+ const branches = rendered.filter((r) => r?.tag === "TableTreeBranchRow");
2676
+ const leaves = rendered.filter((r) => r?.tag === "TableTreeLeafRow");
2677
+ // Both shapes must be drawn: never invent a missing DS row or its cells.
2678
+ if (!branches.length || !leaves.length) return null;
2679
+ const shape = (r) => r.code.replace(/\bdepth=\{[^}]+\}/, "depth={depth}");
2680
+ if ([branches, leaves].some((group) => group.some((r) => shape(r) !== shape(group[0])))) {
2681
+ ctx.note(ctx.path, "table", "tree rows of one kind have different templates; no single row shape (hub-492)");
2682
+ return indent(comment("unmapped: differing tree-row templates"), ctx.depth);
2683
+ }
2684
+ const header = shown.slice(0, first);
2685
+ const heads = [];
2686
+ const columnCounts = [];
2687
+ for (const row of header) {
2688
+ if (row.layout?.mode !== "HORIZONTAL") return null;
2689
+ const cells = [];
2690
+ for (const cell of row.children ?? []) {
2691
+ const code = emitNode(cell, { ...ctx, depth: 0, root: false, bare: true, inTable: true });
2692
+ if (tablePart(/^<([A-Za-z]+)/.exec(code ?? "")?.[1]) !== "head") return null;
2693
+ cells.push(withWidth(code, columnWidth(cell)));
2694
+ }
2695
+ columnCounts.push(cells.length);
2696
+ heads.push(`<TableRow>${cells.join("")}</TableRow>`);
2697
+ }
2698
+ const bodyColumns = [branches[0], leaves[0]].map((r) => 1 + [...r.code.matchAll(/<Table[A-Za-z]*Cell\b/g)].length);
2699
+ if ([...columnCounts, ...bodyColumns].some((n) => n !== bodyColumns[0])) {
2700
+ ctx.note(ctx.path, "table", "tree header and row templates have different column counts (hub-492)");
2701
+ return indent(comment("unmapped: mismatched tree columns"), ctx.depth);
2702
+ }
2703
+ const module = branches[0].imports.map((s) => /\{[^}]*\bTableTreeBranchRow\b[^}]*\}\s+from\s+["']([^"']+)["']/.exec(s)?.[1]).find(Boolean);
2704
+ if (!module) return null;
2705
+ const scope = listScope(node, ctx, scopeName(node), `tree:${shape(branches[0])}:${shape(leaves[0])}`);
2706
+ const rows = mark(ctx, scope, "rows", null);
2707
+ const inert = mark(ctx, scope, "isRowInert", null);
2708
+ const getClick = mark(ctx, scope, "getRowOnClick", null);
2709
+ const click = mark(ctx, scope, "onRowClick", null);
2710
+ const emit = (sample) => {
2711
+ ctx.imports.push(...sample.imports);
2712
+ let code = sample.code.replace(/\bdepth=\{[^}]+\}/, 'depth={row.depth}');
2713
+ // The templates' data slots stay typed by the DS prop or cell they reach.
2714
+ code = code.replace(/\{([a-z][A-Za-z0-9]*)\}/g, (all, name) => JS_LITERALS.has(name) ? all : `{row.${name}}`);
2715
+ code = code.replace(`<${sample.tag}`, `<${sample.tag} key={row.id} onClick={${inert}?.(row) ? undefined : ${getClick} ? ${getClick}(row) : ${click} && (() => ${click}(row))}`);
2716
+ return code;
2717
+ };
2718
+ const branch = emit(branches[0]);
2719
+ const leaf = emit(leaves[0]);
2720
+ ctx.imports.push(`import { Table, TableBody, TableHeader, TableRow } from "${module}";`);
2721
+ ctx.note(ctx.path, LIFTED, "published branch and leaf rows lifted as visible preorder data (hub-492)");
2722
+ return indent([
2723
+ '<Table role="treegrid">',
2724
+ ...(heads.length ? [' <TableHeader>', ...heads.map((h) => indent(h, 2)), ' </TableHeader>'] : []),
2725
+ ' <TableBody>',
2726
+ ` {${rows}.map((row) => (`,
2727
+ ' row.kind === "branch" ? (', indent(branch, 4),
2728
+ ' ) : (', indent(leaf, 4), ' )',
2729
+ ' ))}', ' </TableBody>', '</Table>',
2730
+ ].join("\n"), ctx.depth);
2731
+ }
2732
+
2565
2733
  function tableOf(node, ctx) {
2566
2734
  const shown = (node.children ?? []).filter((c) => c.visible !== false);
2567
2735
  // What follows the rows (a table's Empty State, bare or in its own frame) follows the Table:
@@ -2751,17 +2919,25 @@ function tableOf(node, ctx) {
2751
2919
  const rowsName = mark(ctx, listName, "rows", null);
2752
2920
  // A row is a door to its record when the page passes a handler (U03-7; NODII-DEV-CLI-83).
2753
2921
  const rowClick = mark(ctx, listName, "onRowClick", null);
2922
+ const inert = mark(ctx, listName, "isRowInert", null);
2923
+ const getClick = mark(ctx, listName, "getRowOnClick", null);
2754
2924
  ctx.note(ctx.path, LIFTED, `${dataRows.length} body row${dataRows.length === 1 ? "" : "s"} lifted as data: rows of { id, ${keys.join(", ")} } (NODII-DEV-CLI-82)`);
2755
2925
  // A column whose every body cell is a PiiText is a person's value: its row field is the
2756
2926
  // served pair and the cell draws PiiText from it, never a node the page could fill with a
2757
2927
  // raw name (U05; cli-140). A column that is PiiText in only some rows stays a node, and
2758
2928
  // the report names it.
2759
2929
  const invalidPii = new Map();
2930
+ const nullablePii = new Map();
2760
2931
  const piiColumn = keys.map((key, i) => {
2761
- const drawn = dataRows.filter((p) => piiCellAttrs(p.cells[i]) !== null).length;
2762
- if (drawn > 0 && drawn < dataRows.length) ctx.note(ctx.path, LIFTED, `column ${key} is PiiText in ${drawn} of ${dataRows.length} body rows: it stays a ReactNode, and the page must draw its people through PiiText itself (U05; cli-140)`);
2763
- if (drawn === dataRows.length) {
2764
- const kinds = dataRows.map((p) => piiTreeKind(p.cells[i].cell));
2932
+ const people = dataRows.filter((p) => piiCellAttrs(p.cells[i]) !== null);
2933
+ const drawn = people.length;
2934
+ const others = dataRows.filter((p) => piiCellAttrs(p.cells[i]) === null);
2935
+ const empties = others.map(p => emptyPiiCell(p.cells[i]));
2936
+ const nullable = drawn > 0 && others.length > 0 && empties.every(value => value !== null) && new Set(empties).size === 1;
2937
+ if (nullable) nullablePii.set(i, { sample: people[0].cells[i], empty: empties[0] });
2938
+ if (drawn > 0 && drawn < dataRows.length && !nullable) ctx.note(ctx.path, LIFTED, `column ${key} is PiiText in ${drawn} of ${dataRows.length} body rows: it stays a ReactNode, and the page must draw its people through PiiText itself (U05; cli-140)`);
2939
+ if (drawn === dataRows.length || nullable) {
2940
+ const kinds = people.map((p) => piiTreeKind(p.cells[i].cell));
2765
2941
  const why = kinds.some((kind) => !PII_KINDS.has(kind))
2766
2942
  ? `column ${key} has no recognised PiiText kind in one or more body rows`
2767
2943
  : new Set(kinds).size !== 1 ? `column ${key} has incompatible PiiText kinds` : null;
@@ -2771,7 +2947,7 @@ function tableOf(node, ctx) {
2771
2947
  return false;
2772
2948
  }
2773
2949
  }
2774
- return drawn === dataRows.length;
2950
+ return drawn === dataRows.length || nullable;
2775
2951
  });
2776
2952
  const cells = first.cells.map((c, i) => {
2777
2953
  const w = columnWidth(c.cell);
@@ -2785,12 +2961,17 @@ function tableOf(node, ctx) {
2785
2961
  close = `</${tag}>`;
2786
2962
  }
2787
2963
  if (invalidPii.has(i)) return indent(`${open}${comment(`unmapped: ${invalidPii.get(i)}`)}${close}`, depth + 4);
2788
- if (piiColumn[i]) return indent(`${open}\n ${piiCellText(c, `row.${keys[i]}`)}\n${close}`, depth + 4);
2964
+ if (piiColumn[i]) {
2965
+ const nullable = nullablePii.get(i);
2966
+ const ref = `row.${keys[i]}`;
2967
+ const content = nullable ? `{${ref} == null ? (${nullable.empty}) : (${piiCellText(nullable.sample, ref)})}` : piiCellText(c, ref);
2968
+ return indent(`${open}\n ${content}\n${close}`, depth + 4);
2969
+ }
2789
2970
  return indent(`${open}{row.${keys[i]}}${close}`, depth + 4);
2790
2971
  });
2791
2972
  return [
2792
2973
  indent(`{${rowsName}.map((row) => (`, depth + 2),
2793
- indent(`<TableRow key={row.id} onClick={${rowClick} && (() => ${rowClick}(row))}>`, depth + 3),
2974
+ indent(`<TableRow key={row.id} onClick={${inert}?.(row) ? undefined : ${getClick} ? ${getClick}(row) : ${rowClick} && (() => ${rowClick}(row))}>`, depth + 3),
2794
2975
  ...cells,
2795
2976
  indent("</TableRow>", depth + 3),
2796
2977
  indent("))}", depth + 2),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.153",
3
+ "version": "0.6.155",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {