@nodii/dev 0.6.160 → 0.6.162

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.160";
7
+ export const VERSION = "0.6.162";
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 = 28;
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
@@ -1582,7 +1587,16 @@ function liftFieldControls(code, node, ctx, lift, scope) {
1582
1587
  const changeName = `on${cap(withWord ? joinName(at, word) : at)}Change`;
1583
1588
  const value = `${valueAttr}={${lift(at, valueName)}}`;
1584
1589
  let next = attrs.replace(change[0], `${change[1]}${handler}={${lift(at, changeName)}}`);
1585
- const sample = INPUT_FAMILY.test(tag) ? "" : `|${SAMPLE_LITERAL}`;
1590
+ // Empty values in interactive templates are samples too. An option-only
1591
+ // MultiSelect snippet is an example option, not the editable trigger.
1592
+ const part = node.instance?.props?.control?.props?.part ?? node.instance?.props?.part;
1593
+ const empty = tag === "CurrencyInput" ? String.raw`|\{null\}`
1594
+ : tag === "MultiSelect" && part !== "option" ? String.raw`|\{\[\]\}` : "";
1595
+ const sample = INPUT_FAMILY.test(tag) ? "" : `|${SAMPLE_LITERAL}${empty}`;
1596
+ if (tag === "CurrencyInput") {
1597
+ next = next.replace(new RegExp(String.raw`(^|\s)currency=${LITERAL}`),
1598
+ (_, sp) => `${sp}currency={${lift(at, joinName(at, "currency"))}}`);
1599
+ }
1586
1600
  const drawn = new RegExp(String.raw`(^|\s)(?:${valueAttr}=(?:${GENERIC_VALUE}${sample})|defaultValue=${LITERAL})`).exec(next);
1587
1601
  if (drawn) return next.replace(drawn[0], `${drawn[1]}${value}`);
1588
1602
  if (new RegExp(String.raw`(^|\s)${valueAttr}=`).test(next)) return next;
@@ -1867,6 +1881,12 @@ function dataProps(views, propsType) {
1867
1881
  entry(m[2]).child = true;
1868
1882
  view.uses.add(m[2]);
1869
1883
  }
1884
+ // An overridable table heading retains the drawing's copy when omitted.
1885
+ for (const m of body.matchAll(/\{([a-z][A-Za-z0-9]*Heading) \?\? "(?:[^"\\\n]|\\.)*"\}/g)) {
1886
+ entry(m[1]).child = true;
1887
+ entry(m[1]).optional = true;
1888
+ view.uses.add(m[1]);
1889
+ }
1870
1890
  // A value inside an object prop (`chip={{ label: chipLabel }}`, `points: series1Points`).
1871
1891
  // Strings go first, so a colon in text or a class name is never read as one.
1872
1892
  const noStrings = body.replace(/"(?:[^"\\\n]|\\.)*"|`[^`]*`/g, '""');
@@ -2952,7 +2972,13 @@ function tableOf(node, ctx) {
2952
2972
  };
2953
2973
  // A head that still shows Figma's placeholder copy draws no header the page can read:
2954
2974
  // its copy is a prop, named by its column, in the list's scope (hub-468).
2955
- 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);
2975
+ const liftHeading = (code, key) => {
2976
+ if (!key) return code;
2977
+ 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)}}`);
2978
+ // Display copy may follow a selected dimension; row and sort keys still come
2979
+ // from the drawing. Existing consumers keep the drawn label (hub-507).
2980
+ return lifted.replace(/(<Table(?:Sort)?Head\b[^\n]*>\s*)\{("(?:[^"\\\n]|\\.)*")\}/, (_, open, label) => `${open}{${optionalMark(ctx, listName, `${key}Heading`, null)} ?? ${label}}`);
2981
+ };
2956
2982
  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);
2957
2983
  const liftedRows = () => {
2958
2984
  const first = dataRows[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.160",
3
+ "version": "0.6.162",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {