@nodii/dev 0.6.205 → 0.6.206
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 +9 -0
- package/dist/core.js +1 -1
- package/dist/surface.js +17 -5
- package/dist/vendor/ds-conformance.mjs +71 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1355,6 +1355,15 @@ product-page catalog names the Surface by its published component-set key
|
|
|
1355
1355
|
whole, `value={loading ? <Skeleton shape="text" /> : <PiiText value={emailValue} … />}`,
|
|
1356
1356
|
so PiiText's `value` stays `string | null`. A value that reads nothing (fixed
|
|
1357
1357
|
copy) is left as it is.
|
|
1358
|
+
- **A one-line Rich Cell truncates (hub-646).** In a fixed-layout
|
|
1359
|
+
table a Table Rich Cell (`contentLayout`) whose content slot holds only one
|
|
1360
|
+
text that hugs its width takes `truncate`, as a one-line Table cell does
|
|
1361
|
+
(cli-279). A Rich Cell holding a DS part keeps its own layout.
|
|
1362
|
+
- **An empty head stays empty (hub-647).** A TableHead Figma draws
|
|
1363
|
+
with no text (or only spaces) is emitted as drawn, `{""}`, with no heading
|
|
1364
|
+
prop: a prop there is one no caller sets. Its column is keyed by position, so
|
|
1365
|
+
its row field and sort key are `columnN`. A head with copy takes an optional
|
|
1366
|
+
`<column>Heading` that defaults to the drawn copy (hub-507).
|
|
1358
1367
|
- **A person in a fact row is the served pair (DESIGN-SYSTEM-993).** A PiiText in
|
|
1359
1368
|
a fact row's value slot (a Description List's `value`, a Right Pane / Row's or
|
|
1360
1369
|
a Detail Section / Row's `valueSlot`) takes `value`, `model` and `relation`
|
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ import { chmod, lstat, mkdir, readFile, rename, rm, writeFile } from "node:fs/pr
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { basename, dirname, join } from "node:path";
|
|
6
6
|
|
|
7
|
-
export const VERSION = "0.6.
|
|
7
|
+
export const VERSION = "0.6.206";
|
|
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,13 +34,13 @@ 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 = 61;
|
|
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
|
|
41
41
|
* is a <dt>/<dd> pair in its section's <dl> (CLI-210), a Timeline / Entry is an <li> (CLI-167).
|
|
42
42
|
*/
|
|
43
|
-
const UNWRAPPED_PARTS = new Set(["Detail Section / Row", "Right Pane / Row", "Timeline / Entry"]);
|
|
43
|
+
const UNWRAPPED_PARTS = new Set(["Detail Section / Row", "Right Pane / Row", "Timeline / Entry", "Plan Step List / Step"]);
|
|
44
44
|
export const TREE_DIR = "docs/figma-ux-ds/figma/surface-trees";
|
|
45
45
|
export const GENERATED_SUFFIX = ".surface.generated.tsx";
|
|
46
46
|
/** Where every generated product page lives, as a git glob (NODII-DEV-CLI-77). */
|
|
@@ -4008,11 +4008,21 @@ function tableOf(node, ctx) {
|
|
|
4008
4008
|
// a cell whose label needs up to 3.4 times its width is still one 44px row (cli-279). So a text
|
|
4009
4009
|
// cell, or a person's PiiText, in a fixed-layout table takes the DS TableCell's own `truncate`,
|
|
4010
4010
|
// never a className (U07-19). A cell whose template draws Figma's Truncate property keeps it.
|
|
4011
|
+
// A Rich Cell (contentLayout) does too when its content slot holds only one text that hugs
|
|
4012
|
+
// its width, which Figma never wraps (compliance.pii.audit-logs' Action; hub-646).
|
|
4013
|
+
const slotLine = (cell) => {
|
|
4014
|
+
const slots = (cell.children ?? []).filter((c) => c.type === "SLOT");
|
|
4015
|
+
const only = slots.length === 1 && slots[0].children?.length === 1 ? slots[0].children[0] : null;
|
|
4016
|
+
return only?.type === "TEXT" && only.sizing?.[0] === "HUG";
|
|
4017
|
+
};
|
|
4011
4018
|
const oneLine = (code, cell, body, pii = false) => {
|
|
4012
4019
|
const start = code.trimStart();
|
|
4013
4020
|
const tag = start.slice(0, openTagEnd(start) + 1);
|
|
4014
4021
|
if (!fixed || Object.hasOwn(cell.instance?.props ?? {}, "Truncate") || !/^<TableCell\b/.test(tag) || /\s(?:truncate\b|secondary=)/.test(tag)) return false;
|
|
4015
|
-
|
|
4022
|
+
const text = /^\{"(?:[^"\\\n]|\\.)*"\}$/;
|
|
4023
|
+
if (!/\scontentLayout\b/.test(tag)) return pii || text.test(body.trim());
|
|
4024
|
+
// The slot's text line is emitted in a bare <span>.
|
|
4025
|
+
return pii || (slotLine(cell) && text.test(body.trim().replace(/^<span>([\s\S]*)<\/span>$/, "$1").trim()));
|
|
4016
4026
|
};
|
|
4017
4027
|
const withTruncate = (code) => code.replace(/^(\s*<TableCell\b[^>]*?)(\s*\/?>)/, "$1 truncate$2");
|
|
4018
4028
|
// Each column's width as the header's column carries it (the head template's own
|
|
@@ -4071,8 +4081,10 @@ function tableOf(node, ctx) {
|
|
|
4071
4081
|
if (!key) return code;
|
|
4072
4082
|
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)}}`);
|
|
4073
4083
|
// Display copy may follow a selected dimension; row and sort keys still come
|
|
4074
|
-
// from the drawing. Existing consumers keep the drawn label (hub-507).
|
|
4075
|
-
|
|
4084
|
+
// from the drawing. Existing consumers keep the drawn label (hub-507). A head
|
|
4085
|
+
// Figma draws empty (a menu or check column) stays empty: a prop there is one
|
|
4086
|
+
// no caller sets, so the page would draw copy the frame lacks (hub-647).
|
|
4087
|
+
return lifted.replace(/(<Table(?:Sort)?Head\b[^\n]*>\s*)\{("(?:[^"\\\n]|\\.)*")\}/, (whole, open, label) => (/^"\s*"$/.test(label) ? whole : `${open}{${optionalMark(ctx, listName, `${key}Heading`, null)} ?? ${label}}`));
|
|
4076
4088
|
};
|
|
4077
4089
|
// The lifted rows' loading state: as many skeleton rows as Figma draws body rows, each
|
|
4078
4090
|
// column as wide as the header's (else the first row's) cell and aligned as its head.
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
// it until it returns [] (each round can reveal instances inside slot
|
|
31
31
|
// content).
|
|
32
32
|
|
|
33
|
-
export const VERSION = "1.0.
|
|
33
|
+
export const VERSION = "1.0.19";
|
|
34
34
|
|
|
35
35
|
/** @typedef {{ nodeId: string, check: string, detail: string }} Finding */
|
|
36
36
|
/**
|
|
@@ -170,9 +170,17 @@ const SELF_COMPONENT_SET_KEYS = new Set([
|
|
|
170
170
|
// The published Editable Fields block (by key). On a self route's Surface
|
|
171
171
|
// (Surface / home.me.* or me.*) its rows edit the viewer's own record, so
|
|
172
172
|
// the viewer's email and phone there are revealed (P-10; NODII-DEV-CLI-215).
|
|
173
|
+
// Only a row labelled as the viewer's own email or phone counts; another
|
|
174
|
+
// person's contact on the same record is still flagged (PLANNING-HUB-656).
|
|
173
175
|
const EDITABLE_FIELDS_COMPONENT_SET_KEY =
|
|
174
176
|
"454c48893f60d6d55fe783a1c16d0001d3ae859b";
|
|
175
177
|
const SELF_SURFACE = /^Surface \/ (home\.)?me[.!@ ]/;
|
|
178
|
+
// The labels of the viewer's own email and phone rows. An allow-list: any
|
|
179
|
+
// other label (a spouse's phone, a team lead's email, an HRBP) is not the
|
|
180
|
+
// viewer's (PLANNING-HUB-656).
|
|
181
|
+
const SELF_ROW_EXTENSION = /,?\s*(ext\.?|x|#)\s*\d{1,6}\s*$/i;
|
|
182
|
+
const SELF_ROW_LABEL =
|
|
183
|
+
/^(my |your )?((work|personal|official) )?(e-?mail( address)?|phone( number)?|mobile( number)?)$/i;
|
|
176
184
|
const NOT_A_PERSON = /^(you|the team)$/i;
|
|
177
185
|
const MASKED = /[*•●]/;
|
|
178
186
|
const EMAIL = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g;
|
|
@@ -1064,6 +1072,7 @@ export function checkConformance({
|
|
|
1064
1072
|
if (
|
|
1065
1073
|
!screenText(a, n, overridden) ||
|
|
1066
1074
|
isSelf(a, n) ||
|
|
1075
|
+
selfEditableRow(a, n) ||
|
|
1067
1076
|
revealedByPermission(a, n)
|
|
1068
1077
|
)
|
|
1069
1078
|
continue;
|
|
@@ -1147,6 +1156,7 @@ export function checkConformance({
|
|
|
1147
1156
|
!/\p{L}{2}/u.test(text) ||
|
|
1148
1157
|
MASKED.test(text) ||
|
|
1149
1158
|
isSelf(a, n) ||
|
|
1159
|
+
selfEditableRow(a, n) ||
|
|
1150
1160
|
revealedByPermission(a, n)
|
|
1151
1161
|
)
|
|
1152
1162
|
continue;
|
|
@@ -1456,22 +1466,73 @@ function drawnSet(a, x) {
|
|
|
1456
1466
|
if (x.type === "COMPONENT_SET") return a.componentSets[x.id] ?? null;
|
|
1457
1467
|
return null;
|
|
1458
1468
|
}
|
|
1459
|
-
|
|
1469
|
+
/**
|
|
1470
|
+
* The viewer's own email or phone in an Editable Fields row on a self
|
|
1471
|
+
* route's Surface (NODII-DEV-CLI-215). The row is the block's direct child
|
|
1472
|
+
* holding the text. It is the viewer's only when it has exactly one label (a
|
|
1473
|
+
* shown `label` text, see rowLabelText) that SELF_ROW_LABEL allows, exactly one identifier with no words beside it, and no other text
|
|
1474
|
+
* (PLANNING-HUB-656); anything else fails closed.
|
|
1475
|
+
* Checked per node only, never seeded into the run-wide viewer set, so the
|
|
1476
|
+
* value elsewhere is judged on its own screen.
|
|
1477
|
+
*/
|
|
1478
|
+
/**
|
|
1479
|
+
* A shown text that is a self row's label: a layer named `label`, or a text
|
|
1480
|
+
* whose characters come from a TEXT property named `label` on an instance
|
|
1481
|
+
* between it and the row (PLANNING-HUB-656). A property never counts
|
|
1482
|
+
* through a hidden layer, or on its own.
|
|
1483
|
+
*/
|
|
1484
|
+
function rowLabelText(a, t, row) {
|
|
1485
|
+
if (/^label\b/i.test(t.name ?? "")) return true;
|
|
1486
|
+
const ref = t.componentPropertyReferences?.characters;
|
|
1487
|
+
if (typeof ref !== "string" || !/^label\b/i.test(ref)) return false;
|
|
1488
|
+
for (const x of [t, ...a.ancestors(t)]) {
|
|
1489
|
+
const v = x.componentProperties?.[ref];
|
|
1490
|
+
if (v) return v.type === "TEXT";
|
|
1491
|
+
if (x.id === row.id) break;
|
|
1492
|
+
}
|
|
1493
|
+
return false;
|
|
1494
|
+
}
|
|
1495
|
+
function selfEditableRow(a, n) {
|
|
1460
1496
|
const up = a.ancestors(n);
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1497
|
+
const blockAt = up.findIndex(
|
|
1498
|
+
(x) => drawnSet(a, x)?.key === EDITABLE_FIELDS_COMPONENT_SET_KEY,
|
|
1499
|
+
);
|
|
1500
|
+
if (blockAt < 1) return false;
|
|
1465
1501
|
if (
|
|
1466
|
-
up.some(
|
|
1467
|
-
(x) => drawnSet(a, x)?.key === EDITABLE_FIELDS_COMPONENT_SET_KEY,
|
|
1468
|
-
) &&
|
|
1469
|
-
up.some((x) =>
|
|
1502
|
+
!up.some((x) =>
|
|
1470
1503
|
SELF_SURFACE.test(
|
|
1471
1504
|
x.type === "COMPONENT_SET" ? x.name ?? "" : drawnSet(a, x)?.name ?? "",
|
|
1472
1505
|
),
|
|
1473
1506
|
)
|
|
1474
1507
|
)
|
|
1508
|
+
return false;
|
|
1509
|
+
const row = up[blockAt - 1];
|
|
1510
|
+
const labels = new Set();
|
|
1511
|
+
let found = 0;
|
|
1512
|
+
for (const t of indexTree(row).byId.values()) {
|
|
1513
|
+
if (t.type !== "TEXT" || !a.shown(t)) continue;
|
|
1514
|
+
// A trailing extension ("ext. 12", "x89", "#7") belongs to the phone.
|
|
1515
|
+
const text = textOf(t).replace(SELF_ROW_EXTENSION, "");
|
|
1516
|
+
const ids = identifiers(text).length;
|
|
1517
|
+
if (ids === 0 && rowLabelText(a, t, row)) labels.add(text.trim());
|
|
1518
|
+
// Any other text (a name, a relation, a note) says whose value it is,
|
|
1519
|
+
// and so do words beside the value itself ("Wife: +91 ...").
|
|
1520
|
+
else if (
|
|
1521
|
+
ids === 0 ||
|
|
1522
|
+
/\p{L}/u.test(text.replace(EMAIL, "").replace(PHONE, ""))
|
|
1523
|
+
)
|
|
1524
|
+
return false;
|
|
1525
|
+
found += ids;
|
|
1526
|
+
}
|
|
1527
|
+
if (labels.size !== 1 || found !== 1) return false;
|
|
1528
|
+
const [label] = labels;
|
|
1529
|
+
return SELF_ROW_LABEL.test(label.replace(/\s*:$/, ""));
|
|
1530
|
+
}
|
|
1531
|
+
function isSelf(a, n) {
|
|
1532
|
+
const up = a.ancestors(n);
|
|
1533
|
+
if (up.some((x) => selfPersonName(a, x))) return true;
|
|
1534
|
+
if (selfField(a, n) || markedYou(a, n)) return true;
|
|
1535
|
+
if (up.some((x) => SELF_COMPONENT_SET_KEYS.has(drawnSet(a, x)?.key)))
|
|
1475
1536
|
return true;
|
|
1476
1537
|
|
|
1477
1538
|
// INTERIM: identify a Table row from its direct Table-cell children, or a
|