@nodii/dev 0.6.165 → 0.6.166

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/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.165";
7
+ export const VERSION = "0.6.166";
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 = 34;
35
+ export const GENERATOR_FORMAT = 36;
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). */
@@ -1942,7 +1942,14 @@ function dataProps(views, propsType) {
1942
1942
  if (list) {
1943
1943
  const field = member(entry(list), m[2]);
1944
1944
  const nullable = / == null \? \("(?:[^"\\]|\\.)*"\) : \((?:<div\b[^>]*>\s*)*$/.test(body.slice(0, m.index)) || field.get("\u0000pii")?.raw.endsWith(" | null");
1945
- field.set("\u0000pii", { raw: PII_ROW_FIELD + (nullable ? " | null" : "") });
1945
+ const ref = `${m[1]}.${m[2]}`;
1946
+ const mixed = mixedPiiExpressions(body).find(expression => m.index >= expression.at && m.index < expression.end)?.expression;
1947
+ const alternatives = mixed ? [
1948
+ `{ kind: "person" } & ${PII_ROW_FIELD}`,
1949
+ ...(mixed.includes(`${ref}.kind === "text"`) ? ['{ kind: "text"; text: string }'] : []),
1950
+ ...(mixed.includes(`${ref}.kind === "badge"`) ? ['{ kind: "badge"; text: string }'] : []),
1951
+ ].join(" | ") : null;
1952
+ field.set("\u0000pii", { raw: alternatives ?? PII_ROW_FIELD + (nullable ? " | null" : "") });
1946
1953
  }
1947
1954
  }
