@nodii/dev 0.6.159 → 0.6.161

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.159";
7
+ export const VERSION = "0.6.161";
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 = 25;
35
+ export const GENERATOR_FORMAT = 27;
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). */
@@ -1017,12 +1017,17 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
1017
1017
  // Every Checkbox and Switch is controlled by the page and named by the text beside it
1018
1018
  // (`pfChecked`, `onPfCheckedChange`): Figma's tick is the sample, never a default, and the
1019
1019
  // template's own `checked` / `onCheckedChange` (DESIGN-SYSTEM-508) never shared (hub-468).
1020
- if (TOGGLE.test(out)) {
1020
+ const fieldToggle = /^<Field\b/.test(out) && /<(?:Checkbox|Switch)\b/.test(out);
1021
+ if (TOGGLE.test(out) || fieldToggle) {
1021
1022
  out = rewriteTags(out, "Checkbox|Switch", (attrs) => {
1022
1023
  const rest = attrs
1023
1024
  .replace(new RegExp(String.raw`\s+(?:checked|onCheckedChange)=(?:${LITERAL}|\{[^{}]*\})`, "g"), "")
1024
1025
  .replace(/\s+defaultChecked(?:=\{(?:true|false)\})?(?=[\s/>]|$)/g, "");
1025
- return ` checked={${lift(scope, joinName(scope, "checked"))}} onCheckedChange={${lift(scope, `on${cap(joinName(scope, "checkedChange"))}`)}}${rest}`;
1026
+ // A Field's swapped control still belongs to its caller, including pending
1027
+ // and permission state. Keep the Field's own id, error and hint bindings.
1028
+ const controlled = fieldToggle ? rest.replace(/\s+disabled(?:=(?:\{[^{}]*\}|"[^"]*"))?(?=[\s/>]|$)/g, "") : rest;
1029
+ const disabled = fieldToggle ? ` disabled={${lift(scope, joinName(scope, "disabled"))}}` : "";
1030
+ return ` checked={${lift(scope, joinName(scope, "checked"))}} onCheckedChange={${lift(scope, `on${cap(joinName(scope, "checkedChange"))}`)}}${disabled}${controlled}`;
1026
1031
  });
1027
1032
  }
1028
1033
  // A record's progress, priority and amount, a chip's label and a step's status are the
@@ -1132,6 +1137,14 @@ export const SAMPLE_VALUE = /₹\s?\d|\b\d{1,2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|A
1132
1137
  const RELATIVE_PERIOD = /^(?:(?:this|last|previous|current|next) (?:day|week|month|quarter|year)|today|yesterday|tomorrow)$/i;
1133
1138
  const RECORD_TEXT = (text) => SAMPLE_VALUE.test(text) || /\d/.test(text) || RELATIVE_PERIOD.test(text.trim());
1134
1139
 
1140
+ // A named fact frame is a label/value pair even when its value has no digits
1141
+ // (for example Status / Active). Keep the label and lift only the value.
1142
+ function isFactValue(node, parent) {
1143
+ if (parent?.type !== "FRAME" || !/^Fact\s*·\s*\S/.test(parent.name ?? "")) return false;
1144
+ const children = (parent.children ?? []).filter((child) => child.visible !== false);
1145
+ return children.length === 2 && children.every((child) => child.type === "TEXT") && children[1] === node;
1146
+ }
1147
+
1135
1148
  /** A part named by where it sits: its parent's name, numbered when the parent holds several of the same set. */
1136
1149
  function positionScope(node, ctx, kind) {
1137
1150
  const siblings = (ctx.parent?.children ?? []).filter((c) => c.visible !== false && (node.instance ? c.instance?.set === node.instance.set : c.type === node.type));
@@ -1859,6 +1872,12 @@ function dataProps(views, propsType) {
1859
1872
  entry(m[2]).child = true;
1860
1873
  view.uses.add(m[2]);
1861
1874
  }
1875
+ // An overridable table heading retains the drawing's copy when omitted.
1876
+ for (const m of body.matchAll(/\{([a-z][A-Za-z0-9]*Heading) \?\? "(?:[^"\\\n]|\\.)*"\}/g)) {
1877
+ entry(m[1]).child = true;
1878
+ entry(m[1]).optional = true;
1879
+ view.uses.add(m[1]);
1880
+ }
1862
1881
  // A value inside an object prop (`chip={{ label: chipLabel }}`, `points: series1Points`).
1863
1882
  // Strings go first, so a colon in text or a class name is never read as one.
1864
1883
  const noStrings = body.replace(/"(?:[^"\\\n]|\\.)*"|`[^`]*`/g, '""');
@@ -2309,7 +2328,7 @@ function emitNode(node, ctx) {
2309
2328
  ]);
2310
2329
  // Text naming a record's value (a date, an amount, a code) is Figma's sample: the page's own (NODII-DEV-CLI-82).
2311
2330
  let content = JSON.stringify(node.text);
2312
- if (RECORD_TEXT(node.text) && !ctx.textOwner) {
2331
+ if ((RECORD_TEXT(node.text) || isFactValue(node, parent)) && !ctx.textOwner) {
2313
2332
  const scope = positionScope(node, ctx, "text");
2314
2333
  const name = mark(ctx, scope, scope);
2315
2334
  note(path, LIFTED, `text ${shown} names a record's value: lifted from Figma's sample into the page's props (NODII-DEV-CLI-82)`);
@@ -2944,7 +2963,13 @@ function tableOf(node, ctx) {
2944
2963
  };
2945
2964
  // A head that still shows Figma's placeholder copy draws no header the page can read:
2946
2965
  // its copy is a prop, named by its column, in the list's scope (hub-468).
2947
- const liftHeading = (code, key) => (key ? code.replace(HEAD_PLACEHOLDER_CHILD, (_, open) => `${open}{${mark(ctx, listName, `${key}Heading`, null)}}`).replace(HEAD_FIGURE_CHILD, (_, open) => `${open}{${mark(ctx, listName, `${key}Heading`, null)}}`) : code);
2966
+ const liftHeading = (code, key) => {
2967
+ if (!key) return code;
2968
+ const lifted = code.replace(HEAD_PLACEHOLDER_CHILD, (_, open) => `${open}{${mark(ctx, listName, `${key}Heading`, null)}}`).replace(HEAD_FIGURE_CHILD, (_, open) => `${open}{${mark(ctx, listName, `${key}Heading`, null)}}`);
2969
+ // Display copy may follow a selected dimension; row and sort keys still come
2970
+ // from the drawing. Existing consumers keep the drawn label (hub-507).
2971
+ return lifted.replace(/(<Table(?:Sort)?Head\b[^\n]*>\s*)\{("(?:[^"\\\n]|\\.)*")\}/, (_, open, label) => `${open}{${optionalMark(ctx, listName, `${key}Heading`, null)} ?? ${label}}`);
2972
+ };
2948
2973
  const liftable = !skeleton && dataRows.length > 0 && dataRows.every((p) => !p.unrecognised && !p.framesOnly && p.cells.length === dataRows[0].cells.length) && (!headRow || headRow.cells.length === dataRows[0].cells.length);
2949
2974
  const liftedRows = () => {
2950
2975
  const first = dataRows[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.159",
3
+ "version": "0.6.161",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {