Rebuild the Classic template on the engine with A4/Letter and a template harness

Classic now renders through buildRenderModel, computeFrame, the template
and renderCore, with S.No and HSN/SAC columns, GST slots only through
checked Slot components, taxable value, reverse-charge line, cancelled tag,
continuation band and Page n of N. Letter absorbs its height deficit in
elastic gaps. A harness runs 15 fixtures on A4 and Letter plus an item
sweep and asserts zero audit errors, repeated headers, no split blocks,
rupee extraction and deterministic output. The legacy InvoiceDocument is
removed.
This commit is contained in:
2026-10-04 05:31:14 +05:30
parent 8d4f8e666b
commit a014a907e4
40 changed files with 2185 additions and 832 deletions
+41
View File
@@ -0,0 +1,41 @@
import { getMeasurer, measureToken } from "../engine/measure";
import { resolveFace, roleToken } from "../fonts/roles";
import { useAvailableWidth } from "./AvailableWidth";
import { IdText } from "./IdText";
import { Txt, type TxtProps } from "./Txt";
export interface SafeTxtProps extends Omit<TxtProps, "children" | "width" | "maxLines" | "grow"> {
children: string;
/** Width of the box; defaults to the available width of the enclosing cell. */
width?: number;
}
/**
* Free text (addresses, names, notes) that cannot overflow: normal text wraps at spaces in a box of the
* cell's width; a value with a single token wider than the cell (a long URL or an unbroken string) goes
* through IdText, which shrinks it or splits it at "@ . / - _". textkit never breaks inside a word,
* so without this such a token would run out of its box.
*/
export function SafeTxt({ children, width, align, ...rest }: SafeTxtProps) {
const avail = useAvailableWidth();
const w = width ?? avail;
const token = roleToken(rest.role);
const m = getMeasurer();
const family = resolveFace(token.face, rest.faceOverrides);
const widest = Math.max(
0,
...children.split(" ").map((word) => measureToken(m, token, word, { weight: rest.weight, italic: rest.italic, family })),
);
if (widest > w + 1e-6) {
return (
<IdText {...rest} width={w}>
{children}
</IdText>
);
}
return (
<Txt {...rest} align={align} width={w}>
{children}
</Txt>
);
}