1948
1955
  for (const m of body.matchAll(/(^|>)\s*\{([a-z][A-Za-z0-9]*)\}/gm)) {
@@ -2041,9 +2048,9 @@ function drawnRef({ tag, attr, keys, literals, raw }) {
2041
2048
  /** The type the generated file declares for drawnProps (see there). */
2042
2049
  const DRAWN_TYPE = [
2043
2050
  "/** A DS component's props, narrowed to the member of their union this call draws: every required prop passed, every literal one fitting. */",
2044
- "type Drawn<P, K extends PropertyKey, L = {}> = [DrawnOf<P, K, L>] extends [never] ? P : DrawnOf<P, K, L>;",
2051
+ "type Drawn<P, K extends PropertyKey, L = Record<never, never>> = [DrawnOf<P, K, L>] extends [never] ? P : DrawnOf<P, K, L>;",
2045
2052
  "type DrawnOf<P, K extends PropertyKey, L> = P extends unknown",
2046
- " ? [Exclude<{ [k in keyof P]-?: {} extends Pick<P, k> ? never : k }[keyof P], K>] extends [never]",
2053
+ " ? [Exclude<{ [k in keyof P]-?: Record<never, never> extends Pick<P, k> ? never : k }[keyof P], K>] extends [never]",
2047
2054
  " ? [{ [k in keyof L]: k extends keyof P ? (L[k] extends P[k] ? never : k) : never }[keyof L]] extends [never]",
2048
2055
  " ? P",
2049
2056
  " : never",
@@ -2059,6 +2066,7 @@ const DRAWN_TYPE = [
2059
2066
  function tagAttributes(body, at) {
2060
2067
  const names = [];
2061
2068
  const literals = new Map();
2069
+ const values = new Map();
2062
2070
  let i = at;
2063
2071
  const skipString = (q) => {
2064
2072
  for (i++; i < body.length && body[i] !== q; i++) if (body[i] === "\\") i++;
@@ -2079,8 +2087,8 @@ function tagAttributes(body, at) {
2079
2087
  };
2080
2088
  while (i < body.length) {
2081
2089
  while (/\s/.test(body[i] ?? "")) i++;
2082
- if (body.startsWith("/>", i)) return { names, literals, selfClosing: true };
2083
- if (body[i] === ">") return { names, literals, selfClosing: false };
2090
+ if (body.startsWith("/>", i)) return { names, literals, values, end: i + 2, selfClosing: true };
2091
+ if (body[i] === ">") return { names, literals, values, selfClosing: false };
2084
2092
  if (body[i] === "{") return null;
2085
2093
  const name = /^[A-Za-z_][\w:-]*/.exec(body.slice(i))?.[0];
2086
2094
  if (!name) return null;
@@ -2088,6 +2096,7 @@ function tagAttributes(body, at) {
2088
2096
  i += name.length;
2089
2097
  if (body[i] !== "=") {
2090
2098
  literals.set(name, "true");
2099
+ values.set(name, "true");
2091
2100
  continue;
2092
2101
  }
2093
2102
  i++;
@@ -2095,12 +2104,27 @@ function tagAttributes(body, at) {
2095
2104
  const from = i;
2096
2105
  skipString(body[i]);
2097
2106
  literals.set(name, JSON.stringify(body.slice(from + 1, i - 1)));
2107
+ // JSX quoted attributes decode entities; object-property strings do not.
2108
+ const quoted = body.slice(from + 1, i - 1);
2109
+ let unsupportedEntity = false;
2110
+ const decoded = quoted.replace(/&(#x[0-9a-f]+|#\d+|[a-z][a-z0-9]+);/gi, (entity, key) => {
2111
+ const named = { amp: "&", quot: '"', apos: "'", lt: "<", gt: ">", nbsp: "\u00a0" };
2112
+ if (Object.hasOwn(named, key)) return named[key];
2113
+ const point = key.startsWith("#x") ? Number.parseInt(key.slice(2), 16) : key.startsWith("#") ? Number(key.slice(1)) : NaN;
2114
+ if (Number.isInteger(point) && point > 0 && point <= 0x10ffff && !(point >= 0xd800 && point <= 0xdfff)) return String.fromCodePoint(point);
2115
+ unsupportedEntity = true;
2116
+ return entity;
2117
+ });
2118
+ if (unsupportedEntity) literals.delete(name);
2119
+ else literals.set(name, JSON.stringify(decoded));
2120
+ values.set(name, unsupportedEntity ? null : JSON.stringify(decoded));
2098
2121
  continue;
2099
2122
  }
2100
2123
  if (body[i] !== "{") return null;
2101
2124
  const inner = braced();
2102
2125
  if (inner === null) return null;
2103
2126
  const value = inner.trim();
2127
+ values.set(name, value);
2104
2128
  if (/^(true|false|-?\d+(\.\d+)?|"(?:[^"\\\n]|\\.)*")$/.test(value)) literals.set(name, value);
2105
2129
  }
2106
2130
  return null;
@@ -2325,21 +2349,33 @@ function emitNode(node, ctx) {
2325
2349
  const sizing = ctx.bare || node.instance.set === "Detail Section / Row" ? [] : sizeClasses(node, parent, false);
2326
2350
  // A data slot passed straight to a prop is that prop (`trailing={<>{trailing}</>}` → `trailing={trailing}`).
2327
2351
  let own = rendered.code.trim().replace(/=\{<>\{([a-z][A-Za-z0-9]*)\}<\/>\}/g, "={$1}");
2328
- // The toolbar builds rows itself, so its template never renders the table slot.
2329
- // Preserve the published error component drawn there as its errorState contract.
2330
- if (node.instance.set === "Data Table Toolbar" && /^<DataTableToolbarBlock\b/.test(own) && !/\berrorState=/.test(own)) {
2352
+ // The toolbar owns table rendering, so its template does not emit this slot.
2353
+ // Preserve its drawn failure or zero-row composition through the supported props.
2354
+ if (node.instance.set === "Data Table Toolbar" && /^<DataTableToolbarBlock\b/.test(own)) {
2331
2355
  const tableSlot = (node.children ?? []).find(c => c.type === "SLOT" && c.slot === "table" && c.visible !== false);
2332
- const errors = [];
2356
+ const states = [];
2333
2357
  const collect = (current) => {
2334
2358
  if (current.visible === false) return;
2335
- if (current.instance?.remote && current.instance.set === "Error State Page") errors.push(current);
2359
+ if (current.instance?.remote && ["Error State Page", "Empty State"].includes(current.instance.set)) states.push(current);
2336
2360
  else for (const child of current.children ?? []) collect(child);
2337
2361
  };
2338
2362
  if (tableSlot) collect(tableSlot);
2339
- if (errors.length === 1) {
2340
- const errorCode = emitNode(errors[0], { ...ctx, depth: 0, parent: tableSlot, grand: node, path: `${path} › table`, root: false, inTable: false, inSlot: true, chain: [...chain, tableSlot] });
2341
- if (errorCode) own = own.replace(/^<DataTableToolbarBlock\b/, `<DataTableToolbarBlock errorState={${errorCode}}`);
2342
- } else if (errors.length > 1) note(`${path} › table`, "slot", "multiple Error State Page instances in one toolbar table slot: choose one error state");
2363
+ if (states.length === 1) {
2364
+ const error = states[0].instance.set === "Error State Page" || /(?:^|-)error(?:$|-)/.test(ctx.state ?? "");
2365
+ const prop = error ? "errorState" : "emptyState";
2366
+ if (!new RegExp(`\\b${prop}=`).test(own)) {
2367
+ const code = emitNode(states[0], { ...ctx, depth: 0, parent: tableSlot, grand: node, path: `${path} › table`, root: false, bare: true, inTable: false, inSlot: true, chain: [...chain, tableSlot] });
2368
+ if (error && code) own = own.replace(/^<DataTableToolbarBlock\b/, `<DataTableToolbarBlock errorState={${code}}`);
2369
+ else if (code?.startsWith("<EmptyState")) {
2370
+ const parsed = tagAttributes(code, "<EmptyState".length);
2371
+ const allowed = new Set(["title", "description", "actionLabel", "onAction", "actionDisabled", "actionDisabledReason", "illustration", "secondaryAction"]);
2372
+ if (parsed?.selfClosing && !code.slice(parsed.end).trim() && parsed.names.every(name => allowed.has(name) && parsed.values.get(name) !== null)) {
2373
+ const props = [...parsed.values].map(([name, value]) => `${name}: ${value}`).join(", ");
2374
+ own = own.replace(/^<DataTableToolbarBlock\b/, `<DataTableToolbarBlock emptyState={{ ${props} }}`);
2375
+ } else note(`${path} › table`, "slot", "drawn Empty State has props outside the toolbar emptyState contract");
2376
+ } else note(`${path} › table`, "slot", "drawn Empty State cannot be mapped to the toolbar emptyState contract");
2377
+ }
2378
+ } else if (states.length > 1) note(`${path} › table`, "slot", "multiple empty/error instances in one toolbar table slot: choose one state");
2343
2379
  }
2344
2380
  // A tab strip the page controls (tabOf reads the template's own strip first, to gather a run).
2345
2381
  if (!ctx.tabProbe) own = own.replace(/<Tabs panelless(?: defaultValue="[^"]*")?>/g, CONTROLLED_TABS("tab", "onTabChange"));
@@ -2621,6 +2657,18 @@ const PII_ROW_READ = /<PiiText value=\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]
2621
2657
  * placeholder, so both are `column1`) cannot share a safe contract. Report a mapping
2622
2658
  * failure in every affected column instead of discarding its PiiText protection.
2623
2659
  */
2660
+ function mixedPiiExpressions(body) {
2661
+ const flat = maskStrings(body);
2662
+ return [...body.matchAll(/\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\.kind === "person" \? \(/g)].map(match => {
2663
+ let depth = 0, end = match.index;
2664
+ for (; end < flat.length; end++) {
2665
+ if (flat[end] === "{") depth++;
2666
+ if (flat[end] === "}" && --depth === 0) break;
2667
+ }
2668
+ return { at: match.index, end: end + 1, param: match[1], key: match[2], expression: body.slice(match.index, end + 1) };
2669
+ });
2670
+ }
2671
+
2624
2672
  function settlePiiColumns(views, unmapped) {
2625
2673
  const NODE_READ = /(^|>)\s*\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\}/gm;
2626
2674
  const PII_CELL = />\n[ \t]*(?:<div\b[^>]*>\s*)*<PiiText value=\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\.value\} kind="[^\n]*\/>\s*(?:<\/div>\s*)*<\/TableCell>/g;
@@ -2642,7 +2690,56 @@ function settlePiiColumns(views, unmapped) {
2642
2690
  }
2643
2691
  for (const m of view.body.matchAll(NODE_READ)) count(view, openers, m.index, m[2], m[3], "node");
2644
2692
  }
2645
- const mixed = new Map([...reads].filter(([, r]) => r.pii && r.node));
2693
+ // A mixed cell declares its supported alternatives explicitly. Reuse that contract
2694
+ // in views which happen to draw only people or only the plain alternative.
2695
+ for (const view of views) {
2696
+ const openers = listOpeners(view.body);
2697
+ for (const m of mixedPiiExpressions(view.body)) {
2698
+ const r = reads.get(`${listAt(openers, m.at, m.param)}.${m.key}`);
2699
+ if (r) {
2700
+ const { expression } = m;
2701
+ const branches = expression.slice(1, -' : null}'.length).split(/ : (?=[a-z][A-Za-z0-9]*\.[A-Za-z][A-Za-z0-9]*\.kind === ")/);
2702
+ r.alternatives ??= new Map();
2703
+ for (const branch of branches) {
2704
+ const kind = /\.kind === "([^"]+)"/.exec(branch)?.[1];
2705
+ if (r.alternatives.has(kind) && r.alternatives.get(kind) !== branch) r.conflictingMixed = true;
2706
+ r.alternatives.set(kind, branch);
2707
+ }
2708
+ r.mixed = `{${[...r.alternatives.values()].join(" : ")} : null}`;
2709
+ }
2710
+ }
2711
+ }
2712
+ for (const view of views) {
2713
+ const openers = listOpeners(view.body);
2714
+ const replacements = [];
2715
+ for (const m of mixedPiiExpressions(view.body)) {
2716
+ const r = reads.get(`${listAt(openers, m.at, m.param)}.${m.key}`);
2717
+ if (r) replacements.push([m.at, m.end, r.conflictingMixed ? comment(`unmapped: incompatible mixed cell ${r.key}`) : r.mixed]);
2718
+ }
2719
+ for (const [start, end, replacement] of replacements.reverse()) view.body = view.body.slice(0, start) + replacement + view.body.slice(end);
2720
+ }
2721
+ for (const r of reads.values()) if (r.conflictingMixed) {
2722
+ unmapped.push({ variant: r.variant, path: r.list, kind: "table", detail: `column ${r.key} has incompatible mixed-cell templates across views` });
2723
+ r.mixed = comment(`unmapped: incompatible mixed cell ${r.key}`);
2724
+ }
2725
+ const mixed = new Map([...reads].filter(([, r]) => r.pii && r.node && !r.mixed));
2726
+ for (const view of views) {
2727
+ const openers = listOpeners(view.body);
2728
+ view.body = view.body.replace(PII_CELL, (all, param, key, at) => {
2729
+ const r = reads.get(`${listAt(openers, at, param)}.${key}`);
2730
+ return r?.mixed ? `>\n ${r.mixed}\n</TableCell>` : all;
2731
+ });
2732
+ const nullableOpeners = listOpeners(view.body);
2733
+ view.body = view.body.replace(/>\n[ \t]*\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*) == null \? \("(?:[^"\\]|\\.)*"\) : \((?:<div\b[^>]*>\s*)*<PiiText[^\n]*\/>\s*(?:<\/div>\s*)*\)\}\n[ \t]*<\/TableCell>/g, (all, param, key, at) => {
2734
+ const r = reads.get(`${listAt(nullableOpeners, at, param)}.${key}`);
2735
+ return r?.mixed ? `>\n ${r.mixed}\n</TableCell>` : all;
2736
+ });
2737
+ const plainOpeners = listOpeners(view.body);
2738
+ view.body = view.body.replace(NODE_READ, (all, open, param, key, at) => {
2739
+ const r = reads.get(`${listAt(plainOpeners, at, param)}.${key}`);
2740
+ return r?.mixed ? `${open}${r.mixed}` : all;
2741
+ });
2742
+ }
2646
2743
  // All views share the row type. Once nullable, every view must guard its read.
2647
2744
  for (const view of views) {
2648
2745
  const openers = listOpeners(view.body);
@@ -2726,6 +2823,23 @@ function piiCellText({ cell, code }, ref) {
2726
2823
  return `${before}<PiiText value={${ref}.value} kind="${kind}" model={${ref}.model} relation={${ref}.relation} maskHint={${ref}.maskHint} surface="bulk"${size} />${after}`;
2727
2824
  }
2728
2825
 
2826
+ /** A non-person alternative must be plain text or a plain Badge, never arbitrary JSX. */
2827
+ function plainPiiAlternative(part) {
2828
+ if (part.held || !/^<TableCell\b/.test(part.code ?? "")) return null;
2829
+ const inner = part.code.slice(openTagEnd(part.code) + 1).replace(/<\/TableCell>$/, "").trim();
2830
+ if (/^\{("(?:[^"\\]|\\.)*")\}$/.test(inner)) return { kind: "text" };
2831
+ const badge = /^<Badge([^<>]*)>(?:\{("(?:[^"\\]|\\.)*")\}|([^<>{}]*))<\/Badge>$/.exec(inner);
2832
+ if (!badge || /[{}]/.test(badge[1])) return null;
2833
+ return { kind: "badge", template: `<Badge${badge[1]}>{__plainCellText__}</Badge>` };
2834
+ }
2835
+
2836
+ function mixedPiiText(mixed, ref) {
2837
+ const branches = [`${ref}.kind === "person" ? (${piiCellText(mixed.sample, ref)})`];
2838
+ if (mixed.text) branches.push(`${ref}.kind === "text" ? (<>{${ref}.text}</>)`);
2839
+ if (mixed.badge) branches.push(`${ref}.kind === "badge" ? (${mixed.badge.replace("__plainCellText__", `${ref}.text`)})`);
2840
+ return `{${branches.join(" : ")} : null}`;
2841
+ }
2842
+
2729
2843
  /** Only a plain literal empty cell is compatible with a nullable person. */
2730
2844
  function emptyPiiCell(part) {
2731
2845
  if (part.held || !/^<TableCell\b/.test(part.code ?? "")) return null;
@@ -2874,6 +2988,13 @@ function treeTableOf(node, ctx) {
2874
2988
  ].join("\n"), ctx.depth);
2875
2989
  }
2876
2990
 
2991
+ // The cell template uses a row wrapper to demonstrate Selected in isolation.
2992
+ // Assembly owns that row; lift its selection state once for the whole record.
2993
+ function selectedCell(code) {
2994
+ const match = /^<TableRow selected>\s*([\s\S]*?)\s*<\/TableRow>$/.exec(code?.trim() ?? "");
2995
+ return match && /^<Table(?:Cell|RowActions|SelectionCell)\b/.test(match[1]) ? match[1] : null;
2996
+ }
2997
+
2877
2998
  function tableOf(node, ctx) {
2878
2999
  const shown = (node.children ?? []).filter((c) => c.visible !== false);
2879
3000
  // What follows the rows (a table's Empty State, bare or in its own frame) follows the Table:
@@ -2892,7 +3013,9 @@ function tableOf(node, ctx) {
2892
3013
  for (const cell of (row.children ?? []).filter((c) => c.visible !== false)) {
2893
3014
  if (cell.instance?.remote) {
2894
3015
  const local = [];
2895
- const code = emitNode(cell, { ...ctx, depth: 0, parent: null, path: `${ctx.path} › ${row.name}`, root: false, bare: true, inTable: true, imports: local, note: () => {} });
3016
+ const emitted = emitNode(cell, { ...ctx, depth: 0, parent: null, path: `${ctx.path} › ${row.name}`, root: false, bare: true, inTable: true, imports: local, note: () => {} });
3017
+ const selected = selectedCell(emitted);
3018
+ const code = selected ?? emitted;
2896
3019
  if (isSkeleton(code?.trim())) {
2897
3020
  imports.push(...local);
2898
3021
  cells.push({ cell, code: code.trim(), loading: true });
@@ -2910,7 +3033,7 @@ function tableOf(node, ctx) {
2910
3033
  // Rich Cell) keeps its own template code, as a cell of that row.
2911
3034
  kind = kind === "head" || part === "head" ? "head" : part;
2912
3035
  imports.push(...local);
2913
- cells.push({ cell, code });
3036
+ cells.push({ cell, code, selected: selected !== null });
2914
3037
  } else if (cell.layout || cell.type === "TEXT") cells.push({ cell, code: null });
2915
3038
  else return null;
2916
3039
  }
@@ -2987,7 +3110,7 @@ function tableOf(node, ctx) {
2987
3110
  const density = declaredDensity(parsed.find((p) => p.row === row)?.cells ?? []) ?? tableDensity;
2988
3111
  return `${widthAttr(w)}${density ? ` density="${density}"` : ""}`;
2989
3112
  };
2990
- const cellCode = ({ cell, code, held }, row, d, column = null) => {
3113
+ const cellCode = ({ cell, code, held, selected }, row, d, column = null) => {
2991
3114
  const w = columnWidth(cell);
2992
3115
  if (held) {
2993
3116
  const inner = emitNode(cell, { ...ctx, depth: d + 1, parent: null, path: `${ctx.path} › ${row.name}`, root: false, bare: true, inTable: true });
@@ -2995,7 +3118,8 @@ function tableOf(node, ctx) {
2995
3118
  }
2996
3119
  if (code) {
2997
3120
  // Re-emit for real, so the cell's own unmapped layers are reported.
2998
- return withWidth(emitNode(cell, { ...ctx, depth: d, parent: null, path: `${ctx.path} › ${row.name}`, root: false, bare: true, inTable: true, column }), w);
3121
+ const emitted = emitNode(cell, { ...ctx, depth: d, parent: null, path: `${ctx.path} › ${row.name}`, root: false, bare: true, inTable: true, column });
3122
+ return withWidth(selected ? indent(selectedCell(emitted), d) : emitted, w);
2999
3123
  }
3000
3124
  // The frame stood in for the cell: its size and padding are the TableCell's now.
3001
3125
  const inner = emitNode({ ...cell, sizing: ["HUG", "HUG"], x: undefined, fills: undefined, strokes: undefined, radius: undefined, ...(cell.layout ? { layout: { ...cell.layout, padding: [0, 0, 0, 0] } } : {}) }, { ...ctx, depth: d + 1, parent: null, path: `${ctx.path} › ${row.name}`, root: false, inTable: true });
@@ -3067,6 +3191,9 @@ function tableOf(node, ctx) {
3067
3191
  const first = dataRows[0];
3068
3192
  const keys = columnKeys(first.cells.length);
3069
3193
  const rowsName = mark(ctx, listName, "rows", null);
3194
+ let selectedKey = "isSelected";
3195
+ while (keys.includes(selectedKey)) selectedKey += "Row";
3196
+ const selection = dataRows.some(p => p.cells.some(c => c.selected)) ? ` selected={row.${selectedKey}}` : "";
3070
3197
  // A row is a door to its record when the page passes a handler (U03-7; NODII-DEV-CLI-83).
3071
3198
  const rowClick = mark(ctx, listName, "onRowClick", null);
3072
3199
  const inert = mark(ctx, listName, "isRowInert", null);
@@ -3074,10 +3201,11 @@ function tableOf(node, ctx) {
3074
3201
  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)`);
3075
3202
  // A column whose every body cell is a PiiText is a person's value: its row field is the
3076
3203
  // served pair and the cell draws PiiText from it, never a node the page could fill with a
3077
- // raw name (U05; cli-140). Mixed content must be compatible with a nullable
3078
- // person; otherwise the column is an explicit mapping failure.
3204
+ // raw name (U05; cli-140). Plain text and plain badges form typed alternatives;
3205
+ // unsupported mixed content remains an explicit mapping failure.
3079
3206
  const invalidPii = new Map();
3080
3207
  const nullablePii = new Map();
3208
+ const mixedPii = new Map();
3081
3209
  const personSamples = new Map();
3082
3210
  const piiColumn = keys.map((key, i) => {
3083
3211
  const people = dataRows.filter((p) => piiCellAttrs(p.cells[i]) !== null);
@@ -3091,13 +3219,19 @@ function tableOf(node, ctx) {
3091
3219
  const empties = others.map(p => emptyPiiCell(p.cells[i]));
3092
3220
  const nullable = drawn > 0 && others.length > 0 && empties.every(value => value !== null) && new Set(empties).size === 1;
3093
3221
  if (nullable) nullablePii.set(i, { sample: people[0].cells[i], empty: empties[0] });
3094
- if (drawn > 0 && drawn < dataRows.length && !nullable) {
3222
+ const plain = others.map(p => plainPiiAlternative(p.cells[i]));
3223
+ const mixed = drawn > 0 && others.length > 0 && !nullable && plain.every(Boolean);
3224
+ if (mixed) {
3225
+ const badges = plain.filter(p => p.kind === "badge");
3226
+ if (new Set(badges.map(p => p.template)).size <= 1) mixedPii.set(i, { sample: people[0].cells[i], badge: badges[0]?.template, text: plain.some(p => p.kind === "text") });
3227
+ }
3228
+ if (drawn > 0 && drawn < dataRows.length && !nullable && !mixedPii.has(i)) {
3095
3229
  const why = `column ${key} mixes PiiText with incompatible non-person content`;
3096
3230
  ctx.note(ctx.path, "table", `${why}: left unmapped (U05; cli-140)`);
3097
3231
  invalidPii.set(i, why);
3098
3232
  return false;
3099
3233
  }
3100
- if (drawn === dataRows.length || nullable) {
3234
+ if (drawn === dataRows.length || nullable || mixedPii.has(i)) {
3101
3235
  const kinds = people.map((p) => piiTreeKind(p.cells[i].cell));
3102
3236
  const why = kinds.some((kind) => !PII_KINDS.has(kind))
3103
3237
  ? `column ${key} has no recognised PiiText kind in one or more body rows`
@@ -3108,7 +3242,7 @@ function tableOf(node, ctx) {
3108
3242
  return false;
3109
3243
  }
3110
3244
  }
3111
- return drawn === dataRows.length || nullable;
3245
+ return drawn === dataRows.length || nullable || mixedPii.has(i);
3112
3246
  });
3113
3247
  const secondaryKeys = new Set(keys);
3114
3248
  const cells = first.cells.map((c, i) => {
@@ -3116,7 +3250,8 @@ function tableOf(node, ctx) {
3116
3250
  let open = `<TableCell${wrapperAttrs(w, first.row)}>`;
3117
3251
  let close = "</TableCell>";
3118
3252
  if (c.code && !c.held) {
3119
- const own = withWidth(emitNode(c.cell, { ...ctx, depth: 0, parent: null, path: `${ctx.path} › ${first.row.name}`, root: false, bare: true, inTable: true, scopes: null, note: () => {} }), w).trim();
3253
+ const emitted = emitNode(c.cell, { ...ctx, depth: 0, parent: null, path: `${ctx.path} › ${first.row.name}`, root: false, bare: true, inTable: true, scopes: null, note: () => {} });
3254
+ const own = withWidth(c.selected ? selectedCell(emitted) : emitted, w).trim();
3120
3255
  const end = openTagEnd(own);
3121
3256
  const tag = /^<([A-Za-z]+)/.exec(own)[1];
3122
3257
  open = own.slice(0, end + 1).replace(/\s*\/>$/, ">");
@@ -3136,14 +3271,15 @@ function tableOf(node, ctx) {
3136
3271
  if (piiColumn[i]) {
3137
3272
  const nullable = nullablePii.get(i);
3138
3273
  const ref = `row.${keys[i]}`;
3139
- const content = nullable ? `{${ref} == null ? (${nullable.empty}) : (${piiCellText(nullable.sample, ref)})}` : piiCellText(personSamples.get(i) ?? c, ref);
3274
+ const mixed = mixedPii.get(i);
3275
+ const content = mixed ? mixedPiiText(mixed, ref) : nullable ? `{${ref} == null ? (${nullable.empty}) : (${piiCellText(nullable.sample, ref)})}` : piiCellText(personSamples.get(i) ?? c, ref);
3140
3276
  return indent(`${open}\n ${content}\n${close}`, depth + 4);
3141
3277
  }
3142
3278
  return indent(`${open}{row.${keys[i]}}${close}`, depth + 4);
3143
3279
  });
3144
3280
  return [
3145
3281
  indent(`{${rowsName}.map((row) => (`, depth + 2),
3146
- indent(`<TableRow key={row.id} onClick={${inert}?.(row) ? undefined : ${getClick} ? ${getClick}(row) : ${rowClick} && (() => ${rowClick}(row))}>`, depth + 3),
3282
+ indent(`<TableRow key={row.id}${selection} onClick={${inert}?.(row) ? undefined : ${getClick} ? ${getClick}(row) : ${rowClick} && (() => ${rowClick}(row))}>`, depth + 3),
3147
3283
  ...cells,
3148
3284
  indent("</TableRow>", depth + 3),
3149
3285
  indent("))}", depth + 2),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.165",
3
+ "version": "0.6.166",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {