@nodii/dev 0.6.198 → 0.6.200
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 +21 -3
- package/dist/core.js +1 -1
- package/dist/surface.js +133 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1322,9 +1322,27 @@ product-page catalog names the Surface by its published component-set key
|
|
|
1322
1322
|
`Chart`, `ActivityFeedBlock`, `CommentThreadBlock`, `TenantPickerCardBlock`),
|
|
1323
1323
|
else its own `loading` (`PageMetricsBarBlock`, `QrDisplay`) or `isLoading`
|
|
1324
1324
|
(`DataTableToolbarBlock`, `ChartWithRange`). A Table whose rows are lifted draws
|
|
1325
|
-
`{loading ? <TableSkeletonRows … /> : rows.map(…)}` under its real header,
|
|
1326
|
-
skeleton
|
|
1327
|
-
|
|
1325
|
+
`{loading ? <TableSkeletonRows … /> : rows.map(…)}` under its real header, as
|
|
1326
|
+
many skeleton rows as the Surface's Loading frame draws (NODII-DEV-CLI-279), or
|
|
1327
|
+
a skeleton row per drawn row when it has none. A part that already draws the
|
|
1328
|
+
prop keeps it. So a route passes `loading` and never hand-builds a loading page.
|
|
1329
|
+
- **A list page keeps to its frames (NODII-DEV-CLI-279).** A clipping row whose
|
|
1330
|
+
fixed-width children overflow it (a metric carousel's viewport) keeps them at
|
|
1331
|
+
their Figma width with `shrink-0`; a row whose children fit still reflows. A
|
|
1332
|
+
text or PiiText cell in a `layout="fixed"` table takes the DS TableCell's
|
|
1333
|
+
`truncate`, as Figma's Table cell draws one line, unless its template draws
|
|
1334
|
+
Figma's `Truncate` property. A template's `TableRowActions` is the row's own
|
|
1335
|
+
cell, never held in a `TableCell`. A `PageSizeSelect` takes an optional
|
|
1336
|
+
`pageSizeOptions` (the DS `options`), since the frame draws only the chosen size.
|
|
1337
|
+
- **A record's facts draw their skeleton (hub-634).** While `loading` is
|
|
1338
|
+
true, the value of each `DescriptionItem`, `DetailFact` and `RightPaneRow`, and
|
|
1339
|
+
the lifted value text of a label/value pair (a frame of two texts, a label then
|
|
1340
|
+
its value), is the DS `<Skeleton shape="text" />`:
|
|
1341
|
+
`value={loading ? <Skeleton shape="text" /> : fromValue}`. A lone Description
|
|
1342
|
+
Item hidden while its value is missing still draws while loading
|
|
1343
|
+
(`{(loading || fromValue != null) && (…)}`). Each value keeps the type of the
|
|
1344
|
+
part that draws it. `Skeleton` is imported from the module the page's DS parts
|
|
1345
|
+
come from; a view with no fact is unchanged.
|
|
1328
1346
|
- **Error and Empty views a route drives (NODII-DEV-CLI-260).** The Surface takes
|
|
1329
1347
|
`<Id>SurfaceInput`: a `state` with the full props, as before, or a literal
|
|
1330
1348
|
`state` with only the props its view reads (`{ state: "read-error" } &
|
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.200";
|
|
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 = 54;
|
|
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
|
|
@@ -629,6 +629,32 @@ export function loadingVariantWarning(results) {
|
|
|
629
629
|
return `MW6-29: ${hit.length} Surface${hit.length === 1 ? " still draws" : "s still draw"} a Loading variant; its DS parts draw their own skeleton from \`loading\`, so remove the variant in Figma (warned now, refused later): ${hit.map((r) => `${r.row.id} (${r.loadingVariants.join(", ")})`).join(", ")}`;
|
|
630
630
|
}
|
|
631
631
|
|
|
632
|
+
/**
|
|
633
|
+
* A lifted table's loading rows are as many as the Surface's Loading frame draws (cli-279). The
|
|
634
|
+
* lifted skeleton otherwise draws a row per sample row (7 or 10), where the frame's Loading
|
|
635
|
+
* variant draws its own count (5), so the tab views' loading state was too tall. The count is the
|
|
636
|
+
* Loading view's drawn TableSkeletonRows: its one count when it draws one table (or all its tables
|
|
637
|
+
* draw the same), else the count of the table at the same place in the view. A Surface with no
|
|
638
|
+
* Loading frame (MW6-29) keeps a skeleton row per drawn row.
|
|
639
|
+
*/
|
|
640
|
+
const DRAWN_SKELETON = /(^|[^?] )<TableSkeletonRows columns=\{\d+\} rows=\{(\d+)\}/gm;
|
|
641
|
+
const LIFTED_SKELETON = /\{loading \? <TableSkeletonRows columns=\{(\d+)\} rows=\{\d+\}/g;
|
|
642
|
+
function skeletonRowsFromLoading(views) {
|
|
643
|
+
const loading = views.find((v) => isLoadingState(v.state) && [...v.body.matchAll(DRAWN_SKELETON)].length);
|
|
644
|
+
if (!loading) return;
|
|
645
|
+
const drawn = [...loading.body.matchAll(DRAWN_SKELETON)].map((m) => m[2]);
|
|
646
|
+
const one = new Set(drawn).size === 1 ? drawn[0] : null;
|
|
647
|
+
for (const v of views) {
|
|
648
|
+
if (v === loading) continue;
|
|
649
|
+
let at = 0;
|
|
650
|
+
v.body = v.body.replace(LIFTED_SKELETON, (whole, columns) => {
|
|
651
|
+
const rows = one ?? drawn[at];
|
|
652
|
+
at += 1;
|
|
653
|
+
return rows === undefined ? whole : `{loading ? <TableSkeletonRows columns={${columns}} rows={${rows}}`;
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
632
658
|
export function emitSurface(tree, row, ds) {
|
|
633
659
|
const imports = [];
|
|
634
660
|
const unmapped = [];
|
|
@@ -646,13 +672,15 @@ export function emitSurface(tree, row, ds) {
|
|
|
646
672
|
const optionals = { optional: new Set(), required: new Set() };
|
|
647
673
|
// Each list the generator assembles from sibling parts (alertRun): its members a page may leave out, and any narrowed type.
|
|
648
674
|
const items = new Map();
|
|
675
|
+
// Each loose text lifted as a fact's value, whose skeleton draws while the Surface loads (skeletonFacts).
|
|
676
|
+
const factTexts = new Set();
|
|
649
677
|
const views = graftAbsentSlots(tree.variants).map((variant) => {
|
|
650
678
|
let state = variant.state;
|
|
651
679
|
while (used.has(state)) state += "-x";
|
|
652
680
|
used.add(state);
|
|
653
681
|
const fn = `${pascal(state)}View`;
|
|
654
682
|
const note = (path, kind, detail) => unmapped.push({ variant: variant.name, path, kind, detail });
|
|
655
|
-
const emitted = emitNode(pageBody(variant, row), { depth: 2, parent: null, path: variant.name, row, ds, imports, note, root: true, scopes, layers, layer: "", state, lists: new Map(), shapes, handlers: new Map(), shown: new Map(), optionals, items }) ?? "";
|
|
683
|
+
const emitted = emitNode(pageBody(variant, row), { depth: 2, parent: null, path: variant.name, row, ds, imports, note, root: true, scopes, layers, layer: "", state, lists: new Map(), shapes, handlers: new Map(), shown: new Map(), optionals, items, factTexts }) ?? "";
|
|
656
684
|
// A view the generator can't lay out is no page at all: generation fails rather than ship
|
|
657
685
|
// an empty view (NODII-DEV-CLI-81).
|
|
658
686
|
if (emitted.trimStart().startsWith("{/*")) {
|
|
@@ -662,6 +690,7 @@ export function emitSurface(tree, row, ds) {
|
|
|
662
690
|
const body = passLoading(emitted).replace(/^(\s*)<div\b/, `$1<div data-surface=${JSON.stringify(row.id)}`);
|
|
663
691
|
return { state, fn, body, variant: variant.name };
|
|
664
692
|
});
|
|
693
|
+
skeletonRowsFromLoading(views);
|
|
665
694
|
const component = `${pascal(row.id)}Surface`;
|
|
666
695
|
const stateType = `${component}State`;
|
|
667
696
|
const propsType = `${component}Props`;
|
|
@@ -670,6 +699,8 @@ export function emitSurface(tree, row, ds) {
|
|
|
670
699
|
const named = resolveScopes(views, scopes, layers);
|
|
671
700
|
settlePiiColumns(views, unmapped);
|
|
672
701
|
const data = dataProps(views, propsType);
|
|
702
|
+
// After the props are typed from what each part draws: a fact's value is its skeleton while loading.
|
|
703
|
+
skeletonFacts(views, imports, [...factTexts].map((token) => named.get(token) ?? token));
|
|
673
704
|
// A prop is optional when every template that draws it lists it in `metadata.optionalProps`.
|
|
674
705
|
const optionalNames = new Map();
|
|
675
706
|
for (const [token, name] of named) {
|
|
@@ -1337,7 +1368,16 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
|
|
|
1337
1368
|
if (!at) return attrs;
|
|
1338
1369
|
return `${attrs.slice(0, at.from)}series={${lift(scope, "series")}}${attrs.slice(at.to)}`;
|
|
1339
1370
|
});
|
|
1340
|
-
|
|
1371
|
+
// The sizes a page offers are its own, as its page size is: the Pagination frame draws only the
|
|
1372
|
+
// chosen size (sizeValue "6"), and the DS defaults (10, 20, 50, 100) may not hold it, so the select
|
|
1373
|
+
// showed "10". `options` is optional; a page that passes none keeps the DS defaults (cli-279).
|
|
1374
|
+
out = rewriteTags(out, "PageSizeSelect", (attrs) => {
|
|
1375
|
+
const next = attrs.replace(/\bvalue=\{(?:\d+|Number\("(?:[^"\\\n]|\\.)*"\))\}/, () => `value={${lift(scope, "pageSize")}}`);
|
|
1376
|
+
if (/\boptions=/.test(next)) return next;
|
|
1377
|
+
lifted.push("pageSizeOptions");
|
|
1378
|
+
const options = ` options={${optionalMark(ctx, scope, "pageSizeOptions")}}`;
|
|
1379
|
+
return /\s*\/\s*$/.test(next) ? next.replace(/(\s*\/\s*)$/, `${options}$1`) : `${next}${options}`;
|
|
1380
|
+
});
|
|
1341
1381
|
out = rewriteTags(out, "CopyField", (attrs) => {
|
|
1342
1382
|
const value = new RegExp(String.raw`\bvalue=${LITERAL}`).exec(attrs);
|
|
1343
1383
|
let next = value ? attrs.replace(value[0], `value={${lift(scope, "value")}}`) : attrs;
|
|
@@ -1401,6 +1441,13 @@ function isFactValue(node, parent) {
|
|
|
1401
1441
|
return children.length === 2 && children.every((child) => child.type === "TEXT") && children[1] === node;
|
|
1402
1442
|
}
|
|
1403
1443
|
|
|
1444
|
+
/** A label/value pair's value: the second of a frame's two texts, after a label that is copy (hub-634). */
|
|
1445
|
+
function isPairValue(node, parent) {
|
|
1446
|
+
if (parent?.type !== "FRAME") return false;
|
|
1447
|
+
const children = (parent.children ?? []).filter((child) => child.visible !== false);
|
|
1448
|
+
return children.length === 2 && children.every((child) => child.type === "TEXT") && children[1] === node && !RECORD_TEXT(children[0].text ?? "");
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1404
1451
|
/** A part named by where it sits: its parent's name, numbered when the parent holds several of the same set. */
|
|
1405
1452
|
function positionScope(node, ctx, kind) {
|
|
1406
1453
|
const siblings = (ctx.parent?.children ?? []).filter((c) => c.visible !== false && (node.instance ? c.instance?.set === node.instance.set : c.type === node.type));
|
|
@@ -2385,6 +2432,50 @@ function passLoading(code) {
|
|
|
2385
2432
|
return out + code.slice(last);
|
|
2386
2433
|
}
|
|
2387
2434
|
|
|
2435
|
+
/**
|
|
2436
|
+
* While the Surface loads, a record's facts draw the DS Skeleton text shape in place of
|
|
2437
|
+
* their values, as a lifted table draws TableSkeletonRows (hub-634): the value
|
|
2438
|
+
* of a Description Item, Detail Fact or Right Pane Row, and a label/value pair's lifted
|
|
2439
|
+
* value text. A fact hidden while its value is missing (a lone Description Item) still
|
|
2440
|
+
* draws its skeleton while loading. Run after the props are typed, so each value keeps
|
|
2441
|
+
* the type of the part that draws it. Skeleton comes from the DS module the page's DS
|
|
2442
|
+
* parts come from; a page with no such import is left as it is.
|
|
2443
|
+
*/
|
|
2444
|
+
const FACT_SKELETON = '<Skeleton shape="text" />';
|
|
2445
|
+
const FACT_PARTS = /<(?:DescriptionItem|DetailFact|RightPaneRow)(?=[\s/>])/g;
|
|
2446
|
+
const FACT_VALUE = /(\svalue=\{)([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\}/;
|
|
2447
|
+
const SKELETON_HOST = /\b(?:DescriptionItem|DescriptionList|DetailFact|DetailSection|Card|Badge|PiiText|Tabs|Field|Alert|EmptyState|Button|TableCell|TableHead)\b/;
|
|
2448
|
+
const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2449
|
+
function skeletonFacts(views, imports, factTexts) {
|
|
2450
|
+
const module = imports
|
|
2451
|
+
.map((s) => /^import\s+\{([^}]*)\}\s+from\s+["']([^"']+)["']/.exec(s.trim()))
|
|
2452
|
+
.find((m) => m && !/^(?:\.|@\/)/.test(m[2]) && SKELETON_HOST.test(m[1]))?.[2];
|
|
2453
|
+
if (!module) return;
|
|
2454
|
+
let drawn = false;
|
|
2455
|
+
for (const view of views) {
|
|
2456
|
+
let body = view.body;
|
|
2457
|
+
const masked = maskStrings(body);
|
|
2458
|
+
const edits = [];
|
|
2459
|
+
for (const m of masked.matchAll(FACT_PARTS)) {
|
|
2460
|
+
const open = masked.slice(m.index, m.index + openTagEnd(masked.slice(m.index)) + 1);
|
|
2461
|
+
const value = FACT_VALUE.exec(open);
|
|
2462
|
+
if (value) edits.push({ at: m.index + value.index + value[1].length, read: value[2] });
|
|
2463
|
+
}
|
|
2464
|
+
const gated = new Set();
|
|
2465
|
+
for (const { at, read } of edits.reverse()) {
|
|
2466
|
+
body = `${body.slice(0, at)}loading ? ${FACT_SKELETON} : ${body.slice(at)}`;
|
|
2467
|
+
if (!read.includes(".")) gated.add(read);
|
|
2468
|
+
}
|
|
2469
|
+
for (const read of gated) body = body.replace(new RegExp(String.raw`\{${escapeRegExp(read)} != null && \(`, "g"), `{(loading || ${read} != null) && (`);
|
|
2470
|
+
for (const name of factTexts) body = body.replace(new RegExp(String.raw`(<span\b[^>\n]*>)\{${escapeRegExp(name)}\}(</span>)`, "g"), `$1{loading ? ${FACT_SKELETON} : ${name}}$2`);
|
|
2471
|
+
if (body === view.body) continue;
|
|
2472
|
+
view.body = body;
|
|
2473
|
+
view.uses.add("loading");
|
|
2474
|
+
drawn = true;
|
|
2475
|
+
}
|
|
2476
|
+
if (drawn) imports.push(`import { Skeleton } from "${module}";`);
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2388
2479
|
/** The type the generated file declares for drawnProps (see there). */
|
|
2389
2480
|
const DRAWN_TYPE = [
|
|
2390
2481
|
"/** A DS component's props, narrowed to the member of their union this call draws: every required prop passed, every literal one fitting. */",
|
|
@@ -2555,6 +2646,20 @@ export const INTRINSIC_MAX_PX = 48;
|
|
|
2555
2646
|
* positioned absolutely: that frame is refused (see emitNode); only a child
|
|
2556
2647
|
* Figma itself marks absolute is.
|
|
2557
2648
|
*/
|
|
2649
|
+
/**
|
|
2650
|
+
* A horizontal row Figma clips whose children, laid end to end, are wider than it: Figma draws
|
|
2651
|
+
* them at their own widths and clips the rest (a Carousel's viewport of six 220px metric cards in
|
|
2652
|
+
* a 1168px column). A row whose children fit, or that wraps, is not one.
|
|
2653
|
+
*/
|
|
2654
|
+
function overflowsRow(row) {
|
|
2655
|
+
if (!row?.clips || row.layout?.mode !== "HORIZONTAL" || row.layout.wrap || typeof row.width !== "number") return false;
|
|
2656
|
+
const shown = (row.children ?? []).filter((c) => c.visible !== false && !c.absolute);
|
|
2657
|
+
if (shown.length < 2 || shown.some((c) => typeof c.width !== "number")) return false;
|
|
2658
|
+
const [, right, , left] = row.layout.padding ?? [0, 0, 0, 0];
|
|
2659
|
+
const drawn = shown.reduce((sum, c) => sum + c.width, 0) + (row.layout.gap ?? 0) * (shown.length - 1) + (left ?? 0) + (right ?? 0);
|
|
2660
|
+
return drawn > row.width + 0.5;
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2558
2663
|
function sizeClasses(node, parent, root) {
|
|
2559
2664
|
const out = [];
|
|
2560
2665
|
const [h, v] = node.sizing ?? ["FIXED", "FIXED"];
|
|
@@ -2563,6 +2668,9 @@ function sizeClasses(node, parent, root) {
|
|
|
2563
2668
|
if (node.width === undefined) return out;
|
|
2564
2669
|
if (root) out.push("w-full");
|
|
2565
2670
|
else if (h === "FIXED" && node.width <= INTRINSIC_MAX_PX) out.push(`w-${step(node.width)}`, ...(pm === "HORIZONTAL" ? ["shrink-0"] : []));
|
|
2671
|
+
// A row that clips what overflows it (a metric carousel's viewport) keeps a fixed child at its Figma
|
|
2672
|
+
// width: shrink-0, so the overflow is clipped as Figma clips it, not shrunk to fit (cli-279, cli-240).
|
|
2673
|
+
else if (h === "FIXED" && pm === "HORIZONTAL" && overflowsRow(parent)) out.push(`w-${step(node.width)}`, ...(node.maxWidth ? [] : ["max-w-full"]), "shrink-0");
|
|
2566
2674
|
else if (h === "FIXED") out.push(`w-${step(node.width)}`, ...(node.maxWidth ? [] : ["max-w-full"]), ...(pm === "HORIZONTAL" && !node.minWidth ? ["min-w-0"] : []));
|
|
2567
2675
|
else if (h === "FILL") out.push(...(pm === "HORIZONTAL" ? ["min-w-0", "flex-1"] : pm === "VERTICAL" ? ["self-stretch"] : ["w-full"]));
|
|
2568
2676
|
if (!root && v === "FIXED") out.push(`h-${step(node.height)}`, ...(pm === "VERTICAL" ? ["shrink-0"] : []));
|
|
@@ -2819,6 +2927,7 @@ function emitNode(node, ctx) {
|
|
|
2819
2927
|
const name = mark(ctx, scope, scope);
|
|
2820
2928
|
note(path, LIFTED, `text ${shown} names a record's value: lifted from Figma's sample into the page's props (NODII-DEV-CLI-82)`);
|
|
2821
2929
|
content = name;
|
|
2930
|
+
if (ctx.scopes && !ctx.inTable && isPairValue(node, parent)) ctx.factTexts?.add(name);
|
|
2822
2931
|
}
|
|
2823
2932
|
return indent(`<span${classes ? ` className="${classes}"` : ""}>{${content}}</span>`, depth);
|
|
2824
2933
|
}
|
|
@@ -3476,7 +3585,9 @@ function emptyPiiCell(part) {
|
|
|
3476
3585
|
* part's template imports from. A frame cell (content Figma lays out inside a
|
|
3477
3586
|
* row) becomes a TableCell holding that content. Returns null for anything else.
|
|
3478
3587
|
*/
|
|
3479
|
-
|
|
3588
|
+
// TableRowActions is a body cell too: the row-actions cell the table pins to its end edge, drawn as
|
|
3589
|
+
// its own <td>, so it is never held in a second TableCell (cli-279).
|
|
3590
|
+
const tablePart = (tag) => (/^Table[A-Za-z]*Head$/.test(tag ?? "") ? "head" : /^(?:Table[A-Za-z]*Cell|TableRowActions)$/.test(tag ?? "") ? "body" : null);
|
|
3480
3591
|
/**
|
|
3481
3592
|
* What the Table cell template emits for `State=Loading` (U07-34.15.3, DEC-0457):
|
|
3482
3593
|
* one column of the Table's loading state. A body of them becomes one
|
|
@@ -3506,7 +3617,7 @@ const widthAttr = (w) => (w === null ? "" : typeof w === "number" ? ` width={${w
|
|
|
3506
3617
|
* The DS Table parts that take a column width (`TableColumnWidthProps`). Others, such as
|
|
3507
3618
|
* TableSelectionCell, have no `width` prop, so they never get one (hub-573).
|
|
3508
3619
|
*/
|
|
3509
|
-
const COLUMN_WIDTH_PART = /^\s*<(?:TableHead|TableSortHead|TableCell)[\s>/]/;
|
|
3620
|
+
const COLUMN_WIDTH_PART = /^\s*<(?:TableHead|TableSortHead|TableCell|TableRowActions)[\s>/]/;
|
|
3510
3621
|
/** Add `width` to a TableHead/TableCell's opening tag, unless its template already declares one. */
|
|
3511
3622
|
function withWidth(code, w) {
|
|
3512
3623
|
if (!code) return code;
|
|
@@ -3767,7 +3878,11 @@ function tableOf(node, ctx) {
|
|
|
3767
3878
|
if (code) {
|
|
3768
3879
|
// Re-emit for real, so the cell's own unmapped layers are reported.
|
|
3769
3880
|
const emitted = emitNode(cell, { ...ctx, depth: d, parent: null, path: `${ctx.path} › ${row.name}`, root: false, bare: true, inTable: true, column });
|
|
3770
|
-
|
|
3881
|
+
const own = withWidth(selected ? indent(selectedCell(emitted), d) : emitted, w);
|
|
3882
|
+
const start = own.trimStart();
|
|
3883
|
+
const end = openTagEnd(start);
|
|
3884
|
+
const body = start.slice(end + 1, start.lastIndexOf("</TableCell>"));
|
|
3885
|
+
return !selected && start.lastIndexOf("</TableCell>") > end && oneLine(own, cell, body) ? withTruncate(own) : own;
|
|
3771
3886
|
}
|
|
3772
3887
|
// The frame stood in for the cell: its size and padding are the TableCell's now.
|
|
3773
3888
|
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 });
|
|
@@ -3776,6 +3891,17 @@ function tableOf(node, ctx) {
|
|
|
3776
3891
|
// Every column held at px or fill is a fixed table layout; a hug column needs the browser's auto layout.
|
|
3777
3892
|
const widths = parsed.flatMap((p) => p.cells.map((c) => columnWidth(c.cell)));
|
|
3778
3893
|
const fixed = widths.length > 0 && widths.every((w) => w !== null && w !== "hug");
|
|
3894
|
+
// Figma's Table cell draws its label on one line and clips the rest: in the committed trees,
|
|
3895
|
+
// a cell whose label needs up to 3.4 times its width is still one 44px row (cli-279). So a text
|
|
3896
|
+
// cell, or a person's PiiText, in a fixed-layout table takes the DS TableCell's own `truncate`,
|
|
3897
|
+
// never a className (U07-19). A cell whose template draws Figma's Truncate property keeps it.
|
|
3898
|
+
const oneLine = (code, cell, body, pii = false) => {
|
|
3899
|
+
const start = code.trimStart();
|
|
3900
|
+
const tag = start.slice(0, openTagEnd(start) + 1);
|
|
3901
|
+
if (!fixed || Object.hasOwn(cell.instance?.props ?? {}, "Truncate") || !/^<TableCell\b/.test(tag) || /\s(?:truncate\b|secondary=)/.test(tag)) return false;
|
|
3902
|
+
return pii || (!/\scontentLayout\b/.test(tag) && /^\{"(?:[^"\\\n]|\\.)*"\}$/.test(body.trim()));
|
|
3903
|
+
};
|
|
3904
|
+
const withTruncate = (code) => code.replace(/^(\s*<TableCell\b[^>]*?)(\s*\/?>)/, "$1 truncate$2");
|
|
3779
3905
|
// Each column's width as the header's column carries it (the head template's own
|
|
3780
3906
|
// `width`, else the head cell's sizing); its alignment as the loading cell draws it.
|
|
3781
3907
|
const skeletonRows = () => {
|
|
@@ -3920,6 +4046,7 @@ function tableOf(node, ctx) {
|
|
|
3920
4046
|
const tag = /^<([A-Za-z]+)/.exec(own)[1];
|
|
3921
4047
|
open = withAlign(own.slice(0, end + 1).replace(/\s*\/>$/, ">"), i);
|
|
3922
4048
|
close = `</${tag}>`;
|
|
4049
|
+
if (oneLine(open, c.cell, own.slice(end + 1, own.lastIndexOf(close)), piiColumn[i])) open = withTruncate(open);
|
|
3923
4050
|
}
|
|
3924
4051
|
// Selection is record data even when the drawing shows every row unchecked.
|
|
3925
4052
|
if (/^<TableSelectionCell\b/.test(open)) {
|