diff --git a/apps/web/content/docs/(root)/installation.md b/apps/web/content/docs/(root)/installation.md
index 5da2e74..aa81987 100644
--- a/apps/web/content/docs/(root)/installation.md
+++ b/apps/web/content/docs/(root)/installation.md
@@ -177,6 +177,12 @@ addEventListener("message", async ({ data, ports: [port] }) => {
}
```
+The worker entry also imports `@formepdf/react`, which only Forme's React API uses. Add it to `externalDependencies` in the same build options, so `ng build` leaves it out of the bundle:
+
+```json title="angular.json"
+"externalDependencies": ["@formepdf/react"]
+```
+
```ts title="src/app/pdf.worker.ts"
///
import { init, renderSerializedDoc } from "@formepdf/core/worker";
@@ -197,51 +203,81 @@ addEventListener("message", async ({ data, ports: [port] }) => {
:::
::::
-In your app, send each document to the worker with its own `MessageChannel`, so that concurrent renders get their own replies:
+In your app, start the worker and load the document on the first render. The engine and its `.wasm` file then download only when someone asks for a PDF. Send each document with its own `MessageChannel`, so that concurrent renders get their own replies:
::::tabs
:::tab{value="takumi" label="Takumi"}
-```ts
-import { renderTakumiDocument } from "@/lib/render";
-import { Invoice } from "./invoice";
-
-const worker = new Worker(new URL("./pdf.worker", import.meta.url), {
- type: "module",
-});
+```ts title="src/app/pdf.ts"
+let worker: Worker | undefined;
const renderInWorker = (message: unknown) =>
new Promise((resolve, reject) => {
+ worker ??= new Worker(new URL("./pdf.worker", import.meta.url), {
+ type: "module",
+ });
+ const current = worker;
+ // A worker that fails to load never replies, so reject instead of waiting.
+ const onError = (event: Event) => {
+ if (worker === current) {
+ worker = undefined;
+ }
+ reject(new Error("The PDF worker failed", { cause: event }));
+ };
+ current.addEventListener("error", onError);
const { port1, port2 } = new MessageChannel();
- port1.onmessage = ({ data }) =>
+ port1.onmessage = ({ data }) => {
+ current.removeEventListener("error", onError);
data.error ? reject(data.error) : resolve(data.pdf);
- worker.postMessage(message, [port2]);
+ };
+ current.postMessage(message, [port2]);
});
-const { node } = renderTakumiDocument(Invoice);
-const pdf = await renderInWorker({ node, options: { size: "a4" } });
+export const renderInvoice = async () => {
+ const [{ renderTakumiDocument }, { Invoice }] = await Promise.all([
+ import("@/lib/render"),
+ import("./invoice"),
+ ]);
+ const { node } = renderTakumiDocument(Invoice);
+ return renderInWorker({ node, options: { size: "a4" } });
+};
```
:::
:::tab{value="forme" label="Forme"}
-```ts
-import { renderFormeDocument } from "@/lib/render";
-import { Invoice } from "./invoice";
-
-const worker = new Worker(new URL("./pdf.worker", import.meta.url), {
- type: "module",
-});
+```ts title="src/app/pdf.ts"
+let worker: Worker | undefined;
const renderInWorker = (message: unknown) =>
new Promise((resolve, reject) => {
+ worker ??= new Worker(new URL("./pdf.worker", import.meta.url), {
+ type: "module",
+ });
+ const current = worker;
+ // A worker that fails to load never replies, so reject instead of waiting.
+ const onError = (event: Event) => {
+ if (worker === current) {
+ worker = undefined;
+ }
+ reject(new Error("The PDF worker failed", { cause: event }));
+ };
+ current.addEventListener("error", onError);
const { port1, port2 } = new MessageChannel();
- port1.onmessage = ({ data }) =>
+ port1.onmessage = ({ data }) => {
+ current.removeEventListener("error", onError);
data.error ? reject(data.error) : resolve(data.pdf);
- worker.postMessage(message, [port2]);
+ };
+ current.postMessage(message, [port2]);
});
-const pdf = await renderInWorker(renderFormeDocument(Invoice));
+export const renderInvoice = async () => {
+ const [{ renderFormeDocument }, { Invoice }] = await Promise.all([
+ import("@/lib/render"),
+ import("./invoice"),
+ ]);
+ return renderInWorker(renderFormeDocument(Invoice));
+};
```
:::
@@ -249,13 +285,14 @@ const pdf = await renderInWorker(renderFormeDocument(Invoice));
### Fonts
-Forme renders every font family you don't register with a standard PDF font: Helvetica, Times-Roman, or Courier. These cover Western European text such as ä, ß, „“, and €, and print other characters, such as ≥, →, and ✓, as `?`. Takumi rejects the render instead, with an error such as `No registered font covers ≥ (U+2265)`. Register a TrueType font that covers your text:
+Forme renders every font family you don't register with a standard PDF font: Helvetica, Times-Roman, or Courier. These cover Western European text such as ä, ß, „“, and €, and print other characters, such as ≥, →, and ✓, as `?`. Takumi rejects the render instead, with an error such as `No registered font covers ≥ (U+2265)`. Register a TrueType font that covers your text. In `renderInvoice`, replace the lines after the imports:
::::tabs
:::tab{value="takumi" label="Takumi"}
```ts
-const pdf = await renderInWorker({
+const { node } = renderTakumiDocument(Invoice);
+return renderInWorker({
node,
options: { size: "a4", fonts: ["/fonts/NotoSans-Regular.ttf"] },
});
@@ -264,6 +301,25 @@ const pdf = await renderInWorker({
:::
:::tab{value="forme" label="Forme"}
+Name the font in your theme's typography. Add the theme at the top of `src/app/pdf.ts`:
+
+```ts title="src/app/pdf.ts"
+import { professionalTheme } from "@/lib/pdf-themes/professional";
+
+const theme = {
+ ...professionalTheme,
+ typography: {
+ body: { ...professionalTheme.typography.body, fontFamily: "Noto Sans" },
+ heading: {
+ ...professionalTheme.typography.heading,
+ fontFamily: "Noto Sans",
+ },
+ },
+};
+```
+
+Pass it to the document and register the font:
+
```ts
const doc = renderFormeDocument(Invoice, { inputs: { theme } });
doc.fonts = [
@@ -275,10 +331,10 @@ doc.fonts = [
italic: false,
},
];
-const pdf = await renderInWorker(doc);
+return renderInWorker(doc);
```
-For Forme, `family` must match the font family that your theme's typography names. `src` takes a URL or a data URI. Forme embeds only the glyphs that the document uses.
+`Invoice` needs a `theme` input that it binds to ``, as the blocks do. `family` must match the font family that the theme names. `src` takes a URL or a data URI. The worker fetches the file when it renders, so the font doesn't load with your app. Forme embeds only the glyphs that the document uses.
:::
::::
diff --git a/apps/web/content/docs/components/forme/keep-together.md b/apps/web/content/docs/components/forme/keep-together.md
index 4544cea..45e319b 100644
--- a/apps/web/content/docs/components/forme/keep-together.md
+++ b/apps/web/content/docs/components/forme/keep-together.md
@@ -1,6 +1,6 @@
---
title: "Keep Together"
-description: "Keeps children on the same PDF page."
+description: "Keeps children on one PDF page when they fit."
---
::preview{base="forme" name="keep-together"}
@@ -22,4 +22,6 @@ description: "Keeps children on the same PDF page."
| `minPresenceAhead` | `number` | - |
| `style` | `Style` | - |
-The content to keep on one page is projected content.
+The content to keep on one page is projected content. If it doesn't fit in the space left on the page, it starts on the next page. Text taller than a full page still splits across pages, so it leaves the rest of the previous page empty. Let long text flow instead of wrapping it.
+
+Forme ignores `minPresenceAhead`. The input exists for parity with pdfcn.
diff --git a/apps/web/lib/content/registry.ts b/apps/web/lib/content/registry.ts
index 664fe44..d4c52aa 100644
--- a/apps/web/lib/content/registry.ts
+++ b/apps/web/lib/content/registry.ts
@@ -2,7 +2,7 @@
import { existsSync, readFileSync } from "node:fs";
import path from "node:path";
-import { REGISTRY_NAMESPACE } from "../install";
+import { LICENSE_NOTICE, REGISTRY_NAMESPACE } from "../install";
import { APP_ROOT } from "./source";
interface RegistryItem {
@@ -70,10 +70,10 @@ export const installPlan = (itemName: string, docFile: string) => {
]
.filter((file) => existsSync(path.join(APP_ROOT, file.path)))
.map((file) => ({
- code: toInstalledPaths(
+ code: `${toInstalledPaths(
readFileSync(path.join(APP_ROOT, file.path), "utf-8"),
targets
- ).trim(),
+ ).trim()}\n\n${LICENSE_NOTICE}`,
target: file.target,
}));
return { files, packages };
diff --git a/apps/web/lib/install.ts b/apps/web/lib/install.ts
index a8c8c0e..a9b6d2c 100644
--- a/apps/web/lib/install.ts
+++ b/apps/web/lib/install.ts
@@ -30,3 +30,7 @@ export const TSCONFIG_PATHS = { "@/*": ["./src/*"] };
export const addCommand = (...names: string[]) =>
`npx shadcn@latest add ${names.map((name) => `${REGISTRY_NAMESPACE}/${name}`).join(" ")}`;
+
+/** The attribution line at the end of every installed file. `shadcn add` strips leading comments. */
+export const LICENSE_NOTICE =
+ "// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE";
diff --git a/apps/web/package.json b/apps/web/package.json
index ac6f340..1a5256a 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -23,8 +23,8 @@
"@fontsource-variable/geist": "^5.3.0",
"@fontsource-variable/geist-mono": "^5.3.0",
"@fontsource-variable/inter": "^5.3.0",
- "@formepdf/core": "^0.25.0",
- "@formepdf/shared": "^0.25.0",
+ "@formepdf/core": "^0.32.0",
+ "@formepdf/shared": "^0.32.0",
"@takumi-rs/helpers": "^2.10.0",
"@vercel/analytics": "^2.0.1",
"@web-kits/audio": "^0.1.0",
diff --git a/apps/web/public/r/forme/alert.json b/apps/web/public/r/forme/alert.json
index ce20227..933e7cb 100644
--- a/apps/web/public/r/forme/alert.json
+++ b/apps/web/public/r/forme/alert.json
@@ -3,17 +3,13 @@
"name": "forme/alert",
"title": "Alert",
"description": "Alert PDF component (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils"
],
"files": [
{
"path": "registry/bases/forme/components/alert/alert.ts",
- "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport {\n mergePdfStyles,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeSvg,\n FormeText,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type AlertVariant = \"info\" | \"success\" | \"warning\" | \"error\";\n\n/**\n * Alert box with severity variants for info, success, warning, and error states.\n * Props - `variant` | `title` | `children` | `showIcon` | `showBorder` | `style`\n * @see {@link PdfAlertProps}\n */\nexport interface PdfAlertProps extends Omit {\n /**\n * @default 'info'\n */\n variant?: AlertVariant;\n title?: string;\n /**\n * @default true\n */\n showIcon?: boolean;\n /**\n * @default true\n */\n showBorder?: boolean;\n}\n\n/** Stroke width for all alert SVG icons (SVG user units). */\nconst ICON_STROKE_WIDTH = 1.5;\n\nconst borderLeft = (color: string) => ({\n borderLeftColor: color,\n borderLeftWidth: 4,\n});\n\nconst createAlertStyles = (theme: PdfcnTheme) => {\n const { typography, colors, primitives } = theme;\n\n const variantColors = {\n error: colors.destructive ?? \"#EF4444\",\n info: colors.info ?? \"#3B82F6\",\n success: colors.success ?? \"#22C55E\",\n warning: colors.warning ?? \"#F59E0B\",\n } satisfies Record;\n\n const sheet = StyleSheet.create({\n bg: {\n backgroundColor: colors.muted,\n },\n borderError: borderLeft(variantColors.error),\n borderInfo: borderLeft(variantColors.info),\n borderSuccess: borderLeft(variantColors.success),\n borderWarning: borderLeft(variantColors.warning),\n container: {\n borderRadius: 4,\n flexDirection: \"row\",\n marginBottom: theme.spacing.componentGap,\n padding: 12,\n },\n contentContainer: { flex: 1 },\n description: {\n color: colors.mutedForeground,\n fontFamily: typography.body.fontFamily,\n fontSize: primitives.typography.sm,\n lineHeight: typography.body.lineHeight,\n },\n iconContainer: {\n alignItems: \"center\",\n justifyContent: \"flex-start\",\n marginRight: 10,\n paddingTop: 2,\n width: 20,\n },\n title: {\n color: colors.foreground,\n fontFamily: typography.heading.fontFamily,\n fontSize: primitives.typography.sm,\n fontWeight: primitives.fontWeights.semibold,\n marginBottom: 4,\n },\n });\n\n return {\n ...sheet,\n borderMap: {\n error: sheet.borderError,\n info: sheet.borderInfo,\n success: sheet.borderSuccess,\n warning: sheet.borderWarning,\n } as Record,\n /** Resolved hex colors for each variant — used to tint the SVG icons. */\n variantColors,\n };\n};\n\n/** Container style and icon color of the variant. */\nconst alertStyles = (\n theme: PdfcnTheme,\n { variant = \"info\", showBorder = true, style }: PdfAlertProps\n) => {\n const styles = createAlertStyles(theme);\n\n const containerStyles: Style[] = [\n styles.container,\n styles.bg,\n ...(showBorder ? [styles.borderMap[variant]] : []),\n ...(style ? [style].flat() : []),\n ];\n\n return {\n container: mergePdfStyles(containerStyles),\n iconColor: styles.variantColors[variant],\n styles,\n };\n};\n\n/** Alert box with severity variants for info, success, warning, and error states. */\n@Component({\n imports: [FormeSvg, FormeText, FormeView],\n selector: \"pdf-alert\",\n template: `\n @let s = layout().styles;\n @let color = layout().iconColor;\n \n @if (showIcon()) {\n \n \n \n @switch (variant()) {\n @case (\"error\") {\n \n \n \n }\n @case (\"success\") {\n \n \n }\n @case (\"warning\") {\n \n \n \n }\n @default {\n \n \n \n }\n }\n \n \n }\n \n @if (title()) {\n {{ title() }}\n }\n \n \n \n `,\n})\nexport class PdfAlert {\n readonly variant = input(\"info\");\n readonly title = input();\n readonly showIcon = input(true, { transform: booleanAttribute });\n readonly showBorder = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n protected readonly strokeWidth = ICON_STROKE_WIDTH;\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n alertStyles(this.theme(), {\n showBorder: this.showBorder(),\n style: this.style(),\n variant: this.variant(),\n })\n );\n}\n",
+ "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport {\n mergePdfStyles,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeSvg,\n FormeText,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type AlertVariant = \"info\" | \"success\" | \"warning\" | \"error\";\n\n/**\n * Alert box with severity variants for info, success, warning, and error states.\n * Props - `variant` | `title` | `children` | `showIcon` | `showBorder` | `style`\n * @see {@link PdfAlertProps}\n */\nexport interface PdfAlertProps extends Omit {\n /**\n * @default 'info'\n */\n variant?: AlertVariant;\n title?: string;\n /**\n * @default true\n */\n showIcon?: boolean;\n /**\n * @default true\n */\n showBorder?: boolean;\n}\n\n/** Stroke width for all alert SVG icons (SVG user units). */\nconst ICON_STROKE_WIDTH = 1.5;\n\nconst borderLeft = (color: string) => ({\n borderLeftColor: color,\n borderLeftWidth: 4,\n});\n\nconst createAlertStyles = (theme: PdfcnTheme) => {\n const { typography, colors, primitives } = theme;\n\n const variantColors = {\n error: colors.destructive ?? \"#EF4444\",\n info: colors.info ?? \"#3B82F6\",\n success: colors.success ?? \"#22C55E\",\n warning: colors.warning ?? \"#F59E0B\",\n } satisfies Record;\n\n const sheet = StyleSheet.create({\n bg: {\n backgroundColor: colors.muted,\n },\n borderError: borderLeft(variantColors.error),\n borderInfo: borderLeft(variantColors.info),\n borderSuccess: borderLeft(variantColors.success),\n borderWarning: borderLeft(variantColors.warning),\n container: {\n borderRadius: 4,\n flexDirection: \"row\",\n marginBottom: theme.spacing.componentGap,\n padding: 12,\n },\n contentContainer: { flex: 1 },\n description: {\n color: colors.mutedForeground,\n fontFamily: typography.body.fontFamily,\n fontSize: primitives.typography.sm,\n lineHeight: typography.body.lineHeight,\n },\n iconContainer: {\n alignItems: \"center\",\n justifyContent: \"flex-start\",\n marginRight: 10,\n paddingTop: 2,\n width: 20,\n },\n title: {\n color: colors.foreground,\n fontFamily: typography.heading.fontFamily,\n fontSize: primitives.typography.sm,\n fontWeight: primitives.fontWeights.semibold,\n marginBottom: 4,\n },\n });\n\n return {\n ...sheet,\n borderMap: {\n error: sheet.borderError,\n info: sheet.borderInfo,\n success: sheet.borderSuccess,\n warning: sheet.borderWarning,\n } as Record,\n /** Resolved hex colors for each variant — used to tint the SVG icons. */\n variantColors,\n };\n};\n\n/** Container style and icon color of the variant. */\nconst alertStyles = (\n theme: PdfcnTheme,\n { variant = \"info\", showBorder = true, style }: PdfAlertProps\n) => {\n const styles = createAlertStyles(theme);\n\n const containerStyles: Style[] = [\n styles.container,\n styles.bg,\n ...(showBorder ? [styles.borderMap[variant]] : []),\n ...(style ? [style].flat() : []),\n ];\n\n return {\n container: mergePdfStyles(containerStyles),\n iconColor: styles.variantColors[variant],\n styles,\n };\n};\n\n/** Alert box with severity variants for info, success, warning, and error states. */\n@Component({\n imports: [FormeSvg, FormeText, FormeView],\n selector: \"pdf-alert\",\n template: `\n @let s = layout().styles;\n @let color = layout().iconColor;\n \n @if (showIcon()) {\n \n \n \n @switch (variant()) {\n @case (\"error\") {\n \n \n \n }\n @case (\"success\") {\n \n \n }\n @case (\"warning\") {\n \n \n \n }\n @default {\n \n \n \n }\n }\n \n \n }\n \n @if (title()) {\n {{ title() }}\n }\n \n \n \n `,\n})\nexport class PdfAlert {\n readonly variant = input(\"info\");\n readonly title = input();\n readonly showIcon = input(true, { transform: booleanAttribute });\n readonly showBorder = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n protected readonly strokeWidth = ICON_STROKE_WIDTH;\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n alertStyles(this.theme(), {\n showBorder: this.showBorder(),\n style: this.style(),\n variant: this.variant(),\n })\n );\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/alert/alert.ts"
}
diff --git a/apps/web/public/r/forme/badge.json b/apps/web/public/r/forme/badge.json
index 8664454..c7d6c98 100644
--- a/apps/web/public/r/forme/badge.json
+++ b/apps/web/public/r/forme/badge.json
@@ -3,17 +3,13 @@
"name": "forme/badge",
"title": "Badge",
"description": "Badge PDF component (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils"
],
"files": [
{
"path": "registry/bases/forme/components/badge/badge.ts",
- "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeText,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type BadgeVariant =\n | \"default\"\n | \"primary\"\n | \"success\"\n | \"warning\"\n | \"destructive\"\n | \"info\"\n | \"outline\";\nexport type BadgeSize = \"sm\" | \"md\" | \"lg\";\n\n/**\n * Inline label for status, tags, or categories.\n *\n * Accepts text via either `label` prop or `children` (string). `label` takes\n * precedence when both are provided. Projected text (`text`)\n * also works. Only text content is supported.\n *\n * Props - `label` | `children` | `variant` | `size` | `background` | `color` | `style`\n * @see {@link BadgeProps}\n */\nexport interface BadgeProps extends Omit {\n /** Text to display. Takes precedence over children when both are provided. */\n label?: string;\n /** String children as an alternative to the label prop. */\n children?: string;\n /**\n * @default 'default'\n */\n variant?: BadgeVariant;\n /**\n * @default 'md'\n */\n size?: BadgeSize;\n background?: string;\n color?: string;\n}\n\nconst createBadgeStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius, fontWeights } = t.primitives;\n const c = t.colors;\n const textBase = {\n fontFamily: t.typography.body.fontFamily,\n fontWeight: fontWeights.semibold,\n letterSpacing: 0.3,\n };\n const variantBox = (borderColor: string, bgColor: string = c.muted) => ({\n backgroundColor: bgColor,\n borderColor,\n borderStyle: \"solid\" as const,\n borderWidth: spacing[0.5],\n });\n const sheet = StyleSheet.create({\n containerBase: {\n alignItems: \"center\" as const,\n alignSelf: \"flex-start\" as const,\n borderRadius: borderRadius.full,\n flexDirection: \"row\" as const,\n },\n sizeLg: { paddingHorizontal: spacing[4], paddingVertical: spacing[2] },\n sizeMd: { paddingHorizontal: spacing[3], paddingVertical: spacing[1] },\n sizeSm: { paddingHorizontal: spacing[2], paddingVertical: spacing[0.5] },\n textDefault: { ...textBase, color: c.mutedForeground },\n textDestructive: { ...textBase, color: c.destructive },\n textInfo: { ...textBase, color: c.info },\n textLg: { fontSize: t.primitives.typography.sm },\n textMd: { fontSize: t.primitives.typography.xs },\n textOutline: { ...textBase, color: c.foreground },\n textPrimary: { ...textBase, color: c.primaryForeground },\n textSm: { fontSize: t.primitives.typography.xs - 1 },\n textSuccess: { ...textBase, color: c.success },\n textWarning: { ...textBase, color: c.warning },\n variantDefault: variantBox(c.border),\n variantDestructive: variantBox(c.destructive),\n variantInfo: variantBox(c.info),\n variantOutline: variantBox(c.border, c.background),\n variantPrimary: variantBox(c.primary, c.primary),\n variantSuccess: variantBox(c.success),\n variantWarning: variantBox(c.warning),\n });\n return {\n ...sheet,\n containerSizeMap: {\n lg: sheet.sizeLg,\n md: sheet.sizeMd,\n sm: sheet.sizeSm,\n } as Record,\n containerVariantMap: {\n default: sheet.variantDefault,\n destructive: sheet.variantDestructive,\n info: sheet.variantInfo,\n outline: sheet.variantOutline,\n primary: sheet.variantPrimary,\n success: sheet.variantSuccess,\n warning: sheet.variantWarning,\n } as Record,\n textSizeMap: {\n lg: sheet.textLg,\n md: sheet.textMd,\n sm: sheet.textSm,\n } as Record,\n textVariantMap: {\n default: sheet.textDefault,\n destructive: sheet.textDestructive,\n info: sheet.textInfo,\n outline: sheet.textOutline,\n primary: sheet.textPrimary,\n success: sheet.textSuccess,\n warning: sheet.textWarning,\n } as Record,\n };\n};\n\nconst badgeStyles = (\n theme: PdfcnTheme,\n { variant = \"default\", size = \"md\", background, color, style }: BadgeProps\n) => {\n const styles = createBadgeStyles(theme);\n const containerStyles: Style[] = [\n styles.containerBase,\n styles.containerVariantMap[variant],\n styles.containerSizeMap[size],\n ...(background\n ? [{ backgroundColor: resolveColor(background, theme.colors) }]\n : []),\n ...(style ? [style].flat() : []),\n ];\n const textStyles: Style[] = [\n styles.textVariantMap[variant],\n styles.textSizeMap[size],\n ...(color ? [{ color: resolveColor(color, theme.colors) }] : []),\n ];\n return { container: containerStyles, text: textStyles };\n};\n\n// `label` takes precedence over projected content\n@Component({\n imports: [FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-badge\",\n template: `\n \n \n {{ label()\n }}\n \n `,\n})\nexport class PdfBadge {\n readonly label = input();\n readonly variant = input(\"default\");\n readonly size = input(\"md\");\n readonly background = input();\n readonly color = input();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly styles = computed(() =>\n badgeStyles(this.theme(), {\n background: this.background(),\n color: this.color(),\n size: this.size(),\n style: this.style(),\n variant: this.variant(),\n })\n );\n}\n",
+ "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeText,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type BadgeVariant =\n | \"default\"\n | \"primary\"\n | \"success\"\n | \"warning\"\n | \"destructive\"\n | \"info\"\n | \"outline\";\nexport type BadgeSize = \"sm\" | \"md\" | \"lg\";\n\n/**\n * Inline label for status, tags, or categories.\n *\n * Accepts text via either `label` prop or `children` (string). `label` takes\n * precedence when both are provided. Projected text (`text`)\n * also works. Only text content is supported.\n *\n * Props - `label` | `children` | `variant` | `size` | `background` | `color` | `style`\n * @see {@link BadgeProps}\n */\nexport interface BadgeProps extends Omit {\n /** Text to display. Takes precedence over children when both are provided. */\n label?: string;\n /** String children as an alternative to the label prop. */\n children?: string;\n /**\n * @default 'default'\n */\n variant?: BadgeVariant;\n /**\n * @default 'md'\n */\n size?: BadgeSize;\n background?: string;\n color?: string;\n}\n\nconst createBadgeStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius, fontWeights } = t.primitives;\n const c = t.colors;\n const textBase = {\n fontFamily: t.typography.body.fontFamily,\n fontWeight: fontWeights.semibold,\n letterSpacing: 0.3,\n };\n const variantBox = (borderColor: string, bgColor: string = c.muted) => ({\n backgroundColor: bgColor,\n borderColor,\n borderStyle: \"solid\" as const,\n borderWidth: spacing[0.5],\n });\n const sheet = StyleSheet.create({\n containerBase: {\n alignItems: \"center\" as const,\n alignSelf: \"flex-start\" as const,\n borderRadius: borderRadius.full,\n flexDirection: \"row\" as const,\n },\n sizeLg: { paddingHorizontal: spacing[4], paddingVertical: spacing[2] },\n sizeMd: { paddingHorizontal: spacing[3], paddingVertical: spacing[1] },\n sizeSm: { paddingHorizontal: spacing[2], paddingVertical: spacing[0.5] },\n textDefault: { ...textBase, color: c.mutedForeground },\n textDestructive: { ...textBase, color: c.destructive },\n textInfo: { ...textBase, color: c.info },\n textLg: { fontSize: t.primitives.typography.sm },\n textMd: { fontSize: t.primitives.typography.xs },\n textOutline: { ...textBase, color: c.foreground },\n textPrimary: { ...textBase, color: c.primaryForeground },\n textSm: { fontSize: t.primitives.typography.xs - 1 },\n textSuccess: { ...textBase, color: c.success },\n textWarning: { ...textBase, color: c.warning },\n variantDefault: variantBox(c.border),\n variantDestructive: variantBox(c.destructive),\n variantInfo: variantBox(c.info),\n variantOutline: variantBox(c.border, c.background),\n variantPrimary: variantBox(c.primary, c.primary),\n variantSuccess: variantBox(c.success),\n variantWarning: variantBox(c.warning),\n });\n return {\n ...sheet,\n containerSizeMap: {\n lg: sheet.sizeLg,\n md: sheet.sizeMd,\n sm: sheet.sizeSm,\n } as Record,\n containerVariantMap: {\n default: sheet.variantDefault,\n destructive: sheet.variantDestructive,\n info: sheet.variantInfo,\n outline: sheet.variantOutline,\n primary: sheet.variantPrimary,\n success: sheet.variantSuccess,\n warning: sheet.variantWarning,\n } as Record,\n textSizeMap: {\n lg: sheet.textLg,\n md: sheet.textMd,\n sm: sheet.textSm,\n } as Record,\n textVariantMap: {\n default: sheet.textDefault,\n destructive: sheet.textDestructive,\n info: sheet.textInfo,\n outline: sheet.textOutline,\n primary: sheet.textPrimary,\n success: sheet.textSuccess,\n warning: sheet.textWarning,\n } as Record,\n };\n};\n\nconst badgeStyles = (\n theme: PdfcnTheme,\n { variant = \"default\", size = \"md\", background, color, style }: BadgeProps\n) => {\n const styles = createBadgeStyles(theme);\n const containerStyles: Style[] = [\n styles.containerBase,\n styles.containerVariantMap[variant],\n styles.containerSizeMap[size],\n ...(background\n ? [{ backgroundColor: resolveColor(background, theme.colors) }]\n : []),\n ...(style ? [style].flat() : []),\n ];\n const textStyles: Style[] = [\n styles.textVariantMap[variant],\n styles.textSizeMap[size],\n ...(color ? [{ color: resolveColor(color, theme.colors) }] : []),\n ];\n return { container: containerStyles, text: textStyles };\n};\n\n// `label` takes precedence over projected content\n@Component({\n imports: [FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-badge\",\n template: `\n \n \n {{ label()\n }}\n \n `,\n})\nexport class PdfBadge {\n readonly label = input();\n readonly variant = input(\"default\");\n readonly size = input(\"md\");\n readonly background = input();\n readonly color = input();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly styles = computed(() =>\n badgeStyles(this.theme(), {\n background: this.background(),\n color: this.color(),\n size: this.size(),\n style: this.style(),\n variant: this.variant(),\n })\n );\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/badge/badge.ts"
}
diff --git a/apps/web/public/r/forme/card.json b/apps/web/public/r/forme/card.json
index ed2a530..3fb5363 100644
--- a/apps/web/public/r/forme/card.json
+++ b/apps/web/public/r/forme/card.json
@@ -3,17 +3,13 @@
"name": "forme/card",
"title": "Card",
"description": "Card PDF component (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils"
],
"files": [
{
"path": "registry/bases/forme/components/card/card.ts",
- "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeText,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type CardVariant = \"default\" | \"bordered\" | \"muted\";\n\n/**\n * Bordered content card with optional title and padding presets.\n * Props - `title` | `children` | `variant` | `padding` | `wrap` | `style`\n * @see {@link PdfCardProps}\n */\nexport interface PdfCardProps extends Omit {\n title?: string;\n /**\n * @default 'default'\n */\n variant?: CardVariant;\n /**\n * @default 'md'\n */\n padding?: \"sm\" | \"md\" | \"lg\";\n /**\n * When false, the card will not split across PDF pages.\n * @default false\n */\n wrap?: boolean;\n}\n\nconst createCardStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius, fontWeights } = t.primitives;\n return StyleSheet.create({\n body: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n lineHeight: t.typography.body.lineHeight,\n },\n card: {\n backgroundColor: t.colors.background,\n borderColor: t.colors.border,\n borderRadius: borderRadius.sm,\n borderStyle: \"solid\",\n borderWidth: 1,\n marginBottom: t.spacing.componentGap,\n },\n cardBordered: { borderWidth: 2 },\n cardMuted: { backgroundColor: t.colors.muted },\n paddingLg: { padding: spacing[4] },\n paddingMd: { padding: spacing[3] },\n paddingSm: { padding: spacing[2] },\n title: {\n borderBottomColor: t.colors.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n color: t.colors.foreground,\n fontFamily: t.typography.heading.fontFamily,\n fontSize: t.primitives.typography.base,\n fontWeight: fontWeights.semibold,\n lineHeight: t.typography.heading.lineHeight,\n marginBottom: spacing[2],\n paddingBottom: spacing[1] + 2,\n },\n });\n};\n\n/** Card styles of the variant and padding preset. */\nconst cardStyle = (\n theme: PdfcnTheme,\n { variant = \"default\", padding = \"md\", style }: Omit\n) => {\n const styles = createCardStyles(theme);\n const paddingMap = {\n lg: styles.paddingLg,\n md: styles.paddingMd,\n sm: styles.paddingSm,\n };\n const cardStyles: Style[] = [styles.card];\n if (variant === \"bordered\") {\n cardStyles.push(styles.cardBordered);\n }\n if (variant === \"muted\") {\n cardStyles.push(styles.cardMuted);\n }\n cardStyles.push(paddingMap[padding]);\n if (style) {\n cardStyles.push(style);\n }\n return { card: cardStyles, styles };\n};\n\n/** Bordered content card with optional title and padding presets. */\n@Component({\n imports: [FormeText, FormeView],\n selector: \"pdf-card\",\n template: `\n \n @if (title()) {\n {{ title() }}\n }\n \n \n `,\n})\nexport class PdfCard {\n readonly title = input();\n readonly variant = input(\"default\");\n readonly padding = input>(\"md\");\n readonly wrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n cardStyle(this.theme(), {\n padding: this.padding(),\n style: this.style(),\n variant: this.variant(),\n })\n );\n}\n",
+ "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeText,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type CardVariant = \"default\" | \"bordered\" | \"muted\";\n\n/**\n * Bordered content card with optional title and padding presets.\n * Props - `title` | `children` | `variant` | `padding` | `wrap` | `style`\n * @see {@link PdfCardProps}\n */\nexport interface PdfCardProps extends Omit {\n title?: string;\n /**\n * @default 'default'\n */\n variant?: CardVariant;\n /**\n * @default 'md'\n */\n padding?: \"sm\" | \"md\" | \"lg\";\n /**\n * When false, the card will not split across PDF pages.\n * @default false\n */\n wrap?: boolean;\n}\n\nconst createCardStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius, fontWeights } = t.primitives;\n return StyleSheet.create({\n body: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n lineHeight: t.typography.body.lineHeight,\n },\n card: {\n backgroundColor: t.colors.background,\n borderColor: t.colors.border,\n borderRadius: borderRadius.sm,\n borderStyle: \"solid\",\n borderWidth: 1,\n marginBottom: t.spacing.componentGap,\n },\n cardBordered: { borderWidth: 2 },\n cardMuted: { backgroundColor: t.colors.muted },\n paddingLg: { padding: spacing[4] },\n paddingMd: { padding: spacing[3] },\n paddingSm: { padding: spacing[2] },\n title: {\n borderBottomColor: t.colors.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n color: t.colors.foreground,\n fontFamily: t.typography.heading.fontFamily,\n fontSize: t.primitives.typography.base,\n fontWeight: fontWeights.semibold,\n lineHeight: t.typography.heading.lineHeight,\n marginBottom: spacing[2],\n paddingBottom: spacing[1] + 2,\n },\n });\n};\n\n/** Card styles of the variant and padding preset. */\nconst cardStyle = (\n theme: PdfcnTheme,\n { variant = \"default\", padding = \"md\", style }: Omit\n) => {\n const styles = createCardStyles(theme);\n const paddingMap = {\n lg: styles.paddingLg,\n md: styles.paddingMd,\n sm: styles.paddingSm,\n };\n const cardStyles: Style[] = [styles.card];\n if (variant === \"bordered\") {\n cardStyles.push(styles.cardBordered);\n }\n if (variant === \"muted\") {\n cardStyles.push(styles.cardMuted);\n }\n cardStyles.push(paddingMap[padding]);\n if (style) {\n cardStyles.push(style);\n }\n return { card: cardStyles, styles };\n};\n\n/** Bordered content card with optional title and padding presets. */\n@Component({\n imports: [FormeText, FormeView],\n selector: \"pdf-card\",\n template: `\n \n @if (title()) {\n {{ title() }}\n }\n \n \n `,\n})\nexport class PdfCard {\n readonly title = input();\n readonly variant = input(\"default\");\n readonly padding = input>(\"md\");\n readonly wrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n cardStyle(this.theme(), {\n padding: this.padding(),\n style: this.style(),\n variant: this.variant(),\n })\n );\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/card/card.ts"
}
diff --git a/apps/web/public/r/forme/data-table.json b/apps/web/public/r/forme/data-table.json
index 0447eab..489d817 100644
--- a/apps/web/public/r/forme/data-table.json
+++ b/apps/web/public/r/forme/data-table.json
@@ -3,10 +3,6 @@
"name": "forme/data-table",
"title": "Data Table",
"description": "Data Table PDF component (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils",
"@angular-pdfcn/forme/table"
@@ -14,19 +10,19 @@
"files": [
{
"path": "registry/bases/forme/components/data-table/data-table.styles.ts",
- "content": "import { StyleSheet } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Creates compact-mode cell and text styles for the DataTable component.\n * Used when `size=\"compact\"` to render denser rows with smaller font sizes.\n * @param t - The resolved PdfcnTheme instance.\n */\nexport const createCompactStyles = (t: PdfcnTheme) => {\n const { spacing, fontWeights, lineHeights } = t.primitives;\n return StyleSheet.create({\n cell: {\n paddingHorizontal: spacing[2],\n paddingVertical: spacing[0.5],\n },\n footerText: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n fontWeight: fontWeights.semibold,\n lineHeight: lineHeights.normal,\n },\n headerText: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n fontWeight: fontWeights.semibold,\n lineHeight: lineHeights.normal,\n },\n text: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n lineHeight: lineHeights.normal,\n },\n });\n};\n\n/**\n * Converts an arbitrary cell value to a display string.\n * Returns an empty string for null/undefined values.\n * @param value - The raw cell value to format.\n */\nexport const formatValue = (value: unknown): string => {\n if (value === null || value === undefined) {\n return \"\";\n }\n if (typeof value === \"number\") {\n return String(value);\n }\n return String(value);\n};\n",
+ "content": "import { StyleSheet } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Creates compact-mode cell and text styles for the DataTable component.\n * Used when `size=\"compact\"` to render denser rows with smaller font sizes.\n * @param t - The resolved PdfcnTheme instance.\n */\nexport const createCompactStyles = (t: PdfcnTheme) => {\n const { spacing, fontWeights, lineHeights } = t.primitives;\n return StyleSheet.create({\n cell: {\n paddingHorizontal: spacing[2],\n paddingVertical: spacing[0.5],\n },\n footerText: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n fontWeight: fontWeights.semibold,\n lineHeight: lineHeights.normal,\n },\n headerText: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n fontWeight: fontWeights.semibold,\n lineHeight: lineHeights.normal,\n },\n text: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n lineHeight: lineHeights.normal,\n },\n });\n};\n\n/**\n * Converts an arbitrary cell value to a display string.\n * Returns an empty string for null/undefined values.\n * @param value - The raw cell value to format.\n */\nexport const formatValue = (value: unknown): string => {\n if (value === null || value === undefined) {\n return \"\";\n }\n if (typeof value === \"number\") {\n return String(value);\n }\n return String(value);\n};\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/data-table/data-table.styles.ts"
},
{
"path": "registry/bases/forme/components/data-table/data-table.ts",
- "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport {\n booleanAttribute,\n Component,\n computed,\n Directive,\n input,\n inject,\n Injector,\n} from \"@angular/core\";\n\nimport { PdfTable, TABLE } from \"@/components/pdf/table/table\";\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport { FormeText } from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { createCompactStyles, formatValue } from \"./data-table.styles\";\nimport type {\n DataTableColumn,\n DataTableProps,\n DataTableSize,\n} from \"./data-table.types\";\n\n/** Header, body, and footer cells with their text and compact styles. */\nconst dataTableLayout = >(\n theme: PdfcnTheme,\n {\n columns,\n data,\n footer,\n size = \"default\",\n }: Pick, \"columns\" | \"data\" | \"footer\" | \"size\">\n) => {\n const compact = createCompactStyles(theme);\n const isCompact = size === \"compact\";\n const alignStyle = (col: DataTableColumn) =>\n col.align ? ({ textAlign: col.align } as Style) : {};\n\n return {\n footer:\n footer &&\n columns.map((col) => {\n const value = col.key in footer ? footer[col.key] : \"\";\n return {\n col,\n context: { $implicit: value },\n footer: !!value,\n text: formatValue(value),\n textStyle: isCompact\n ? [value ? compact.footerText : compact.text, alignStyle(col)]\n : undefined,\n };\n }),\n header: columns.map((col) => ({\n col,\n text: col.header,\n textStyle: isCompact ? [compact.headerText, alignStyle(col)] : undefined,\n })),\n isCompact,\n rows: data.map((row) =>\n columns.map((col) => {\n const value = row[col.key];\n return {\n col,\n context: { $implicit: value, row },\n text: formatValue(value),\n textStyle: isCompact ? [compact.text, alignStyle(col)] : undefined,\n };\n })\n ),\n styles: compact,\n };\n};\n\n/**\n * Matches the original pdfcn, where a per-row wrapper hides body rows\n * from `Table`: they keep the default variant and get no zebra stripes.\n */\n@Directive({\n providers: [{ provide: PdfTable, useValue: null }],\n selector: \"[pdfDataTableRowFragment]\",\n})\nclass DataTableRowFragment {}\n\n/** Data table for PDF rendering with column definitions, footer support, and stripe options. */\n@Component({\n imports: [DataTableRowFragment, FormeText, NgTemplateOutlet, TABLE],\n selector: \"pdf-data-table\",\n template: `\n @let l = layout();\n @let cellStyle = l.isCompact ? l.styles.cell : undefined;\n \n \n \n @for (cell of l.header; track cell.col.key) {\n \n }\n \n \n \n @for (row of l.rows; track $index) {\n \n @for (cell of row; track cell.col.key) {\n \n }\n \n }\n \n @if (l.footer; as footer) {\n \n \n @for (cell of footer; track cell.col.key) {\n \n }\n \n \n }\n \n \n @if (render) {\n \n } @else if (cell.textStyle) {\n {{ cell.text }}\n } @else {\n {{ cell.text }}\n }\n \n `,\n})\nexport class PdfDataTable> {\n /** Templates passed in resolve the theme from where they render, not where they are declared. */\n protected readonly injector = inject(Injector);\n readonly columns = input.required[]>();\n readonly data = input.required();\n readonly variant = input[\"variant\"]>>(\"grid\");\n readonly footer = input[\"footer\"]>();\n readonly stripe = input(false, { transform: booleanAttribute });\n readonly size = input(\"default\");\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input[\"style\"]>();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n dataTableLayout(this.theme(), {\n columns: this.columns(),\n data: this.data(),\n footer: this.footer(),\n size: this.size(),\n })\n );\n}\n",
+ "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport {\n booleanAttribute,\n Component,\n computed,\n Directive,\n input,\n inject,\n Injector,\n} from \"@angular/core\";\n\nimport { PdfTable, TABLE } from \"@/components/pdf/table/table\";\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport { FormeText } from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { createCompactStyles, formatValue } from \"./data-table.styles\";\nimport type {\n DataTableColumn,\n DataTableProps,\n DataTableSize,\n} from \"./data-table.types\";\n\n/** Header, body, and footer cells with their text and compact styles. */\nconst dataTableLayout = >(\n theme: PdfcnTheme,\n {\n columns,\n data,\n footer,\n size = \"default\",\n }: Pick, \"columns\" | \"data\" | \"footer\" | \"size\">\n) => {\n const compact = createCompactStyles(theme);\n const isCompact = size === \"compact\";\n const alignStyle = (col: DataTableColumn) =>\n col.align ? ({ textAlign: col.align } as Style) : {};\n\n return {\n footer:\n footer &&\n columns.map((col) => {\n const value = col.key in footer ? footer[col.key] : \"\";\n return {\n col,\n context: { $implicit: value },\n footer: !!value,\n text: formatValue(value),\n textStyle: isCompact\n ? [value ? compact.footerText : compact.text, alignStyle(col)]\n : undefined,\n };\n }),\n header: columns.map((col) => ({\n col,\n text: col.header,\n textStyle: isCompact ? [compact.headerText, alignStyle(col)] : undefined,\n })),\n isCompact,\n rows: data.map((row) =>\n columns.map((col) => {\n const value = row[col.key];\n return {\n col,\n context: { $implicit: value, row },\n text: formatValue(value),\n textStyle: isCompact ? [compact.text, alignStyle(col)] : undefined,\n };\n })\n ),\n styles: compact,\n };\n};\n\n/**\n * Matches the original pdfcn, where a per-row wrapper hides body rows\n * from `Table`: they keep the default variant and get no zebra stripes.\n */\n@Directive({\n providers: [{ provide: PdfTable, useValue: null }],\n selector: \"[pdfDataTableRowFragment]\",\n})\nclass DataTableRowFragment {}\n\n/** Data table for PDF rendering with column definitions, footer support, and stripe options. */\n@Component({\n imports: [DataTableRowFragment, FormeText, NgTemplateOutlet, TABLE],\n selector: \"pdf-data-table\",\n template: `\n @let l = layout();\n @let cellStyle = l.isCompact ? l.styles.cell : undefined;\n \n \n \n @for (cell of l.header; track cell.col.key) {\n \n }\n \n \n \n @for (row of l.rows; track $index) {\n \n @for (cell of row; track cell.col.key) {\n \n }\n \n }\n \n @if (l.footer; as footer) {\n \n \n @for (cell of footer; track cell.col.key) {\n \n }\n \n \n }\n \n \n @if (render) {\n \n } @else if (cell.textStyle) {\n {{ cell.text }}\n } @else {\n {{ cell.text }}\n }\n \n `,\n})\nexport class PdfDataTable> {\n /** Templates passed in resolve the theme from where they render, not where they are declared. */\n protected readonly injector = inject(Injector);\n readonly columns = input.required[]>();\n readonly data = input.required();\n readonly variant = input[\"variant\"]>>(\"grid\");\n readonly footer = input[\"footer\"]>();\n readonly stripe = input(false, { transform: booleanAttribute });\n readonly size = input(\"default\");\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input[\"style\"]>();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n dataTableLayout(this.theme(), {\n columns: this.columns(),\n data: this.data(),\n footer: this.footer(),\n size: this.size(),\n })\n );\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/data-table/data-table.ts"
},
{
"path": "registry/bases/forme/components/data-table/data-table.types.ts",
- "content": "import type { TemplateRef } from \"@angular/core\";\n\nimport type { TableVariant } from \"@/components/pdf/table/table.types\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\n\n/** DataTable row density size. */\nexport type DataTableSize = \"default\" | \"compact\";\n\n/** Template context of a `render` cell: the cell value and its row. */\nexport interface DataTableCellContext> {\n $implicit: unknown;\n row: T;\n}\n\n/** Template context of a `renderFooter` cell: the footer value. */\nexport interface DataTableFooterContext {\n $implicit: unknown;\n}\n\n/**\n * Column definition for a DataTable.\n * Props - `key` | `header` | `align` | `width` | `render` | `renderFooter`\n * @see {@link DataTableColumn}\n */\nexport interface DataTableColumn> {\n key: keyof T & string;\n header: string;\n align?: \"left\" | \"center\" | \"right\";\n width?: string | number;\n /**\n * Custom cell template. Must contain forme-* primitives (``,\n * ``, etc.), NOT HTML DOM elements.\n */\n render?: TemplateRef>;\n /**\n * Custom footer cell template. Same constraint: forme-* primitives only.\n */\n renderFooter?: TemplateRef;\n}\n\n/**\n * Data table for PDF rendering with column definitions, footer support, and stripe options.\n * Props - `columns` | `data` | `variant` | `footer` | `stripe` | `size` | `noWrap` | `style`\n * @see {@link DataTableProps}\n */\nexport interface DataTableProps> extends Omit<\n PDFComponentProps,\n \"children\"\n> {\n columns: DataTableColumn[];\n data: T[];\n /**\n * @default 'grid'\n */\n variant?: TableVariant;\n footer?: Partial>;\n stripe?: boolean;\n /**\n * @default 'default'\n */\n size?: DataTableSize;\n noWrap?: boolean;\n}\n",
+ "content": "import type { TemplateRef } from \"@angular/core\";\n\nimport type { TableVariant } from \"@/components/pdf/table/table.types\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\n\n/** DataTable row density size. */\nexport type DataTableSize = \"default\" | \"compact\";\n\n/** Template context of a `render` cell: the cell value and its row. */\nexport interface DataTableCellContext> {\n $implicit: unknown;\n row: T;\n}\n\n/** Template context of a `renderFooter` cell: the footer value. */\nexport interface DataTableFooterContext {\n $implicit: unknown;\n}\n\n/**\n * Column definition for a DataTable.\n * Props - `key` | `header` | `align` | `width` | `render` | `renderFooter`\n * @see {@link DataTableColumn}\n */\nexport interface DataTableColumn> {\n key: keyof T & string;\n header: string;\n align?: \"left\" | \"center\" | \"right\";\n width?: string | number;\n /**\n * Custom cell template. Must contain forme-* primitives (``,\n * ``, etc.), NOT HTML DOM elements.\n */\n render?: TemplateRef>;\n /**\n * Custom footer cell template. Same constraint: forme-* primitives only.\n */\n renderFooter?: TemplateRef;\n}\n\n/**\n * Data table for PDF rendering with column definitions, footer support, and stripe options.\n * Props - `columns` | `data` | `variant` | `footer` | `stripe` | `size` | `noWrap` | `style`\n * @see {@link DataTableProps}\n */\nexport interface DataTableProps> extends Omit<\n PDFComponentProps,\n \"children\"\n> {\n columns: DataTableColumn[];\n data: T[];\n /**\n * @default 'grid'\n */\n variant?: TableVariant;\n footer?: Partial>;\n stripe?: boolean;\n /**\n * @default 'default'\n */\n size?: DataTableSize;\n noWrap?: boolean;\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/data-table/data-table.types.ts"
}
diff --git a/apps/web/public/r/forme/divider.json b/apps/web/public/r/forme/divider.json
index 7c99d4f..cd5eaf6 100644
--- a/apps/web/public/r/forme/divider.json
+++ b/apps/web/public/r/forme/divider.json
@@ -3,17 +3,13 @@
"name": "forme/divider",
"title": "Divider",
"description": "Divider PDF component (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils"
],
"files": [
{
"path": "registry/bases/forme/components/divider/divider.ts",
- "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeText,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type DividerVariant = \"solid\" | \"dashed\" | \"dotted\";\nexport type DividerThickness = \"thin\" | \"medium\" | \"thick\";\nexport type DividerSpacing = \"none\" | \"sm\" | \"md\" | \"lg\";\n\n/**\n * Horizontal rule with optional label, style variants, and spacing presets.\n * Props - `spacing` | `variant` | `color` | `thickness` | `label` | `width` | `style`\n * @see {@link DividerProps}\n */\nexport interface DividerProps extends Omit {\n /**\n * @default 'md'\n */\n spacing?: DividerSpacing;\n /**\n * @default 'solid'\n */\n variant?: DividerVariant;\n color?: string;\n /**\n * @default 'thin'\n */\n thickness?: DividerThickness;\n label?: string;\n width?: string | number;\n}\n\n// Forme's `Style` lacks `borderBottomStyle`, so the sheet is cast.\ntype DividerStyleName =\n | \"base\"\n | \"dashed\"\n | \"dotted\"\n | \"labelContainer\"\n | \"labelLine\"\n | \"labelText\"\n | \"medium\"\n | \"solid\"\n | \"spacingLg\"\n | \"spacingMd\"\n | \"spacingNone\"\n | \"spacingSm\"\n | \"thick\"\n | \"thin\";\n\nconst createDividerStyles = (t: PdfcnTheme) => {\n const { spacing, fontWeights } = t.primitives;\n return StyleSheet.create({\n base: { borderBottomColor: t.colors.border, borderBottomStyle: \"solid\" },\n dashed: { borderBottomStyle: \"dashed\" },\n dotted: { borderBottomStyle: \"dotted\" },\n labelContainer: { alignItems: \"center\", flexDirection: \"row\" },\n labelLine: {\n borderBottomColor: t.colors.border,\n borderBottomStyle: \"solid\",\n flex: 1,\n },\n labelText: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n fontWeight: fontWeights.medium,\n letterSpacing: t.primitives.letterSpacing.wider * 10,\n paddingHorizontal: spacing[3],\n textTransform: \"uppercase\",\n },\n medium: { borderBottomWidth: spacing[1] },\n solid: { borderBottomStyle: \"solid\" },\n spacingLg: { marginVertical: t.spacing.sectionGap },\n spacingMd: { marginVertical: t.spacing.componentGap },\n spacingNone: { marginVertical: spacing[0] },\n spacingSm: { marginVertical: t.spacing.paragraphGap },\n thick: { borderBottomWidth: spacing[2] },\n thin: { borderBottomWidth: spacing[0.5] },\n } as Record);\n};\n\nconst dividerLayout = (\n theme: PdfcnTheme,\n {\n spacing = \"md\",\n variant = \"solid\",\n color,\n thickness = \"thin\",\n label,\n width,\n style,\n }: DividerProps\n) => {\n const styles = createDividerStyles(theme);\n const spacingMap = {\n lg: styles.spacingLg,\n md: styles.spacingMd,\n none: styles.spacingNone,\n sm: styles.spacingSm,\n };\n const variantMap = {\n dashed: styles.dashed,\n dotted: styles.dotted,\n solid: styles.solid,\n };\n const thicknessMap = {\n medium: styles.medium,\n thick: styles.thick,\n thin: styles.thin,\n };\n\n if (label) {\n const lineStyle: Style[] = [\n styles.labelLine,\n thicknessMap[thickness],\n variantMap[variant],\n ];\n if (color) {\n lineStyle.push({\n borderBottomColor: resolveColor(color, theme.colors),\n } as Style);\n }\n const containerStyles: Style[] = [\n styles.labelContainer,\n spacingMap[spacing],\n ];\n if (width !== undefined) {\n containerStyles.push({ width } as Style);\n }\n if (style) {\n containerStyles.push(...[style].flat());\n }\n const labelTextStyle: Style[] = [styles.labelText];\n if (color) {\n labelTextStyle.push({ color: resolveColor(color, theme.colors) });\n }\n return {\n container: containerStyles,\n label: labelTextStyle,\n labeled: true,\n line: lineStyle,\n } as const;\n }\n\n const styleArray: Style[] = [\n styles.base,\n spacingMap[spacing],\n variantMap[variant],\n thicknessMap[thickness],\n ];\n if (color) {\n styleArray.push({ borderBottomColor: resolveColor(color, theme.colors) });\n }\n if (width !== undefined) {\n styleArray.push({ width } as Style);\n }\n if (style) {\n styleArray.push(...[style].flat());\n }\n return { labeled: false, line: styleArray } as const;\n};\n\n@Component({\n imports: [FormeText, FormeView],\n selector: \"pdf-divider\",\n template: `\n @let l = layout();\n @if (l.labeled) {\n \n \n {{ label() }}\n \n \n } @else {\n \n }\n `,\n})\nexport class PdfDivider {\n readonly spacing = input(\"md\");\n readonly variant = input(\"solid\");\n readonly color = input();\n readonly thickness = input(\"thin\");\n readonly label = input();\n readonly width = input();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n dividerLayout(this.theme(), {\n color: this.color(),\n label: this.label(),\n spacing: this.spacing(),\n style: this.style(),\n thickness: this.thickness(),\n variant: this.variant(),\n width: this.width(),\n })\n );\n}\n",
+ "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeText,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type DividerVariant = \"solid\" | \"dashed\" | \"dotted\";\nexport type DividerThickness = \"thin\" | \"medium\" | \"thick\";\nexport type DividerSpacing = \"none\" | \"sm\" | \"md\" | \"lg\";\n\n/**\n * Horizontal rule with optional label, style variants, and spacing presets.\n * Props - `spacing` | `variant` | `color` | `thickness` | `label` | `width` | `style`\n * @see {@link DividerProps}\n */\nexport interface DividerProps extends Omit {\n /**\n * @default 'md'\n */\n spacing?: DividerSpacing;\n /**\n * @default 'solid'\n */\n variant?: DividerVariant;\n color?: string;\n /**\n * @default 'thin'\n */\n thickness?: DividerThickness;\n label?: string;\n width?: string | number;\n}\n\n// Forme's `Style` lacks `borderBottomStyle`, so the sheet is cast.\ntype DividerStyleName =\n | \"base\"\n | \"dashed\"\n | \"dotted\"\n | \"labelContainer\"\n | \"labelLine\"\n | \"labelText\"\n | \"medium\"\n | \"solid\"\n | \"spacingLg\"\n | \"spacingMd\"\n | \"spacingNone\"\n | \"spacingSm\"\n | \"thick\"\n | \"thin\";\n\nconst createDividerStyles = (t: PdfcnTheme) => {\n const { spacing, fontWeights } = t.primitives;\n return StyleSheet.create({\n base: { borderBottomColor: t.colors.border, borderBottomStyle: \"solid\" },\n dashed: { borderBottomStyle: \"dashed\" },\n dotted: { borderBottomStyle: \"dotted\" },\n labelContainer: { alignItems: \"center\", flexDirection: \"row\" },\n labelLine: {\n borderBottomColor: t.colors.border,\n borderBottomStyle: \"solid\",\n flex: 1,\n },\n labelText: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n fontWeight: fontWeights.medium,\n letterSpacing: t.primitives.letterSpacing.wider * 10,\n paddingHorizontal: spacing[3],\n textTransform: \"uppercase\",\n },\n medium: { borderBottomWidth: spacing[1] },\n solid: { borderBottomStyle: \"solid\" },\n spacingLg: { marginVertical: t.spacing.sectionGap },\n spacingMd: { marginVertical: t.spacing.componentGap },\n spacingNone: { marginVertical: spacing[0] },\n spacingSm: { marginVertical: t.spacing.paragraphGap },\n thick: { borderBottomWidth: spacing[2] },\n thin: { borderBottomWidth: spacing[0.5] },\n } as Record);\n};\n\nconst dividerLayout = (\n theme: PdfcnTheme,\n {\n spacing = \"md\",\n variant = \"solid\",\n color,\n thickness = \"thin\",\n label,\n width,\n style,\n }: DividerProps\n) => {\n const styles = createDividerStyles(theme);\n const spacingMap = {\n lg: styles.spacingLg,\n md: styles.spacingMd,\n none: styles.spacingNone,\n sm: styles.spacingSm,\n };\n const variantMap = {\n dashed: styles.dashed,\n dotted: styles.dotted,\n solid: styles.solid,\n };\n const thicknessMap = {\n medium: styles.medium,\n thick: styles.thick,\n thin: styles.thin,\n };\n\n if (label) {\n const lineStyle: Style[] = [\n styles.labelLine,\n thicknessMap[thickness],\n variantMap[variant],\n ];\n if (color) {\n lineStyle.push({\n borderBottomColor: resolveColor(color, theme.colors),\n } as Style);\n }\n const containerStyles: Style[] = [\n styles.labelContainer,\n spacingMap[spacing],\n ];\n if (width !== undefined) {\n containerStyles.push({ width } as Style);\n }\n if (style) {\n containerStyles.push(...[style].flat());\n }\n const labelTextStyle: Style[] = [styles.labelText];\n if (color) {\n labelTextStyle.push({ color: resolveColor(color, theme.colors) });\n }\n return {\n container: containerStyles,\n label: labelTextStyle,\n labeled: true,\n line: lineStyle,\n } as const;\n }\n\n const styleArray: Style[] = [\n styles.base,\n spacingMap[spacing],\n variantMap[variant],\n thicknessMap[thickness],\n ];\n if (color) {\n styleArray.push({ borderBottomColor: resolveColor(color, theme.colors) });\n }\n if (width !== undefined) {\n styleArray.push({ width } as Style);\n }\n if (style) {\n styleArray.push(...[style].flat());\n }\n return { labeled: false, line: styleArray } as const;\n};\n\n@Component({\n imports: [FormeText, FormeView],\n selector: \"pdf-divider\",\n template: `\n @let l = layout();\n @if (l.labeled) {\n \n \n {{ label() }}\n \n \n } @else {\n \n }\n `,\n})\nexport class PdfDivider {\n readonly spacing = input(\"md\");\n readonly variant = input(\"solid\");\n readonly color = input();\n readonly thickness = input(\"thin\");\n readonly label = input();\n readonly width = input();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n dividerLayout(this.theme(), {\n color: this.color(),\n label: this.label(),\n spacing: this.spacing(),\n style: this.style(),\n thickness: this.thickness(),\n variant: this.variant(),\n width: this.width(),\n })\n );\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/divider/divider.ts"
}
diff --git a/apps/web/public/r/forme/event-agenda.json b/apps/web/public/r/forme/event-agenda.json
index 632ecfe..ea3e9f2 100644
--- a/apps/web/public/r/forme/event-agenda.json
+++ b/apps/web/public/r/forme/event-agenda.json
@@ -3,26 +3,21 @@
"name": "forme/event-agenda",
"title": "Event Agenda",
"description": "Event Agenda PDF block (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils",
- "@angular-pdfcn/forme/page-footer",
"@angular-pdfcn/forme/section",
"@angular-pdfcn/forme/text"
],
"files": [
{
"path": "registry/bases/forme/blocks/event-agenda/event-agenda.ts",
- "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfSection } from \"@/components/pdf/section/section\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { EventAgendaProps, Session } from \"./event-agenda.types\";\nimport { sampleEventAgendaData } from \"./event-agenda.types\";\n\ninterface TimeSlotGroup {\n sessions: Session[];\n time: string;\n}\n\nconst groupSessionsByTime = (sessions: Session[]): TimeSlotGroup[] => {\n const groups: TimeSlotGroup[] = [];\n const map = new Map();\n\n for (const session of sessions) {\n const existing = map.get(session.time);\n if (existing) {\n existing.push(session);\n } else {\n const list = [session];\n map.set(session.time, list);\n groups.push({ sessions: list, time: session.time });\n }\n }\n\n return groups;\n};\n\nconst eventAgendaLayout = (theme: PdfcnTheme, data: EventAgendaProps) => {\n const accent = data.accentColor ?? theme.colors.primary;\n\n const trackColorMap = new Map();\n if (data.tracks) {\n for (const track of data.tracks) {\n trackColorMap.set(track.name.toLowerCase(), track.color);\n }\n }\n\n const styles = StyleSheet.create({\n breakBadge: {\n backgroundColor: theme.colors.muted,\n borderColor: theme.colors.border,\n borderRadius: 4,\n borderStyle: \"solid\",\n borderWidth: 1,\n paddingHorizontal: 6,\n paddingVertical: 2,\n },\n breakCard: {\n backgroundColor: theme.colors.muted,\n borderColor: theme.colors.border,\n borderRadius: 6,\n borderStyle: \"dashed\",\n borderWidth: 1,\n flex: 1,\n paddingHorizontal: 10,\n paddingVertical: 7,\n },\n dayBanner: {\n alignItems: \"center\",\n backgroundColor: theme.colors.muted,\n borderColor: theme.colors.border,\n borderRadius: 6,\n borderStyle: \"solid\",\n borderWidth: 1,\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 10,\n marginTop: 8,\n paddingHorizontal: 12,\n paddingVertical: 6,\n },\n footerContainer: {\n borderTopColor: theme.colors.border,\n borderTopStyle: \"solid\",\n borderTopWidth: 1,\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginTop: \"auto\",\n paddingTop: 8,\n },\n headerContainer: {\n borderBottomColor: theme.colors.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1.5,\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: 10,\n },\n legendContainer: {\n alignItems: \"center\",\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 6,\n marginBottom: 8,\n },\n legendDot: {\n borderRadius: 3,\n height: 7,\n marginRight: 4,\n width: 7,\n },\n legendItem: {\n alignItems: \"center\",\n backgroundColor: theme.colors.muted,\n borderColor: theme.colors.border,\n borderRadius: 4,\n borderStyle: \"solid\",\n borderWidth: 1,\n flexDirection: \"row\",\n paddingHorizontal: 6,\n paddingVertical: 2,\n },\n pageContent: {\n backgroundColor: theme.colors.background,\n flex: 1,\n },\n roomBadge: {\n backgroundColor: theme.colors.muted,\n borderColor: theme.colors.border,\n borderRadius: 3,\n borderStyle: \"solid\",\n borderWidth: 1,\n paddingHorizontal: 5,\n paddingVertical: 1,\n },\n sessionCard: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: 6,\n borderStyle: \"solid\",\n borderWidth: 1,\n flex: 1,\n flexDirection: \"column\",\n paddingHorizontal: 10,\n paddingVertical: 7,\n },\n sessionsRow: {\n flex: 1,\n flexDirection: \"row\",\n gap: 8,\n },\n timeBox: {\n alignItems: \"flex-start\",\n flexDirection: \"column\",\n paddingTop: 2,\n width: 78,\n },\n timeSlotRow: {\n flexDirection: \"row\",\n marginBottom: 8,\n },\n trackBadge: {\n borderRadius: 3,\n paddingHorizontal: 6,\n paddingVertical: 1,\n },\n });\n\n return { accent, styles, trackColorMap };\n};\n\n@Component({\n imports: [FormeDocument, FormePage, FormeView, PdfSection, PdfText],\n selector: \"pdf-event-agenda-content\",\n template: `\n @let data = this.data();\n @let theme = this.theme();\n @let accent = this.layout().accent;\n @let styles = this.layout().styles;\n @let trackColorMap = this.layout().trackColorMap;\n \n @for (day of data.days; track day.label; let dayIndex = $index) {\n @let timeSlots = groupSessionsByTime(day.sessions);\n \n \n \n \n \n Event Agenda\n {{ data.eventName }}\n {{ data.date\n }}{{ data.endDate ? \" – \" + data.endDate : \"\" }} •\n {{ data.venue }}\n \n\n \n \n AGENDA\n \n \n \n\n \n \n \n {{ day.label }}\n — {{ day.date }}\n \n\n Day {{ dayIndex + 1 }} of {{ data.days.length }}\n \n\n \n @if (data.tracks && data.tracks.length > 0) {\n \n Tracks:\n @for (track of data.tracks; track track.name) {\n \n \n \n {{ track.name }}\n \n }\n \n }\n\n \n \n @for (slot of timeSlots; track slot.time) {\n @let isSingleBreak =\n slot.sessions.length === 1 && slot.sessions[0].isBreak;\n \n \n \n {{ slot.time }}\n @if (slot.sessions[0].endTime) {\n to {{ slot.sessions[0].endTime }}\n }\n \n\n \n @if (isSingleBreak) {\n \n \n {{ slot.sessions[0].title }}\n \n Break\n \n \n @if (slot.sessions[0].description) {\n {{ slot.sessions[0].description }}\n }\n \n } @else {\n \n @for (\n session of slot.sessions;\n track session.title + \"-\" + sIndex;\n let sIndex = $index\n ) {\n @let trackColor =\n session.track\n ? trackColorMap.get(session.track.toLowerCase())\n : undefined;\n \n \n \n \n @if (session.track) {\n \n \n {{ session.track }}\n \n }\n @if (session.room) {\n \n {{ session.room }}\n \n }\n \n\n \n {{ session.title }}\n\n \n @if (session.speaker) {\n {{ session.speaker }}\n }\n\n \n @if (session.description) {\n {{ session.description }}\n }\n \n }\n \n }\n \n }\n \n\n \n \n \n @if (data.wifiInfo) {\n Wi-Fi: {{ data.wifiInfo }}\n }\n @if (data.emergencyContact) {\n {{ data.emergencyContact }}\n }\n \n\n \n Page {{ dayIndex + 1 }} of {{ data.days.length }}\n \n \n \n \n }\n \n `,\n})\nexport class EventAgendaContent {\n readonly data = input.required();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly groupSessionsByTime = groupSessionsByTime;\n\n protected readonly layout = computed(() =>\n eventAgendaLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [EventAgendaContent, PdfcnThemeProvider],\n selector: \"pdf-event-agenda\",\n template: `\n \n \n \n `,\n})\nexport class EventAgendaDocument {\n readonly theme = input();\n readonly data = input(sampleEventAgendaData);\n}\n\nexport { EventAgendaDocument as EventAgenda };\n",
+ "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfSection } from \"@/components/pdf/section/section\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { EventAgendaProps, Session } from \"./event-agenda.types\";\nimport { sampleEventAgendaData } from \"./event-agenda.types\";\n\ninterface TimeSlotGroup {\n sessions: Session[];\n time: string;\n}\n\nconst groupSessionsByTime = (sessions: Session[]): TimeSlotGroup[] => {\n const groups: TimeSlotGroup[] = [];\n const map = new Map();\n\n for (const session of sessions) {\n const existing = map.get(session.time);\n if (existing) {\n existing.push(session);\n } else {\n const list = [session];\n map.set(session.time, list);\n groups.push({ sessions: list, time: session.time });\n }\n }\n\n return groups;\n};\n\nconst eventAgendaLayout = (theme: PdfcnTheme, data: EventAgendaProps) => {\n const accent = data.accentColor ?? theme.colors.primary;\n\n const trackColorMap = new Map();\n if (data.tracks) {\n for (const track of data.tracks) {\n trackColorMap.set(track.name.toLowerCase(), track.color);\n }\n }\n\n const styles = StyleSheet.create({\n breakBadge: {\n backgroundColor: theme.colors.muted,\n borderColor: theme.colors.border,\n borderRadius: 4,\n borderStyle: \"solid\",\n borderWidth: 1,\n paddingHorizontal: 6,\n paddingVertical: 2,\n },\n breakCard: {\n backgroundColor: theme.colors.muted,\n borderColor: theme.colors.border,\n borderRadius: 6,\n borderStyle: \"dashed\",\n borderWidth: 1,\n flex: 1,\n paddingHorizontal: 10,\n paddingVertical: 7,\n },\n dayBanner: {\n alignItems: \"center\",\n backgroundColor: theme.colors.muted,\n borderColor: theme.colors.border,\n borderRadius: 6,\n borderStyle: \"solid\",\n borderWidth: 1,\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 10,\n marginTop: 8,\n paddingHorizontal: 12,\n paddingVertical: 6,\n },\n footerContainer: {\n borderTopColor: theme.colors.border,\n borderTopStyle: \"solid\",\n borderTopWidth: 1,\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginTop: \"auto\",\n paddingTop: 8,\n },\n headerContainer: {\n borderBottomColor: theme.colors.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1.5,\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: 10,\n },\n legendContainer: {\n alignItems: \"center\",\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 6,\n marginBottom: 8,\n },\n legendDot: {\n borderRadius: 3,\n height: 7,\n marginRight: 4,\n width: 7,\n },\n legendItem: {\n alignItems: \"center\",\n backgroundColor: theme.colors.muted,\n borderColor: theme.colors.border,\n borderRadius: 4,\n borderStyle: \"solid\",\n borderWidth: 1,\n flexDirection: \"row\",\n paddingHorizontal: 6,\n paddingVertical: 2,\n },\n pageContent: {\n backgroundColor: theme.colors.background,\n flex: 1,\n },\n roomBadge: {\n backgroundColor: theme.colors.muted,\n borderColor: theme.colors.border,\n borderRadius: 3,\n borderStyle: \"solid\",\n borderWidth: 1,\n paddingHorizontal: 5,\n paddingVertical: 1,\n },\n sessionCard: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: 6,\n borderStyle: \"solid\",\n borderWidth: 1,\n flex: 1,\n flexDirection: \"column\",\n paddingHorizontal: 10,\n paddingVertical: 7,\n },\n sessionsRow: {\n flex: 1,\n flexDirection: \"row\",\n gap: 8,\n },\n timeBox: {\n alignItems: \"flex-start\",\n flexDirection: \"column\",\n paddingTop: 2,\n width: 78,\n },\n timeSlotRow: {\n flexDirection: \"row\",\n marginBottom: 8,\n },\n trackBadge: {\n borderRadius: 3,\n paddingHorizontal: 6,\n paddingVertical: 1,\n },\n });\n\n return { accent, styles, trackColorMap };\n};\n\n@Component({\n imports: [FormeDocument, FormePage, FormeView, PdfSection, PdfText],\n selector: \"pdf-event-agenda-content\",\n template: `\n @let data = this.data();\n @let theme = this.theme();\n @let accent = this.layout().accent;\n @let styles = this.layout().styles;\n @let trackColorMap = this.layout().trackColorMap;\n \n @for (day of data.days; track day.label; let dayIndex = $index) {\n @let timeSlots = groupSessionsByTime(day.sessions);\n \n \n \n \n \n Event Agenda\n {{ data.eventName }}\n {{ data.date\n }}{{ data.endDate ? \" – \" + data.endDate : \"\" }} •\n {{ data.venue }}\n \n\n \n \n AGENDA\n \n \n \n\n \n \n \n {{ day.label }}\n — {{ day.date }}\n \n\n Day {{ dayIndex + 1 }} of {{ data.days.length }}\n \n\n \n @if (data.tracks && data.tracks.length > 0) {\n \n Tracks:\n @for (track of data.tracks; track track.name) {\n \n \n \n {{ track.name }}\n \n }\n \n }\n\n \n \n @for (slot of timeSlots; track slot.time) {\n @let isSingleBreak =\n slot.sessions.length === 1 && slot.sessions[0].isBreak;\n \n \n \n {{ slot.time }}\n @if (slot.sessions[0].endTime) {\n to {{ slot.sessions[0].endTime }}\n }\n \n\n \n @if (isSingleBreak) {\n \n \n {{ slot.sessions[0].title }}\n \n Break\n \n \n @if (slot.sessions[0].description) {\n {{ slot.sessions[0].description }}\n }\n \n } @else {\n \n @for (\n session of slot.sessions;\n track session.title + \"-\" + sIndex;\n let sIndex = $index\n ) {\n @let trackColor =\n session.track\n ? trackColorMap.get(session.track.toLowerCase())\n : undefined;\n \n \n \n \n @if (session.track) {\n \n \n {{ session.track }}\n \n }\n @if (session.room) {\n \n {{ session.room }}\n \n }\n \n\n \n {{ session.title }}\n\n \n @if (session.speaker) {\n {{ session.speaker }}\n }\n\n \n @if (session.description) {\n {{ session.description }}\n }\n \n }\n \n }\n \n }\n \n\n \n \n \n @if (data.wifiInfo) {\n Wi-Fi: {{ data.wifiInfo }}\n }\n @if (data.emergencyContact) {\n {{ data.emergencyContact }}\n }\n \n\n \n Page {{ dayIndex + 1 }} of {{ data.days.length }}\n \n \n \n \n }\n \n `,\n})\nexport class EventAgendaContent {\n readonly data = input.required();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly groupSessionsByTime = groupSessionsByTime;\n\n protected readonly layout = computed(() =>\n eventAgendaLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [EventAgendaContent, PdfcnThemeProvider],\n selector: \"pdf-event-agenda\",\n template: `\n \n \n \n `,\n})\nexport class EventAgendaDocument {\n readonly theme = input();\n readonly data = input(sampleEventAgendaData);\n}\n\nexport { EventAgendaDocument as EventAgenda };\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/event-agenda/event-agenda.ts"
},
{
"path": "registry/bases/forme/blocks/event-agenda/event-agenda.types.ts",
- "content": "export interface Session {\n description?: string;\n endTime?: string;\n isBreak?: boolean;\n room?: string;\n speaker?: string;\n time: string;\n title: string;\n track?: string;\n}\n\nexport interface DaySchedule {\n date: string;\n label: string;\n sessions: Session[];\n}\n\nexport interface Track {\n color: string;\n name: string;\n}\n\nexport interface EventAgendaProps {\n accentColor?: string;\n date: string;\n days: DaySchedule[];\n emergencyContact?: string;\n endDate?: string;\n eventName: string;\n renderingBase?: \"takumi\" | \"forme\";\n tracks?: Track[];\n venue: string;\n wifiInfo?: string;\n}\n\nexport const sampleEventAgendaData: EventAgendaProps = {\n accentColor: \"#dc2626\",\n date: \"October 20, 2026\",\n days: [\n {\n date: \"October 20, 2026\",\n label: \"Day 1\",\n sessions: [\n {\n description:\n \"Check-in, grab your badge, and enjoy breakfast with peers.\",\n endTime: \"9:00 AM\",\n isBreak: true,\n time: \"8:00 AM\",\n title: \"Registration & Breakfast\",\n },\n {\n description:\n \"An overview of recent evolutions and the road ahead for UI engineering.\",\n endTime: \"9:45 AM\",\n room: \"Main Hall\",\n speaker: \"Dan Abramov\",\n time: \"9:00 AM\",\n title: \"Opening Keynote: The Next Decade of React\",\n track: \"Core React\",\n },\n {\n description:\n \"Real-world architecture patterns, streaming benefits, and edge-case handling.\",\n endTime: \"10:45 AM\",\n room: \"Room A\",\n speaker: \"Sarah Chen\",\n time: \"10:00 AM\",\n title: \"Server Components in Production\",\n track: \"Core React\",\n },\n {\n description:\n \"Navigating signals, atomic state, and server state synchronization.\",\n endTime: \"10:45 AM\",\n room: \"Room B\",\n speaker: \"Mark Erikson\",\n time: \"10:00 AM\",\n title: \"State Management in 2026\",\n track: \"Ecosystem\",\n },\n {\n description: \"Exhibition hall coffee stations open.\",\n endTime: \"11:30 AM\",\n isBreak: true,\n time: \"11:00 AM\",\n title: \"Coffee & Networking Break\",\n },\n {\n description:\n \"Ensuring WCAG AAA compliance with composable headless components.\",\n endTime: \"12:15 PM\",\n room: \"Room A\",\n speaker: \"Rachel Andrew\",\n time: \"11:30 AM\",\n title: \"Building Accessible Design Systems\",\n track: \"Core React\",\n },\n {\n description:\n \"How automatic memoization transforms rendering pipelines.\",\n endTime: \"12:15 PM\",\n room: \"Room B\",\n speaker: \"Andrew Clark\",\n time: \"11:30 AM\",\n title: \"Compiler Deep Dive: Under the Hood\",\n track: \"Ecosystem\",\n },\n {\n description: \"Lunch served in the Grand Ballroom.\",\n endTime: \"1:45 PM\",\n isBreak: true,\n time: \"12:30 PM\",\n title: \"Catered Lunch & Sponsor Showcase\",\n },\n {\n description:\n \"Hands-on exercises exploring Actions, optimistic updates, and new hooks.\",\n endTime: \"3:30 PM\",\n room: \"Workshop Lab\",\n speaker: \"Ken Wheeler\",\n time: \"2:00 PM\",\n title: \"Interactive Workshop: Building with React 19\",\n track: \"Workshop\",\n },\n {\n description:\n \"Module federation techniques across distributed product teams.\",\n endTime: \"3:00 PM\",\n room: \"Room A\",\n speaker: \"Zack Jackson\",\n time: \"2:00 PM\",\n title: \"Micro-Frontends at Scale\",\n track: \"Ecosystem\",\n },\n {\n endTime: \"4:00 PM\",\n isBreak: true,\n time: \"3:30 PM\",\n title: \"Afternoon Refreshments\",\n },\n {\n description:\n \"Reflections on Day 1 highlights, open mic session, and evening preview.\",\n endTime: \"5:00 PM\",\n room: \"Main Hall\",\n speaker: \"Sophie Alpert\",\n time: \"4:00 PM\",\n title: \"Closing Keynote & Community Q&A\",\n track: \"Core React\",\n },\n ],\n },\n {\n date: \"October 21, 2026\",\n label: \"Day 2\",\n sessions: [\n {\n description: \"Morning refreshments in the networking lounge.\",\n endTime: \"9:30 AM\",\n isBreak: true,\n time: \"8:30 AM\",\n title: \"Welcome Coffee & Light Breakfast\",\n },\n {\n description:\n \"How generative agents and generative UI are shaping application architectures.\",\n endTime: \"10:30 AM\",\n room: \"Main Hall\",\n speaker: \"Seb Markbåge\",\n time: \"9:30 AM\",\n title: \"Future of React & AI Agent Integrations\",\n track: \"Core React\",\n },\n {\n description:\n \"Actionable metrics, Core Web Vitals, and avoiding main-thread bottlenecks.\",\n endTime: \"11:45 AM\",\n room: \"Room A\",\n speaker: \"Addy Osmani\",\n time: \"10:45 AM\",\n title: \"Performance Profiling for Modern Web Apps\",\n track: \"Core React\",\n },\n {\n description:\n \"Sync engines, conflict resolution, and ultra-fast client-side queries.\",\n endTime: \"11:45 AM\",\n room: \"Room B\",\n speaker: \"Tanner Linsley\",\n time: \"10:45 AM\",\n title: \"Offline-First Architecture with Local-First Databases\",\n track: \"Ecosystem\",\n },\n {\n description:\n \"Quick 5-minute community-submitted presentations in the theater.\",\n endTime: \"1:15 PM\",\n isBreak: true,\n time: \"12:00 PM\",\n title: \"Lunch & Community Lightning Talks\",\n },\n {\n description:\n \"Profiling real-world codebases, memory leak identification, and bundle size reduction.\",\n endTime: \"3:00 PM\",\n room: \"Workshop Lab\",\n speaker: \"Lydia Hallie\",\n time: \"1:30 PM\",\n title: \"Hands-on Performance Optimization Workshop\",\n track: \"Workshop\",\n },\n {\n description:\n \"Vite, Turbopack, Biome, Oxfmt, and next-generation dev speed.\",\n endTime: \"4:15 PM\",\n room: \"Main Hall\",\n speaker: \"Industry Panelists\",\n time: \"3:15 PM\",\n title: \"Panel Discussion: What's Next for Developer Tooling\",\n track: \"Ecosystem\",\n },\n {\n description: \"Drinks and appetizers at the convention terrace.\",\n endTime: \"6:00 PM\",\n isBreak: true,\n time: \"4:30 PM\",\n title: \"Closing Reception & Networking Afterparty\",\n },\n ],\n },\n ],\n emergencyContact:\n \"Organizers Desk: +31 20 123 4567 | emergency@reactsummit.com\",\n endDate: \"October 21, 2026\",\n eventName: \"React Summit 2026\",\n tracks: [\n { color: \"#3b82f6\", name: \"Core React\" },\n { color: \"#10b981\", name: \"Ecosystem\" },\n { color: \"#f59e0b\", name: \"Workshop\" },\n ],\n venue: \"Amsterdam Convention Center\",\n wifiInfo: \"Network: ReactSummit / Password: react2026\",\n};\n",
+ "content": "export interface Session {\n description?: string;\n endTime?: string;\n isBreak?: boolean;\n room?: string;\n speaker?: string;\n time: string;\n title: string;\n track?: string;\n}\n\nexport interface DaySchedule {\n date: string;\n label: string;\n sessions: Session[];\n}\n\nexport interface Track {\n color: string;\n name: string;\n}\n\nexport interface EventAgendaProps {\n accentColor?: string;\n date: string;\n days: DaySchedule[];\n emergencyContact?: string;\n endDate?: string;\n eventName: string;\n renderingBase?: \"takumi\" | \"forme\";\n tracks?: Track[];\n venue: string;\n wifiInfo?: string;\n}\n\nexport const sampleEventAgendaData: EventAgendaProps = {\n accentColor: \"#dc2626\",\n date: \"October 20, 2026\",\n days: [\n {\n date: \"October 20, 2026\",\n label: \"Day 1\",\n sessions: [\n {\n description:\n \"Check-in, grab your badge, and enjoy breakfast with peers.\",\n endTime: \"9:00 AM\",\n isBreak: true,\n time: \"8:00 AM\",\n title: \"Registration & Breakfast\",\n },\n {\n description:\n \"An overview of recent evolutions and the road ahead for UI engineering.\",\n endTime: \"9:45 AM\",\n room: \"Main Hall\",\n speaker: \"Dan Abramov\",\n time: \"9:00 AM\",\n title: \"Opening Keynote: The Next Decade of React\",\n track: \"Core React\",\n },\n {\n description:\n \"Real-world architecture patterns, streaming benefits, and edge-case handling.\",\n endTime: \"10:45 AM\",\n room: \"Room A\",\n speaker: \"Sarah Chen\",\n time: \"10:00 AM\",\n title: \"Server Components in Production\",\n track: \"Core React\",\n },\n {\n description:\n \"Navigating signals, atomic state, and server state synchronization.\",\n endTime: \"10:45 AM\",\n room: \"Room B\",\n speaker: \"Mark Erikson\",\n time: \"10:00 AM\",\n title: \"State Management in 2026\",\n track: \"Ecosystem\",\n },\n {\n description: \"Exhibition hall coffee stations open.\",\n endTime: \"11:30 AM\",\n isBreak: true,\n time: \"11:00 AM\",\n title: \"Coffee & Networking Break\",\n },\n {\n description:\n \"Ensuring WCAG AAA compliance with composable headless components.\",\n endTime: \"12:15 PM\",\n room: \"Room A\",\n speaker: \"Rachel Andrew\",\n time: \"11:30 AM\",\n title: \"Building Accessible Design Systems\",\n track: \"Core React\",\n },\n {\n description:\n \"How automatic memoization transforms rendering pipelines.\",\n endTime: \"12:15 PM\",\n room: \"Room B\",\n speaker: \"Andrew Clark\",\n time: \"11:30 AM\",\n title: \"Compiler Deep Dive: Under the Hood\",\n track: \"Ecosystem\",\n },\n {\n description: \"Lunch served in the Grand Ballroom.\",\n endTime: \"1:45 PM\",\n isBreak: true,\n time: \"12:30 PM\",\n title: \"Catered Lunch & Sponsor Showcase\",\n },\n {\n description:\n \"Hands-on exercises exploring Actions, optimistic updates, and new hooks.\",\n endTime: \"3:30 PM\",\n room: \"Workshop Lab\",\n speaker: \"Ken Wheeler\",\n time: \"2:00 PM\",\n title: \"Interactive Workshop: Building with React 19\",\n track: \"Workshop\",\n },\n {\n description:\n \"Module federation techniques across distributed product teams.\",\n endTime: \"3:00 PM\",\n room: \"Room A\",\n speaker: \"Zack Jackson\",\n time: \"2:00 PM\",\n title: \"Micro-Frontends at Scale\",\n track: \"Ecosystem\",\n },\n {\n endTime: \"4:00 PM\",\n isBreak: true,\n time: \"3:30 PM\",\n title: \"Afternoon Refreshments\",\n },\n {\n description:\n \"Reflections on Day 1 highlights, open mic session, and evening preview.\",\n endTime: \"5:00 PM\",\n room: \"Main Hall\",\n speaker: \"Sophie Alpert\",\n time: \"4:00 PM\",\n title: \"Closing Keynote & Community Q&A\",\n track: \"Core React\",\n },\n ],\n },\n {\n date: \"October 21, 2026\",\n label: \"Day 2\",\n sessions: [\n {\n description: \"Morning refreshments in the networking lounge.\",\n endTime: \"9:30 AM\",\n isBreak: true,\n time: \"8:30 AM\",\n title: \"Welcome Coffee & Light Breakfast\",\n },\n {\n description:\n \"How generative agents and generative UI are shaping application architectures.\",\n endTime: \"10:30 AM\",\n room: \"Main Hall\",\n speaker: \"Seb Markbåge\",\n time: \"9:30 AM\",\n title: \"Future of React & AI Agent Integrations\",\n track: \"Core React\",\n },\n {\n description:\n \"Actionable metrics, Core Web Vitals, and avoiding main-thread bottlenecks.\",\n endTime: \"11:45 AM\",\n room: \"Room A\",\n speaker: \"Addy Osmani\",\n time: \"10:45 AM\",\n title: \"Performance Profiling for Modern Web Apps\",\n track: \"Core React\",\n },\n {\n description:\n \"Sync engines, conflict resolution, and ultra-fast client-side queries.\",\n endTime: \"11:45 AM\",\n room: \"Room B\",\n speaker: \"Tanner Linsley\",\n time: \"10:45 AM\",\n title: \"Offline-First Architecture with Local-First Databases\",\n track: \"Ecosystem\",\n },\n {\n description:\n \"Quick 5-minute community-submitted presentations in the theater.\",\n endTime: \"1:15 PM\",\n isBreak: true,\n time: \"12:00 PM\",\n title: \"Lunch & Community Lightning Talks\",\n },\n {\n description:\n \"Profiling real-world codebases, memory leak identification, and bundle size reduction.\",\n endTime: \"3:00 PM\",\n room: \"Workshop Lab\",\n speaker: \"Lydia Hallie\",\n time: \"1:30 PM\",\n title: \"Hands-on Performance Optimization Workshop\",\n track: \"Workshop\",\n },\n {\n description:\n \"Vite, Turbopack, Biome, Oxfmt, and next-generation dev speed.\",\n endTime: \"4:15 PM\",\n room: \"Main Hall\",\n speaker: \"Industry Panelists\",\n time: \"3:15 PM\",\n title: \"Panel Discussion: What's Next for Developer Tooling\",\n track: \"Ecosystem\",\n },\n {\n description: \"Drinks and appetizers at the convention terrace.\",\n endTime: \"6:00 PM\",\n isBreak: true,\n time: \"4:30 PM\",\n title: \"Closing Reception & Networking Afterparty\",\n },\n ],\n },\n ],\n emergencyContact:\n \"Organizers Desk: +31 20 123 4567 | emergency@reactsummit.com\",\n endDate: \"October 21, 2026\",\n eventName: \"React Summit 2026\",\n tracks: [\n { color: \"#3b82f6\", name: \"Core React\" },\n { color: \"#10b981\", name: \"Ecosystem\" },\n { color: \"#f59e0b\", name: \"Workshop\" },\n ],\n venue: \"Amsterdam Convention Center\",\n wifiInfo: \"Network: ReactSummit / Password: react2026\",\n};\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/event-agenda/event-agenda.types.ts"
}
diff --git a/apps/web/public/r/forme/event-ticket.json b/apps/web/public/r/forme/event-ticket.json
index 819217a..9306306 100644
--- a/apps/web/public/r/forme/event-ticket.json
+++ b/apps/web/public/r/forme/event-ticket.json
@@ -4,8 +4,6 @@
"title": "Event Ticket",
"description": "Event Ticket PDF block (forme)",
"dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0",
"qrcode@^1.5.4"
],
"devDependencies": [
@@ -20,13 +18,13 @@
"files": [
{
"path": "registry/bases/forme/blocks/event-ticket/event-ticket.ts",
- "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfImage } from \"@/components/pdf/pdf-image/pdf-image\";\nimport { PdfQRCode } from \"@/components/pdf/qrcode/qrcode\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { EventTicketData } from \"./event-ticket.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: EventTicketData = {\n accentColor: \"#52525b\",\n address: \"123 Main St, Las Vegas, NV\",\n doorsOpen: \"8:00 AM\",\n eventDate: \"May 15, 2026\",\n eventName: \"ShadCN Labs Conf\",\n eventTime: \"9:00 AM\",\n logoUrl: \"/favicon.png\",\n organizer: \"ShadCN Labs\",\n seat: { number: \"12\", row: \"3\", section: \"A\" },\n socialLinks: [\n { platform: \"X\", url: \"x.com/shadcn\" },\n { platform: \"Instagram\", url: \"instagram.com/shadcn\" },\n ],\n terms: \"Ticket is non-transferable. All sales final. No re-entry.\",\n ticketNumber: \"TKT-00142\",\n ticketType: \"VIP\",\n venue: \"Convention Center\",\n};\n\n// Standard event ticket, 7\" x 3.5\", expressed in PDF points (72 dpi)\nconst TICKET_SIZE = { height: 252, width: 504 };\n\nconst STUB_WIDTH = 120;\n\nconst STRIPE_WIDTH = 8;\n\nconst NOTCH_RADIUS = 8;\n\n// Forme renders neither dashed borders nor dashed SVG strokes, so the\n// perforation is painted as a stack of short dashes along the stub seam.\nconst PERFORATION_WIDTH = 1.5;\n\nconst PERFORATION_DASH = 4;\n\nconst PERFORATION_GAP = 3;\n\nconst perforationOffsets: number[] = [];\nfor (\n let offset = 0;\n offset < TICKET_SIZE.height;\n offset += PERFORATION_DASH + PERFORATION_GAP\n) {\n perforationOffsets.push(offset);\n}\n\nconst hexRgb = (color: string): [number, number, number] | null => {\n const hex = color.trim().replace(/^#/, \"\");\n\n if (/^[0-9a-f]{3}$/i.test(hex)) {\n return [\n Number.parseInt(hex[0] + hex[0], 16),\n Number.parseInt(hex[1] + hex[1], 16),\n Number.parseInt(hex[2] + hex[2], 16),\n ];\n }\n\n if (/^[0-9a-f]{6}([0-9a-f]{2})?$/i.test(hex)) {\n return [\n Number.parseInt(hex.slice(0, 2), 16),\n Number.parseInt(hex.slice(2, 4), 16),\n Number.parseInt(hex.slice(4, 6), 16),\n ];\n }\n\n return null;\n};\n\nconst inkOnAccent = (accent: string, light: string, dark: string) => {\n const rgb = hexRgb(accent);\n\n if (!rgb) {\n return dark;\n }\n\n const [r, g, b] = rgb;\n const luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;\n\n return luminance > 0.55 ? dark : light;\n};\n\nconst socialHandle = (url: string) => {\n const clean = url\n .replace(/^https?:\\/\\//i, \"\")\n .replace(/^www\\./i, \"\")\n .replace(/\\/$/, \"\");\n const parts = clean.split(\"/\").filter(Boolean);\n const handle = parts.at(-1);\n\n if (parts.length > 1 && handle) {\n return handle.startsWith(\"@\") ? handle : `@${handle}`;\n }\n\n return clean;\n};\n\nconst eventTicketStyles = (theme: PdfcnTheme, data: EventTicketData) => {\n const paper = theme.colors.background;\n const ink = theme.colors.foreground;\n const quiet = theme.colors.mutedForeground;\n\n const accent = resolveColor(\n data.accentColor ?? theme.colors.primary,\n theme.colors\n );\n const onAccent = inkOnAccent(accent, paper, ink);\n\n const styles = StyleSheet.create({\n admit: {\n color: onAccent,\n fontSize: 7,\n fontWeight: \"bold\",\n letterSpacing: 2,\n textTransform: \"uppercase\",\n },\n body: {\n flex: 1,\n height: TICKET_SIZE.height,\n justifyContent: \"space-between\",\n paddingBottom: 16,\n paddingLeft: 20,\n paddingRight: 18,\n paddingTop: 18,\n },\n brand: {\n alignItems: \"center\",\n flexDirection: \"row\",\n gap: 8,\n marginBottom: 14,\n },\n fact: {\n flexShrink: 1,\n minWidth: 0,\n paddingRight: 12,\n },\n facts: {\n flexDirection: \"row\",\n },\n footer: {\n alignItems: \"center\",\n flexDirection: \"row\",\n gap: 12,\n marginTop: 10,\n },\n label: {\n color: quiet,\n fontSize: 7,\n fontWeight: \"bold\",\n letterSpacing: 1.2,\n marginBottom: 3,\n textTransform: \"uppercase\",\n },\n logo: { borderRadius: 3, height: 14, width: 14 },\n notchBottom: {\n backgroundColor: paper,\n borderRadius: NOTCH_RADIUS,\n bottom: -NOTCH_RADIUS,\n height: NOTCH_RADIUS * 2,\n left: TICKET_SIZE.width - STUB_WIDTH - NOTCH_RADIUS,\n position: \"absolute\",\n width: NOTCH_RADIUS * 2,\n },\n notchTop: {\n backgroundColor: paper,\n borderRadius: NOTCH_RADIUS,\n height: NOTCH_RADIUS * 2,\n left: TICKET_SIZE.width - STUB_WIDTH - NOTCH_RADIUS,\n position: \"absolute\",\n top: -NOTCH_RADIUS,\n width: NOTCH_RADIUS * 2,\n },\n organizer: {\n color: quiet,\n // Forme ignores `marginLeft: \"auto\"`, so the organizer line absorbs the\n // free space and pushes the ticket-type pill to the right edge.\n flexGrow: 1,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1.1,\n textTransform: \"uppercase\",\n },\n page: {\n alignItems: \"stretch\",\n backgroundColor: paper,\n flexDirection: \"row\",\n height: TICKET_SIZE.height,\n overflow: \"hidden\",\n position: \"relative\",\n width: TICKET_SIZE.width,\n },\n perforation: {\n height: TICKET_SIZE.height,\n left: TICKET_SIZE.width - STUB_WIDTH - PERFORATION_WIDTH / 2,\n position: \"absolute\",\n top: 0,\n width: PERFORATION_WIDTH,\n },\n perforationDash: {\n backgroundColor: paper,\n height: PERFORATION_DASH,\n marginBottom: PERFORATION_GAP,\n width: PERFORATION_WIDTH,\n },\n pill: {\n backgroundColor: accent,\n borderRadius: 9,\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n pillText: {\n color: onAccent,\n fontSize: 7,\n fontWeight: \"bold\",\n letterSpacing: 1.2,\n textTransform: \"uppercase\",\n },\n qr: {\n backgroundColor: \"#ffffff\",\n borderRadius: 6,\n padding: 5,\n },\n serial: {\n color: onAccent,\n fontSize: 7,\n fontWeight: \"bold\",\n letterSpacing: 1.1,\n textTransform: \"uppercase\",\n },\n socialItem: {\n alignItems: \"center\",\n flexDirection: \"row\",\n gap: 4,\n },\n socialLabel: {\n color: quiet,\n fontSize: 6.5,\n fontWeight: \"bold\",\n letterSpacing: 0.4,\n textTransform: \"uppercase\",\n },\n socialList: {\n alignItems: \"center\",\n flexDirection: \"row\",\n gap: 8,\n },\n socialValue: {\n color: quiet,\n fontSize: 6.5,\n },\n stripe: {\n backgroundColor: accent,\n height: TICKET_SIZE.height,\n width: STRIPE_WIDTH,\n },\n stub: {\n alignItems: \"center\",\n backgroundColor: accent,\n height: TICKET_SIZE.height,\n justifyContent: \"space-between\",\n paddingBottom: 14,\n paddingHorizontal: 12,\n paddingTop: 16,\n width: STUB_WIDTH,\n },\n terms: {\n color: quiet,\n flex: 1,\n fontSize: 6.5,\n lineHeight: 1.4,\n paddingRight: 8,\n },\n title: {\n color: ink,\n fontSize: 26,\n fontWeight: \"bold\",\n letterSpacing: -0.6,\n lineHeight: 1.08,\n marginBottom: 8,\n },\n value: {\n color: ink,\n fontSize: 12,\n fontWeight: \"bold\",\n },\n venue: {\n color: quiet,\n fontSize: 10,\n lineHeight: 1.4,\n },\n });\n\n return styles;\n};\n\n@Component({\n imports: [FormeDocument, FormePage, FormeView, PdfImage, PdfQRCode, PdfText],\n selector: \"pdf-event-ticket-content\",\n template: `\n @let data = this.data();\n @let styles = this.styles();\n \n \n \n \n\n \n \n \n @if (data.logoUrl) {\n \n }\n {{\n data.organizer ?? \"Event ticket\"\n }}\n \n {{\n data.ticketType\n }}\n \n \n {{\n data.eventName\n }}\n {{\n data.venue\n }}\n {{\n data.address\n }}\n \n\n \n \n \n Date\n {{\n data.eventDate\n }}\n \n \n Time\n {{\n data.eventTime\n }}\n \n @if (data.doorsOpen) {\n \n Doors\n {{\n data.doorsOpen\n }}\n \n }\n @if (data.seat) {\n \n Seat\n {{\n data.seat.section +\n \"–\" +\n data.seat.row +\n \"–\" +\n data.seat.number\n }}\n \n }\n \n @if (\n data.terms || (data.socialLinks && data.socialLinks.length > 0)\n ) {\n \n @if (data.terms) {\n {{\n data.terms\n }}\n }\n @if (data.socialLinks && data.socialLinks.length > 0) {\n \n @for (\n link of data.socialLinks;\n track link.platform + \"-\" + link.url\n ) {\n \n {{\n link.platform\n }}\n {{\n socialHandle(link.url)\n }}\n \n }\n \n }\n \n }\n \n \n\n \n Admit one\n \n @if (data.qrCodeUrl) {\n \n } @else {\n \n }\n \n {{\n data.ticketNumber\n }}\n \n\n \n @for (offset of perforationOffsets; track offset) {\n \n }\n \n\n \n \n \n \n \n `,\n})\nexport class EventTicketContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly TICKET_SIZE = TICKET_SIZE;\n protected readonly perforationOffsets = perforationOffsets;\n protected readonly socialHandle = socialHandle;\n\n protected readonly styles = computed(() =>\n eventTicketStyles(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [EventTicketContent, PdfcnThemeProvider],\n selector: \"pdf-event-ticket\",\n template: `\n \n \n \n `,\n})\nexport class EventTicketDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n",
+ "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfImage } from \"@/components/pdf/pdf-image/pdf-image\";\nimport { PdfQRCode } from \"@/components/pdf/qrcode/qrcode\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { EventTicketData } from \"./event-ticket.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: EventTicketData = {\n accentColor: \"#52525b\",\n address: \"123 Main St, Las Vegas, NV\",\n doorsOpen: \"8:00 AM\",\n eventDate: \"May 15, 2026\",\n eventName: \"ShadCN Labs Conf\",\n eventTime: \"9:00 AM\",\n logoUrl: \"/favicon.png\",\n organizer: \"ShadCN Labs\",\n seat: { number: \"12\", row: \"3\", section: \"A\" },\n socialLinks: [\n { platform: \"X\", url: \"x.com/shadcn\" },\n { platform: \"Instagram\", url: \"instagram.com/shadcn\" },\n ],\n terms: \"Ticket is non-transferable. All sales final. No re-entry.\",\n ticketNumber: \"TKT-00142\",\n ticketType: \"VIP\",\n venue: \"Convention Center\",\n};\n\n// Standard event ticket, 7\" x 3.5\", expressed in PDF points (72 dpi)\nconst TICKET_SIZE = { height: 252, width: 504 };\n\nconst STUB_WIDTH = 120;\n\nconst STRIPE_WIDTH = 8;\n\nconst NOTCH_RADIUS = 8;\n\n// Forme renders neither dashed borders nor dashed SVG strokes, so the\n// perforation is painted as a stack of short dashes along the stub seam.\nconst PERFORATION_WIDTH = 1.5;\n\nconst PERFORATION_DASH = 4;\n\nconst PERFORATION_GAP = 3;\n\nconst perforationOffsets: number[] = [];\nfor (\n let offset = 0;\n offset < TICKET_SIZE.height;\n offset += PERFORATION_DASH + PERFORATION_GAP\n) {\n perforationOffsets.push(offset);\n}\n\nconst hexRgb = (color: string): [number, number, number] | null => {\n const hex = color.trim().replace(/^#/, \"\");\n\n if (/^[0-9a-f]{3}$/i.test(hex)) {\n return [\n Number.parseInt(hex[0] + hex[0], 16),\n Number.parseInt(hex[1] + hex[1], 16),\n Number.parseInt(hex[2] + hex[2], 16),\n ];\n }\n\n if (/^[0-9a-f]{6}([0-9a-f]{2})?$/i.test(hex)) {\n return [\n Number.parseInt(hex.slice(0, 2), 16),\n Number.parseInt(hex.slice(2, 4), 16),\n Number.parseInt(hex.slice(4, 6), 16),\n ];\n }\n\n return null;\n};\n\nconst inkOnAccent = (accent: string, light: string, dark: string) => {\n const rgb = hexRgb(accent);\n\n if (!rgb) {\n return dark;\n }\n\n const [r, g, b] = rgb;\n const luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;\n\n return luminance > 0.55 ? dark : light;\n};\n\nconst socialHandle = (url: string) => {\n const clean = url\n .replace(/^https?:\\/\\//i, \"\")\n .replace(/^www\\./i, \"\")\n .replace(/\\/$/, \"\");\n const parts = clean.split(\"/\").filter(Boolean);\n const handle = parts.at(-1);\n\n if (parts.length > 1 && handle) {\n return handle.startsWith(\"@\") ? handle : `@${handle}`;\n }\n\n return clean;\n};\n\nconst eventTicketStyles = (theme: PdfcnTheme, data: EventTicketData) => {\n const paper = theme.colors.background;\n const ink = theme.colors.foreground;\n const quiet = theme.colors.mutedForeground;\n\n const accent = resolveColor(\n data.accentColor ?? theme.colors.primary,\n theme.colors\n );\n const onAccent = inkOnAccent(accent, paper, ink);\n\n const styles = StyleSheet.create({\n admit: {\n color: onAccent,\n fontSize: 7,\n fontWeight: \"bold\",\n letterSpacing: 2,\n textTransform: \"uppercase\",\n },\n body: {\n flex: 1,\n height: TICKET_SIZE.height,\n justifyContent: \"space-between\",\n paddingBottom: 16,\n paddingLeft: 20,\n paddingRight: 18,\n paddingTop: 18,\n },\n brand: {\n alignItems: \"center\",\n flexDirection: \"row\",\n gap: 8,\n marginBottom: 14,\n },\n fact: {\n flexShrink: 1,\n minWidth: 0,\n paddingRight: 12,\n },\n facts: {\n flexDirection: \"row\",\n },\n footer: {\n alignItems: \"center\",\n flexDirection: \"row\",\n gap: 12,\n marginTop: 10,\n },\n label: {\n color: quiet,\n fontSize: 7,\n fontWeight: \"bold\",\n letterSpacing: 1.2,\n marginBottom: 3,\n textTransform: \"uppercase\",\n },\n logo: { borderRadius: 3, height: 14, width: 14 },\n notchBottom: {\n backgroundColor: paper,\n borderRadius: NOTCH_RADIUS,\n bottom: -NOTCH_RADIUS,\n height: NOTCH_RADIUS * 2,\n left: TICKET_SIZE.width - STUB_WIDTH - NOTCH_RADIUS,\n position: \"absolute\",\n width: NOTCH_RADIUS * 2,\n },\n notchTop: {\n backgroundColor: paper,\n borderRadius: NOTCH_RADIUS,\n height: NOTCH_RADIUS * 2,\n left: TICKET_SIZE.width - STUB_WIDTH - NOTCH_RADIUS,\n position: \"absolute\",\n top: -NOTCH_RADIUS,\n width: NOTCH_RADIUS * 2,\n },\n organizer: {\n color: quiet,\n // Forme ignores `marginLeft: \"auto\"`, so the organizer line absorbs the\n // free space and pushes the ticket-type pill to the right edge.\n flexGrow: 1,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1.1,\n textTransform: \"uppercase\",\n },\n page: {\n alignItems: \"stretch\",\n backgroundColor: paper,\n flexDirection: \"row\",\n height: TICKET_SIZE.height,\n overflow: \"hidden\",\n position: \"relative\",\n width: TICKET_SIZE.width,\n },\n perforation: {\n height: TICKET_SIZE.height,\n left: TICKET_SIZE.width - STUB_WIDTH - PERFORATION_WIDTH / 2,\n position: \"absolute\",\n top: 0,\n width: PERFORATION_WIDTH,\n },\n perforationDash: {\n backgroundColor: paper,\n height: PERFORATION_DASH,\n marginBottom: PERFORATION_GAP,\n width: PERFORATION_WIDTH,\n },\n pill: {\n backgroundColor: accent,\n borderRadius: 9,\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n pillText: {\n color: onAccent,\n fontSize: 7,\n fontWeight: \"bold\",\n letterSpacing: 1.2,\n textTransform: \"uppercase\",\n },\n qr: {\n backgroundColor: \"#ffffff\",\n borderRadius: 6,\n padding: 5,\n },\n serial: {\n color: onAccent,\n fontSize: 7,\n fontWeight: \"bold\",\n letterSpacing: 1.1,\n textTransform: \"uppercase\",\n },\n socialItem: {\n alignItems: \"center\",\n flexDirection: \"row\",\n gap: 4,\n },\n socialLabel: {\n color: quiet,\n fontSize: 6.5,\n fontWeight: \"bold\",\n letterSpacing: 0.4,\n textTransform: \"uppercase\",\n },\n socialList: {\n alignItems: \"center\",\n flexDirection: \"row\",\n gap: 8,\n },\n socialValue: {\n color: quiet,\n fontSize: 6.5,\n },\n stripe: {\n backgroundColor: accent,\n height: TICKET_SIZE.height,\n width: STRIPE_WIDTH,\n },\n stub: {\n alignItems: \"center\",\n backgroundColor: accent,\n height: TICKET_SIZE.height,\n justifyContent: \"space-between\",\n paddingBottom: 14,\n paddingHorizontal: 12,\n paddingTop: 16,\n width: STUB_WIDTH,\n },\n terms: {\n color: quiet,\n flex: 1,\n fontSize: 6.5,\n lineHeight: 1.4,\n paddingRight: 8,\n },\n title: {\n color: ink,\n fontSize: 26,\n fontWeight: \"bold\",\n letterSpacing: -0.6,\n lineHeight: 1.08,\n marginBottom: 8,\n },\n value: {\n color: ink,\n fontSize: 12,\n fontWeight: \"bold\",\n },\n venue: {\n color: quiet,\n fontSize: 10,\n lineHeight: 1.4,\n },\n });\n\n return styles;\n};\n\n@Component({\n imports: [FormeDocument, FormePage, FormeView, PdfImage, PdfQRCode, PdfText],\n selector: \"pdf-event-ticket-content\",\n template: `\n @let data = this.data();\n @let styles = this.styles();\n \n \n \n \n\n \n \n \n @if (data.logoUrl) {\n \n }\n {{\n data.organizer ?? \"Event ticket\"\n }}\n \n {{\n data.ticketType\n }}\n \n \n {{\n data.eventName\n }}\n {{\n data.venue\n }}\n {{\n data.address\n }}\n \n\n \n \n \n Date\n {{\n data.eventDate\n }}\n \n \n Time\n {{\n data.eventTime\n }}\n \n @if (data.doorsOpen) {\n \n Doors\n {{\n data.doorsOpen\n }}\n \n }\n @if (data.seat) {\n \n Seat\n {{\n data.seat.section +\n \"–\" +\n data.seat.row +\n \"–\" +\n data.seat.number\n }}\n \n }\n \n @if (\n data.terms || (data.socialLinks && data.socialLinks.length > 0)\n ) {\n \n @if (data.terms) {\n {{\n data.terms\n }}\n }\n @if (data.socialLinks && data.socialLinks.length > 0) {\n \n @for (\n link of data.socialLinks;\n track link.platform + \"-\" + link.url\n ) {\n \n {{\n link.platform\n }}\n {{\n socialHandle(link.url)\n }}\n \n }\n \n }\n \n }\n \n \n\n \n Admit one\n \n @if (data.qrCodeUrl) {\n \n } @else {\n \n }\n \n {{\n data.ticketNumber\n }}\n \n\n \n @for (offset of perforationOffsets; track offset) {\n \n }\n \n\n \n \n \n \n \n `,\n})\nexport class EventTicketContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly TICKET_SIZE = TICKET_SIZE;\n protected readonly perforationOffsets = perforationOffsets;\n protected readonly socialHandle = socialHandle;\n\n protected readonly styles = computed(() =>\n eventTicketStyles(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [EventTicketContent, PdfcnThemeProvider],\n selector: \"pdf-event-ticket\",\n template: `\n \n \n \n `,\n})\nexport class EventTicketDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/event-ticket/event-ticket.ts"
},
{
"path": "registry/bases/forme/blocks/event-ticket/event-ticket.types.ts",
- "content": "export interface EventTicketSeat {\n number: string;\n row: string;\n section: string;\n}\n\nexport interface EventTicketSocialLink {\n platform: string;\n url: string;\n}\n\nexport interface EventTicketData {\n accentColor?: string;\n address: string;\n doorsOpen?: string;\n eventName: string;\n eventDate: string;\n eventTime: string;\n logoUrl?: string;\n organizer?: string;\n qrCodeUrl?: string;\n seat?: EventTicketSeat;\n socialLinks?: EventTicketSocialLink[];\n terms?: string;\n ticketNumber: string;\n ticketType: string;\n venue: string;\n}\n",
+ "content": "export interface EventTicketSeat {\n number: string;\n row: string;\n section: string;\n}\n\nexport interface EventTicketSocialLink {\n platform: string;\n url: string;\n}\n\nexport interface EventTicketData {\n accentColor?: string;\n address: string;\n doorsOpen?: string;\n eventName: string;\n eventDate: string;\n eventTime: string;\n logoUrl?: string;\n organizer?: string;\n qrCodeUrl?: string;\n seat?: EventTicketSeat;\n socialLinks?: EventTicketSocialLink[];\n terms?: string;\n ticketNumber: string;\n ticketType: string;\n venue: string;\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/event-ticket/event-ticket.types.ts"
}
diff --git a/apps/web/public/r/forme/form.json b/apps/web/public/r/forme/form.json
index 40be69a..7850d40 100644
--- a/apps/web/public/r/forme/form.json
+++ b/apps/web/public/r/forme/form.json
@@ -3,29 +3,25 @@
"name": "forme/form",
"title": "Form",
"description": "Form PDF component (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils"
],
"files": [
{
"path": "registry/bases/forme/components/form/form.styles.ts",
- "content": "import { StyleSheet } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { PdfFormVariant } from \"./form.types\";\n\n/** Style factory for fillable form layouts, derived from the active theme. */\nexport const createFormStyles = (\n t: PdfcnTheme,\n variant: PdfFormVariant = \"underline\"\n) => {\n const { spacing, borderRadius, fontWeights, typography } = t.primitives;\n const borderColor = t.colors.border;\n // lighter than spacing[0.5]=2pt — more refined\n const hairline = 0.75;\n // group title rule\n const rule = 1;\n\n const fieldAreaByVariant: Record = {\n box: {\n borderColor,\n borderRadius: borderRadius.sm,\n borderStyle: \"solid\",\n borderWidth: hairline,\n },\n ghost: {\n backgroundColor: t.colors.muted,\n borderRadius: borderRadius.sm,\n },\n outlined: {\n borderColor: t.colors.foreground,\n borderRadius: borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: hairline,\n },\n underline: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n },\n };\n\n const hasPadding =\n variant === \"box\" || variant === \"outlined\" || variant === \"ghost\";\n\n return StyleSheet.create({\n column: {\n flex: 1,\n },\n\n columnsRow: {\n flexDirection: \"row\",\n gap: spacing[4],\n },\n fieldAbove: {\n marginBottom: spacing[3],\n width: \"100%\",\n },\n fieldArea: {\n width: \"100%\" as const,\n ...fieldAreaByVariant[variant],\n },\n\n fieldLeft: {\n alignItems: \"flex-end\",\n flexDirection: \"row\",\n gap: spacing[2],\n marginBottom: spacing[3],\n },\n fieldLeftArea: {\n flex: 1,\n },\n\n formDivider: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n marginBottom: spacing[4],\n },\n formSubtitle: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n lineHeight: t.typography.body.lineHeight,\n marginBottom: spacing[3],\n },\n\n formTitle: {\n color: t.colors.foreground,\n fontFamily: t.typography.heading.fontFamily,\n fontSize: typography.xl,\n fontWeight: fontWeights.bold,\n lineHeight: t.typography.heading.lineHeight,\n marginBottom: spacing[1],\n },\n group: {\n marginBottom: spacing[5],\n },\n\n groupTitle: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.semibold,\n letterSpacing: 0.8,\n lineHeight: 1.2,\n marginBottom: spacing[3],\n textTransform: \"uppercase\",\n },\n hint: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n opacity: 0.14,\n paddingBottom: hasPadding ? spacing[1] : 0,\n paddingHorizontal: hasPadding ? spacing[2] : 0,\n paddingTop: hasPadding ? spacing[1] : spacing[0.5],\n },\n labelAbove: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.medium,\n letterSpacing: 0.5,\n lineHeight: 1.2,\n marginBottom: spacing[1],\n textTransform: \"uppercase\",\n },\n\n labelLeft: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.medium,\n lineHeight: t.typography.body.lineHeight,\n paddingBottom: hasPadding ? spacing[1] : 0,\n width: 80,\n },\n\n root: {\n marginBottom: t.spacing.componentGap,\n width: \"100%\",\n },\n });\n};\n",
+ "content": "import { StyleSheet } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { PdfFormVariant } from \"./form.types\";\n\n/** Style factory for fillable form layouts, derived from the active theme. */\nexport const createFormStyles = (\n t: PdfcnTheme,\n variant: PdfFormVariant = \"underline\"\n) => {\n const { spacing, borderRadius, fontWeights, typography } = t.primitives;\n const borderColor = t.colors.border;\n // lighter than spacing[0.5]=2pt — more refined\n const hairline = 0.75;\n // group title rule\n const rule = 1;\n\n const fieldAreaByVariant: Record = {\n box: {\n borderColor,\n borderRadius: borderRadius.sm,\n borderStyle: \"solid\",\n borderWidth: hairline,\n },\n ghost: {\n backgroundColor: t.colors.muted,\n borderRadius: borderRadius.sm,\n },\n outlined: {\n borderColor: t.colors.foreground,\n borderRadius: borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: hairline,\n },\n underline: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n },\n };\n\n const hasPadding =\n variant === \"box\" || variant === \"outlined\" || variant === \"ghost\";\n\n return StyleSheet.create({\n column: {\n flex: 1,\n },\n\n columnsRow: {\n flexDirection: \"row\",\n gap: spacing[4],\n },\n fieldAbove: {\n marginBottom: spacing[3],\n width: \"100%\",\n },\n fieldArea: {\n width: \"100%\" as const,\n ...fieldAreaByVariant[variant],\n },\n\n fieldLeft: {\n alignItems: \"flex-end\",\n flexDirection: \"row\",\n gap: spacing[2],\n marginBottom: spacing[3],\n },\n fieldLeftArea: {\n flex: 1,\n },\n\n formDivider: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n marginBottom: spacing[4],\n },\n formSubtitle: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n lineHeight: t.typography.body.lineHeight,\n marginBottom: spacing[3],\n },\n\n formTitle: {\n color: t.colors.foreground,\n fontFamily: t.typography.heading.fontFamily,\n fontSize: typography.xl,\n fontWeight: fontWeights.bold,\n lineHeight: t.typography.heading.lineHeight,\n marginBottom: spacing[1],\n },\n group: {\n marginBottom: spacing[5],\n },\n\n groupTitle: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.semibold,\n letterSpacing: 0.8,\n lineHeight: 1.2,\n marginBottom: spacing[3],\n textTransform: \"uppercase\",\n },\n hint: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n opacity: 0.14,\n paddingBottom: hasPadding ? spacing[1] : 0,\n paddingHorizontal: hasPadding ? spacing[2] : 0,\n paddingTop: hasPadding ? spacing[1] : spacing[0.5],\n },\n labelAbove: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.medium,\n letterSpacing: 0.5,\n lineHeight: 1.2,\n marginBottom: spacing[1],\n textTransform: \"uppercase\",\n },\n\n labelLeft: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.medium,\n lineHeight: t.typography.body.lineHeight,\n paddingBottom: hasPadding ? spacing[1] : 0,\n width: 80,\n },\n\n root: {\n marginBottom: t.spacing.componentGap,\n width: \"100%\",\n },\n });\n};\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/form/form.styles.ts"
},
{
"path": "registry/bases/forme/components/form/form.ts",
- "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeText,\n FormeView,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { createFormStyles } from \"./form.styles\";\nimport type {\n FormLabelPosition,\n FormLayout,\n PdfFormField,\n PdfFormGroup,\n PdfFormProps,\n PdfFormVariant,\n} from \"./form.types\";\n\nconst renderFieldAbove = (\n field: PdfFormField,\n idx: number,\n styles: ReturnType\n) => {\n const areaHeight = field.height ?? 18;\n const areaStyle: Style[] = [styles.fieldArea, { minHeight: areaHeight }];\n\n return {\n areaStyle,\n field,\n fieldStyle: styles.fieldAbove,\n key: `${field.label}-${idx}`,\n labelStyle: styles.labelAbove,\n };\n};\n\nconst renderFieldLeft = (\n field: PdfFormField,\n idx: number,\n styles: ReturnType\n) => {\n const areaHeight = field.height ?? 18;\n const areaStyle: Style[] = [\n styles.fieldArea,\n styles.fieldLeftArea,\n { minHeight: areaHeight },\n ];\n\n return {\n areaStyle,\n field,\n fieldStyle: styles.fieldLeft,\n key: `${field.label}-${idx}`,\n labelStyle: styles.labelLeft,\n };\n};\n\nconst renderGroup = (\n group: PdfFormGroup,\n gi: number,\n styles: ReturnType,\n labelPosition: \"above\" | \"left\"\n) => {\n const layout: FormLayout = group.layout ?? \"single\";\n let cols: number;\n if (layout === \"three-column\") {\n cols = 3;\n } else if (layout === \"two-column\") {\n cols = 2;\n } else {\n cols = 1;\n }\n\n const renderField = (field: PdfFormField, idx: number) =>\n labelPosition === \"left\"\n ? renderFieldLeft(field, idx, styles)\n : renderFieldAbove(field, idx, styles);\n\n if (cols === 1) {\n return {\n chunks: null,\n fields: group.fields.map(renderField),\n key: `group-${gi}`,\n title: group.title,\n };\n }\n\n const chunkSize = Math.ceil(group.fields.length / cols);\n const chunks: PdfFormField[][] = [];\n for (let i = 0; i < group.fields.length; i += chunkSize) {\n chunks.push(group.fields.slice(i, i + chunkSize));\n }\n while (chunks.length < cols) {\n chunks.push([]);\n }\n\n return {\n chunks: chunks.map((chunk, ci) => ({\n fields: chunk.map(renderField),\n key: `col-${gi}-${chunk[0]?.label ?? ci}`,\n })),\n fields: [],\n key: `group-${gi}`,\n title: group.title,\n };\n};\n\nconst formLayout = (\n theme: PdfcnTheme,\n {\n groups,\n variant = \"underline\",\n labelPosition = \"above\",\n style,\n }: Omit\n) => {\n const styles = createFormStyles(theme, variant);\n\n const rootStyles: Style[] = [styles.root];\n if (style) {\n rootStyles.push(style);\n }\n\n return {\n groups: groups.map((group, gi) =>\n renderGroup(group, gi, styles, labelPosition)\n ),\n root: rootStyles,\n styles,\n };\n};\n\n/** Fillable PDF form with grouped fields, layout variants, and label positioning options. */\n@Component({\n imports: [FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-form\",\n template: `\n @if (noWrap()) {\n \n \n \n } @else {\n \n }\n \n @let l = layout();\n @let s = l.styles;\n \n @if (title()) {\n {{ title() }}\n }\n @if (subtitle()) {\n {{ subtitle() }}\n }\n @if (title() || subtitle()) {\n \n }\n @for (group of l.groups; track group.key) {\n \n @if (group.title) {\n {{ group.title }}\n }\n @if (group.chunks) {\n \n @for (chunk of group.chunks; track chunk.key) {\n \n @for (f of chunk.fields; track f.key) {\n \n }\n \n }\n \n } @else {\n @for (f of group.fields; track f.key) {\n \n }\n }\n \n }\n \n \n \n \n {{ f.field.label }}\n \n @if (f.field.hint) {\n {{\n f.field.hint\n }}\n }\n \n \n \n `,\n})\nexport class PdfForm {\n readonly title = input();\n readonly subtitle = input();\n readonly groups = input.required();\n readonly variant = input(\"underline\");\n readonly labelPosition = input(\"above\");\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n formLayout(this.theme(), {\n groups: this.groups(),\n labelPosition: this.labelPosition(),\n style: this.style(),\n variant: this.variant(),\n })\n );\n}\n",
+ "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeText,\n FormeView,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { createFormStyles } from \"./form.styles\";\nimport type {\n FormLabelPosition,\n FormLayout,\n PdfFormField,\n PdfFormGroup,\n PdfFormProps,\n PdfFormVariant,\n} from \"./form.types\";\n\nconst renderFieldAbove = (\n field: PdfFormField,\n idx: number,\n styles: ReturnType\n) => {\n const areaHeight = field.height ?? 18;\n const areaStyle: Style[] = [styles.fieldArea, { minHeight: areaHeight }];\n\n return {\n areaStyle,\n field,\n fieldStyle: styles.fieldAbove,\n key: `${field.label}-${idx}`,\n labelStyle: styles.labelAbove,\n };\n};\n\nconst renderFieldLeft = (\n field: PdfFormField,\n idx: number,\n styles: ReturnType\n) => {\n const areaHeight = field.height ?? 18;\n const areaStyle: Style[] = [\n styles.fieldArea,\n styles.fieldLeftArea,\n { minHeight: areaHeight },\n ];\n\n return {\n areaStyle,\n field,\n fieldStyle: styles.fieldLeft,\n key: `${field.label}-${idx}`,\n labelStyle: styles.labelLeft,\n };\n};\n\nconst renderGroup = (\n group: PdfFormGroup,\n gi: number,\n styles: ReturnType,\n labelPosition: \"above\" | \"left\"\n) => {\n const layout: FormLayout = group.layout ?? \"single\";\n let cols: number;\n if (layout === \"three-column\") {\n cols = 3;\n } else if (layout === \"two-column\") {\n cols = 2;\n } else {\n cols = 1;\n }\n\n const renderField = (field: PdfFormField, idx: number) =>\n labelPosition === \"left\"\n ? renderFieldLeft(field, idx, styles)\n : renderFieldAbove(field, idx, styles);\n\n if (cols === 1) {\n return {\n chunks: null,\n fields: group.fields.map(renderField),\n key: `group-${gi}`,\n title: group.title,\n };\n }\n\n const chunkSize = Math.ceil(group.fields.length / cols);\n const chunks: PdfFormField[][] = [];\n for (let i = 0; i < group.fields.length; i += chunkSize) {\n chunks.push(group.fields.slice(i, i + chunkSize));\n }\n while (chunks.length < cols) {\n chunks.push([]);\n }\n\n return {\n chunks: chunks.map((chunk, ci) => ({\n fields: chunk.map(renderField),\n key: `col-${gi}-${chunk[0]?.label ?? ci}`,\n })),\n fields: [],\n key: `group-${gi}`,\n title: group.title,\n };\n};\n\nconst formLayout = (\n theme: PdfcnTheme,\n {\n groups,\n variant = \"underline\",\n labelPosition = \"above\",\n style,\n }: Omit\n) => {\n const styles = createFormStyles(theme, variant);\n\n const rootStyles: Style[] = [styles.root];\n if (style) {\n rootStyles.push(style);\n }\n\n return {\n groups: groups.map((group, gi) =>\n renderGroup(group, gi, styles, labelPosition)\n ),\n root: rootStyles,\n styles,\n };\n};\n\n/** Fillable PDF form with grouped fields, layout variants, and label positioning options. */\n@Component({\n imports: [FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-form\",\n template: `\n @if (noWrap()) {\n \n \n \n } @else {\n \n }\n \n @let l = layout();\n @let s = l.styles;\n \n @if (title()) {\n {{ title() }}\n }\n @if (subtitle()) {\n {{ subtitle() }}\n }\n @if (title() || subtitle()) {\n \n }\n @for (group of l.groups; track group.key) {\n \n @if (group.title) {\n {{ group.title }}\n }\n @if (group.chunks) {\n \n @for (chunk of group.chunks; track chunk.key) {\n \n @for (f of chunk.fields; track f.key) {\n \n }\n \n }\n \n } @else {\n @for (f of group.fields; track f.key) {\n \n }\n }\n \n }\n \n \n \n \n {{ f.field.label }}\n \n @if (f.field.hint) {\n {{\n f.field.hint\n }}\n }\n \n \n \n `,\n})\nexport class PdfForm {\n readonly title = input();\n readonly subtitle = input();\n readonly groups = input.required();\n readonly variant = input(\"underline\");\n readonly labelPosition = input(\"above\");\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n formLayout(this.theme(), {\n groups: this.groups(),\n labelPosition: this.labelPosition(),\n style: this.style(),\n variant: this.variant(),\n })\n );\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/form/form.ts"
},
{
"path": "registry/bases/forme/components/form/form.types.ts",
- "content": "import type { Style } from \"@/lib/pdf-primitives\";\n\n/** Visual style variant for the fillable form. */\nexport type PdfFormVariant = \"underline\" | \"box\" | \"outlined\" | \"ghost\";\n\n/** Column layout for a form section. */\nexport type FormLayout = \"single\" | \"two-column\" | \"three-column\";\n\n/** Label position relative to the field. */\nexport type FormLabelPosition = \"above\" | \"left\";\n\n/**\n * A single fillable field definition.\n * Props - `label` | `hint` | `height` | `width`\n * @see {@link PdfFormField}\n */\nexport interface PdfFormField {\n label: string;\n hint?: string;\n /**\n * Height of the blank field area in points.\n * @default 18\n */\n height?: number;\n width?: number | string;\n}\n\n/**\n * A logical group of fields with an optional section title.\n * Props - `title` | `fields` | `layout`\n * @see {@link PdfFormGroup}\n */\nexport interface PdfFormGroup {\n title?: string;\n fields: PdfFormField[];\n /**\n * @default 'single'\n */\n layout?: FormLayout;\n}\n\n/**\n * Fillable PDF form with grouped fields, layout variants, and label positioning options.\n * Props - `title` | `subtitle` | `groups` | `variant` | `labelPosition` | `noWrap` | `style`\n * @see {@link PdfFormProps}\n */\nexport interface PdfFormProps {\n title?: string;\n subtitle?: string;\n groups: PdfFormGroup[];\n /**\n * @default 'underline'\n */\n variant?: PdfFormVariant;\n /**\n * @default 'above'\n */\n labelPosition?: FormLabelPosition;\n noWrap?: boolean;\n style?: Style;\n}\n",
+ "content": "import type { Style } from \"@/lib/pdf-primitives\";\n\n/** Visual style variant for the fillable form. */\nexport type PdfFormVariant = \"underline\" | \"box\" | \"outlined\" | \"ghost\";\n\n/** Column layout for a form section. */\nexport type FormLayout = \"single\" | \"two-column\" | \"three-column\";\n\n/** Label position relative to the field. */\nexport type FormLabelPosition = \"above\" | \"left\";\n\n/**\n * A single fillable field definition.\n * Props - `label` | `hint` | `height` | `width`\n * @see {@link PdfFormField}\n */\nexport interface PdfFormField {\n label: string;\n hint?: string;\n /**\n * Height of the blank field area in points.\n * @default 18\n */\n height?: number;\n width?: number | string;\n}\n\n/**\n * A logical group of fields with an optional section title.\n * Props - `title` | `fields` | `layout`\n * @see {@link PdfFormGroup}\n */\nexport interface PdfFormGroup {\n title?: string;\n fields: PdfFormField[];\n /**\n * @default 'single'\n */\n layout?: FormLayout;\n}\n\n/**\n * Fillable PDF form with grouped fields, layout variants, and label positioning options.\n * Props - `title` | `subtitle` | `groups` | `variant` | `labelPosition` | `noWrap` | `style`\n * @see {@link PdfFormProps}\n */\nexport interface PdfFormProps {\n title?: string;\n subtitle?: string;\n groups: PdfFormGroup[];\n /**\n * @default 'underline'\n */\n variant?: PdfFormVariant;\n /**\n * @default 'above'\n */\n labelPosition?: FormLabelPosition;\n noWrap?: boolean;\n style?: Style;\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/form/form.types.ts"
}
diff --git a/apps/web/public/r/forme/gift-certificate.json b/apps/web/public/r/forme/gift-certificate.json
index c0f084a..803d145 100644
--- a/apps/web/public/r/forme/gift-certificate.json
+++ b/apps/web/public/r/forme/gift-certificate.json
@@ -3,10 +3,6 @@
"name": "forme/gift-certificate",
"title": "Gift Certificate",
"description": "Gift Certificate PDF block (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils",
"@angular-pdfcn/forme/pdf-image",
@@ -16,13 +12,13 @@
"files": [
{
"path": "registry/bases/forme/blocks/gift-certificate/gift-certificate.ts",
- "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfImage } from \"@/components/pdf/pdf-image/pdf-image\";\nimport { PdfSection } from \"@/components/pdf/section/section\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { GiftCertificateData } from \"./gift-certificate.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: GiftCertificateData = {\n accentColor: \"#000000\",\n amount: 50,\n certificateCode: \"PDFCN-GC-2026-00891\",\n companyLogo: \"/favicon.png\",\n companyName: \"pdfcn\",\n currency: \"USD\",\n expiryDate: \"March 31, 2027\",\n message: \"Happy Birthday! Enjoy a coffee on us.\",\n recipientName: \"Sarah\",\n redemptionInstructions: \"Present this certificate at any pdfcn location.\",\n senderName: \"Mom & Dad\",\n terms: \"No cash value. Non-refundable. One use per visit.\",\n};\n\nconst giftCertificateLayout = (\n theme: PdfcnTheme,\n data: GiftCertificateData\n) => {\n const accentColor = data.accentColor || \"#000000\";\n const currencySymbol = data.currency === \"USD\" ? \"$\" : data.currency || \"$\";\n\n const styles = StyleSheet.create({\n amount: {\n color: accentColor,\n fontSize: 36,\n fontWeight: \"bold\",\n },\n amountContainer: {\n alignItems: \"center\",\n backgroundColor: theme.colors.muted,\n borderColor: accentColor,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 2,\n marginBottom: 10,\n marginTop: 10,\n paddingHorizontal: 20,\n paddingVertical: 12,\n },\n code: {\n color: theme.colors.foreground,\n fontFamily: \"Courier\",\n fontSize: 13,\n fontWeight: \"bold\",\n letterSpacing: 1.2,\n },\n codeBox: {\n alignItems: \"center\",\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.sm,\n borderStyle: \"solid\",\n borderWidth: 1,\n marginBottom: 8,\n marginTop: 8,\n paddingHorizontal: 14,\n paddingVertical: 8,\n },\n decorativeBorder: {\n borderColor: accentColor,\n borderRadius: theme.primitives.borderRadius.lg,\n borderStyle: \"solid\",\n borderWidth: 3,\n padding: 16,\n position: \"relative\",\n },\n fieldLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n fontWeight: \"bold\",\n letterSpacing: 1,\n marginBottom: 4,\n textTransform: \"uppercase\",\n },\n fieldValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: 500,\n },\n header: {\n alignItems: \"center\",\n marginBottom: 8,\n },\n innerBorder: {\n borderColor: accentColor,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"dashed\",\n borderWidth: 1,\n padding: 18,\n },\n instructionsBox: {\n marginTop: 8,\n },\n logo: {\n height: 28,\n marginBottom: 6,\n width: 28,\n },\n messageBox: {\n backgroundColor: theme.colors.muted,\n borderRadius: theme.primitives.borderRadius.sm,\n marginBottom: 8,\n marginTop: 8,\n padding: 10,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n termsText: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n lineHeight: 1.4,\n textAlign: \"center\",\n },\n title: {\n color: accentColor,\n fontSize: 22,\n fontWeight: \"bold\",\n letterSpacing: 2,\n textAlign: \"center\",\n textTransform: \"uppercase\",\n },\n });\n\n return { accentColor, currencySymbol, styles };\n};\n\n@Component({\n imports: [FormeDocument, FormePage, FormeView, PdfImage, PdfSection, PdfText],\n selector: \"pdf-gift-certificate-content\",\n template: `\n @let data = this.data();\n @let theme = this.theme();\n @let accentColor = layout().accentColor;\n @let styles = layout().styles;\n \n \n \n \n \n \n @if (data.companyLogo) {\n \n }\n Gift Certificate\n @if (data.companyName) {\n {{ data.companyName }}\n }\n \n\n \n {{ layout().currencySymbol\n }}{{ data.amount.toFixed(2) }}\n \n\n \n \n To\n {{\n data.recipientName\n }}\n \n \n From\n {{\n data.senderName\n }}\n \n \n\n @if (data.message) {\n \n \"{{ data.message }}\"\n \n }\n\n \n Certificate Code\n {{\n data.certificateCode\n }}\n \n\n \n Valid Until\n {{ data.expiryDate }}\n \n\n @if (data.redemptionInstructions) {\n \n {{ data.redemptionInstructions }}\n \n }\n\n @if (data.terms) {\n \n {{\n data.terms\n }}\n \n }\n \n \n \n \n \n `,\n})\nexport class GiftCertificateContent {\n readonly data = input.required();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly layout = computed(() =>\n giftCertificateLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [GiftCertificateContent, PdfcnThemeProvider],\n selector: \"pdf-gift-certificate\",\n template: `\n \n \n \n `,\n})\nexport class GiftCertificateDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n",
+ "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfImage } from \"@/components/pdf/pdf-image/pdf-image\";\nimport { PdfSection } from \"@/components/pdf/section/section\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { GiftCertificateData } from \"./gift-certificate.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: GiftCertificateData = {\n accentColor: \"#000000\",\n amount: 50,\n certificateCode: \"PDFCN-GC-2026-00891\",\n companyLogo: \"/favicon.png\",\n companyName: \"pdfcn\",\n currency: \"USD\",\n expiryDate: \"March 31, 2027\",\n message: \"Happy Birthday! Enjoy a coffee on us.\",\n recipientName: \"Sarah\",\n redemptionInstructions: \"Present this certificate at any pdfcn location.\",\n senderName: \"Mom & Dad\",\n terms: \"No cash value. Non-refundable. One use per visit.\",\n};\n\nconst giftCertificateLayout = (\n theme: PdfcnTheme,\n data: GiftCertificateData\n) => {\n const accentColor = data.accentColor || \"#000000\";\n const currencySymbol = data.currency === \"USD\" ? \"$\" : data.currency || \"$\";\n\n const styles = StyleSheet.create({\n amount: {\n color: accentColor,\n fontSize: 36,\n fontWeight: \"bold\",\n },\n amountContainer: {\n alignItems: \"center\",\n backgroundColor: theme.colors.muted,\n borderColor: accentColor,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 2,\n marginBottom: 10,\n marginTop: 10,\n paddingHorizontal: 20,\n paddingVertical: 12,\n },\n code: {\n color: theme.colors.foreground,\n fontFamily: \"Courier\",\n fontSize: 13,\n fontWeight: \"bold\",\n letterSpacing: 1.2,\n },\n codeBox: {\n alignItems: \"center\",\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.sm,\n borderStyle: \"solid\",\n borderWidth: 1,\n marginBottom: 8,\n marginTop: 8,\n paddingHorizontal: 14,\n paddingVertical: 8,\n },\n decorativeBorder: {\n borderColor: accentColor,\n borderRadius: theme.primitives.borderRadius.lg,\n borderStyle: \"solid\",\n borderWidth: 3,\n padding: 16,\n position: \"relative\",\n },\n fieldLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n fontWeight: \"bold\",\n letterSpacing: 1,\n marginBottom: 4,\n textTransform: \"uppercase\",\n },\n fieldValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: 500,\n },\n header: {\n alignItems: \"center\",\n marginBottom: 8,\n },\n innerBorder: {\n borderColor: accentColor,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"dashed\",\n borderWidth: 1,\n padding: 18,\n },\n instructionsBox: {\n marginTop: 8,\n },\n logo: {\n height: 28,\n marginBottom: 6,\n width: 28,\n },\n messageBox: {\n backgroundColor: theme.colors.muted,\n borderRadius: theme.primitives.borderRadius.sm,\n marginBottom: 8,\n marginTop: 8,\n padding: 10,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n termsText: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n lineHeight: 1.4,\n textAlign: \"center\",\n },\n title: {\n color: accentColor,\n fontSize: 22,\n fontWeight: \"bold\",\n letterSpacing: 2,\n textAlign: \"center\",\n textTransform: \"uppercase\",\n },\n });\n\n return { accentColor, currencySymbol, styles };\n};\n\n@Component({\n imports: [FormeDocument, FormePage, FormeView, PdfImage, PdfSection, PdfText],\n selector: \"pdf-gift-certificate-content\",\n template: `\n @let data = this.data();\n @let theme = this.theme();\n @let accentColor = layout().accentColor;\n @let styles = layout().styles;\n \n \n \n \n \n \n @if (data.companyLogo) {\n \n }\n Gift Certificate\n @if (data.companyName) {\n {{ data.companyName }}\n }\n \n\n \n {{ layout().currencySymbol\n }}{{ data.amount.toFixed(2) }}\n \n\n \n \n To\n {{\n data.recipientName\n }}\n \n \n From\n {{\n data.senderName\n }}\n \n \n\n @if (data.message) {\n \n \"{{ data.message }}\"\n \n }\n\n \n Certificate Code\n {{\n data.certificateCode\n }}\n \n\n \n Valid Until\n {{ data.expiryDate }}\n \n\n @if (data.redemptionInstructions) {\n \n {{ data.redemptionInstructions }}\n \n }\n\n @if (data.terms) {\n \n {{\n data.terms\n }}\n \n }\n \n \n \n \n \n `,\n})\nexport class GiftCertificateContent {\n readonly data = input.required();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly layout = computed(() =>\n giftCertificateLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [GiftCertificateContent, PdfcnThemeProvider],\n selector: \"pdf-gift-certificate\",\n template: `\n \n \n \n `,\n})\nexport class GiftCertificateDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/gift-certificate/gift-certificate.ts"
},
{
"path": "registry/bases/forme/blocks/gift-certificate/gift-certificate.types.ts",
- "content": "export interface GiftCertificateData {\n companyName: string;\n companyLogo?: string;\n amount: number;\n currency?: string;\n recipientName: string;\n senderName: string;\n message?: string;\n certificateCode: string;\n expiryDate: string;\n redemptionInstructions?: string;\n terms?: string;\n companyContact?: string;\n accentColor?: string;\n renderingBase?: \"takumi\" | \"forme\";\n}\n",
+ "content": "export interface GiftCertificateData {\n companyName: string;\n companyLogo?: string;\n amount: number;\n currency?: string;\n recipientName: string;\n senderName: string;\n message?: string;\n certificateCode: string;\n expiryDate: string;\n redemptionInstructions?: string;\n terms?: string;\n companyContact?: string;\n accentColor?: string;\n renderingBase?: \"takumi\" | \"forme\";\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/gift-certificate/gift-certificate.types.ts"
}
diff --git a/apps/web/public/r/forme/graph.json b/apps/web/public/r/forme/graph.json
index bd130c7..30cbc29 100644
--- a/apps/web/public/r/forme/graph.json
+++ b/apps/web/public/r/forme/graph.json
@@ -3,35 +3,31 @@
"name": "forme/graph",
"title": "Graph",
"description": "Graph PDF component (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils"
],
"files": [
{
"path": "registry/bases/forme/components/graph/graph.styles.ts",
- "content": "import { StyleSheet } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport const createGraphStyles = (t: PdfcnTheme) =>\n StyleSheet.create({\n chartWithRightLegend: {\n alignItems: \"flex-start\",\n display: \"flex\",\n flexDirection: \"row\",\n },\n container: {\n display: \"flex\",\n flexDirection: \"column\",\n marginBottom: t.spacing.componentGap,\n },\n legendColumn: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: 8,\n marginLeft: 12,\n marginTop: 18,\n minWidth: 120,\n },\n legendItem: {\n alignItems: \"center\",\n display: \"flex\",\n flexDirection: \"row\",\n gap: 4,\n },\n legendRow: {\n display: \"flex\",\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 12,\n marginTop: 6,\n },\n legendText: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n },\n subtitle: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginBottom: 6,\n },\n title: {\n color: t.colors.foreground,\n fontFamily: t.typography.heading.fontFamily,\n fontSize: t.primitives.typography.base,\n fontWeight: t.primitives.fontWeights.semibold,\n marginBottom: 2,\n },\n });\n",
+ "content": "import { StyleSheet } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport const createGraphStyles = (t: PdfcnTheme) =>\n StyleSheet.create({\n chartWithRightLegend: {\n alignItems: \"flex-start\",\n display: \"flex\",\n flexDirection: \"row\",\n },\n container: {\n display: \"flex\",\n flexDirection: \"column\",\n marginBottom: t.spacing.componentGap,\n },\n legendColumn: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: 8,\n marginLeft: 12,\n marginTop: 18,\n minWidth: 120,\n },\n legendItem: {\n alignItems: \"center\",\n display: \"flex\",\n flexDirection: \"row\",\n gap: 4,\n },\n legendRow: {\n display: \"flex\",\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 12,\n marginTop: 6,\n },\n legendText: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n },\n subtitle: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginBottom: 6,\n },\n title: {\n color: t.colors.foreground,\n fontFamily: t.typography.heading.fontFamily,\n fontSize: t.primitives.typography.base,\n fontWeight: t.primitives.fontWeights.semibold,\n marginBottom: 2,\n },\n });\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/graph/graph.styles.ts"
},
{
"path": "registry/bases/forme/components/graph/graph.ts",
- "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeSvg,\n FormeText,\n FormeView,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { createGraphStyles } from \"./graph.styles\";\nimport type {\n ChartLayout,\n GraphDataPoint,\n GraphLegendPosition,\n GraphProps,\n GraphSeries,\n GraphVariant,\n} from \"./graph.types\";\nimport {\n GRAPH_SAFE_WIDTHS,\n arcPath,\n buildLayout,\n fmtNum,\n getDefaultPalette,\n getGraphWidth,\n normalizeData,\n polarToCartesian,\n smoothPath,\n truncate,\n} from \"./graph.utils\";\n\n/**\n * Shared Y-axis grid lines and tick labels for cartesian charts (bar, line, area).\n * Extracted to avoid duplicating the identical block across render functions.\n */\nconst renderGridAndYAxis = (\n ticks: number[],\n toY: (v: number) => number,\n chartX: number,\n chartW: number,\n showGrid: boolean,\n gridColor: string,\n textColor: string\n) =>\n ticks.map((tick) => {\n const ty = toY(tick);\n return {\n line: showGrid\n ? { stroke: gridColor, x1: chartX, x2: chartX + chartW, y1: ty, y2: ty }\n : null,\n text: { fill: textColor, text: fmtNum(tick), x: chartX - 4, y: ty + 3 },\n };\n });\n\nconst renderBarChart = (\n series: GraphSeries[],\n layout: ChartLayout,\n palette: string[],\n showGrid: boolean,\n showValues: boolean,\n theme: PdfcnTheme\n) => {\n const { chartX, chartY, chartW, chartH, yMin, yMax, yTicks, xLabels } =\n layout;\n const nCategories = xLabels.length;\n const nSeries = series.length;\n const groupGap = 0.25;\n const groupW = chartW / nCategories;\n const barW = (groupW * (1 - groupGap)) / nSeries;\n const textColor = theme.colors.mutedForeground;\n const gridColor = theme.colors.border;\n const axisColor = theme.colors.foreground;\n const range = yMax - yMin || 1;\n const toY = (v: number) => chartY + chartH - ((v - yMin) / range) * chartH;\n\n return {\n axis: {\n stroke: axisColor,\n x1: chartX,\n x2: chartX + chartW,\n y1: chartY + chartH,\n y2: chartY + chartH,\n },\n grid: renderGridAndYAxis(\n yTicks,\n toY,\n chartX,\n chartW,\n showGrid,\n gridColor,\n textColor\n ),\n groups: xLabels.map((label, ci) => {\n const groupLeft = chartX + ci * groupW + groupW * (groupGap / 2);\n return {\n bars: series.map((s, si) => {\n const val = s.data[ci]?.value ?? 0;\n const color =\n s.data[ci]?.color ?? s.color ?? palette[si % palette.length];\n const barH = ((val - yMin) / range) * chartH;\n const bx = groupLeft + si * barW;\n const by = chartY + chartH - barH;\n return {\n rect: { fill: color, height: barH, width: barW - 1, x: bx, y: by },\n value:\n showValues && barH > 10\n ? {\n fill: axisColor,\n text: fmtNum(val),\n x: bx + barW / 2 - 0.5,\n y: by - 2,\n }\n : null,\n };\n }),\n label: {\n fill: textColor,\n text: truncate(label, 10),\n x: groupLeft + (nSeries * barW) / 2,\n y: chartY + chartH + 10,\n },\n };\n }),\n };\n};\n\nconst renderHorizontalBarChart = (\n series: GraphSeries[],\n layout: ChartLayout,\n palette: string[],\n showValues: boolean,\n theme: PdfcnTheme\n) => {\n const { chartX, chartY, chartW, chartH, xLabels } = layout;\n const nCategories = xLabels.length;\n const allValues = series.flatMap((s) => s.data.map((d) => d.value));\n const maxVal = Math.max(...allValues, 1);\n const rowH = chartH / nCategories;\n const barH = rowH * 0.5;\n const textColor = theme.colors.mutedForeground;\n const axisColor = theme.colors.foreground;\n const labelW = 60;\n\n return {\n axis: {\n stroke: axisColor,\n x1: chartX + labelW,\n x2: chartX + labelW,\n y1: chartY,\n y2: chartY + chartH,\n },\n rows: xLabels.map((label, ci) => {\n const rowY = chartY + ci * rowH;\n const val = series[0]?.data[ci]?.value ?? 0;\n const color =\n series[0]?.data[ci]?.color ??\n series[0]?.color ??\n palette[ci % palette.length];\n const barW = (val / maxVal) * (chartW - labelW);\n return {\n label: {\n fill: textColor,\n text: truncate(label, 14),\n x: chartX + labelW - 4,\n y: rowY + rowH / 2 + 3,\n },\n rect: {\n fill: color,\n height: barH,\n width: Math.max(barW, 1),\n x: chartX + labelW,\n y: rowY + (rowH - barH) / 2,\n },\n value: showValues\n ? {\n fill: axisColor,\n text: fmtNum(val),\n x: chartX + labelW + barW + 3,\n y: rowY + rowH / 2 + 3,\n }\n : null,\n };\n }),\n };\n};\n\nconst renderLineAreaChart = (\n series: GraphSeries[],\n layout: ChartLayout,\n palette: string[],\n showGrid: boolean,\n showValues: boolean,\n showDots: boolean,\n smooth: boolean,\n isArea: boolean,\n theme: PdfcnTheme\n) => {\n const { chartX, chartY, chartW, chartH, yMin, yMax, yTicks, xLabels } =\n layout;\n const range = yMax - yMin || 1;\n const textColor = theme.colors.mutedForeground;\n const gridColor = theme.colors.border;\n const axisColor = theme.colors.foreground;\n const nPoints = xLabels.length;\n\n const xFor = (i: number) => chartX + (i / Math.max(nPoints - 1, 1)) * chartW;\n const yFor = (v: number) => chartY + chartH - ((v - yMin) / range) * chartH;\n\n return {\n axis: {\n stroke: axisColor,\n x1: chartX,\n x2: chartX + chartW,\n y1: chartY + chartH,\n y2: chartY + chartH,\n },\n grid: renderGridAndYAxis(\n yTicks,\n yFor,\n chartX,\n chartW,\n showGrid,\n gridColor,\n textColor\n ),\n labels: xLabels.map((label, i) => ({\n fill: textColor,\n text: truncate(label, 8),\n x: xFor(i),\n y: chartY + chartH + 10,\n })),\n series: series.map((s, si) => {\n const color = s.color ?? palette[si % palette.length];\n const points = s.data.map((d, i) => ({ x: xFor(i), y: yFor(d.value) }));\n\n const lineDStr = smooth\n ? smoothPath(points)\n : `M ${points.map((p) => `${p.x} ${p.y}`).join(\" L \")}`;\n\n const lastPoint = points.at(-1);\n const firstPoint = points.at(0);\n const areaPath =\n isArea && points.length > 1 && lastPoint && firstPoint\n ? `${lineDStr} L ${lastPoint.x} ${chartY + chartH} L ${firstPoint.x} ${chartY + chartH} Z`\n : null;\n\n return {\n area: isArea && areaPath ? areaPath : null,\n color,\n dots: showDots ? points : [],\n line: lineDStr,\n values: showValues\n ? points.map((p, pi) => ({\n text: fmtNum(s.data[pi].value),\n x: p.x,\n y: p.y - 5,\n }))\n : [],\n };\n }),\n };\n};\n\nconst renderPieDonutChart = (\n series: GraphSeries[],\n layout: ChartLayout,\n palette: string[],\n centerLabel: string | undefined,\n isDonut: boolean,\n theme: PdfcnTheme\n) => {\n const { svgW, svgH } = layout;\n const cx = svgW / 2;\n const cy = svgH / 2;\n const r = Math.min(svgW, svgH) / 2 - 20;\n const innerR = isDonut ? r * 0.52 : 0;\n const textColor = theme.colors.mutedForeground;\n\n const data = series[0]?.data ?? [];\n const total = data.reduce((sum, d) => sum + d.value, 0) || 1;\n\n let currentAngle = 0;\n\n return {\n center:\n isDonut && centerLabel\n ? {\n cx,\n cy,\n fill: theme.colors.foreground,\n r: innerR,\n text: centerLabel,\n y: cy + 4,\n }\n : null,\n slices: data.map((d, i) => {\n const color = d.color ?? palette[i % palette.length];\n const sweep = (d.value / total) * 360;\n const midAngle = currentAngle + sweep / 2;\n const path = arcPath(\n cx,\n cy,\n r,\n currentAngle,\n currentAngle + sweep,\n innerR\n );\n currentAngle += sweep;\n\n const labelR = r * 1.18;\n const lp = polarToCartesian(cx, cy, labelR, midAngle);\n const anchor = lp.x > cx ? \"start\" : \"end\";\n\n return {\n color,\n // Show label only if slice is large enough to label\n label:\n sweep > 15\n ? {\n anchor,\n fill: textColor,\n text: truncate(d.label, 10),\n x: lp.x,\n y: lp.y + 3,\n }\n : null,\n path,\n };\n }),\n };\n};\n\nconst Legend = ({\n series,\n palette,\n styles,\n position = \"bottom\",\n}: {\n series: GraphSeries[];\n palette: string[];\n styles: ReturnType;\n position?: \"bottom\" | \"right\";\n}) => {\n const containerStyle =\n position === \"right\" ? styles.legendColumn : styles.legendRow;\n\n return {\n containerStyle,\n items: series.map((s, i) => ({\n color: s.color ?? palette[i % palette.length],\n name: s.name,\n })),\n };\n};\n\ninterface ChartContent {\n bar?: ReturnType;\n horizontalBar?: ReturnType;\n lineArea?: ReturnType;\n pieDonut?: ReturnType;\n}\n\nconst renderChartContent = (\n variant: string,\n series: GraphSeries[],\n layout: ChartLayout,\n palette: string[],\n showGrid: boolean,\n showValues: boolean,\n showDots: boolean,\n smooth: boolean,\n centerLabel: string | undefined,\n theme: PdfcnTheme\n): ChartContent => {\n switch (variant) {\n case \"bar\": {\n return {\n bar: renderBarChart(\n series,\n layout,\n palette,\n showGrid,\n showValues,\n theme\n ),\n };\n }\n case \"horizontal-bar\": {\n return {\n horizontalBar: renderHorizontalBarChart(\n series,\n layout,\n palette,\n showValues,\n theme\n ),\n };\n }\n case \"line\":\n case \"area\": {\n return {\n lineArea: renderLineAreaChart(\n series,\n layout,\n palette,\n showGrid,\n showValues,\n showDots,\n smooth,\n variant === \"area\",\n theme\n ),\n };\n }\n case \"pie\": {\n return {\n pieDonut: renderPieDonutChart(\n series,\n layout,\n palette,\n undefined,\n false,\n theme\n ),\n };\n }\n case \"donut\": {\n return {\n pieDonut: renderPieDonutChart(\n series,\n layout,\n palette,\n centerLabel,\n true,\n theme\n ),\n };\n }\n default: {\n return {};\n }\n }\n};\n\nconst renderAxisLabels = (\n isPieOrDonut: boolean,\n xLabel: string | undefined,\n yLabel: string | undefined,\n chartX: number,\n chartW: number,\n height: number,\n mutedForeground: string\n) => ({\n fill: mutedForeground,\n x:\n !isPieOrDonut && xLabel\n ? { text: xLabel, x: chartX + chartW / 2, y: height - 2 }\n : null,\n y: !isPieOrDonut && yLabel ? { text: yLabel, x: 2, y: 10 } : null,\n});\n\nconst renderTextFallback = (\n variant: GraphProps[\"variant\"],\n series: GraphSeries[],\n layout: ChartLayout,\n showValues: boolean,\n textColor: string\n) => {\n if (variant === \"pie\" || variant === \"donut\") {\n const data = series[0]?.data ?? [];\n const total = data.reduce((sum, point) => sum + point.value, 0) || 1;\n const cx = layout.svgW / 2;\n const cy = layout.svgH / 2;\n const radius = Math.min(layout.svgW, layout.svgH) / 2 - 20;\n const labelRadius = radius * 1.18;\n let currentAngle = 0;\n\n return {\n labels: data.map((point) => {\n const sweep = (point.value / total) * 360;\n const midAngle = currentAngle + sweep / 2;\n currentAngle += sweep;\n if (sweep <= 15) {\n return null;\n }\n const labelPoint = polarToCartesian(cx, cy, labelRadius, midAngle);\n const onRight = labelPoint.x > cx;\n return {\n style: {\n color: textColor,\n fontSize: 7,\n left: onRight ? labelPoint.x : labelPoint.x - 60,\n lineHeight: 1,\n position: \"absolute\",\n textAlign: onRight ? \"left\" : \"right\",\n top: labelPoint.y - 4,\n width: 60,\n } satisfies Style,\n text: truncate(point.label, 10),\n };\n }),\n rows: [],\n style: {\n height: layout.svgH,\n left: 0,\n position: \"absolute\",\n top: 0,\n width: layout.svgW,\n } satisfies Style,\n };\n }\n\n const {\n chartH,\n chartW,\n chartX,\n chartY,\n svgH,\n svgW,\n xLabels,\n yMax,\n yMin,\n yTicks,\n } = layout;\n const range = yMax - yMin || 1;\n const toY = (value: number) =>\n chartY + chartH - ((value - yMin) / range) * chartH;\n const labelStyle = {\n color: textColor,\n fontSize: 7,\n lineHeight: 1,\n position: \"absolute\" as const,\n };\n\n if (variant === \"horizontal-bar\") {\n const labelWidth = 60;\n const rowHeight = chartH / Math.max(xLabels.length, 1);\n const maxValue = Math.max(\n ...series.flatMap((item) => item.data.map((point) => point.value)),\n 1\n );\n\n return {\n labels: [],\n rows: xLabels.map((label, index) => {\n const value = series[0]?.data[index]?.value ?? 0;\n const barWidth = (value / maxValue) * (chartW - labelWidth);\n return {\n label: {\n style: {\n ...labelStyle,\n left: chartX,\n textAlign: \"right\",\n top: chartY + index * rowHeight + rowHeight / 2 - 4,\n width: labelWidth - 4,\n } satisfies Style,\n text: truncate(label, 14),\n },\n value: showValues\n ? {\n style: {\n ...labelStyle,\n color: textColor,\n fontSize: 6,\n left: chartX + labelWidth + barWidth + 3,\n top: chartY + index * rowHeight + rowHeight / 2 - 4,\n width: 28,\n } satisfies Style,\n text: fmtNum(value),\n }\n : null,\n };\n }),\n style: {\n height: svgH,\n left: 0,\n position: \"absolute\",\n top: 0,\n width: svgW,\n } satisfies Style,\n };\n }\n\n const pointX = (index: number) =>\n chartX + (index / Math.max(xLabels.length - 1, 1)) * chartW;\n const groupWidth = chartW / Math.max(xLabels.length, 1);\n const barGap = 2;\n const barWidth = Math.max(\n (groupWidth - barGap * (series.length + 1)) / Math.max(series.length, 1),\n 1\n );\n\n return {\n labels: [\n ...yTicks.map((tick) => ({\n style: {\n ...labelStyle,\n left: 0,\n textAlign: \"right\",\n top: toY(tick) - 4,\n width: chartX - 4,\n } satisfies Style,\n text: fmtNum(tick),\n })),\n ...(variant === \"line\" || variant === \"area\"\n ? xLabels.map((label, index) => ({\n style: {\n ...labelStyle,\n left: pointX(index) - 12,\n textAlign: \"center\",\n top: chartY + chartH + 3,\n width: 24,\n } satisfies Style,\n text: truncate(label, 8),\n }))\n : []),\n ...(variant === \"bar\" && showValues\n ? xLabels.flatMap((_label, categoryIndex) =>\n series.map((item, seriesIndex) => {\n const value = item.data[categoryIndex]?.value ?? 0;\n const left =\n chartX +\n categoryIndex * groupWidth +\n barGap +\n seriesIndex * (barWidth + barGap);\n return {\n style: {\n ...labelStyle,\n fontSize: 6,\n left,\n textAlign: \"center\",\n top: toY(value) - 8,\n width: barWidth,\n } satisfies Style,\n text: fmtNum(value),\n };\n })\n )\n : []),\n ],\n rows: [],\n style: {\n height: svgH,\n left: 0,\n position: \"absolute\",\n top: 0,\n width: svgW,\n } satisfies Style,\n };\n};\n\nconst renderBarLabels = (\n variant: GraphProps[\"variant\"],\n series: GraphSeries[],\n chartX: number,\n chartW: number\n) => {\n if (variant !== \"bar\") {\n return null;\n }\n\n return {\n cellStyle: { alignItems: \"center\", flex: 1 } satisfies Style,\n labels: (series[0]?.data ?? []).map((point) => truncate(point.label, 10)),\n style: {\n display: \"flex\",\n flexDirection: \"row\",\n marginLeft: chartX,\n width: chartW,\n } satisfies Style,\n textStyle: { fontSize: 7 } satisfies Style,\n };\n};\n\nconst graphLayout = (\n theme: PdfcnTheme,\n {\n variant = \"bar\",\n data,\n title,\n subtitle,\n xLabel,\n yLabel,\n width: explicitWidth,\n height = 260,\n fullWidth = false,\n containerPadding = 0,\n wrapperPadding = 0,\n colors,\n showValues = false,\n showGrid = true,\n legend = \"bottom\",\n centerLabel,\n showDots = true,\n smooth = false,\n yTicks: yTickCount = 5,\n style,\n }: GraphProps\n) => {\n const styles = createGraphStyles(theme);\n const palette = colors ?? getDefaultPalette(theme);\n const series = normalizeData(data);\n\n const width = fullWidth\n ? getGraphWidth(theme, { containerPadding, wrapperPadding })\n : (explicitWidth ?? GRAPH_SAFE_WIDTHS.default);\n\n const isPieOrDonut = variant === \"pie\" || variant === \"donut\";\n const layout = buildLayout(series, width, height, isPieOrDonut, yTickCount);\n const { chartX, chartW } = layout;\n\n const chartContent = renderChartContent(\n variant,\n series,\n layout,\n palette,\n showGrid,\n showValues,\n showDots,\n smooth,\n centerLabel,\n theme\n );\n\n const showLegend = legend !== \"none\" && !isPieOrDonut;\n const chartLabels = renderBarLabels(variant, series, chartX, chartW);\n\n const containerStyles: Style[] = [styles.container];\n if (style) {\n containerStyles.push(style);\n }\n\n return {\n axisLabels: renderAxisLabels(\n isPieOrDonut,\n xLabel,\n yLabel,\n chartX,\n chartW,\n height,\n theme.colors.mutedForeground\n ),\n chartContent,\n chartLabels,\n containerStyles,\n height,\n legend,\n legends: {\n bottom: Legend({ palette, position: \"bottom\", series, styles }),\n right: Legend({ palette, position: \"right\", series, styles }),\n },\n showLegend,\n styles,\n subtitle,\n textFallback: renderTextFallback(\n variant,\n series,\n layout,\n showValues,\n theme.colors.mutedForeground\n ),\n title,\n width,\n };\n};\n\n/**\n * PdfGraph — renders bar, horizontal-bar, line, area, pie, and donut charts\n * natively inside Forme documents using SVG primitives.\n *\n * No external chart libraries are required or used — all rendering is done via\n * Forme's SVG support (`` with plain ``, ``, ``, and so on).\n *\n * @example Bar chart\n * ```html\n * \n * ```\n *\n * @example Donut chart with center label\n * ```html\n * \n * ```\n *\n * **Limitations (by design):**\n * - No interactivity (PDFs are static)\n * - No animations\n * - SVG text inside charts uses SVG font attributes, not theme fonts\n * - For print PDFs use SVG-friendly fonts registered with Font.register()\n */\n@Component({\n imports: [FormeSvg, FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-graph\",\n template: `\n @if (noWrap()) {\n \n \n \n } @else {\n \n }\n \n @let g = graph();\n \n @if (g.title) {\n {{ g.title }}\n }\n @if (g.subtitle) {\n {{ g.subtitle }}\n }\n \n \n \n @if (g.chartContent.bar; as bar) {\n \n \n @for (group of bar.groups; track $index) {\n \n @for (b of group.bars; track $index) {\n \n \n @if (b.value; as v) {\n \n {{ v.text }}\n \n }\n \n }\n \n {{ group.label.text }}\n \n \n }\n }\n @if (g.chartContent.horizontalBar; as hbar) {\n @for (row of hbar.rows; track $index) {\n \n \n {{ row.label.text }}\n \n \n @if (row.value; as v) {\n \n {{ v.text }}\n \n }\n \n }\n \n }\n @if (g.chartContent.lineArea; as chart) {\n \n \n @for (s of chart.series; track $index) {\n \n @if (s.area) {\n \n }\n \n @for (p of s.dots; track $index) {\n \n }\n @for (v of s.values; track $index) {\n \n {{ v.text }}\n \n }\n \n }\n @for (label of chart.labels; track $index) {\n \n {{ label.text }}\n \n }\n }\n @if (g.chartContent.pieDonut; as pie) {\n @for (slice of pie.slices; track $index) {\n \n \n @if (slice.label; as label) {\n \n {{ label.text }}\n \n }\n \n }\n @if (pie.center; as center) {\n \n \n {{ center.text }}\n \n }\n }\n @if (g.axisLabels.x; as label) {\n \n {{ label.text }}\n \n }\n @if (g.axisLabels.y; as label) {\n \n {{ label.text }}\n \n }\n \n \n @for (label of g.textFallback.labels; track $index) {\n @if (label) {\n {{\n label.text\n }}\n }\n }\n @for (row of g.textFallback.rows; track $index) {\n \n {{\n row.label.text\n }}\n @if (row.value; as value) {\n {{\n value.text\n }}\n }\n \n }\n \n \n @if (g.showLegend && g.legend === \"right\") {\n \n }\n \n @if (g.chartLabels; as chartLabels) {\n \n @for (label of chartLabels.labels; track $index) {\n \n {{\n label\n }}\n \n }\n \n }\n @if (g.showLegend && g.legend === \"bottom\") {\n \n }\n \n \n \n @for (item of legend.items; track $index) {\n \n \n \n \n {{\n item.name\n }}\n \n }\n \n \n \n\n \n @for (tick of chart.grid; track $index) {\n \n @if (tick.line; as line) {\n \n }\n \n {{ tick.text.text }}\n \n \n }\n \n\n \n \n \n `,\n})\nexport class PdfGraph {\n readonly variant = input(\"bar\");\n readonly data = input.required();\n readonly title = input();\n readonly subtitle = input();\n readonly xLabel = input();\n readonly yLabel = input();\n readonly width = input();\n readonly height = input(260);\n readonly fullWidth = input(false, { transform: booleanAttribute });\n readonly containerPadding = input(0);\n readonly wrapperPadding = input(0);\n readonly colors = input();\n readonly showValues = input(false, { transform: booleanAttribute });\n readonly showGrid = input(true, { transform: booleanAttribute });\n readonly legend = input(\"bottom\");\n readonly centerLabel = input();\n readonly showDots = input(true, { transform: booleanAttribute });\n readonly smooth = input(false, { transform: booleanAttribute });\n readonly yTicks = input(5);\n readonly noWrap = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly graph = computed(() =>\n graphLayout(this.theme(), {\n centerLabel: this.centerLabel(),\n colors: this.colors(),\n containerPadding: this.containerPadding(),\n data: this.data(),\n fullWidth: this.fullWidth(),\n height: this.height(),\n legend: this.legend(),\n showDots: this.showDots(),\n showGrid: this.showGrid(),\n showValues: this.showValues(),\n smooth: this.smooth(),\n style: this.style(),\n subtitle: this.subtitle(),\n title: this.title(),\n variant: this.variant(),\n width: this.width(),\n wrapperPadding: this.wrapperPadding(),\n xLabel: this.xLabel(),\n yLabel: this.yLabel(),\n yTicks: this.yTicks(),\n })\n );\n}\n",
+ "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeSvg,\n FormeText,\n FormeView,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { createGraphStyles } from \"./graph.styles\";\nimport type {\n ChartLayout,\n GraphDataPoint,\n GraphLegendPosition,\n GraphProps,\n GraphSeries,\n GraphVariant,\n} from \"./graph.types\";\nimport {\n GRAPH_SAFE_WIDTHS,\n arcPath,\n buildLayout,\n fmtNum,\n getDefaultPalette,\n getGraphWidth,\n normalizeData,\n polarToCartesian,\n smoothPath,\n truncate,\n} from \"./graph.utils\";\n\n/**\n * Shared Y-axis grid lines and tick labels for cartesian charts (bar, line, area).\n * Extracted to avoid duplicating the identical block across render functions.\n */\nconst renderGridAndYAxis = (\n ticks: number[],\n toY: (v: number) => number,\n chartX: number,\n chartW: number,\n showGrid: boolean,\n gridColor: string,\n textColor: string\n) =>\n ticks.map((tick) => {\n const ty = toY(tick);\n return {\n line: showGrid\n ? { stroke: gridColor, x1: chartX, x2: chartX + chartW, y1: ty, y2: ty }\n : null,\n text: { fill: textColor, text: fmtNum(tick), x: chartX - 4, y: ty + 3 },\n };\n });\n\nconst renderBarChart = (\n series: GraphSeries[],\n layout: ChartLayout,\n palette: string[],\n showGrid: boolean,\n showValues: boolean,\n theme: PdfcnTheme\n) => {\n const { chartX, chartY, chartW, chartH, yMin, yMax, yTicks, xLabels } =\n layout;\n const nCategories = xLabels.length;\n const nSeries = series.length;\n const groupGap = 0.25;\n const groupW = chartW / nCategories;\n const barW = (groupW * (1 - groupGap)) / nSeries;\n const textColor = theme.colors.mutedForeground;\n const gridColor = theme.colors.border;\n const axisColor = theme.colors.foreground;\n const range = yMax - yMin || 1;\n const toY = (v: number) => chartY + chartH - ((v - yMin) / range) * chartH;\n\n return {\n axis: {\n stroke: axisColor,\n x1: chartX,\n x2: chartX + chartW,\n y1: chartY + chartH,\n y2: chartY + chartH,\n },\n grid: renderGridAndYAxis(\n yTicks,\n toY,\n chartX,\n chartW,\n showGrid,\n gridColor,\n textColor\n ),\n groups: xLabels.map((label, ci) => {\n const groupLeft = chartX + ci * groupW + groupW * (groupGap / 2);\n return {\n bars: series.map((s, si) => {\n const val = s.data[ci]?.value ?? 0;\n const color =\n s.data[ci]?.color ?? s.color ?? palette[si % palette.length];\n const barH = ((val - yMin) / range) * chartH;\n const bx = groupLeft + si * barW;\n const by = chartY + chartH - barH;\n return {\n rect: { fill: color, height: barH, width: barW - 1, x: bx, y: by },\n value:\n showValues && barH > 10\n ? {\n fill: axisColor,\n text: fmtNum(val),\n x: bx + barW / 2 - 0.5,\n y: by - 2,\n }\n : null,\n };\n }),\n label: {\n fill: textColor,\n text: truncate(label, 10),\n x: groupLeft + (nSeries * barW) / 2,\n y: chartY + chartH + 10,\n },\n };\n }),\n };\n};\n\nconst renderHorizontalBarChart = (\n series: GraphSeries[],\n layout: ChartLayout,\n palette: string[],\n showValues: boolean,\n theme: PdfcnTheme\n) => {\n const { chartX, chartY, chartW, chartH, xLabels } = layout;\n const nCategories = xLabels.length;\n const allValues = series.flatMap((s) => s.data.map((d) => d.value));\n const maxVal = Math.max(...allValues, 1);\n const rowH = chartH / nCategories;\n const barH = rowH * 0.5;\n const textColor = theme.colors.mutedForeground;\n const axisColor = theme.colors.foreground;\n const labelW = 60;\n\n return {\n axis: {\n stroke: axisColor,\n x1: chartX + labelW,\n x2: chartX + labelW,\n y1: chartY,\n y2: chartY + chartH,\n },\n rows: xLabels.map((label, ci) => {\n const rowY = chartY + ci * rowH;\n const val = series[0]?.data[ci]?.value ?? 0;\n const color =\n series[0]?.data[ci]?.color ??\n series[0]?.color ??\n palette[ci % palette.length];\n const barW = (val / maxVal) * (chartW - labelW);\n return {\n label: {\n fill: textColor,\n text: truncate(label, 14),\n x: chartX + labelW - 4,\n y: rowY + rowH / 2 + 3,\n },\n rect: {\n fill: color,\n height: barH,\n width: Math.max(barW, 1),\n x: chartX + labelW,\n y: rowY + (rowH - barH) / 2,\n },\n value: showValues\n ? {\n fill: axisColor,\n text: fmtNum(val),\n x: chartX + labelW + barW + 3,\n y: rowY + rowH / 2 + 3,\n }\n : null,\n };\n }),\n };\n};\n\nconst renderLineAreaChart = (\n series: GraphSeries[],\n layout: ChartLayout,\n palette: string[],\n showGrid: boolean,\n showValues: boolean,\n showDots: boolean,\n smooth: boolean,\n isArea: boolean,\n theme: PdfcnTheme\n) => {\n const { chartX, chartY, chartW, chartH, yMin, yMax, yTicks, xLabels } =\n layout;\n const range = yMax - yMin || 1;\n const textColor = theme.colors.mutedForeground;\n const gridColor = theme.colors.border;\n const axisColor = theme.colors.foreground;\n const nPoints = xLabels.length;\n\n const xFor = (i: number) => chartX + (i / Math.max(nPoints - 1, 1)) * chartW;\n const yFor = (v: number) => chartY + chartH - ((v - yMin) / range) * chartH;\n\n return {\n axis: {\n stroke: axisColor,\n x1: chartX,\n x2: chartX + chartW,\n y1: chartY + chartH,\n y2: chartY + chartH,\n },\n grid: renderGridAndYAxis(\n yTicks,\n yFor,\n chartX,\n chartW,\n showGrid,\n gridColor,\n textColor\n ),\n labels: xLabels.map((label, i) => ({\n fill: textColor,\n text: truncate(label, 8),\n x: xFor(i),\n y: chartY + chartH + 10,\n })),\n series: series.map((s, si) => {\n const color = s.color ?? palette[si % palette.length];\n const points = s.data.map((d, i) => ({ x: xFor(i), y: yFor(d.value) }));\n\n const lineDStr = smooth\n ? smoothPath(points)\n : `M ${points.map((p) => `${p.x} ${p.y}`).join(\" L \")}`;\n\n const lastPoint = points.at(-1);\n const firstPoint = points.at(0);\n const areaPath =\n isArea && points.length > 1 && lastPoint && firstPoint\n ? `${lineDStr} L ${lastPoint.x} ${chartY + chartH} L ${firstPoint.x} ${chartY + chartH} Z`\n : null;\n\n return {\n area: isArea && areaPath ? areaPath : null,\n color,\n dots: showDots ? points : [],\n line: lineDStr,\n values: showValues\n ? points.map((p, pi) => ({\n text: fmtNum(s.data[pi].value),\n x: p.x,\n y: p.y - 5,\n }))\n : [],\n };\n }),\n };\n};\n\nconst renderPieDonutChart = (\n series: GraphSeries[],\n layout: ChartLayout,\n palette: string[],\n centerLabel: string | undefined,\n isDonut: boolean,\n theme: PdfcnTheme\n) => {\n const { svgW, svgH } = layout;\n const cx = svgW / 2;\n const cy = svgH / 2;\n const r = Math.min(svgW, svgH) / 2 - 20;\n const innerR = isDonut ? r * 0.52 : 0;\n const textColor = theme.colors.mutedForeground;\n\n const data = series[0]?.data ?? [];\n const total = data.reduce((sum, d) => sum + d.value, 0) || 1;\n\n let currentAngle = 0;\n\n return {\n center:\n isDonut && centerLabel\n ? {\n cx,\n cy,\n fill: theme.colors.foreground,\n r: innerR,\n text: centerLabel,\n y: cy + 4,\n }\n : null,\n slices: data.map((d, i) => {\n const color = d.color ?? palette[i % palette.length];\n const sweep = (d.value / total) * 360;\n const midAngle = currentAngle + sweep / 2;\n const path = arcPath(\n cx,\n cy,\n r,\n currentAngle,\n currentAngle + sweep,\n innerR\n );\n currentAngle += sweep;\n\n const labelR = r * 1.18;\n const lp = polarToCartesian(cx, cy, labelR, midAngle);\n const anchor = lp.x > cx ? \"start\" : \"end\";\n\n return {\n color,\n // Show label only if slice is large enough to label\n label:\n sweep > 15\n ? {\n anchor,\n fill: textColor,\n text: truncate(d.label, 10),\n x: lp.x,\n y: lp.y + 3,\n }\n : null,\n path,\n };\n }),\n };\n};\n\nconst Legend = ({\n series,\n palette,\n styles,\n position = \"bottom\",\n}: {\n series: GraphSeries[];\n palette: string[];\n styles: ReturnType;\n position?: \"bottom\" | \"right\";\n}) => {\n const containerStyle =\n position === \"right\" ? styles.legendColumn : styles.legendRow;\n\n return {\n containerStyle,\n items: series.map((s, i) => ({\n color: s.color ?? palette[i % palette.length],\n name: s.name,\n })),\n };\n};\n\ninterface ChartContent {\n bar?: ReturnType;\n horizontalBar?: ReturnType;\n lineArea?: ReturnType;\n pieDonut?: ReturnType;\n}\n\nconst renderChartContent = (\n variant: string,\n series: GraphSeries[],\n layout: ChartLayout,\n palette: string[],\n showGrid: boolean,\n showValues: boolean,\n showDots: boolean,\n smooth: boolean,\n centerLabel: string | undefined,\n theme: PdfcnTheme\n): ChartContent => {\n switch (variant) {\n case \"bar\": {\n return {\n bar: renderBarChart(\n series,\n layout,\n palette,\n showGrid,\n showValues,\n theme\n ),\n };\n }\n case \"horizontal-bar\": {\n return {\n horizontalBar: renderHorizontalBarChart(\n series,\n layout,\n palette,\n showValues,\n theme\n ),\n };\n }\n case \"line\":\n case \"area\": {\n return {\n lineArea: renderLineAreaChart(\n series,\n layout,\n palette,\n showGrid,\n showValues,\n showDots,\n smooth,\n variant === \"area\",\n theme\n ),\n };\n }\n case \"pie\": {\n return {\n pieDonut: renderPieDonutChart(\n series,\n layout,\n palette,\n undefined,\n false,\n theme\n ),\n };\n }\n case \"donut\": {\n return {\n pieDonut: renderPieDonutChart(\n series,\n layout,\n palette,\n centerLabel,\n true,\n theme\n ),\n };\n }\n default: {\n return {};\n }\n }\n};\n\nconst renderAxisLabels = (\n isPieOrDonut: boolean,\n xLabel: string | undefined,\n yLabel: string | undefined,\n chartX: number,\n chartW: number,\n height: number,\n mutedForeground: string\n) => ({\n fill: mutedForeground,\n x:\n !isPieOrDonut && xLabel\n ? { text: xLabel, x: chartX + chartW / 2, y: height - 2 }\n : null,\n y: !isPieOrDonut && yLabel ? { text: yLabel, x: 2, y: 10 } : null,\n});\n\nconst renderTextFallback = (\n variant: GraphProps[\"variant\"],\n series: GraphSeries[],\n layout: ChartLayout,\n showValues: boolean,\n textColor: string\n) => {\n if (variant === \"pie\" || variant === \"donut\") {\n const data = series[0]?.data ?? [];\n const total = data.reduce((sum, point) => sum + point.value, 0) || 1;\n const cx = layout.svgW / 2;\n const cy = layout.svgH / 2;\n const radius = Math.min(layout.svgW, layout.svgH) / 2 - 20;\n const labelRadius = radius * 1.18;\n let currentAngle = 0;\n\n return {\n labels: data.map((point) => {\n const sweep = (point.value / total) * 360;\n const midAngle = currentAngle + sweep / 2;\n currentAngle += sweep;\n if (sweep <= 15) {\n return null;\n }\n const labelPoint = polarToCartesian(cx, cy, labelRadius, midAngle);\n const onRight = labelPoint.x > cx;\n return {\n style: {\n color: textColor,\n fontSize: 7,\n left: onRight ? labelPoint.x : labelPoint.x - 60,\n lineHeight: 1,\n position: \"absolute\",\n textAlign: onRight ? \"left\" : \"right\",\n top: labelPoint.y - 4,\n width: 60,\n } satisfies Style,\n text: truncate(point.label, 10),\n };\n }),\n rows: [],\n style: {\n height: layout.svgH,\n left: 0,\n position: \"absolute\",\n top: 0,\n width: layout.svgW,\n } satisfies Style,\n };\n }\n\n const {\n chartH,\n chartW,\n chartX,\n chartY,\n svgH,\n svgW,\n xLabels,\n yMax,\n yMin,\n yTicks,\n } = layout;\n const range = yMax - yMin || 1;\n const toY = (value: number) =>\n chartY + chartH - ((value - yMin) / range) * chartH;\n const labelStyle = {\n color: textColor,\n fontSize: 7,\n lineHeight: 1,\n position: \"absolute\" as const,\n };\n\n if (variant === \"horizontal-bar\") {\n const labelWidth = 60;\n const rowHeight = chartH / Math.max(xLabels.length, 1);\n const maxValue = Math.max(\n ...series.flatMap((item) => item.data.map((point) => point.value)),\n 1\n );\n\n return {\n labels: [],\n rows: xLabels.map((label, index) => {\n const value = series[0]?.data[index]?.value ?? 0;\n const barWidth = (value / maxValue) * (chartW - labelWidth);\n return {\n label: {\n style: {\n ...labelStyle,\n left: chartX,\n textAlign: \"right\",\n top: chartY + index * rowHeight + rowHeight / 2 - 4,\n width: labelWidth - 4,\n } satisfies Style,\n text: truncate(label, 14),\n },\n value: showValues\n ? {\n style: {\n ...labelStyle,\n color: textColor,\n fontSize: 6,\n left: chartX + labelWidth + barWidth + 3,\n top: chartY + index * rowHeight + rowHeight / 2 - 4,\n width: 28,\n } satisfies Style,\n text: fmtNum(value),\n }\n : null,\n };\n }),\n style: {\n height: svgH,\n left: 0,\n position: \"absolute\",\n top: 0,\n width: svgW,\n } satisfies Style,\n };\n }\n\n const pointX = (index: number) =>\n chartX + (index / Math.max(xLabels.length - 1, 1)) * chartW;\n const groupWidth = chartW / Math.max(xLabels.length, 1);\n const barGap = 2;\n const barWidth = Math.max(\n (groupWidth - barGap * (series.length + 1)) / Math.max(series.length, 1),\n 1\n );\n\n return {\n labels: [\n ...yTicks.map((tick) => ({\n style: {\n ...labelStyle,\n left: 0,\n textAlign: \"right\",\n top: toY(tick) - 4,\n width: chartX - 4,\n } satisfies Style,\n text: fmtNum(tick),\n })),\n ...(variant === \"line\" || variant === \"area\"\n ? xLabels.map((label, index) => ({\n style: {\n ...labelStyle,\n left: pointX(index) - 12,\n textAlign: \"center\",\n top: chartY + chartH + 3,\n width: 24,\n } satisfies Style,\n text: truncate(label, 8),\n }))\n : []),\n ...(variant === \"bar\" && showValues\n ? xLabels.flatMap((_label, categoryIndex) =>\n series.map((item, seriesIndex) => {\n const value = item.data[categoryIndex]?.value ?? 0;\n const left =\n chartX +\n categoryIndex * groupWidth +\n barGap +\n seriesIndex * (barWidth + barGap);\n return {\n style: {\n ...labelStyle,\n fontSize: 6,\n left,\n textAlign: \"center\",\n top: toY(value) - 8,\n width: barWidth,\n } satisfies Style,\n text: fmtNum(value),\n };\n })\n )\n : []),\n ],\n rows: [],\n style: {\n height: svgH,\n left: 0,\n position: \"absolute\",\n top: 0,\n width: svgW,\n } satisfies Style,\n };\n};\n\nconst renderBarLabels = (\n variant: GraphProps[\"variant\"],\n series: GraphSeries[],\n chartX: number,\n chartW: number\n) => {\n if (variant !== \"bar\") {\n return null;\n }\n\n return {\n cellStyle: { alignItems: \"center\", flex: 1 } satisfies Style,\n labels: (series[0]?.data ?? []).map((point) => truncate(point.label, 10)),\n style: {\n display: \"flex\",\n flexDirection: \"row\",\n marginLeft: chartX,\n width: chartW,\n } satisfies Style,\n textStyle: { fontSize: 7 } satisfies Style,\n };\n};\n\nconst graphLayout = (\n theme: PdfcnTheme,\n {\n variant = \"bar\",\n data,\n title,\n subtitle,\n xLabel,\n yLabel,\n width: explicitWidth,\n height = 260,\n fullWidth = false,\n containerPadding = 0,\n wrapperPadding = 0,\n colors,\n showValues = false,\n showGrid = true,\n legend = \"bottom\",\n centerLabel,\n showDots = true,\n smooth = false,\n yTicks: yTickCount = 5,\n style,\n }: GraphProps\n) => {\n const styles = createGraphStyles(theme);\n const palette = colors ?? getDefaultPalette(theme);\n const series = normalizeData(data);\n\n const width = fullWidth\n ? getGraphWidth(theme, { containerPadding, wrapperPadding })\n : (explicitWidth ?? GRAPH_SAFE_WIDTHS.default);\n\n const isPieOrDonut = variant === \"pie\" || variant === \"donut\";\n const layout = buildLayout(series, width, height, isPieOrDonut, yTickCount);\n const { chartX, chartW } = layout;\n\n const chartContent = renderChartContent(\n variant,\n series,\n layout,\n palette,\n showGrid,\n showValues,\n showDots,\n smooth,\n centerLabel,\n theme\n );\n\n const showLegend = legend !== \"none\" && !isPieOrDonut;\n const chartLabels = renderBarLabels(variant, series, chartX, chartW);\n\n const containerStyles: Style[] = [styles.container];\n if (style) {\n containerStyles.push(style);\n }\n\n return {\n axisLabels: renderAxisLabels(\n isPieOrDonut,\n xLabel,\n yLabel,\n chartX,\n chartW,\n height,\n theme.colors.mutedForeground\n ),\n chartContent,\n chartLabels,\n containerStyles,\n height,\n legend,\n legends: {\n bottom: Legend({ palette, position: \"bottom\", series, styles }),\n right: Legend({ palette, position: \"right\", series, styles }),\n },\n showLegend,\n styles,\n subtitle,\n textFallback: renderTextFallback(\n variant,\n series,\n layout,\n showValues,\n theme.colors.mutedForeground\n ),\n title,\n width,\n };\n};\n\n/**\n * PdfGraph — renders bar, horizontal-bar, line, area, pie, and donut charts\n * natively inside Forme documents using SVG primitives.\n *\n * No external chart libraries are required or used — all rendering is done via\n * Forme's SVG support (`` with plain ``, ``, ``, and so on).\n *\n * @example Bar chart\n * ```html\n * \n * ```\n *\n * @example Donut chart with center label\n * ```html\n * \n * ```\n *\n * **Limitations (by design):**\n * - No interactivity (PDFs are static)\n * - No animations\n * - SVG text inside charts uses SVG font attributes, not theme fonts\n * - For print PDFs use SVG-friendly fonts registered with Font.register()\n */\n@Component({\n imports: [FormeSvg, FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-graph\",\n template: `\n @if (noWrap()) {\n \n \n \n } @else {\n \n }\n \n @let g = graph();\n \n @if (g.title) {\n {{ g.title }}\n }\n @if (g.subtitle) {\n {{ g.subtitle }}\n }\n \n \n \n @if (g.chartContent.bar; as bar) {\n \n \n @for (group of bar.groups; track $index) {\n \n @for (b of group.bars; track $index) {\n \n \n @if (b.value; as v) {\n \n {{ v.text }}\n \n }\n \n }\n \n {{ group.label.text }}\n \n \n }\n }\n @if (g.chartContent.horizontalBar; as hbar) {\n @for (row of hbar.rows; track $index) {\n \n \n {{ row.label.text }}\n \n \n @if (row.value; as v) {\n \n {{ v.text }}\n \n }\n \n }\n \n }\n @if (g.chartContent.lineArea; as chart) {\n \n \n @for (s of chart.series; track $index) {\n \n @if (s.area) {\n \n }\n \n @for (p of s.dots; track $index) {\n \n }\n @for (v of s.values; track $index) {\n \n {{ v.text }}\n \n }\n \n }\n @for (label of chart.labels; track $index) {\n \n {{ label.text }}\n \n }\n }\n @if (g.chartContent.pieDonut; as pie) {\n @for (slice of pie.slices; track $index) {\n \n \n @if (slice.label; as label) {\n \n {{ label.text }}\n \n }\n \n }\n @if (pie.center; as center) {\n \n \n {{ center.text }}\n \n }\n }\n @if (g.axisLabels.x; as label) {\n \n {{ label.text }}\n \n }\n @if (g.axisLabels.y; as label) {\n \n {{ label.text }}\n \n }\n \n \n @for (label of g.textFallback.labels; track $index) {\n @if (label) {\n {{\n label.text\n }}\n }\n }\n @for (row of g.textFallback.rows; track $index) {\n \n {{\n row.label.text\n }}\n @if (row.value; as value) {\n {{\n value.text\n }}\n }\n \n }\n \n \n @if (g.showLegend && g.legend === \"right\") {\n \n }\n \n @if (g.chartLabels; as chartLabels) {\n \n @for (label of chartLabels.labels; track $index) {\n \n {{\n label\n }}\n \n }\n \n }\n @if (g.showLegend && g.legend === \"bottom\") {\n \n }\n \n \n \n @for (item of legend.items; track $index) {\n \n \n \n \n {{\n item.name\n }}\n \n }\n \n \n \n\n \n @for (tick of chart.grid; track $index) {\n \n @if (tick.line; as line) {\n \n }\n \n {{ tick.text.text }}\n \n \n }\n \n\n \n \n \n `,\n})\nexport class PdfGraph {\n readonly variant = input(\"bar\");\n readonly data = input.required();\n readonly title = input();\n readonly subtitle = input();\n readonly xLabel = input();\n readonly yLabel = input();\n readonly width = input();\n readonly height = input(260);\n readonly fullWidth = input(false, { transform: booleanAttribute });\n readonly containerPadding = input(0);\n readonly wrapperPadding = input(0);\n readonly colors = input();\n readonly showValues = input(false, { transform: booleanAttribute });\n readonly showGrid = input(true, { transform: booleanAttribute });\n readonly legend = input(\"bottom\");\n readonly centerLabel = input();\n readonly showDots = input(true, { transform: booleanAttribute });\n readonly smooth = input(false, { transform: booleanAttribute });\n readonly yTicks = input(5);\n readonly noWrap = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly graph = computed(() =>\n graphLayout(this.theme(), {\n centerLabel: this.centerLabel(),\n colors: this.colors(),\n containerPadding: this.containerPadding(),\n data: this.data(),\n fullWidth: this.fullWidth(),\n height: this.height(),\n legend: this.legend(),\n showDots: this.showDots(),\n showGrid: this.showGrid(),\n showValues: this.showValues(),\n smooth: this.smooth(),\n style: this.style(),\n subtitle: this.subtitle(),\n title: this.title(),\n variant: this.variant(),\n width: this.width(),\n wrapperPadding: this.wrapperPadding(),\n xLabel: this.xLabel(),\n yLabel: this.yLabel(),\n yTicks: this.yTicks(),\n })\n );\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/graph/graph.ts"
},
{
"path": "registry/bases/forme/components/graph/graph.types.ts",
- "content": "import type { Style } from \"@/lib/pdf-primitives\";\n\n/**\n * Options for calculating graph width based on theme page margins and container context.\n * Props - `containerPadding` | `wrapperPadding` | `pageWidth`\n * @see {@link GraphWidthOptions}\n */\nexport interface GraphWidthOptions {\n containerPadding?: number;\n wrapperPadding?: number;\n pageWidth?: number;\n}\n\nexport type GraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\nexport type GraphLegendPosition = \"bottom\" | \"right\" | \"none\";\n\n/**\n * A single data point with a label, numeric value, and optional color override.\n * Props - `label` | `value` | `color`\n * @see {@link GraphDataPoint}\n */\nexport interface GraphDataPoint {\n label: string;\n value: number;\n color?: string;\n}\n\n/**\n * A named data series containing multiple data points, used for multi-series charts.\n * Props - `name` | `data` | `color`\n * @see {@link GraphSeries}\n */\nexport interface GraphSeries {\n name: string;\n data: GraphDataPoint[];\n color?: string;\n}\n\n/**\n * Multi-variant PDF chart (bar, line, area, pie, donut) rendered with SVG primitives.\n * Props - `variant` | `data` | `title` | `subtitle` | `xLabel` | `yLabel` | `width` | `height` | `fullWidth` | `containerPadding` | `wrapperPadding` | `colors` | `showValues` | `showGrid` | `legend` | `centerLabel` | `showDots` | `smooth` | `yTicks` | `noWrap` | `style`\n * @see {@link GraphProps}\n */\nexport interface GraphProps {\n /**\n * @default 'bar'\n */\n variant?: GraphVariant;\n data: GraphDataPoint[] | GraphSeries[];\n title?: string;\n subtitle?: string;\n xLabel?: string;\n yLabel?: string;\n /**\n * @default 420\n */\n width?: number;\n /**\n * @default 260\n */\n height?: number;\n /**\n * @default false\n */\n fullWidth?: boolean;\n containerPadding?: number;\n wrapperPadding?: number;\n colors?: string[];\n /**\n * @default false\n */\n showValues?: boolean;\n /**\n * @default true\n */\n showGrid?: boolean;\n /**\n * @default 'bottom'\n */\n legend?: GraphLegendPosition;\n centerLabel?: string;\n /**\n * @default true\n */\n showDots?: boolean;\n /**\n * @default false\n */\n smooth?: boolean;\n /**\n * @default 5\n */\n yTicks?: number;\n /**\n * @default true\n */\n noWrap?: boolean;\n style?: Style;\n}\n\n/** Internal chart layout dimensions computed from props and data. */\nexport interface ChartLayout {\n svgW: number;\n svgH: number;\n chartX: number;\n chartY: number;\n chartW: number;\n chartH: number;\n yMin: number;\n yMax: number;\n yTicks: number[];\n xLabels: string[];\n}\n",
+ "content": "import type { Style } from \"@/lib/pdf-primitives\";\n\n/**\n * Options for calculating graph width based on theme page margins and container context.\n * Props - `containerPadding` | `wrapperPadding` | `pageWidth`\n * @see {@link GraphWidthOptions}\n */\nexport interface GraphWidthOptions {\n containerPadding?: number;\n wrapperPadding?: number;\n pageWidth?: number;\n}\n\nexport type GraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\nexport type GraphLegendPosition = \"bottom\" | \"right\" | \"none\";\n\n/**\n * A single data point with a label, numeric value, and optional color override.\n * Props - `label` | `value` | `color`\n * @see {@link GraphDataPoint}\n */\nexport interface GraphDataPoint {\n label: string;\n value: number;\n color?: string;\n}\n\n/**\n * A named data series containing multiple data points, used for multi-series charts.\n * Props - `name` | `data` | `color`\n * @see {@link GraphSeries}\n */\nexport interface GraphSeries {\n name: string;\n data: GraphDataPoint[];\n color?: string;\n}\n\n/**\n * Multi-variant PDF chart (bar, line, area, pie, donut) rendered with SVG primitives.\n * Props - `variant` | `data` | `title` | `subtitle` | `xLabel` | `yLabel` | `width` | `height` | `fullWidth` | `containerPadding` | `wrapperPadding` | `colors` | `showValues` | `showGrid` | `legend` | `centerLabel` | `showDots` | `smooth` | `yTicks` | `noWrap` | `style`\n * @see {@link GraphProps}\n */\nexport interface GraphProps {\n /**\n * @default 'bar'\n */\n variant?: GraphVariant;\n data: GraphDataPoint[] | GraphSeries[];\n title?: string;\n subtitle?: string;\n xLabel?: string;\n yLabel?: string;\n /**\n * @default 420\n */\n width?: number;\n /**\n * @default 260\n */\n height?: number;\n /**\n * @default false\n */\n fullWidth?: boolean;\n containerPadding?: number;\n wrapperPadding?: number;\n colors?: string[];\n /**\n * @default false\n */\n showValues?: boolean;\n /**\n * @default true\n */\n showGrid?: boolean;\n /**\n * @default 'bottom'\n */\n legend?: GraphLegendPosition;\n centerLabel?: string;\n /**\n * @default true\n */\n showDots?: boolean;\n /**\n * @default false\n */\n smooth?: boolean;\n /**\n * @default 5\n */\n yTicks?: number;\n /**\n * @default true\n */\n noWrap?: boolean;\n style?: Style;\n}\n\n/** Internal chart layout dimensions computed from props and data. */\nexport interface ChartLayout {\n svgW: number;\n svgH: number;\n chartX: number;\n chartY: number;\n chartW: number;\n chartH: number;\n yMin: number;\n yMax: number;\n yTicks: number[];\n xLabels: string[];\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/graph/graph.types.ts"
},
{
"path": "registry/bases/forme/components/graph/graph.utils.ts",
- "content": "import type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type {\n ChartLayout,\n GraphDataPoint,\n GraphSeries,\n GraphWidthOptions,\n} from \"./graph.types\";\n\n/** Standard A4 page width in PDF points. */\nexport const A4_WIDTH = 595;\n\n/**\n * Pre-calculated safe graph widths for common scenarios.\n * These values work with all built-in themes on A4 pages.\n */\nexport const GRAPH_SAFE_WIDTHS = {\n /** Safe width for graph directly in page content (no extra containers) */\n default: 420,\n /** Safe width for graph inside a Section with md padding */\n inSection: 400,\n /** Safe width for graph inside a Section + bordered wrapper (like graphShell) */\n inSectionWithWrapper: 380,\n} as const;\n\n/**\n * Calculate the safe graph width based on theme page margins and container context.\n *\n * This utility ensures graphs don't overflow their container by accounting for:\n * - Page margins (from theme)\n * - Container padding (e.g., Section component)\n * - Wrapper padding (e.g., a bordered graphShell View)\n *\n * @example\n * ```ts\n * const width = getGraphWidth(theme);\n * // For a graph inside a Section with padding=\"md\" (12pt) and a graphShell (12pt):\n * const width = getGraphWidth(theme, { containerPadding: 12, wrapperPadding: 12 });\n * ```\n */\nexport const getGraphWidth = (\n theme: PdfcnTheme,\n options: GraphWidthOptions = {}\n): number => {\n const {\n containerPadding = 0,\n wrapperPadding = 0,\n pageWidth = A4_WIDTH,\n } = options;\n const { marginLeft, marginRight } = theme.spacing.page;\n const availableWidth =\n pageWidth -\n marginLeft -\n marginRight -\n containerPadding * 2 -\n wrapperPadding * 2;\n return Math.max(Math.floor(availableWidth), 100);\n};\n\nexport const CHART_MARGINS = {\n axisBottom: 24,\n axisLeft: 40,\n pieBottom: 10,\n pieLeft: 10,\n right: 10,\n top: 10,\n} as const;\n\n/** Normalize to always work with GraphSeries[]. */\nexport const normalizeData = (\n data: GraphDataPoint[] | GraphSeries[]\n): GraphSeries[] => {\n if (data.length === 0) {\n return [];\n }\n if (\"label\" in data[0] && \"value\" in data[0]) {\n return [{ data: data as GraphDataPoint[], name: \"Series 1\" }];\n }\n return data as GraphSeries[];\n};\n\n/** Compute nice Y-axis ticks for a given value range. */\nexport const computeYTicks = (\n min: number,\n max: number,\n count: number\n): number[] => {\n if (min === max) {\n return [0, max || 1];\n }\n const step = (max - min) / (count - 1);\n return Array.from({ length: count }, (_, i) => {\n const v = min + i * step;\n return Math.round(v * 100) / 100;\n });\n};\n\n/** Format a number for display on axis labels. */\nexport const fmtNum = (v: number): string => {\n if (Math.abs(v) >= 1_000_000) {\n return `${(v / 1_000_000).toFixed(1)}M`;\n }\n if (Math.abs(v) >= 1000) {\n return `${(v / 1000).toFixed(1)}K`;\n }\n if (!Number.isInteger(v)) {\n return v.toFixed(1);\n }\n return String(v);\n};\n\n/** Truncate a label to at most maxLen characters. */\nexport const truncate = (s: string, maxLen: number): string =>\n s.length > maxLen ? `${s.slice(0, maxLen - 1)}…` : s;\n\n/** Polar to Cartesian coordinate conversion for pie/donut arcs. */\nexport const polarToCartesian = (\n cx: number,\n cy: number,\n r: number,\n angleDeg: number\n) => {\n const rad = ((angleDeg - 90) * Math.PI) / 180;\n return { x: cx + r * Math.cos(rad), y: cy + r * Math.sin(rad) };\n};\n\n/** Build an SVG arc path for a pie/donut slice. */\nexport const arcPath = (\n cx: number,\n cy: number,\n r: number,\n startAngle: number,\n endAngle: number,\n innerR = 0\n): string => {\n const safeEnd = Math.min(endAngle, startAngle + 359.999);\n const large = safeEnd - startAngle > 180 ? 1 : 0;\n const s = polarToCartesian(cx, cy, r, safeEnd);\n const e = polarToCartesian(cx, cy, r, startAngle);\n if (innerR === 0) {\n return `M ${cx} ${cy} L ${s.x} ${s.y} A ${r} ${r} 0 ${large} 0 ${e.x} ${e.y} Z`;\n }\n const si = polarToCartesian(cx, cy, innerR, safeEnd);\n const ei = polarToCartesian(cx, cy, innerR, startAngle);\n return [\n `M ${s.x} ${s.y}`,\n `A ${r} ${r} 0 ${large} 0 ${e.x} ${e.y}`,\n `L ${ei.x} ${ei.y}`,\n `A ${innerR} ${innerR} 0 ${large} 1 ${si.x} ${si.y}`,\n \"Z\",\n ].join(\" \");\n};\n\n/** Compute smooth bezier control points (Catmull-Rom → cubic bezier). */\nexport const smoothPath = (\n points: { x: number; y: number }[],\n tension = 0.4\n): string => {\n if (points.length < 2) {\n return \"\";\n }\n if (points.length === 2) {\n return `M ${points[0].x} ${points[0].y} L ${points[1].x} ${points[1].y}`;\n }\n const parts: string[] = [`M ${points[0].x} ${points[0].y}`];\n for (let i = 0; i < points.length - 1; i += 1) {\n const p0 = points[Math.max(i - 1, 0)];\n const p1 = points[i];\n const p2 = points[i + 1];\n const p3 = points[Math.min(i + 2, points.length - 1)];\n const cp1x = p1.x + (p2.x - p0.x) * tension;\n const cp1y = p1.y + (p2.y - p0.y) * tension;\n const cp2x = p2.x - (p3.x - p1.x) * tension;\n const cp2y = p2.y - (p3.y - p1.y) * tension;\n parts.push(`C ${cp1x} ${cp1y} ${cp2x} ${cp2y} ${p2.x} ${p2.y}`);\n }\n return parts.join(\" \");\n};\n\n/** Get the default chart color palette from the theme. */\nexport const getDefaultPalette = (t: PdfcnTheme): string[] => [\n t.colors.primary,\n t.colors.info ?? \"#3B82F6\",\n t.colors.success ?? \"#22C55E\",\n t.colors.warning ?? \"#F59E0B\",\n t.colors.destructive ?? \"#EF4444\",\n \"#8B5CF6\",\n \"#F97316\",\n \"#14B8A6\",\n];\n\n/** Derive ChartLayout from series data, SVG dimensions, and variant. */\nexport const buildLayout = (\n series: GraphSeries[],\n width: number,\n height: number,\n isPieOrDonut: boolean,\n yTickCount: number\n): ChartLayout => {\n const mL = isPieOrDonut ? CHART_MARGINS.pieLeft : CHART_MARGINS.axisLeft;\n const mB = isPieOrDonut ? CHART_MARGINS.pieBottom : CHART_MARGINS.axisBottom;\n const chartX = mL;\n const chartY = CHART_MARGINS.top;\n const chartW = width - mL - CHART_MARGINS.right;\n const chartH = height - CHART_MARGINS.top - mB;\n const allValues = series.flatMap((s) => s.data.map((d) => d.value));\n const rawMin = Math.min(...allValues, 0);\n const rawMax = Math.max(...allValues, 1);\n const yMin = Math.min(0, rawMin);\n const yMax = rawMax + (rawMax - yMin) * 0.08;\n return {\n chartH,\n chartW,\n chartX,\n chartY,\n svgH: height,\n svgW: width,\n xLabels: series[0]?.data.map((d) => d.label) ?? [],\n yMax,\n yMin,\n yTicks: computeYTicks(yMin, yMax, yTickCount),\n };\n};\n",
+ "content": "import type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type {\n ChartLayout,\n GraphDataPoint,\n GraphSeries,\n GraphWidthOptions,\n} from \"./graph.types\";\n\n/** Standard A4 page width in PDF points. */\nexport const A4_WIDTH = 595;\n\n/**\n * Pre-calculated safe graph widths for common scenarios.\n * These values work with all built-in themes on A4 pages.\n */\nexport const GRAPH_SAFE_WIDTHS = {\n /** Safe width for graph directly in page content (no extra containers) */\n default: 420,\n /** Safe width for graph inside a Section with md padding */\n inSection: 400,\n /** Safe width for graph inside a Section + bordered wrapper (like graphShell) */\n inSectionWithWrapper: 380,\n} as const;\n\n/**\n * Calculate the safe graph width based on theme page margins and container context.\n *\n * This utility ensures graphs don't overflow their container by accounting for:\n * - Page margins (from theme)\n * - Container padding (e.g., Section component)\n * - Wrapper padding (e.g., a bordered graphShell View)\n *\n * @example\n * ```ts\n * const width = getGraphWidth(theme);\n * // For a graph inside a Section with padding=\"md\" (12pt) and a graphShell (12pt):\n * const width = getGraphWidth(theme, { containerPadding: 12, wrapperPadding: 12 });\n * ```\n */\nexport const getGraphWidth = (\n theme: PdfcnTheme,\n options: GraphWidthOptions = {}\n): number => {\n const {\n containerPadding = 0,\n wrapperPadding = 0,\n pageWidth = A4_WIDTH,\n } = options;\n const { marginLeft, marginRight } = theme.spacing.page;\n const availableWidth =\n pageWidth -\n marginLeft -\n marginRight -\n containerPadding * 2 -\n wrapperPadding * 2;\n return Math.max(Math.floor(availableWidth), 100);\n};\n\nexport const CHART_MARGINS = {\n axisBottom: 24,\n axisLeft: 40,\n pieBottom: 10,\n pieLeft: 10,\n right: 10,\n top: 10,\n} as const;\n\n/** Normalize to always work with GraphSeries[]. */\nexport const normalizeData = (\n data: GraphDataPoint[] | GraphSeries[]\n): GraphSeries[] => {\n if (data.length === 0) {\n return [];\n }\n if (\"label\" in data[0] && \"value\" in data[0]) {\n return [{ data: data as GraphDataPoint[], name: \"Series 1\" }];\n }\n return data as GraphSeries[];\n};\n\n/** Compute nice Y-axis ticks for a given value range. */\nexport const computeYTicks = (\n min: number,\n max: number,\n count: number\n): number[] => {\n if (min === max) {\n return [0, max || 1];\n }\n const step = (max - min) / (count - 1);\n return Array.from({ length: count }, (_, i) => {\n const v = min + i * step;\n return Math.round(v * 100) / 100;\n });\n};\n\n/** Format a number for display on axis labels. */\nexport const fmtNum = (v: number): string => {\n if (Math.abs(v) >= 1_000_000) {\n return `${(v / 1_000_000).toFixed(1)}M`;\n }\n if (Math.abs(v) >= 1000) {\n return `${(v / 1000).toFixed(1)}K`;\n }\n if (!Number.isInteger(v)) {\n return v.toFixed(1);\n }\n return String(v);\n};\n\n/** Truncate a label to at most maxLen characters. */\nexport const truncate = (s: string, maxLen: number): string =>\n s.length > maxLen ? `${s.slice(0, maxLen - 1)}…` : s;\n\n/** Polar to Cartesian coordinate conversion for pie/donut arcs. */\nexport const polarToCartesian = (\n cx: number,\n cy: number,\n r: number,\n angleDeg: number\n) => {\n const rad = ((angleDeg - 90) * Math.PI) / 180;\n return { x: cx + r * Math.cos(rad), y: cy + r * Math.sin(rad) };\n};\n\n/** Build an SVG arc path for a pie/donut slice. */\nexport const arcPath = (\n cx: number,\n cy: number,\n r: number,\n startAngle: number,\n endAngle: number,\n innerR = 0\n): string => {\n const safeEnd = Math.min(endAngle, startAngle + 359.999);\n const large = safeEnd - startAngle > 180 ? 1 : 0;\n const s = polarToCartesian(cx, cy, r, safeEnd);\n const e = polarToCartesian(cx, cy, r, startAngle);\n if (innerR === 0) {\n return `M ${cx} ${cy} L ${s.x} ${s.y} A ${r} ${r} 0 ${large} 0 ${e.x} ${e.y} Z`;\n }\n const si = polarToCartesian(cx, cy, innerR, safeEnd);\n const ei = polarToCartesian(cx, cy, innerR, startAngle);\n return [\n `M ${s.x} ${s.y}`,\n `A ${r} ${r} 0 ${large} 0 ${e.x} ${e.y}`,\n `L ${ei.x} ${ei.y}`,\n `A ${innerR} ${innerR} 0 ${large} 1 ${si.x} ${si.y}`,\n \"Z\",\n ].join(\" \");\n};\n\n/** Compute smooth bezier control points (Catmull-Rom → cubic bezier). */\nexport const smoothPath = (\n points: { x: number; y: number }[],\n tension = 0.4\n): string => {\n if (points.length < 2) {\n return \"\";\n }\n if (points.length === 2) {\n return `M ${points[0].x} ${points[0].y} L ${points[1].x} ${points[1].y}`;\n }\n const parts: string[] = [`M ${points[0].x} ${points[0].y}`];\n for (let i = 0; i < points.length - 1; i += 1) {\n const p0 = points[Math.max(i - 1, 0)];\n const p1 = points[i];\n const p2 = points[i + 1];\n const p3 = points[Math.min(i + 2, points.length - 1)];\n const cp1x = p1.x + (p2.x - p0.x) * tension;\n const cp1y = p1.y + (p2.y - p0.y) * tension;\n const cp2x = p2.x - (p3.x - p1.x) * tension;\n const cp2y = p2.y - (p3.y - p1.y) * tension;\n parts.push(`C ${cp1x} ${cp1y} ${cp2x} ${cp2y} ${p2.x} ${p2.y}`);\n }\n return parts.join(\" \");\n};\n\n/** Get the default chart color palette from the theme. */\nexport const getDefaultPalette = (t: PdfcnTheme): string[] => [\n t.colors.primary,\n t.colors.info ?? \"#3B82F6\",\n t.colors.success ?? \"#22C55E\",\n t.colors.warning ?? \"#F59E0B\",\n t.colors.destructive ?? \"#EF4444\",\n \"#8B5CF6\",\n \"#F97316\",\n \"#14B8A6\",\n];\n\n/** Derive ChartLayout from series data, SVG dimensions, and variant. */\nexport const buildLayout = (\n series: GraphSeries[],\n width: number,\n height: number,\n isPieOrDonut: boolean,\n yTickCount: number\n): ChartLayout => {\n const mL = isPieOrDonut ? CHART_MARGINS.pieLeft : CHART_MARGINS.axisLeft;\n const mB = isPieOrDonut ? CHART_MARGINS.pieBottom : CHART_MARGINS.axisBottom;\n const chartX = mL;\n const chartY = CHART_MARGINS.top;\n const chartW = width - mL - CHART_MARGINS.right;\n const chartH = height - CHART_MARGINS.top - mB;\n const allValues = series.flatMap((s) => s.data.map((d) => d.value));\n const rawMin = Math.min(...allValues, 0);\n const rawMax = Math.max(...allValues, 1);\n const yMin = Math.min(0, rawMin);\n const yMax = rawMax + (rawMax - yMin) * 0.08;\n return {\n chartH,\n chartW,\n chartX,\n chartY,\n svgH: height,\n svgW: width,\n xLabels: series[0]?.data.map((d) => d.label) ?? [],\n yMax,\n yMin,\n yTicks: computeYTicks(yMin, yMax, yTickCount),\n };\n};\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/graph/graph.utils.ts"
}
diff --git a/apps/web/public/r/forme/heading.json b/apps/web/public/r/forme/heading.json
index 51b0054..73f349a 100644
--- a/apps/web/public/r/forme/heading.json
+++ b/apps/web/public/r/forme/heading.json
@@ -3,17 +3,13 @@
"name": "forme/heading",
"title": "Heading",
"description": "Heading PDF component (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils"
],
"files": [
{
"path": "registry/bases/forme/components/heading/heading.ts",
- "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport {\n injectPdfcnTheme,\n mergePdfStyles,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeText,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type HeadingWeight = \"normal\" | \"medium\" | \"semibold\" | \"bold\";\nexport type HeadingTracking = \"tighter\" | \"tight\" | \"normal\" | \"wide\" | \"wider\";\n\n/**\n * PDF heading mapped to h1–h6 font sizes from the theme.\n * Props - `level` | `align` | `color` | `transform` | `weight` | `tracking` | `noMargin` | `keepWithNext` | `children` | `style`\n * @see {@link HeadingProps}\n */\nexport interface HeadingProps extends PDFComponentProps {\n /**\n * @default 1\n */\n level?: 1 | 2 | 3 | 4 | 5 | 6;\n /**\n * @default 'left'\n */\n align?: \"left\" | \"center\" | \"right\";\n color?: string;\n transform?: \"uppercase\" | \"lowercase\" | \"capitalize\";\n /**\n * @default 'bold'\n */\n weight?: HeadingWeight;\n /**\n * @default 'normal'\n */\n tracking?: HeadingTracking;\n /**\n * @default false\n */\n noMargin?: boolean;\n keepWithNext?: boolean;\n}\n\nconst createHeadingStyles = (t: PdfcnTheme) => {\n const { heading } = t.typography;\n const { spacing, fontWeights, letterSpacing } = t.primitives;\n const { sectionGap, componentGap, paragraphGap } = t.spacing;\n const base = {\n color: t.colors.foreground,\n fontFamily: heading.fontFamily,\n fontWeight: fontWeights.bold,\n lineHeight: heading.lineHeight,\n };\n return StyleSheet.create({\n capitalize: { textTransform: \"capitalize\" },\n h1: {\n ...base,\n fontSize: heading.fontSize.h1,\n marginBottom: paragraphGap,\n marginTop: spacing[0],\n },\n h2: {\n ...base,\n fontSize: heading.fontSize.h2,\n marginBottom: paragraphGap,\n marginTop: sectionGap,\n },\n h3: {\n ...base,\n fontSize: heading.fontSize.h3,\n marginBottom: paragraphGap,\n marginTop: componentGap,\n },\n h4: {\n ...base,\n fontSize: heading.fontSize.h4,\n marginBottom: paragraphGap,\n marginTop: paragraphGap,\n },\n h5: {\n ...base,\n fontSize: heading.fontSize.h5,\n marginBottom: spacing[1],\n marginTop: paragraphGap,\n },\n h6: {\n ...base,\n fontSize: heading.fontSize.h6,\n marginBottom: spacing[1],\n marginTop: paragraphGap,\n },\n lowercase: { textTransform: \"lowercase\" },\n noMargin: { marginBottom: 0, marginTop: 0 },\n trackingNormal: { letterSpacing: letterSpacing.normal },\n trackingTight: { letterSpacing: letterSpacing.tight * 10 },\n trackingTighter: { letterSpacing: letterSpacing.tight * 15 },\n trackingWide: { letterSpacing: letterSpacing.wide * 10 },\n trackingWider: { letterSpacing: letterSpacing.wider * 10 },\n uppercase: {\n letterSpacing: letterSpacing.wider * 10,\n textTransform: \"uppercase\",\n },\n weightBold: { fontWeight: fontWeights.bold },\n weightMedium: { fontWeight: fontWeights.medium },\n weightNormal: { fontWeight: fontWeights.regular },\n weightSemibold: { fontWeight: fontWeights.semibold },\n });\n};\n\nconst headingStyle = (\n theme: PdfcnTheme,\n {\n level = 1,\n align,\n color,\n transform,\n weight,\n tracking,\n noMargin,\n style,\n }: HeadingProps\n) => {\n const styles = createHeadingStyles(theme);\n const safeLevel = Math.min(Math.max(Math.round(level), 1), 6) as\n | 1\n | 2\n | 3\n | 4\n | 5\n | 6;\n const weightMap = {\n bold: styles.weightBold,\n medium: styles.weightMedium,\n normal: styles.weightNormal,\n semibold: styles.weightSemibold,\n };\n const trackingMap = {\n normal: styles.trackingNormal,\n tight: styles.trackingTight,\n tighter: styles.trackingTighter,\n wide: styles.trackingWide,\n wider: styles.trackingWider,\n };\n const transformMap = {\n capitalize: styles.capitalize,\n lowercase: styles.lowercase,\n uppercase: styles.uppercase,\n };\n const styleArray: Style[] = [\n styles[`h${safeLevel}` as keyof typeof styles] as Style,\n ];\n if (weight && weight in weightMap) {\n styleArray.push(weightMap[weight]);\n }\n if (tracking && tracking in trackingMap) {\n styleArray.push(trackingMap[tracking]);\n }\n if (transform && transform in transformMap) {\n styleArray.push(transformMap[transform as keyof typeof transformMap]);\n }\n if (noMargin) {\n styleArray.push(styles.noMargin);\n }\n const semantic = {} as Style;\n if (align) {\n semantic.textAlign = align;\n }\n if (color) {\n semantic.color = resolveColor(color, theme.colors);\n }\n if (Object.keys(semantic).length > 0) {\n styleArray.push(semantic);\n }\n if (style) {\n styleArray.push(...[style].flat());\n }\n return mergePdfStyles(styleArray);\n};\n\n@Component({\n imports: [FormeText],\n selector: \"pdf-heading\",\n template: ``,\n})\nexport class PdfHeading {\n readonly level = input(1);\n readonly align = input();\n readonly color = input();\n readonly transform = input();\n readonly weight = input();\n readonly tracking = input();\n readonly noMargin = input(false, { transform: booleanAttribute });\n /** Part of the props API but unused, as in the original. */\n readonly keepWithNext = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly headingStyle = computed(() =>\n headingStyle(this.theme(), {\n align: this.align(),\n color: this.color(),\n level: this.level(),\n noMargin: this.noMargin(),\n style: this.style(),\n tracking: this.tracking(),\n transform: this.transform(),\n weight: this.weight(),\n })\n );\n}\n",
+ "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport {\n injectPdfcnTheme,\n mergePdfStyles,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeText,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type HeadingWeight = \"normal\" | \"medium\" | \"semibold\" | \"bold\";\nexport type HeadingTracking = \"tighter\" | \"tight\" | \"normal\" | \"wide\" | \"wider\";\n\n/**\n * PDF heading mapped to h1–h6 font sizes from the theme.\n * Props - `level` | `align` | `color` | `transform` | `weight` | `tracking` | `noMargin` | `keepWithNext` | `children` | `style`\n * @see {@link HeadingProps}\n */\nexport interface HeadingProps extends PDFComponentProps {\n /**\n * @default 1\n */\n level?: 1 | 2 | 3 | 4 | 5 | 6;\n /**\n * @default 'left'\n */\n align?: \"left\" | \"center\" | \"right\";\n color?: string;\n transform?: \"uppercase\" | \"lowercase\" | \"capitalize\";\n /**\n * @default 'bold'\n */\n weight?: HeadingWeight;\n /**\n * @default 'normal'\n */\n tracking?: HeadingTracking;\n /**\n * @default false\n */\n noMargin?: boolean;\n keepWithNext?: boolean;\n}\n\nconst createHeadingStyles = (t: PdfcnTheme) => {\n const { heading } = t.typography;\n const { spacing, fontWeights, letterSpacing } = t.primitives;\n const { sectionGap, componentGap, paragraphGap } = t.spacing;\n const base = {\n color: t.colors.foreground,\n fontFamily: heading.fontFamily,\n fontWeight: fontWeights.bold,\n lineHeight: heading.lineHeight,\n };\n return StyleSheet.create({\n capitalize: { textTransform: \"capitalize\" },\n h1: {\n ...base,\n fontSize: heading.fontSize.h1,\n marginBottom: paragraphGap,\n marginTop: spacing[0],\n },\n h2: {\n ...base,\n fontSize: heading.fontSize.h2,\n marginBottom: paragraphGap,\n marginTop: sectionGap,\n },\n h3: {\n ...base,\n fontSize: heading.fontSize.h3,\n marginBottom: paragraphGap,\n marginTop: componentGap,\n },\n h4: {\n ...base,\n fontSize: heading.fontSize.h4,\n marginBottom: paragraphGap,\n marginTop: paragraphGap,\n },\n h5: {\n ...base,\n fontSize: heading.fontSize.h5,\n marginBottom: spacing[1],\n marginTop: paragraphGap,\n },\n h6: {\n ...base,\n fontSize: heading.fontSize.h6,\n marginBottom: spacing[1],\n marginTop: paragraphGap,\n },\n lowercase: { textTransform: \"lowercase\" },\n noMargin: { marginBottom: 0, marginTop: 0 },\n trackingNormal: { letterSpacing: letterSpacing.normal },\n trackingTight: { letterSpacing: letterSpacing.tight * 10 },\n trackingTighter: { letterSpacing: letterSpacing.tight * 15 },\n trackingWide: { letterSpacing: letterSpacing.wide * 10 },\n trackingWider: { letterSpacing: letterSpacing.wider * 10 },\n uppercase: {\n letterSpacing: letterSpacing.wider * 10,\n textTransform: \"uppercase\",\n },\n weightBold: { fontWeight: fontWeights.bold },\n weightMedium: { fontWeight: fontWeights.medium },\n weightNormal: { fontWeight: fontWeights.regular },\n weightSemibold: { fontWeight: fontWeights.semibold },\n });\n};\n\nconst headingStyle = (\n theme: PdfcnTheme,\n {\n level = 1,\n align,\n color,\n transform,\n weight,\n tracking,\n noMargin,\n style,\n }: HeadingProps\n) => {\n const styles = createHeadingStyles(theme);\n const safeLevel = Math.min(Math.max(Math.round(level), 1), 6) as\n | 1\n | 2\n | 3\n | 4\n | 5\n | 6;\n const weightMap = {\n bold: styles.weightBold,\n medium: styles.weightMedium,\n normal: styles.weightNormal,\n semibold: styles.weightSemibold,\n };\n const trackingMap = {\n normal: styles.trackingNormal,\n tight: styles.trackingTight,\n tighter: styles.trackingTighter,\n wide: styles.trackingWide,\n wider: styles.trackingWider,\n };\n const transformMap = {\n capitalize: styles.capitalize,\n lowercase: styles.lowercase,\n uppercase: styles.uppercase,\n };\n const styleArray: Style[] = [\n styles[`h${safeLevel}` as keyof typeof styles] as Style,\n ];\n if (weight && weight in weightMap) {\n styleArray.push(weightMap[weight]);\n }\n if (tracking && tracking in trackingMap) {\n styleArray.push(trackingMap[tracking]);\n }\n if (transform && transform in transformMap) {\n styleArray.push(transformMap[transform as keyof typeof transformMap]);\n }\n if (noMargin) {\n styleArray.push(styles.noMargin);\n }\n const semantic = {} as Style;\n if (align) {\n semantic.textAlign = align;\n }\n if (color) {\n semantic.color = resolveColor(color, theme.colors);\n }\n if (Object.keys(semantic).length > 0) {\n styleArray.push(semantic);\n }\n if (style) {\n styleArray.push(...[style].flat());\n }\n return mergePdfStyles(styleArray);\n};\n\n@Component({\n imports: [FormeText],\n selector: \"pdf-heading\",\n template: ``,\n})\nexport class PdfHeading {\n readonly level = input(1);\n readonly align = input();\n readonly color = input();\n readonly transform = input();\n readonly weight = input();\n readonly tracking = input();\n readonly noMargin = input(false, { transform: booleanAttribute });\n /** Part of the props API but unused, as in the original. */\n readonly keepWithNext = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly headingStyle = computed(() =>\n headingStyle(this.theme(), {\n align: this.align(),\n color: this.color(),\n level: this.level(),\n noMargin: this.noMargin(),\n style: this.style(),\n tracking: this.tracking(),\n transform: this.transform(),\n weight: this.weight(),\n })\n );\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/heading/heading.ts"
}
diff --git a/apps/web/public/r/forme/invoice-classic.json b/apps/web/public/r/forme/invoice-classic.json
index ce620f5..9359a06 100644
--- a/apps/web/public/r/forme/invoice-classic.json
+++ b/apps/web/public/r/forme/invoice-classic.json
@@ -3,10 +3,6 @@
"name": "forme/invoice-classic",
"title": "Invoice Classic",
"description": "Invoice Classic PDF block (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils",
"@angular-pdfcn/forme/key-value",
@@ -20,13 +16,13 @@
"files": [
{
"path": "registry/bases/forme/blocks/invoice-classic/invoice-classic.ts",
- "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport type { KeyValueEntry } from \"@/components/pdf/key-value/key-value\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfImage } from \"@/components/pdf/pdf-image/pdf-image\";\nimport { PdfSection } from \"@/components/pdf/section/section\";\nimport { TABLE } from \"@/components/pdf/table/table\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { InvoiceClassicData } from \"./invoice-classic.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: InvoiceClassicData = {\n billTo: {\n address: \"456 Client Ave, Suite 2\",\n email: \"contact@clientcorp.com\",\n name: \"Client Corp.\",\n phone: \"+1 (555) 123-4567\",\n },\n companyAddress: \"Nagpur, IN\",\n companyEmail: \"hello@pdfcn.app\",\n companyName: \"pdfcn\",\n dueDate: \"March 17, 2026\",\n invoiceDate: \"February 17, 2026\",\n invoiceNumber: \"INV-2026-001\",\n items: [\n { description: \"Web Development\", quantity: 1, unitPrice: 12_500 },\n { description: \"UI/UX Design\", quantity: 1, unitPrice: 8750 },\n { description: \"Consulting\", quantity: 10, unitPrice: 1500 },\n ],\n logo: \"/favicon.png\",\n notes: \"Thank you for your business!\",\n paymentTerms: {\n dueDate: \"March 17, 2026\",\n gst: \"GSTIN 123456789\",\n method: \"UPI / Card / Bank Transfer\",\n },\n subtitle: \"Innovative PDF Solutions\",\n summary: {\n subtotal: 36_250,\n tax: 2537.5,\n total: 38_787.5,\n },\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfImage,\n PdfKeyValue,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-invoice-classic-content\",\n template: `\n @let data = this.data();\n \n \n \n \n \n \n \n \n \n \n From\n {{ data.companyName }}\n {{\n data.companyAddress\n }}\n {{ data.companyEmail }}\n \n \n Bill To\n {{ data.billTo.name }}\n {{\n data.billTo.address\n }}\n {{ data.billTo.email }}\n \n \n Payment Terms\n {{\n data.paymentTerms.method\n }}\n {{\n data.paymentTerms.gst\n }}\n {{\n data.paymentTerms.dueDate\n }}\n \n \n \n \n \n Description\n QTY\n Rate\n Total\n \n \n \n @for (item of data.items; track $index) {\n \n {{ item.description }}\n {{\n item.quantity\n }}\n {{\n \"$\" + item.unitPrice\n }}\n {{\n \"$\" + (item.quantity * item.unitPrice).toFixed(2)\n }}\n \n }\n \n \n \n \n \n \n \n \n \n \n `,\n})\nexport class InvoiceClassicContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() =>\n StyleSheet.create({\n page: {\n backgroundColor: this.theme().colors.background,\n },\n })\n );\n\n protected readonly labelStyle = {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\n };\n\n protected readonly summaryItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n return [\n {\n key: \"Subtotal\",\n value: `$${data.summary.subtotal.toFixed(2)}`,\n },\n { key: \"Tax\", value: `$${data.summary.tax.toFixed(2)}` },\n {\n key: \"Total\",\n keyStyle: { fontSize: 12, fontWeight: \"bold\" },\n value: `$${data.summary.total.toFixed(2)}`,\n valueStyle: { fontSize: 12, fontWeight: \"bold\" },\n },\n ];\n });\n}\n\n@Component({\n imports: [InvoiceClassicContent, PdfcnThemeProvider],\n selector: \"pdf-invoice-classic\",\n template: `\n \n \n \n `,\n})\nexport class InvoiceClassicDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n",
+ "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport type { KeyValueEntry } from \"@/components/pdf/key-value/key-value\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfImage } from \"@/components/pdf/pdf-image/pdf-image\";\nimport { PdfSection } from \"@/components/pdf/section/section\";\nimport { TABLE } from \"@/components/pdf/table/table\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { InvoiceClassicData } from \"./invoice-classic.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: InvoiceClassicData = {\n billTo: {\n address: \"456 Client Ave, Suite 2\",\n email: \"contact@clientcorp.com\",\n name: \"Client Corp.\",\n phone: \"+1 (555) 123-4567\",\n },\n companyAddress: \"Nagpur, IN\",\n companyEmail: \"hello@pdfcn.app\",\n companyName: \"pdfcn\",\n dueDate: \"March 17, 2026\",\n invoiceDate: \"February 17, 2026\",\n invoiceNumber: \"INV-2026-001\",\n items: [\n { description: \"Web Development\", quantity: 1, unitPrice: 12_500 },\n { description: \"UI/UX Design\", quantity: 1, unitPrice: 8750 },\n { description: \"Consulting\", quantity: 10, unitPrice: 1500 },\n ],\n logo: \"/favicon.png\",\n notes: \"Thank you for your business!\",\n paymentTerms: {\n dueDate: \"March 17, 2026\",\n gst: \"GSTIN 123456789\",\n method: \"UPI / Card / Bank Transfer\",\n },\n subtitle: \"Innovative PDF Solutions\",\n summary: {\n subtotal: 36_250,\n tax: 2537.5,\n total: 38_787.5,\n },\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfImage,\n PdfKeyValue,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-invoice-classic-content\",\n template: `\n @let data = this.data();\n \n \n \n \n \n \n \n \n \n \n From\n {{ data.companyName }}\n {{\n data.companyAddress\n }}\n {{ data.companyEmail }}\n \n \n Bill To\n {{ data.billTo.name }}\n {{\n data.billTo.address\n }}\n {{ data.billTo.email }}\n \n \n Payment Terms\n {{\n data.paymentTerms.method\n }}\n {{\n data.paymentTerms.gst\n }}\n {{\n data.paymentTerms.dueDate\n }}\n \n \n \n \n \n Description\n QTY\n Rate\n Total\n \n \n \n @for (item of data.items; track $index) {\n \n {{ item.description }}\n {{\n item.quantity\n }}\n {{\n \"$\" + item.unitPrice\n }}\n {{\n \"$\" + (item.quantity * item.unitPrice).toFixed(2)\n }}\n \n }\n \n \n \n \n \n \n \n \n \n \n `,\n})\nexport class InvoiceClassicContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() =>\n StyleSheet.create({\n page: {\n backgroundColor: this.theme().colors.background,\n },\n })\n );\n\n protected readonly labelStyle = {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\n };\n\n protected readonly summaryItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n return [\n {\n key: \"Subtotal\",\n value: `$${data.summary.subtotal.toFixed(2)}`,\n },\n { key: \"Tax\", value: `$${data.summary.tax.toFixed(2)}` },\n {\n key: \"Total\",\n keyStyle: { fontSize: 12, fontWeight: \"bold\" },\n value: `$${data.summary.total.toFixed(2)}`,\n valueStyle: { fontSize: 12, fontWeight: \"bold\" },\n },\n ];\n });\n}\n\n@Component({\n imports: [InvoiceClassicContent, PdfcnThemeProvider],\n selector: \"pdf-invoice-classic\",\n template: `\n \n \n \n `,\n})\nexport class InvoiceClassicDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/invoice-classic/invoice-classic.ts"
},
{
"path": "registry/bases/forme/blocks/invoice-classic/invoice-classic.types.ts",
- "content": "export interface InvoiceClassicData {\n invoiceNumber: string;\n invoiceDate: string;\n dueDate: string;\n companyName: string;\n subtitle: string;\n companyAddress: string;\n companyEmail: string;\n logo?: string;\n billTo: {\n name: string;\n address: string;\n email: string;\n phone: string;\n };\n items: {\n description: string;\n quantity: number;\n unitPrice: number;\n }[];\n summary: {\n subtotal: number;\n tax: number;\n total: number;\n };\n paymentTerms: {\n dueDate: string;\n method: string;\n gst: string;\n };\n notes?: string;\n}\n",
+ "content": "export interface InvoiceClassicData {\n invoiceNumber: string;\n invoiceDate: string;\n dueDate: string;\n companyName: string;\n subtitle: string;\n companyAddress: string;\n companyEmail: string;\n logo?: string;\n billTo: {\n name: string;\n address: string;\n email: string;\n phone: string;\n };\n items: {\n description: string;\n quantity: number;\n unitPrice: number;\n }[];\n summary: {\n subtotal: number;\n tax: number;\n total: number;\n };\n paymentTerms: {\n dueDate: string;\n method: string;\n gst: string;\n };\n notes?: string;\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/invoice-classic/invoice-classic.types.ts"
}
diff --git a/apps/web/public/r/forme/invoice-consultant.json b/apps/web/public/r/forme/invoice-consultant.json
index 8c5067d..d080e07 100644
--- a/apps/web/public/r/forme/invoice-consultant.json
+++ b/apps/web/public/r/forme/invoice-consultant.json
@@ -3,10 +3,6 @@
"name": "forme/invoice-consultant",
"title": "Invoice Consultant",
"description": "Invoice Consultant PDF block (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils",
"@angular-pdfcn/forme/key-value",
@@ -18,13 +14,13 @@
"files": [
{
"path": "registry/bases/forme/blocks/invoice-consultant/invoice-consultant.ts",
- "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport type { KeyValueEntry } from \"@/components/pdf/key-value/key-value\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfSection } from \"@/components/pdf/section/section\";\nimport { TABLE } from \"@/components/pdf/table/table\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { InvoiceConsultantData } from \"./invoice-consultant.types\";\n\nconst sampleData: InvoiceConsultantData = {\n client: {\n address: \"500 Tech Park, Suite 200\",\n company: \"Acme Technologies\",\n email: \"sarah.johnson@acmetech.com\",\n name: \"Sarah Johnson\",\n },\n companyAddress: \"Nagpur, IN · hello@pdfcn.app\",\n companyName: \"pdfcn\",\n consultant: {\n email: \"john.smith@pdfcn.app\",\n name: \"John Smith\",\n title: \"Senior Technical Consultant\",\n },\n dueDate: \"March 28, 2026\",\n invoiceDate: \"February 26, 2026\",\n invoiceNumber: \"INV-2026-006\",\n notes:\n \"Services rendered for February 2026. All hours verified and approved by client.\",\n paymentTerms: {\n dueDate: \"March 28, 2026\",\n method: \"Bank Transfer / Check\",\n },\n projectRef: \"PROJ-2026-ACME-001\",\n services: [\n { description: \"Architecture Review & Planning\", hours: 16, rate: 175 },\n { description: \"Code Review & Optimization\", hours: 24, rate: 150 },\n { description: \"Technical Documentation\", hours: 12, rate: 125 },\n { description: \"Team Training & Knowledge Transfer\", hours: 8, rate: 200 },\n ],\n subtitle: \"Professional Consulting Services\",\n summary: {\n subtotal: 9500,\n tax: 475,\n total: 9975,\n totalHours: 60,\n },\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfKeyValue,\n PdfPageFooter,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-invoice-consultant-content\",\n template: `\n @let data = this.data();\n @let s = styles();\n \n \n \n \n \n \n {{\n data.companyName\n }}\n {{\n data.subtitle\n }}\n {{\n data.companyAddress\n }}\n \n \n Invoice\n {{\n data.invoiceNumber\n }}\n {{\n data.invoiceDate\n }}\n Due: {{ data.dueDate }}\n \n \n @if (data.projectRef) {\n \n Project Reference:\n {{\n data.projectRef\n }}\n \n }\n \n \n From (Consultant)\n {{\n data.consultant.name\n }}\n {{\n data.consultant.title\n }}\n {{\n data.consultant.email\n }}\n \n \n Bill To (Client)\n {{\n data.client.name\n }}\n {{\n data.client.company\n }}\n {{\n data.client.address\n }}\n {{\n data.client.email\n }}\n \n \n \n \n \n Service Description\n Hours\n Rate ($/hr)\n Amount\n \n \n \n @for (service of data.services; track $index) {\n \n {{ service.description }}\n {{\n service.hours\n }}\n {{\n \"$\" + service.rate\n }}\n {{\n \"$\" + (service.hours * service.rate).toLocaleString()\n }}\n \n }\n \n \n \n \n \n Total Hours: {{ data.summary.totalHours }}\n \n Payment: {{ data.paymentTerms.method }}\n \n \n \n \n \n @if (data.notes) {\n \n {{\n data.notes\n }}\n \n }\n \n \n \n `,\n})\nexport class InvoiceConsultantContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() => {\n const theme = this.theme();\n return StyleSheet.create({\n calloutNote: {\n backgroundColor: theme.colors.muted,\n borderLeftColor: theme.colors.info,\n borderLeftStyle: \"solid\",\n borderLeftWidth: 3,\n marginTop: 16,\n paddingLeft: 12,\n paddingVertical: 8,\n },\n companyInfo: {\n flex: 1,\n },\n headerRow: {\n alignItems: \"flex-start\",\n borderBottomColor: theme.colors.primary,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 2,\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: theme.spacing.sectionGap,\n paddingBottom: theme.spacing.componentGap,\n },\n hoursBadge: {\n alignSelf: \"flex-start\",\n backgroundColor: theme.colors.primary,\n borderRadius: theme.primitives.borderRadius.sm,\n color: theme.colors.primaryForeground,\n paddingHorizontal: 12,\n paddingVertical: 8,\n },\n hoursBox: {\n flex: 1,\n paddingRight: 24,\n },\n invoiceInfo: {\n alignItems: \"flex-end\",\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n partiesRow: {\n flexDirection: \"row\",\n gap: 40,\n marginBottom: theme.spacing.sectionGap,\n },\n partyColumn: {\n flex: 1,\n },\n partyLabel: {\n borderBottomColor: theme.colors.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n color: theme.colors.primary,\n fontSize: 9,\n fontWeight: \"bold\",\n letterSpacing: 0.6,\n marginBottom: 6,\n paddingBottom: 4,\n textTransform: \"uppercase\",\n },\n projectRef: {\n alignItems: \"center\",\n backgroundColor: theme.colors.muted,\n borderRadius: theme.primitives.borderRadius.sm,\n flexDirection: \"row\",\n gap: 8,\n marginBottom: theme.spacing.sectionGap,\n paddingHorizontal: 10,\n paddingVertical: 6,\n },\n summaryRow: {\n flexDirection: \"row\",\n marginTop: 20,\n },\n totalsBox: {\n width: 250,\n },\n });\n });\n\n protected readonly hoursTextStyle = computed(() => ({\n color: this.theme().colors.primaryForeground,\n fontSize: 9,\n fontWeight: \"bold\",\n }));\n\n protected readonly summaryItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n const theme = this.theme();\n return [\n {\n key: \"Subtotal\",\n value: `$${data.summary.subtotal.toLocaleString()}`,\n },\n { key: \"Tax (5%)\", value: `$${data.summary.tax.toFixed(2)}` },\n {\n key: \"Amount Due\",\n keyStyle: { fontSize: 13, fontWeight: \"bold\" },\n value: `$${data.summary.total.toFixed(2)}`,\n valueStyle: {\n color: theme.colors.primary,\n fontSize: 14,\n fontWeight: \"bold\",\n },\n },\n ];\n });\n}\n\n@Component({\n imports: [InvoiceConsultantContent, PdfcnThemeProvider],\n selector: \"pdf-invoice-consultant\",\n template: `\n \n \n \n `,\n})\nexport class InvoiceConsultantDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n",
+ "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport type { KeyValueEntry } from \"@/components/pdf/key-value/key-value\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfSection } from \"@/components/pdf/section/section\";\nimport { TABLE } from \"@/components/pdf/table/table\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { InvoiceConsultantData } from \"./invoice-consultant.types\";\n\nconst sampleData: InvoiceConsultantData = {\n client: {\n address: \"500 Tech Park, Suite 200\",\n company: \"Acme Technologies\",\n email: \"sarah.johnson@acmetech.com\",\n name: \"Sarah Johnson\",\n },\n companyAddress: \"Nagpur, IN · hello@pdfcn.app\",\n companyName: \"pdfcn\",\n consultant: {\n email: \"john.smith@pdfcn.app\",\n name: \"John Smith\",\n title: \"Senior Technical Consultant\",\n },\n dueDate: \"March 28, 2026\",\n invoiceDate: \"February 26, 2026\",\n invoiceNumber: \"INV-2026-006\",\n notes:\n \"Services rendered for February 2026. All hours verified and approved by client.\",\n paymentTerms: {\n dueDate: \"March 28, 2026\",\n method: \"Bank Transfer / Check\",\n },\n projectRef: \"PROJ-2026-ACME-001\",\n services: [\n { description: \"Architecture Review & Planning\", hours: 16, rate: 175 },\n { description: \"Code Review & Optimization\", hours: 24, rate: 150 },\n { description: \"Technical Documentation\", hours: 12, rate: 125 },\n { description: \"Team Training & Knowledge Transfer\", hours: 8, rate: 200 },\n ],\n subtitle: \"Professional Consulting Services\",\n summary: {\n subtotal: 9500,\n tax: 475,\n total: 9975,\n totalHours: 60,\n },\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfKeyValue,\n PdfPageFooter,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-invoice-consultant-content\",\n template: `\n @let data = this.data();\n @let s = styles();\n \n \n \n \n \n \n {{\n data.companyName\n }}\n {{\n data.subtitle\n }}\n {{\n data.companyAddress\n }}\n \n \n Invoice\n {{\n data.invoiceNumber\n }}\n {{\n data.invoiceDate\n }}\n Due: {{ data.dueDate }}\n \n \n @if (data.projectRef) {\n \n Project Reference:\n {{\n data.projectRef\n }}\n \n }\n \n \n From (Consultant)\n {{\n data.consultant.name\n }}\n {{\n data.consultant.title\n }}\n {{\n data.consultant.email\n }}\n \n \n Bill To (Client)\n {{\n data.client.name\n }}\n {{\n data.client.company\n }}\n {{\n data.client.address\n }}\n {{\n data.client.email\n }}\n \n \n \n \n \n Service Description\n Hours\n Rate ($/hr)\n Amount\n \n \n \n @for (service of data.services; track $index) {\n \n {{ service.description }}\n {{\n service.hours\n }}\n {{\n \"$\" + service.rate\n }}\n {{\n \"$\" + (service.hours * service.rate).toLocaleString()\n }}\n \n }\n \n \n \n \n \n Total Hours: {{ data.summary.totalHours }}\n \n Payment: {{ data.paymentTerms.method }}\n \n \n \n \n \n @if (data.notes) {\n \n {{\n data.notes\n }}\n \n }\n \n \n \n `,\n})\nexport class InvoiceConsultantContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() => {\n const theme = this.theme();\n return StyleSheet.create({\n calloutNote: {\n backgroundColor: theme.colors.muted,\n borderLeftColor: theme.colors.info,\n borderLeftStyle: \"solid\",\n borderLeftWidth: 3,\n marginTop: 16,\n paddingLeft: 12,\n paddingVertical: 8,\n },\n companyInfo: {\n flex: 1,\n },\n headerRow: {\n alignItems: \"flex-start\",\n borderBottomColor: theme.colors.primary,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 2,\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: theme.spacing.sectionGap,\n paddingBottom: theme.spacing.componentGap,\n },\n hoursBadge: {\n alignSelf: \"flex-start\",\n backgroundColor: theme.colors.primary,\n borderRadius: theme.primitives.borderRadius.sm,\n color: theme.colors.primaryForeground,\n paddingHorizontal: 12,\n paddingVertical: 8,\n },\n hoursBox: {\n flex: 1,\n paddingRight: 24,\n },\n invoiceInfo: {\n alignItems: \"flex-end\",\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n partiesRow: {\n flexDirection: \"row\",\n gap: 40,\n marginBottom: theme.spacing.sectionGap,\n },\n partyColumn: {\n flex: 1,\n },\n partyLabel: {\n borderBottomColor: theme.colors.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n color: theme.colors.primary,\n fontSize: 9,\n fontWeight: \"bold\",\n letterSpacing: 0.6,\n marginBottom: 6,\n paddingBottom: 4,\n textTransform: \"uppercase\",\n },\n projectRef: {\n alignItems: \"center\",\n backgroundColor: theme.colors.muted,\n borderRadius: theme.primitives.borderRadius.sm,\n flexDirection: \"row\",\n gap: 8,\n marginBottom: theme.spacing.sectionGap,\n paddingHorizontal: 10,\n paddingVertical: 6,\n },\n summaryRow: {\n flexDirection: \"row\",\n marginTop: 20,\n },\n totalsBox: {\n width: 250,\n },\n });\n });\n\n protected readonly hoursTextStyle = computed(() => ({\n color: this.theme().colors.primaryForeground,\n fontSize: 9,\n fontWeight: \"bold\",\n }));\n\n protected readonly summaryItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n const theme = this.theme();\n return [\n {\n key: \"Subtotal\",\n value: `$${data.summary.subtotal.toLocaleString()}`,\n },\n { key: \"Tax (5%)\", value: `$${data.summary.tax.toFixed(2)}` },\n {\n key: \"Amount Due\",\n keyStyle: { fontSize: 13, fontWeight: \"bold\" },\n value: `$${data.summary.total.toFixed(2)}`,\n valueStyle: {\n color: theme.colors.primary,\n fontSize: 14,\n fontWeight: \"bold\",\n },\n },\n ];\n });\n}\n\n@Component({\n imports: [InvoiceConsultantContent, PdfcnThemeProvider],\n selector: \"pdf-invoice-consultant\",\n template: `\n \n \n \n `,\n})\nexport class InvoiceConsultantDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/invoice-consultant/invoice-consultant.ts"
},
{
"path": "registry/bases/forme/blocks/invoice-consultant/invoice-consultant.types.ts",
- "content": "export interface InvoiceConsultantData {\n invoiceNumber: string;\n invoiceDate: string;\n dueDate: string;\n companyName: string;\n subtitle: string;\n companyAddress: string;\n consultant: {\n name: string;\n title: string;\n email: string;\n };\n client: {\n name: string;\n company: string;\n address: string;\n email: string;\n };\n services: {\n description: string;\n hours: number;\n rate: number;\n }[];\n summary: {\n totalHours: number;\n subtotal: number;\n tax: number;\n total: number;\n };\n paymentTerms: {\n dueDate: string;\n method: string;\n };\n projectRef?: string;\n notes?: string;\n}\n",
+ "content": "export interface InvoiceConsultantData {\n invoiceNumber: string;\n invoiceDate: string;\n dueDate: string;\n companyName: string;\n subtitle: string;\n companyAddress: string;\n consultant: {\n name: string;\n title: string;\n email: string;\n };\n client: {\n name: string;\n company: string;\n address: string;\n email: string;\n };\n services: {\n description: string;\n hours: number;\n rate: number;\n }[];\n summary: {\n totalHours: number;\n subtotal: number;\n tax: number;\n total: number;\n };\n paymentTerms: {\n dueDate: string;\n method: string;\n };\n projectRef?: string;\n notes?: string;\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/invoice-consultant/invoice-consultant.types.ts"
}
diff --git a/apps/web/public/r/forme/invoice-corporate.json b/apps/web/public/r/forme/invoice-corporate.json
index a1e738a..97bff68 100644
--- a/apps/web/public/r/forme/invoice-corporate.json
+++ b/apps/web/public/r/forme/invoice-corporate.json
@@ -3,10 +3,6 @@
"name": "forme/invoice-corporate",
"title": "Invoice Corporate",
"description": "Invoice Corporate PDF block (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils",
"@angular-pdfcn/forme/key-value",
@@ -19,13 +15,13 @@
"files": [
{
"path": "registry/bases/forme/blocks/invoice-corporate/invoice-corporate.ts",
- "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport type { KeyValueEntry } from \"@/components/pdf/key-value/key-value\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfImage } from \"@/components/pdf/pdf-image/pdf-image\";\nimport { TABLE } from \"@/components/pdf/table/table\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { InvoiceCorporateData } from \"./invoice-corporate.types\";\n\nconst sampleData: InvoiceCorporateData = {\n billTo: {\n address: \"100 Corporate Plaza, Tower B\",\n email: \"accounts@globalindustries.com\",\n name: \"Global Industries Ltd.\",\n phone: \"+1 (555) 888-9999\",\n },\n companyAddress: \"Nagpur, IN\",\n companyEmail: \"hello@pdfcn.app\",\n companyName: \"pdfcn\",\n dueDate: \"March 24, 2026\",\n invoiceDate: \"February 22, 2026\",\n invoiceNumber: \"INV-2026-004\",\n items: [\n {\n description: \"Enterprise Software License\",\n quantity: 5,\n unitPrice: 4500,\n },\n { description: \"Implementation Services\", quantity: 1, unitPrice: 18_000 },\n {\n description: \"Training Workshop (per session)\",\n quantity: 3,\n unitPrice: 2500,\n },\n { description: \"Annual Support Package\", quantity: 1, unitPrice: 8500 },\n ],\n logo: \"/favicon.png\",\n notes:\n \"Corporate billing – Net 30 terms apply. For inquiries, contact accounts@pdfcn.app\",\n paymentTerms: {\n dueDate: \"March 24, 2026\",\n gst: \"GSTIN 987654321\",\n method: \"Wire Transfer / Corporate Account\",\n },\n subtitle: \"Innovative PDF Solutions\",\n summary: {\n subtotal: 56_500,\n tax: 4520,\n total: 61_020,\n },\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfImage,\n PdfKeyValue,\n PdfPageFooter,\n PdfPageHeader,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-invoice-corporate-content\",\n template: `\n @let data = this.data();\n @let s = styles();\n \n \n \n \n \n \n \n \n \n \n Invoice Details\n \n \n \n Bill To\n {{\n data.billTo.name\n }}\n {{\n data.billTo.address\n }}\n {{\n data.billTo.email\n }}\n {{\n data.billTo.phone\n }}\n \n \n \n \n \n Description\n Qty\n Unit Price\n Amount\n \n \n \n @for (item of data.items; track $index) {\n \n {{ item.description }}\n {{\n item.quantity\n }}\n {{\n \"$\" + item.unitPrice.toLocaleString()\n }}\n {{\n \"$\" + (item.quantity * item.unitPrice).toLocaleString()\n }}\n \n }\n \n \n \n \n \n \n \n \n \n \n \n \n `,\n})\nexport class InvoiceCorporateContent {\n readonly data = input.required();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() => {\n const theme = this.theme();\n return StyleSheet.create({\n infoColumn: {\n flex: 1,\n },\n infoGrid: {\n flexDirection: \"row\",\n gap: 24,\n marginBottom: theme.spacing.sectionGap,\n },\n infoLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n fontWeight: \"bold\",\n letterSpacing: 0.6,\n marginBottom: 6,\n textTransform: \"uppercase\",\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n summaryCard: {\n backgroundColor: theme.colors.muted,\n borderRadius: theme.primitives.borderRadius.md,\n marginTop: 20,\n padding: 16,\n },\n summaryRow: {\n flexDirection: \"row\",\n justifyContent: \"flex-end\",\n },\n });\n });\n\n protected readonly detailItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n return [\n { key: \"Invoice #\", value: data.invoiceNumber },\n { key: \"Issue Date\", value: data.invoiceDate },\n { key: \"Due Date\", value: data.dueDate },\n { key: \"Payment\", value: data.paymentTerms.method },\n ];\n });\n\n protected readonly summaryItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n const theme = this.theme();\n return [\n {\n key: \"Subtotal\",\n value: `$${data.summary.subtotal.toLocaleString()}`,\n },\n {\n key: \"Tax (8%)\",\n value: `$${data.summary.tax.toFixed(2)}`,\n },\n {\n key: \"Total Due\",\n keyStyle: { fontSize: 13, fontWeight: \"bold\" },\n value: `$${data.summary.total.toFixed(2)}`,\n valueStyle: {\n color: theme.colors.primary,\n fontSize: 14,\n fontWeight: \"bold\",\n },\n },\n ];\n });\n}\n\n@Component({\n imports: [InvoiceCorporateContent, PdfcnThemeProvider],\n selector: \"pdf-invoice-corporate\",\n template: `\n \n \n \n `,\n})\nexport class InvoiceCorporateDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n",
+ "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport type { KeyValueEntry } from \"@/components/pdf/key-value/key-value\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfImage } from \"@/components/pdf/pdf-image/pdf-image\";\nimport { TABLE } from \"@/components/pdf/table/table\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { InvoiceCorporateData } from \"./invoice-corporate.types\";\n\nconst sampleData: InvoiceCorporateData = {\n billTo: {\n address: \"100 Corporate Plaza, Tower B\",\n email: \"accounts@globalindustries.com\",\n name: \"Global Industries Ltd.\",\n phone: \"+1 (555) 888-9999\",\n },\n companyAddress: \"Nagpur, IN\",\n companyEmail: \"hello@pdfcn.app\",\n companyName: \"pdfcn\",\n dueDate: \"March 24, 2026\",\n invoiceDate: \"February 22, 2026\",\n invoiceNumber: \"INV-2026-004\",\n items: [\n {\n description: \"Enterprise Software License\",\n quantity: 5,\n unitPrice: 4500,\n },\n { description: \"Implementation Services\", quantity: 1, unitPrice: 18_000 },\n {\n description: \"Training Workshop (per session)\",\n quantity: 3,\n unitPrice: 2500,\n },\n { description: \"Annual Support Package\", quantity: 1, unitPrice: 8500 },\n ],\n logo: \"/favicon.png\",\n notes:\n \"Corporate billing – Net 30 terms apply. For inquiries, contact accounts@pdfcn.app\",\n paymentTerms: {\n dueDate: \"March 24, 2026\",\n gst: \"GSTIN 987654321\",\n method: \"Wire Transfer / Corporate Account\",\n },\n subtitle: \"Innovative PDF Solutions\",\n summary: {\n subtotal: 56_500,\n tax: 4520,\n total: 61_020,\n },\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfImage,\n PdfKeyValue,\n PdfPageFooter,\n PdfPageHeader,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-invoice-corporate-content\",\n template: `\n @let data = this.data();\n @let s = styles();\n \n \n \n \n \n \n \n \n \n \n Invoice Details\n \n \n \n Bill To\n {{\n data.billTo.name\n }}\n {{\n data.billTo.address\n }}\n {{\n data.billTo.email\n }}\n {{\n data.billTo.phone\n }}\n \n \n \n \n \n Description\n Qty\n Unit Price\n Amount\n \n \n \n @for (item of data.items; track $index) {\n \n {{ item.description }}\n {{\n item.quantity\n }}\n {{\n \"$\" + item.unitPrice.toLocaleString()\n }}\n {{\n \"$\" + (item.quantity * item.unitPrice).toLocaleString()\n }}\n \n }\n \n \n \n \n \n \n \n \n \n \n \n \n `,\n})\nexport class InvoiceCorporateContent {\n readonly data = input.required();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() => {\n const theme = this.theme();\n return StyleSheet.create({\n infoColumn: {\n flex: 1,\n },\n infoGrid: {\n flexDirection: \"row\",\n gap: 24,\n marginBottom: theme.spacing.sectionGap,\n },\n infoLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n fontWeight: \"bold\",\n letterSpacing: 0.6,\n marginBottom: 6,\n textTransform: \"uppercase\",\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n summaryCard: {\n backgroundColor: theme.colors.muted,\n borderRadius: theme.primitives.borderRadius.md,\n marginTop: 20,\n padding: 16,\n },\n summaryRow: {\n flexDirection: \"row\",\n justifyContent: \"flex-end\",\n },\n });\n });\n\n protected readonly detailItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n return [\n { key: \"Invoice #\", value: data.invoiceNumber },\n { key: \"Issue Date\", value: data.invoiceDate },\n { key: \"Due Date\", value: data.dueDate },\n { key: \"Payment\", value: data.paymentTerms.method },\n ];\n });\n\n protected readonly summaryItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n const theme = this.theme();\n return [\n {\n key: \"Subtotal\",\n value: `$${data.summary.subtotal.toLocaleString()}`,\n },\n {\n key: \"Tax (8%)\",\n value: `$${data.summary.tax.toFixed(2)}`,\n },\n {\n key: \"Total Due\",\n keyStyle: { fontSize: 13, fontWeight: \"bold\" },\n value: `$${data.summary.total.toFixed(2)}`,\n valueStyle: {\n color: theme.colors.primary,\n fontSize: 14,\n fontWeight: \"bold\",\n },\n },\n ];\n });\n}\n\n@Component({\n imports: [InvoiceCorporateContent, PdfcnThemeProvider],\n selector: \"pdf-invoice-corporate\",\n template: `\n \n \n \n `,\n})\nexport class InvoiceCorporateDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/invoice-corporate/invoice-corporate.ts"
},
{
"path": "registry/bases/forme/blocks/invoice-corporate/invoice-corporate.types.ts",
- "content": "export interface InvoiceCorporateData {\n invoiceNumber: string;\n invoiceDate: string;\n dueDate: string;\n companyName: string;\n subtitle: string;\n companyAddress: string;\n companyEmail: string;\n logo?: string;\n billTo: {\n name: string;\n address: string;\n email: string;\n phone: string;\n };\n items: {\n description: string;\n quantity: number;\n unitPrice: number;\n }[];\n summary: {\n subtotal: number;\n tax: number;\n total: number;\n };\n paymentTerms: {\n dueDate: string;\n method: string;\n gst: string;\n };\n notes?: string;\n}\n",
+ "content": "export interface InvoiceCorporateData {\n invoiceNumber: string;\n invoiceDate: string;\n dueDate: string;\n companyName: string;\n subtitle: string;\n companyAddress: string;\n companyEmail: string;\n logo?: string;\n billTo: {\n name: string;\n address: string;\n email: string;\n phone: string;\n };\n items: {\n description: string;\n quantity: number;\n unitPrice: number;\n }[];\n summary: {\n subtotal: number;\n tax: number;\n total: number;\n };\n paymentTerms: {\n dueDate: string;\n method: string;\n gst: string;\n };\n notes?: string;\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/invoice-corporate/invoice-corporate.types.ts"
}
diff --git a/apps/web/public/r/forme/invoice-creative.json b/apps/web/public/r/forme/invoice-creative.json
index c1c8a36..0b7e40d 100644
--- a/apps/web/public/r/forme/invoice-creative.json
+++ b/apps/web/public/r/forme/invoice-creative.json
@@ -3,10 +3,6 @@
"name": "forme/invoice-creative",
"title": "Invoice Creative",
"description": "Invoice Creative PDF block (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils",
"@angular-pdfcn/forme/key-value",
@@ -19,13 +15,13 @@
"files": [
{
"path": "registry/bases/forme/blocks/invoice-creative/invoice-creative.ts",
- "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport type { KeyValueEntry } from \"@/components/pdf/key-value/key-value\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfSection } from \"@/components/pdf/section/section\";\nimport { TABLE } from \"@/components/pdf/table/table\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { InvoiceCreativeData } from \"./invoice-creative.types\";\n\nconst sampleData: InvoiceCreativeData = {\n billTo: {\n address: \"250 Design District, Loft 5\",\n email: \"studio@creativeagency.co\",\n name: \"Creative Agency Co.\",\n phone: \"+1 (555) 321-7654\",\n },\n companyAddress: \"Nagpur, IN · hello@pdfcn.app\",\n companyName: \"pdfcn\",\n dueDate: \"March 26, 2026\",\n invoiceDate: \"February 24, 2026\",\n invoiceNumber: \"INV-2026-005\",\n items: [\n { description: \"Brand Identity Design\", quantity: 1, unitPrice: 8500 },\n {\n description: \"Marketing Collateral Package\",\n quantity: 1,\n unitPrice: 4200,\n },\n {\n description: \"Social Media Assets (per set)\",\n quantity: 4,\n unitPrice: 750,\n },\n { description: \"Motion Graphics (30s)\", quantity: 2, unitPrice: 3500 },\n ],\n notes:\n \"Creative work is protected under copyright. Full usage rights transfer upon payment.\",\n paymentTerms: {\n dueDate: \"March 26, 2026\",\n gst: \"GSTIN 456789123\",\n method: \"Credit Card / PayPal / Stripe\",\n },\n subtitle: \"Innovative PDF Solutions\",\n summary: {\n subtotal: 22_700,\n tax: 1475.5,\n total: 24_175.5,\n },\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfKeyValue,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-invoice-creative-content\",\n template: `\n @let data = this.data();\n @let s = styles();\n \n \n \n \n \n \n \n \n \n Invoice\n {{\n data.invoiceNumber\n }}\n \n \n \n \n \n Billed To\n {{\n data.billTo.name\n }}\n {{\n data.billTo.address\n }}\n {{ data.billTo.email }} · {{ data.billTo.phone }}\n \n \n Invoice Info\n \n \n \n \n \n \n \n Deliverable\n Qty\n Rate\n Amount\n \n \n \n @for (item of data.items; track $index) {\n \n {{ item.description }}\n {{\n item.quantity\n }}\n {{\n \"$\" + item.unitPrice.toLocaleString()\n }}\n {{\n \"$\" + (item.quantity * item.unitPrice).toLocaleString()\n }}\n \n }\n \n \n \n \n Notes & Terms\n {{\n data.notes\n }}\n GST: {{ data.paymentTerms.gst }}\n \n \n \n \n \n \n \n \n `,\n})\nexport class InvoiceCreativeContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() => {\n const theme = this.theme();\n return StyleSheet.create({\n accentBlock: {\n backgroundColor: theme.colors.muted,\n borderLeftColor: theme.colors.accent,\n borderLeftStyle: \"solid\",\n borderLeftWidth: 4,\n marginBottom: theme.spacing.sectionGap,\n paddingLeft: 14,\n paddingVertical: 10,\n },\n badgeLabel: {\n color: theme.colors.primaryForeground,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1.2,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n badgeNumber: {\n color: theme.colors.primaryForeground,\n fontSize: 16,\n fontWeight: \"bold\",\n },\n heroSection: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: theme.spacing.sectionGap,\n },\n infoColumn: {\n flex: 1,\n },\n infoGrid: {\n flexDirection: \"row\",\n gap: 32,\n },\n invoiceBadge: {\n alignItems: \"center\",\n backgroundColor: theme.colors.primary,\n borderRadius: theme.primitives.borderRadius.md,\n paddingHorizontal: 20,\n paddingVertical: 14,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n sectionLabel: {\n color: theme.colors.accent,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 0.8,\n marginBottom: 6,\n textTransform: \"uppercase\",\n },\n summaryLeft: {\n flex: 1,\n paddingRight: 20,\n },\n summaryRight: {\n backgroundColor: theme.colors.muted,\n borderRadius: theme.primitives.borderRadius.sm,\n padding: 14,\n width: 240,\n },\n summarySection: {\n flexDirection: \"row\",\n marginTop: 24,\n },\n });\n });\n\n protected readonly infoItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n return [\n { key: \"Issue Date\", value: data.invoiceDate },\n { key: \"Due Date\", value: data.dueDate },\n { key: \"Payment\", value: data.paymentTerms.method },\n ];\n });\n\n protected readonly summaryItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n const theme = this.theme();\n return [\n {\n key: \"Subtotal\",\n value: `$${data.summary.subtotal.toLocaleString()}`,\n },\n {\n key: \"Tax (6.5%)\",\n value: `$${data.summary.tax.toFixed(2)}`,\n },\n {\n key: \"Total\",\n keyStyle: { fontSize: 13, fontWeight: \"bold\" },\n value: `$${data.summary.total.toFixed(2)}`,\n valueStyle: {\n color: theme.colors.accent,\n fontSize: 14,\n fontWeight: \"bold\",\n },\n },\n ];\n });\n}\n\n@Component({\n imports: [InvoiceCreativeContent, PdfcnThemeProvider],\n selector: \"pdf-invoice-creative\",\n template: `\n \n \n \n `,\n})\nexport class InvoiceCreativeDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n",
+ "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport type { KeyValueEntry } from \"@/components/pdf/key-value/key-value\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfSection } from \"@/components/pdf/section/section\";\nimport { TABLE } from \"@/components/pdf/table/table\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { InvoiceCreativeData } from \"./invoice-creative.types\";\n\nconst sampleData: InvoiceCreativeData = {\n billTo: {\n address: \"250 Design District, Loft 5\",\n email: \"studio@creativeagency.co\",\n name: \"Creative Agency Co.\",\n phone: \"+1 (555) 321-7654\",\n },\n companyAddress: \"Nagpur, IN · hello@pdfcn.app\",\n companyName: \"pdfcn\",\n dueDate: \"March 26, 2026\",\n invoiceDate: \"February 24, 2026\",\n invoiceNumber: \"INV-2026-005\",\n items: [\n { description: \"Brand Identity Design\", quantity: 1, unitPrice: 8500 },\n {\n description: \"Marketing Collateral Package\",\n quantity: 1,\n unitPrice: 4200,\n },\n {\n description: \"Social Media Assets (per set)\",\n quantity: 4,\n unitPrice: 750,\n },\n { description: \"Motion Graphics (30s)\", quantity: 2, unitPrice: 3500 },\n ],\n notes:\n \"Creative work is protected under copyright. Full usage rights transfer upon payment.\",\n paymentTerms: {\n dueDate: \"March 26, 2026\",\n gst: \"GSTIN 456789123\",\n method: \"Credit Card / PayPal / Stripe\",\n },\n subtitle: \"Innovative PDF Solutions\",\n summary: {\n subtotal: 22_700,\n tax: 1475.5,\n total: 24_175.5,\n },\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfKeyValue,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-invoice-creative-content\",\n template: `\n @let data = this.data();\n @let s = styles();\n \n \n \n \n \n \n \n \n \n Invoice\n {{\n data.invoiceNumber\n }}\n \n \n \n \n \n Billed To\n {{\n data.billTo.name\n }}\n {{\n data.billTo.address\n }}\n {{ data.billTo.email }} · {{ data.billTo.phone }}\n \n \n Invoice Info\n \n \n \n \n \n \n \n Deliverable\n Qty\n Rate\n Amount\n \n \n \n @for (item of data.items; track $index) {\n \n {{ item.description }}\n {{\n item.quantity\n }}\n {{\n \"$\" + item.unitPrice.toLocaleString()\n }}\n {{\n \"$\" + (item.quantity * item.unitPrice).toLocaleString()\n }}\n \n }\n \n \n \n \n Notes & Terms\n {{\n data.notes\n }}\n GST: {{ data.paymentTerms.gst }}\n \n \n \n \n \n \n \n \n `,\n})\nexport class InvoiceCreativeContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() => {\n const theme = this.theme();\n return StyleSheet.create({\n accentBlock: {\n backgroundColor: theme.colors.muted,\n borderLeftColor: theme.colors.accent,\n borderLeftStyle: \"solid\",\n borderLeftWidth: 4,\n marginBottom: theme.spacing.sectionGap,\n paddingLeft: 14,\n paddingVertical: 10,\n },\n badgeLabel: {\n color: theme.colors.primaryForeground,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1.2,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n badgeNumber: {\n color: theme.colors.primaryForeground,\n fontSize: 16,\n fontWeight: \"bold\",\n },\n heroSection: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: theme.spacing.sectionGap,\n },\n infoColumn: {\n flex: 1,\n },\n infoGrid: {\n flexDirection: \"row\",\n gap: 32,\n },\n invoiceBadge: {\n alignItems: \"center\",\n backgroundColor: theme.colors.primary,\n borderRadius: theme.primitives.borderRadius.md,\n paddingHorizontal: 20,\n paddingVertical: 14,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n sectionLabel: {\n color: theme.colors.accent,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 0.8,\n marginBottom: 6,\n textTransform: \"uppercase\",\n },\n summaryLeft: {\n flex: 1,\n paddingRight: 20,\n },\n summaryRight: {\n backgroundColor: theme.colors.muted,\n borderRadius: theme.primitives.borderRadius.sm,\n padding: 14,\n width: 240,\n },\n summarySection: {\n flexDirection: \"row\",\n marginTop: 24,\n },\n });\n });\n\n protected readonly infoItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n return [\n { key: \"Issue Date\", value: data.invoiceDate },\n { key: \"Due Date\", value: data.dueDate },\n { key: \"Payment\", value: data.paymentTerms.method },\n ];\n });\n\n protected readonly summaryItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n const theme = this.theme();\n return [\n {\n key: \"Subtotal\",\n value: `$${data.summary.subtotal.toLocaleString()}`,\n },\n {\n key: \"Tax (6.5%)\",\n value: `$${data.summary.tax.toFixed(2)}`,\n },\n {\n key: \"Total\",\n keyStyle: { fontSize: 13, fontWeight: \"bold\" },\n value: `$${data.summary.total.toFixed(2)}`,\n valueStyle: {\n color: theme.colors.accent,\n fontSize: 14,\n fontWeight: \"bold\",\n },\n },\n ];\n });\n}\n\n@Component({\n imports: [InvoiceCreativeContent, PdfcnThemeProvider],\n selector: \"pdf-invoice-creative\",\n template: `\n \n \n \n `,\n})\nexport class InvoiceCreativeDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/invoice-creative/invoice-creative.ts"
},
{
"path": "registry/bases/forme/blocks/invoice-creative/invoice-creative.types.ts",
- "content": "export interface InvoiceCreativeData {\n invoiceNumber: string;\n invoiceDate: string;\n dueDate: string;\n companyName: string;\n subtitle: string;\n companyAddress: string;\n billTo: {\n name: string;\n address: string;\n email: string;\n phone: string;\n };\n items: {\n description: string;\n quantity: number;\n unitPrice: number;\n }[];\n summary: {\n subtotal: number;\n tax: number;\n total: number;\n };\n paymentTerms: {\n dueDate: string;\n method: string;\n gst: string;\n };\n notes?: string;\n}\n",
+ "content": "export interface InvoiceCreativeData {\n invoiceNumber: string;\n invoiceDate: string;\n dueDate: string;\n companyName: string;\n subtitle: string;\n companyAddress: string;\n billTo: {\n name: string;\n address: string;\n email: string;\n phone: string;\n };\n items: {\n description: string;\n quantity: number;\n unitPrice: number;\n }[];\n summary: {\n subtotal: number;\n tax: number;\n total: number;\n };\n paymentTerms: {\n dueDate: string;\n method: string;\n gst: string;\n };\n notes?: string;\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/invoice-creative/invoice-creative.types.ts"
}
diff --git a/apps/web/public/r/forme/invoice-minimal.json b/apps/web/public/r/forme/invoice-minimal.json
index 82c19da..6dabd4a 100644
--- a/apps/web/public/r/forme/invoice-minimal.json
+++ b/apps/web/public/r/forme/invoice-minimal.json
@@ -3,10 +3,6 @@
"name": "forme/invoice-minimal",
"title": "Invoice Minimal",
"description": "Invoice Minimal PDF block (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils",
"@angular-pdfcn/forme/key-value",
@@ -19,13 +15,13 @@
"files": [
{
"path": "registry/bases/forme/blocks/invoice-minimal/invoice-minimal.ts",
- "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport type { KeyValueEntry } from \"@/components/pdf/key-value/key-value\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfSection } from \"@/components/pdf/section/section\";\nimport { TABLE } from \"@/components/pdf/table/table\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { InvoiceMinimalData } from \"./invoice-minimal.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: InvoiceMinimalData = {\n billTo: {\n address: \"500 Enterprise Way, Building A\",\n email: \"finance@enterprisecorp.io\",\n name: \"Enterprise Corp\",\n phone: \"+1 (555) 246-8135\",\n },\n companyAddress: \"Nagpur, IN\",\n companyEmail: \"hello@pdfcn.app\",\n companyName: \"pdfcn\",\n dueDate: \"March 22, 2026\",\n invoiceDate: \"February 20, 2026\",\n invoiceNumber: \"INV-2026-003\",\n items: [\n { description: \"Annual License Plan\", quantity: 1, unitPrice: 25_000 },\n { description: \"Support & Maintenance\", quantity: 12, unitPrice: 1500 },\n { description: \"Custom Integration\", quantity: 1, unitPrice: 12_000 },\n ],\n notes:\n \"Invoice for annual enterprise subscription. Please retain for your records.\",\n paymentTerms: {\n dueDate: \"March 22, 2026\",\n gst: \"GSTIN 123456789\",\n method: \"ACH Transfer / Check\",\n },\n subtitle: \"Innovative PDF Solutions\",\n summary: {\n subtotal: 55_000,\n tax: 3850,\n total: 58_850,\n },\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfKeyValue,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-invoice-minimal-content\",\n template: `\n @let data = this.data();\n @let theme = this.theme();\n \n \n \n \n \n \n \n \n \n Invoice\n {{ data.invoiceNumber }}\n {{ data.invoiceDate }}\n \n \n \n \n Bill To\n {{ data.billTo.name }}\n {{\n data.billTo.address\n }}\n {{\n data.billTo.email\n }}\n {{\n data.billTo.phone\n }}\n \n \n Invoice Details\n \n \n \n \n \n \n Description\n Qty\n Rate\n Total\n \n \n \n @for (item of data.items; track $index) {\n \n {{ item.description }}\n {{\n item.quantity\n }}\n {{\n \"$\" + item.unitPrice.toLocaleString()\n }}\n {{\n \"$\" + (item.quantity * item.unitPrice).toFixed(2)\n }}\n \n }\n \n \n \n \n \n \n \n \n \n \n \n `,\n})\nexport class InvoiceMinimalContent {\n readonly data = input.required();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() => {\n const theme = this.theme();\n const styles = StyleSheet.create({\n infoLabel: {\n color: theme.colors.primary,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 0.8,\n marginBottom: 4,\n textTransform: \"uppercase\",\n },\n infoRow: {\n flexDirection: \"row\",\n marginBottom: 28,\n },\n invoiceStamp: {\n alignSelf: \"flex-start\",\n borderColor: theme.colors.primary,\n borderRadius: theme.primitives.borderRadius.sm,\n borderStyle: \"solid\",\n borderWidth: 2,\n paddingHorizontal: 12,\n paddingVertical: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n });\n return styles;\n });\n\n protected readonly detailItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n return [\n { key: \"Due Date\", value: data.dueDate },\n { key: \"Payment\", value: data.paymentTerms.method },\n { key: \"GST\", value: data.paymentTerms.gst },\n ];\n });\n\n protected readonly summaryItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n const theme = this.theme();\n return [\n {\n key: \"Subtotal\",\n value: `$${data.summary.subtotal.toFixed(2)}`,\n },\n { key: \"Tax (7%)\", value: `$${data.summary.tax.toFixed(2)}` },\n {\n key: \"Balance Due\",\n keyStyle: { fontSize: 12, fontWeight: \"bold\" },\n value: `$${data.summary.total.toFixed(2)}`,\n valueStyle: {\n color: theme.colors.primary,\n fontSize: 13,\n fontWeight: \"bold\",\n },\n },\n ];\n });\n}\n\n@Component({\n imports: [InvoiceMinimalContent, PdfcnThemeProvider],\n selector: \"pdf-invoice-minimal\",\n template: `\n \n \n \n `,\n})\nexport class InvoiceMinimalDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n",
+ "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport type { KeyValueEntry } from \"@/components/pdf/key-value/key-value\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfSection } from \"@/components/pdf/section/section\";\nimport { TABLE } from \"@/components/pdf/table/table\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { InvoiceMinimalData } from \"./invoice-minimal.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: InvoiceMinimalData = {\n billTo: {\n address: \"500 Enterprise Way, Building A\",\n email: \"finance@enterprisecorp.io\",\n name: \"Enterprise Corp\",\n phone: \"+1 (555) 246-8135\",\n },\n companyAddress: \"Nagpur, IN\",\n companyEmail: \"hello@pdfcn.app\",\n companyName: \"pdfcn\",\n dueDate: \"March 22, 2026\",\n invoiceDate: \"February 20, 2026\",\n invoiceNumber: \"INV-2026-003\",\n items: [\n { description: \"Annual License Plan\", quantity: 1, unitPrice: 25_000 },\n { description: \"Support & Maintenance\", quantity: 12, unitPrice: 1500 },\n { description: \"Custom Integration\", quantity: 1, unitPrice: 12_000 },\n ],\n notes:\n \"Invoice for annual enterprise subscription. Please retain for your records.\",\n paymentTerms: {\n dueDate: \"March 22, 2026\",\n gst: \"GSTIN 123456789\",\n method: \"ACH Transfer / Check\",\n },\n subtitle: \"Innovative PDF Solutions\",\n summary: {\n subtotal: 55_000,\n tax: 3850,\n total: 58_850,\n },\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfKeyValue,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-invoice-minimal-content\",\n template: `\n @let data = this.data();\n @let theme = this.theme();\n \n \n \n \n \n \n \n \n \n Invoice\n {{ data.invoiceNumber }}\n {{ data.invoiceDate }}\n \n \n \n \n Bill To\n {{ data.billTo.name }}\n {{\n data.billTo.address\n }}\n {{\n data.billTo.email\n }}\n {{\n data.billTo.phone\n }}\n \n \n Invoice Details\n \n \n \n \n \n \n Description\n Qty\n Rate\n Total\n \n \n \n @for (item of data.items; track $index) {\n \n {{ item.description }}\n {{\n item.quantity\n }}\n {{\n \"$\" + item.unitPrice.toLocaleString()\n }}\n {{\n \"$\" + (item.quantity * item.unitPrice).toFixed(2)\n }}\n \n }\n \n \n \n \n \n \n \n \n \n \n \n `,\n})\nexport class InvoiceMinimalContent {\n readonly data = input.required();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() => {\n const theme = this.theme();\n const styles = StyleSheet.create({\n infoLabel: {\n color: theme.colors.primary,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 0.8,\n marginBottom: 4,\n textTransform: \"uppercase\",\n },\n infoRow: {\n flexDirection: \"row\",\n marginBottom: 28,\n },\n invoiceStamp: {\n alignSelf: \"flex-start\",\n borderColor: theme.colors.primary,\n borderRadius: theme.primitives.borderRadius.sm,\n borderStyle: \"solid\",\n borderWidth: 2,\n paddingHorizontal: 12,\n paddingVertical: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n });\n return styles;\n });\n\n protected readonly detailItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n return [\n { key: \"Due Date\", value: data.dueDate },\n { key: \"Payment\", value: data.paymentTerms.method },\n { key: \"GST\", value: data.paymentTerms.gst },\n ];\n });\n\n protected readonly summaryItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n const theme = this.theme();\n return [\n {\n key: \"Subtotal\",\n value: `$${data.summary.subtotal.toFixed(2)}`,\n },\n { key: \"Tax (7%)\", value: `$${data.summary.tax.toFixed(2)}` },\n {\n key: \"Balance Due\",\n keyStyle: { fontSize: 12, fontWeight: \"bold\" },\n value: `$${data.summary.total.toFixed(2)}`,\n valueStyle: {\n color: theme.colors.primary,\n fontSize: 13,\n fontWeight: \"bold\",\n },\n },\n ];\n });\n}\n\n@Component({\n imports: [InvoiceMinimalContent, PdfcnThemeProvider],\n selector: \"pdf-invoice-minimal\",\n template: `\n \n \n \n `,\n})\nexport class InvoiceMinimalDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/invoice-minimal/invoice-minimal.ts"
},
{
"path": "registry/bases/forme/blocks/invoice-minimal/invoice-minimal.types.ts",
- "content": "export interface InvoiceMinimalData {\n invoiceNumber: string;\n invoiceDate: string;\n dueDate: string;\n companyName: string;\n subtitle: string;\n companyAddress: string;\n companyEmail: string;\n billTo: {\n name: string;\n address: string;\n email: string;\n phone: string;\n };\n items: {\n description: string;\n quantity: number;\n unitPrice: number;\n }[];\n summary: {\n subtotal: number;\n tax: number;\n total: number;\n };\n paymentTerms: {\n dueDate: string;\n method: string;\n gst: string;\n };\n notes?: string;\n}\n",
+ "content": "export interface InvoiceMinimalData {\n invoiceNumber: string;\n invoiceDate: string;\n dueDate: string;\n companyName: string;\n subtitle: string;\n companyAddress: string;\n companyEmail: string;\n billTo: {\n name: string;\n address: string;\n email: string;\n phone: string;\n };\n items: {\n description: string;\n quantity: number;\n unitPrice: number;\n }[];\n summary: {\n subtotal: number;\n tax: number;\n total: number;\n };\n paymentTerms: {\n dueDate: string;\n method: string;\n gst: string;\n };\n notes?: string;\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/invoice-minimal/invoice-minimal.types.ts"
}
diff --git a/apps/web/public/r/forme/invoice-modern.json b/apps/web/public/r/forme/invoice-modern.json
index c207cbf..7a02ac8 100644
--- a/apps/web/public/r/forme/invoice-modern.json
+++ b/apps/web/public/r/forme/invoice-modern.json
@@ -3,10 +3,6 @@
"name": "forme/invoice-modern",
"title": "Invoice Modern",
"description": "Invoice Modern PDF block (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils",
"@angular-pdfcn/forme/key-value",
@@ -19,13 +15,13 @@
"files": [
{
"path": "registry/bases/forme/blocks/invoice-modern/invoice-modern.ts",
- "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport type { KeyValueEntry } from \"@/components/pdf/key-value/key-value\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfSection } from \"@/components/pdf/section/section\";\nimport { TABLE } from \"@/components/pdf/table/table\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { InvoiceModernData } from \"./invoice-modern.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: InvoiceModernData = {\n billTo: {\n address: \"789 Innovation Blvd, Floor 3\",\n email: \"billing@techstart.com\",\n name: \"TechStart Solutions\",\n phone: \"+1 (555) 987-6543\",\n },\n companyAddress: \"Nagpur, IN\",\n companyEmail: \"hello@pdfcn.app\",\n companyName: \"pdfcn\",\n dueDate: \"March 20, 2026\",\n invoiceDate: \"February 18, 2026\",\n invoiceNumber: \"INV-2026-002\",\n items: [\n { description: \"API Integration\", quantity: 1, unitPrice: 15_000 },\n { description: \"SEO\", quantity: 2, unitPrice: 5500 },\n { description: \"Security Audit\", quantity: 1, unitPrice: 7200 },\n ],\n notes: \"Payment terms: Net 30 days. Thank you for your business!\",\n paymentTerms: {\n dueDate: \"March 20, 2026\",\n gst: \"GSTIN 123456789\",\n method: \"Wire Transfer / Bank Account\",\n },\n subtitle: \"Innovative PDF Solutions\",\n summary: {\n subtotal: 33_200,\n tax: 2324,\n total: 35_524,\n },\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfKeyValue,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-invoice-modern-content\",\n template: `\n @let data = this.data();\n @let theme = this.theme();\n @let styles = this.styles();\n \n \n \n \n \n \n \n Invoice Number\n {{ data.invoiceNumber }}\n \n \n Invoice Date\n {{\n data.invoiceDate\n }}\n \n \n Due Date\n {{\n data.dueDate\n }}\n \n \n \n Billed To\n {{ data.billTo.name }}\n {{ data.billTo.address }}\n {{ data.billTo.email }}\n {{ data.billTo.phone }}\n \n \n \n \n \n Description\n Qty\n Unit Price\n Amount\n \n \n \n @for (item of data.items; track $index) {\n \n {{ item.description }}\n {{\n item.quantity\n }}\n {{\n \"$\" + item.unitPrice.toLocaleString()\n }}\n {{\n \"$\" + (item.quantity * item.unitPrice).toFixed(2)\n }}\n \n }\n \n \n \n \n Payment Method\n {{\n data.paymentTerms.method\n }}\n {{\n data.paymentTerms.gst\n }}\n \n \n \n \n \n \n \n \n `,\n})\nexport class InvoiceModernContent {\n readonly data = input.required();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() => {\n const theme = this.theme();\n const styles = StyleSheet.create({\n dividerCol: {\n backgroundColor: theme.colors.border,\n marginRight: 12,\n width: 1,\n },\n metaCol: {\n flex: 1,\n paddingRight: 12,\n },\n metaLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 0.5,\n marginBottom: 3,\n textTransform: \"uppercase\",\n },\n metaRow: {\n flexDirection: \"row\",\n marginBottom: theme.spacing.sectionGap,\n },\n metaValue: {\n color: theme.colors.foreground,\n fontSize: 9,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n });\n return styles;\n });\n\n protected readonly summaryItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n return [\n {\n key: \"Subtotal\",\n value: `$${data.summary.subtotal.toFixed(2)}`,\n },\n { key: \"Tax (7%)\", value: `$${data.summary.tax.toFixed(2)}` },\n {\n key: \"Total Due\",\n keyStyle: { fontSize: 12, fontWeight: \"bold\" },\n value: `$${data.summary.total.toFixed(2)}`,\n valueStyle: { fontSize: 12, fontWeight: \"bold\" },\n },\n ];\n });\n}\n\n@Component({\n imports: [InvoiceModernContent, PdfcnThemeProvider],\n selector: \"pdf-invoice-modern\",\n template: `\n \n \n \n `,\n})\nexport class InvoiceModernDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n",
+ "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport type { KeyValueEntry } from \"@/components/pdf/key-value/key-value\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfSection } from \"@/components/pdf/section/section\";\nimport { TABLE } from \"@/components/pdf/table/table\";\nimport { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n FormeDocument,\n FormePage,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { InvoiceModernData } from \"./invoice-modern.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: InvoiceModernData = {\n billTo: {\n address: \"789 Innovation Blvd, Floor 3\",\n email: \"billing@techstart.com\",\n name: \"TechStart Solutions\",\n phone: \"+1 (555) 987-6543\",\n },\n companyAddress: \"Nagpur, IN\",\n companyEmail: \"hello@pdfcn.app\",\n companyName: \"pdfcn\",\n dueDate: \"March 20, 2026\",\n invoiceDate: \"February 18, 2026\",\n invoiceNumber: \"INV-2026-002\",\n items: [\n { description: \"API Integration\", quantity: 1, unitPrice: 15_000 },\n { description: \"SEO\", quantity: 2, unitPrice: 5500 },\n { description: \"Security Audit\", quantity: 1, unitPrice: 7200 },\n ],\n notes: \"Payment terms: Net 30 days. Thank you for your business!\",\n paymentTerms: {\n dueDate: \"March 20, 2026\",\n gst: \"GSTIN 123456789\",\n method: \"Wire Transfer / Bank Account\",\n },\n subtitle: \"Innovative PDF Solutions\",\n summary: {\n subtotal: 33_200,\n tax: 2324,\n total: 35_524,\n },\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfKeyValue,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-invoice-modern-content\",\n template: `\n @let data = this.data();\n @let theme = this.theme();\n @let styles = this.styles();\n \n \n \n \n \n \n \n Invoice Number\n {{ data.invoiceNumber }}\n \n \n Invoice Date\n {{\n data.invoiceDate\n }}\n \n \n Due Date\n {{\n data.dueDate\n }}\n \n \n \n Billed To\n {{ data.billTo.name }}\n {{ data.billTo.address }}\n {{ data.billTo.email }}\n {{ data.billTo.phone }}\n \n \n \n \n \n Description\n Qty\n Unit Price\n Amount\n \n \n \n @for (item of data.items; track $index) {\n \n {{ item.description }}\n {{\n item.quantity\n }}\n {{\n \"$\" + item.unitPrice.toLocaleString()\n }}\n {{\n \"$\" + (item.quantity * item.unitPrice).toFixed(2)\n }}\n \n }\n \n \n \n \n Payment Method\n {{\n data.paymentTerms.method\n }}\n {{\n data.paymentTerms.gst\n }}\n \n \n \n \n \n \n \n \n `,\n})\nexport class InvoiceModernContent {\n readonly data = input.required();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() => {\n const theme = this.theme();\n const styles = StyleSheet.create({\n dividerCol: {\n backgroundColor: theme.colors.border,\n marginRight: 12,\n width: 1,\n },\n metaCol: {\n flex: 1,\n paddingRight: 12,\n },\n metaLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 0.5,\n marginBottom: 3,\n textTransform: \"uppercase\",\n },\n metaRow: {\n flexDirection: \"row\",\n marginBottom: theme.spacing.sectionGap,\n },\n metaValue: {\n color: theme.colors.foreground,\n fontSize: 9,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n });\n return styles;\n });\n\n protected readonly summaryItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n return [\n {\n key: \"Subtotal\",\n value: `$${data.summary.subtotal.toFixed(2)}`,\n },\n { key: \"Tax (7%)\", value: `$${data.summary.tax.toFixed(2)}` },\n {\n key: \"Total Due\",\n keyStyle: { fontSize: 12, fontWeight: \"bold\" },\n value: `$${data.summary.total.toFixed(2)}`,\n valueStyle: { fontSize: 12, fontWeight: \"bold\" },\n },\n ];\n });\n}\n\n@Component({\n imports: [InvoiceModernContent, PdfcnThemeProvider],\n selector: \"pdf-invoice-modern\",\n template: `\n \n \n \n `,\n})\nexport class InvoiceModernDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/invoice-modern/invoice-modern.ts"
},
{
"path": "registry/bases/forme/blocks/invoice-modern/invoice-modern.types.ts",
- "content": "export interface InvoiceModernData {\n invoiceNumber: string;\n invoiceDate: string;\n dueDate: string;\n companyName: string;\n subtitle: string;\n companyAddress: string;\n companyEmail: string;\n billTo: {\n name: string;\n address: string;\n email: string;\n phone: string;\n };\n items: {\n description: string;\n quantity: number;\n unitPrice: number;\n }[];\n summary: {\n subtotal: number;\n tax: number;\n total: number;\n };\n paymentTerms: {\n dueDate: string;\n method: string;\n gst: string;\n };\n notes?: string;\n}\n",
+ "content": "export interface InvoiceModernData {\n invoiceNumber: string;\n invoiceDate: string;\n dueDate: string;\n companyName: string;\n subtitle: string;\n companyAddress: string;\n companyEmail: string;\n billTo: {\n name: string;\n address: string;\n email: string;\n phone: string;\n };\n items: {\n description: string;\n quantity: number;\n unitPrice: number;\n }[];\n summary: {\n subtotal: number;\n tax: number;\n total: number;\n };\n paymentTerms: {\n dueDate: string;\n method: string;\n gst: string;\n };\n notes?: string;\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:block",
"target": "components/pdf/blocks/invoice-modern/invoice-modern.types.ts"
}
diff --git a/apps/web/public/r/forme/keep-together.json b/apps/web/public/r/forme/keep-together.json
index 742aeb1..fa066ef 100644
--- a/apps/web/public/r/forme/keep-together.json
+++ b/apps/web/public/r/forme/keep-together.json
@@ -3,17 +3,13 @@
"name": "forme/keep-together",
"title": "Keep Together",
"description": "Keep Together PDF component (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils"
],
"files": [
{
"path": "registry/bases/forme/components/keep-together/keep-together.ts",
- "content": "import { Component, input } from \"@angular/core\";\n\nimport { FormeView } from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/types/pdf-components\";\n\nexport interface KeepTogetherProps {\n minPresenceAhead?: number;\n style?: Style;\n}\n\n@Component({\n imports: [FormeView],\n selector: \"pdf-keep-together\",\n template: ``,\n})\nexport class PdfKeepTogether {\n readonly minPresenceAhead = input();\n readonly style = input();\n}\n",
+ "content": "import { Component, input } from \"@angular/core\";\n\nimport { FormeView } from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/types/pdf-components\";\n\nexport interface KeepTogetherProps {\n minPresenceAhead?: number;\n style?: Style;\n}\n\n@Component({\n imports: [FormeView],\n selector: \"pdf-keep-together\",\n template: ``,\n})\nexport class PdfKeepTogether {\n readonly minPresenceAhead = input();\n readonly style = input();\n}\n\n// Copyright (c) 2026 Shadcn Labs and Ahmad El Mir. MIT License: https://github.com/aFlamee/angular-pdfcn/blob/main/LICENSE\n",
"type": "registry:component",
"target": "components/pdf/keep-together/keep-together.ts"
}
diff --git a/apps/web/public/r/forme/key-value.json b/apps/web/public/r/forme/key-value.json
index be85afc..99c6253 100644
--- a/apps/web/public/r/forme/key-value.json
+++ b/apps/web/public/r/forme/key-value.json
@@ -3,17 +3,13 @@
"name": "forme/key-value",
"title": "Key Value",
"description": "Key Value PDF component (forme)",
- "dependencies": [
- "@formepdf/core@^0.25.0",
- "@formepdf/shared@^0.25.0"
- ],
"registryDependencies": [
"@angular-pdfcn/forme/utils"
],
"files": [
{
"path": "registry/bases/forme/components/key-value/key-value.ts",
- "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeText,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type KeyValueDirection = \"horizontal\" | \"vertical\";\nexport type KeyValueSize = \"sm\" | \"md\" | \"lg\";\n\n/**\n * A single key-value row with optional per-item color and style overrides.\n * Props - `key` | `value` | `valueColor` | `valueStyle` | `keyStyle`\n * @see {@link KeyValueEntry}\n */\nexport interface KeyValueEntry {\n key: string;\n value: string;\n valueColor?: string;\n valueStyle?: Style;\n keyStyle?: Style;\n}\n\n/**\n * List of key-value pairs with layout and style options.\n * Props - `items` | `direction` | `divided` | `size` | `labelFlex` | `labelColor` | `valueColor` | `boldValue` | `noWrap` | `dividerColor` | `dividerThickness` | `dividerMargin` | `style`\n * @see {@link KeyValueProps}\n */\nexport interface KeyValueProps extends PDFComponentProps {\n items: KeyValueEntry[];\n /**\n * @default 'horizontal'\n */\n direction?: KeyValueDirection;\n /**\n * @default false\n */\n divided?: boolean;\n /**\n * @default 'md'\n */\n size?: KeyValueSize;\n /**\n * @default 1\n */\n labelFlex?: number;\n labelColor?: string;\n valueColor?: string;\n /**\n * @default false\n */\n boldValue?: boolean;\n /**\n * @default false\n */\n noWrap?: boolean;\n dividerColor?: string;\n dividerThickness?: number;\n dividerMargin?: number;\n}\n\nconst createKeyValueStyles = (t: PdfcnTheme) => {\n const { spacing, fontWeights } = t.primitives;\n const c = t.colors;\n const { body } = t.typography;\n const keyBase = {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontWeight: fontWeights.medium,\n };\n const valueBase = {\n color: c.foreground,\n fontFamily: body.fontFamily,\n fontWeight: fontWeights.regular,\n };\n return StyleSheet.create({\n container: { flexDirection: \"column\", width: \"100%\" },\n divider: {\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n },\n keyLg: { ...keyBase, fontSize: t.primitives.typography.base },\n keyMd: { ...keyBase, fontSize: body.fontSize },\n keySm: { ...keyBase, fontSize: t.primitives.typography.xs },\n lastRowStretch: {\n borderBottomColor: \"#ffffff\",\n borderBottomStyle: \"solid\",\n borderBottomWidth: 0.01,\n },\n rowHorizontal: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n paddingVertical: spacing[1],\n width: \"100%\",\n },\n rowVertical: {\n flexDirection: \"column\",\n marginBottom: t.spacing.paragraphGap,\n },\n valueBold: { fontWeight: fontWeights.bold },\n valueLg: { ...valueBase, fontSize: t.primitives.typography.base },\n valueMd: { ...valueBase, fontSize: body.fontSize },\n valueSm: { ...valueBase, fontSize: t.primitives.typography.xs },\n });\n};\n\nconst keyValueLayout = (\n theme: PdfcnTheme,\n {\n items,\n direction = \"horizontal\",\n divided = false,\n size = \"md\",\n labelFlex = 1,\n labelColor,\n valueColor,\n boldValue = false,\n dividerColor,\n dividerThickness,\n dividerMargin,\n style,\n }: KeyValueProps\n) => {\n const styles = createKeyValueStyles(theme);\n const keyStyleMap = {\n lg: styles.keyLg,\n md: styles.keyMd,\n sm: styles.keySm,\n } as Record;\n const valueStyleMap = {\n lg: styles.valueLg,\n md: styles.valueMd,\n sm: styles.valueSm,\n } as Record;\n const containerStyles: Style[] = [styles.container];\n if (style) {\n containerStyles.push(...[style].flat());\n }\n\n return {\n container: containerStyles,\n rows: items.map((item, index) => {\n const isLast = index === items.length - 1;\n const keyStyles: Style[] = [keyStyleMap[size]];\n if (labelColor) {\n keyStyles.push({ color: resolveColor(labelColor, theme.colors) });\n }\n if (item.keyStyle) {\n keyStyles.push(item.keyStyle);\n }\n const valStyles: Style[] = [valueStyleMap[size]];\n if (boldValue) {\n valStyles.push(styles.valueBold);\n }\n const resolvedValueColor = item.valueColor ?? valueColor;\n if (resolvedValueColor) {\n valStyles.push({\n color: resolveColor(resolvedValueColor, theme.colors),\n });\n }\n if (item.valueStyle) {\n valStyles.push(item.valueStyle);\n }\n\n if (direction === \"horizontal\") {\n const rowStyles: Style[] = [styles.rowHorizontal];\n if (divided) {\n if (isLast) {\n rowStyles.push(styles.lastRowStretch);\n } else {\n const dividerStyle: Style = {};\n if (dividerColor) {\n dividerStyle.borderBottomColor = resolveColor(\n dividerColor,\n theme.colors\n );\n }\n if (dividerThickness) {\n dividerStyle.borderBottomWidth = dividerThickness;\n }\n if (dividerMargin) {\n dividerStyle.marginBottom = dividerMargin;\n }\n rowStyles.push({ ...styles.divider, ...dividerStyle });\n }\n }\n return {\n item,\n keyStyle: [...keyStyles, { flex: labelFlex }],\n rowStyle: rowStyles,\n valueStyle: [...valStyles, { flex: 1, textAlign: \"right\" } as Style],\n };\n }\n\n const rowStyles: Style[] = [styles.rowVertical];\n if (divided && !isLast) {\n rowStyles.push(styles.divider);\n }\n return {\n item,\n keyStyle: keyStyles,\n rowStyle: rowStyles,\n valueStyle: valStyles,\n };\n }),\n };\n};\n\n@Component({\n imports: [FormeText, FormeView],\n selector: \"pdf-key-value\",\n template: `\n \n @for (row of layout().rows; track row.item.key) {\n \n {{ row.item.key }}\n {{ row.item.value }}\n \n }\n \n `,\n})\nexport class PdfKeyValue {\n readonly items = input.required();\n readonly direction = input(\"horizontal\");\n readonly divided = input(false, { transform: booleanAttribute });\n readonly size = input(\"md\");\n readonly labelFlex = input(1);\n readonly labelColor = input();\n readonly valueColor = input();\n readonly boldValue = input(false, { transform: booleanAttribute });\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly dividerColor = input();\n readonly dividerThickness = input();\n readonly dividerMargin = input();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n keyValueLayout(this.theme(), {\n boldValue: this.boldValue(),\n direction: this.direction(),\n divided: this.divided(),\n dividerColor: this.dividerColor(),\n dividerMargin: this.dividerMargin(),\n dividerThickness: this.dividerThickness(),\n items: this.items(),\n labelColor: this.labelColor(),\n labelFlex: this.labelFlex(),\n size: this.size(),\n style: this.style(),\n valueColor: this.valueColor(),\n })\n );\n}\n",
+ "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeText,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type KeyValueDirection = \"horizontal\" | \"vertical\";\nexport type KeyValueSize = \"sm\" | \"md\" | \"lg\";\n\n/**\n * A single key-value row with optional per-item color and style overrides.\n * Props - `key` | `value` | `valueColor` | `valueStyle` | `keyStyle`\n * @see {@link KeyValueEntry}\n */\nexport interface KeyValueEntry {\n key: string;\n value: string;\n valueColor?: string;\n valueStyle?: Style;\n keyStyle?: Style;\n}\n\n/**\n * List of key-value pairs with layout and style options.\n * Props - `items` | `direction` | `divided` | `size` | `labelFlex` | `labelColor` | `valueColor` | `boldValue` | `noWrap` | `dividerColor` | `dividerThickness` | `dividerMargin` | `style`\n * @see {@link KeyValueProps}\n */\nexport interface KeyValueProps extends PDFComponentProps {\n items: KeyValueEntry[];\n /**\n * @default 'horizontal'\n */\n direction?: KeyValueDirection;\n /**\n * @default false\n */\n divided?: boolean;\n /**\n * @default 'md'\n */\n size?: KeyValueSize;\n /**\n * @default 1\n */\n labelFlex?: number;\n labelColor?: string;\n valueColor?: string;\n /**\n * @default false\n */\n boldValue?: boolean;\n /**\n * @default false\n */\n noWrap?: boolean;\n dividerColor?: string;\n dividerThickness?: number;\n dividerMargin?: number;\n}\n\nconst createKeyValueStyles = (t: PdfcnTheme) => {\n const { spacing, fontWeights } = t.primitives;\n const c = t.colors;\n const { body } = t.typography;\n const keyBase = {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontWeight: fontWeights.medium,\n };\n const valueBase = {\n color: c.foreground,\n fontFamily: body.fontFamily,\n fontWeight: fontWeights.regular,\n };\n return StyleSheet.create({\n container: { flexDirection: \"column\", width: \"100%\" },\n divider: {\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n },\n keyLg: { ...keyBase, fontSize: t.primitives.typography.base },\n keyMd: { ...keyBase, fontSize: body.fontSize },\n keySm: { ...keyBase, fontSize: t.primitives.typography.xs },\n lastRowStretch: {\n borderBottomColor: \"#ffffff\",\n borderBottomStyle: \"solid\",\n borderBottomWidth: 0.01,\n },\n rowHorizontal: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n paddingVertical: spacing[1],\n width: \"100%\",\n },\n rowVertical: {\n flexDirection: \"column\",\n marginBottom: t.spacing.paragraphGap,\n },\n valueBold: { fontWeight: fontWeights.bold },\n valueLg: { ...valueBase, fontSize: t.primitives.typography.base },\n valueMd: { ...valueBase, fontSize: body.fontSize },\n valueSm: { ...valueBase, fontSize: t.primitives.typography.xs },\n });\n};\n\nconst keyValueLayout = (\n theme: PdfcnTheme,\n {\n items,\n direction = \"horizontal\",\n divided = false,\n size = \"md\",\n labelFlex = 1,\n labelColor,\n valueColor,\n boldValue = false,\n dividerColor,\n dividerThickness,\n dividerMargin,\n style,\n }: KeyValueProps\n) => {\n const styles = createKeyValueStyles(theme);\n const keyStyleMap = {\n lg: styles.keyLg,\n md: styles.keyMd,\n sm: styles.keySm,\n } as Record