@nodii/dev 0.6.187 → 0.6.188
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 +1 -1
- package/dist/surface.js +19 -11
- package/package.json +1 -1
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.
|
|
7
|
+
export const VERSION = "0.6.188";
|
|
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
|
@@ -34,7 +34,7 @@ import { MIN_FIGMA_INTERVAL_MS, figmaRest } from "./figma-rest.js";
|
|
|
34
34
|
import { createRenderer } from "./vendor/render-templates.mjs";
|
|
35
35
|
|
|
36
36
|
/** Bumped whenever the emitted code changes shape for the same inputs. */
|
|
37
|
-
export const GENERATOR_FORMAT =
|
|
37
|
+
export const GENERATOR_FORMAT = 45;
|
|
38
38
|
/**
|
|
39
39
|
* DS parts that are an item of their parent's own list or grid, so they take no sizing
|
|
40
40
|
* wrapper: a Detail Section / Row's facts are the section grid's cells, a Right Pane / Row
|
|
@@ -2710,27 +2710,35 @@ function emitChildren(children, emitOne, ctx) {
|
|
|
2710
2710
|
}
|
|
2711
2711
|
|
|
2712
2712
|
const LABEL_FOR = /<Label\b[^>]*?\bhtmlFor=\{([A-Za-z_$][\w$]*)\}/;
|
|
2713
|
-
const LABELLED_CONTROL = /<(?:Checkbox|Switch|RadioGroupItem)(?=[\s/>])/;
|
|
2713
|
+
const LABELLED_CONTROL = /<(?:Checkbox|Switch|RadioGroupItem|Textarea|Input|SelectField)(?=[\s/>])/;
|
|
2714
2714
|
/**
|
|
2715
2715
|
* A DS Label beside its control names it: the Label template emits htmlFor={x}, so the
|
|
2716
|
-
* Checkbox, Switch or
|
|
2717
|
-
*
|
|
2716
|
+
* Checkbox, Switch, RadioGroupItem, Textarea, Input or SelectField next to it (in the same
|
|
2717
|
+
* container) takes id={x}, or, when that control already has an id of its own, the Label's
|
|
2718
|
+
* htmlFor takes that id. Without it the label isn't tied to the control and the control has
|
|
2718
2719
|
* no accessible name (DESIGN-SYSTEM-817). Each label names the one control beside it.
|
|
2719
2720
|
*/
|
|
2720
2721
|
function pairLabelledControls(codes) {
|
|
2722
|
+
const out = [...codes];
|
|
2721
2723
|
const labelOf = codes.map((c) => LABEL_FOR.exec(c ?? "")?.[1] ?? null);
|
|
2722
2724
|
const used = new Set();
|
|
2723
|
-
|
|
2725
|
+
codes.forEach((code, i) => {
|
|
2724
2726
|
const control = code ? LABELLED_CONTROL.exec(code) : null;
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
if (/\sid=/.test(open)) return code;
|
|
2727
|
+
// A container that holds a Label of its own is already paired, at its own level.
|
|
2728
|
+
if (!control || /<Label\b/.test(code)) return;
|
|
2728
2729
|
const at = [i + 1, i - 1].find((j) => labelOf[j] && !used.has(j));
|
|
2729
|
-
if (at === undefined) return
|
|
2730
|
+
if (at === undefined) return;
|
|
2730
2731
|
used.add(at);
|
|
2731
|
-
const
|
|
2732
|
-
|
|
2732
|
+
const open = code.slice(control.index, control.index + openTagEnd(code.slice(control.index)) + 1);
|
|
2733
|
+
const own = /\sid=("(?:[^"\\\n]|\\.)*"|\{[^{}]*\})/.exec(open)?.[1];
|
|
2734
|
+
// The control keeps its own id; its Label points at it.
|
|
2735
|
+
if (own) out[at] = out[at].replace(LABEL_FOR, (tag) => tag.replace(/htmlFor=\{[^}]*\}/, `htmlFor=${own}`));
|
|
2736
|
+
else {
|
|
2737
|
+
const end = control.index + control[0].length;
|
|
2738
|
+
out[i] = `${code.slice(0, end)} id={${labelOf[at]}}${code.slice(end)}`;
|
|
2739
|
+
}
|
|
2733
2740
|
});
|
|
2741
|
+
return out;
|
|
2734
2742
|
}
|
|
2735
2743
|
|
|
2736
2744
|
/** What the DescriptionList template emits for one field: one DescriptionItem in its list. */
|