From 54b4a13d9aaec98c68347b14d5630de58da06f65 Mon Sep 17 00:00:00 2001 From: Ahmad El Mir Date: Fri, 20 Nov 2026 14:15:27 +0000 Subject: [PATCH 1/2] fix(forme): move consumers to Forme 0.32 and load the engine on first render The registry pinned @formepdf/core to ^0.25.0, which keeps consumers on 0.25.x. Bump to ^0.32.0 and declare the engine once, on forme/utils. The browser docs started the worker and fetched the WASM on every app load. Create the worker and import the document on first render, and mark @formepdf/react external so ng build drops a chunk nothing loads. Installed files now end with an MIT notice. shadcn add strips leading comments, so the notice goes last. build-registry fails on registry dependencies that no file imports, and four stale ones are removed. The keep-together docs say what happens to content taller than the remaining page and that Forme ignores minPresenceAhead. Co-Authored-By: Claude Opus 5.5 --- apps/web/content/docs/(root)/installation.md | 61 ++++++++++------- .../docs/components/forme/keep-together.md | 6 +- apps/web/lib/content/registry.ts | 6 +- apps/web/lib/install.ts | 4 ++ apps/web/package.json | 4 +- apps/web/public/r/forme/alert.json | 6 +- apps/web/public/r/forme/badge.json | 6 +- apps/web/public/r/forme/card.json | 6 +- apps/web/public/r/forme/data-table.json | 10 +-- apps/web/public/r/forme/divider.json | 6 +- apps/web/public/r/forme/event-agenda.json | 9 +-- apps/web/public/r/forme/event-ticket.json | 6 +- apps/web/public/r/forme/form.json | 10 +-- apps/web/public/r/forme/gift-certificate.json | 8 +-- apps/web/public/r/forme/graph.json | 12 ++-- apps/web/public/r/forme/heading.json | 6 +- apps/web/public/r/forme/invoice-classic.json | 8 +-- .../public/r/forme/invoice-consultant.json | 8 +-- .../web/public/r/forme/invoice-corporate.json | 8 +-- apps/web/public/r/forme/invoice-creative.json | 8 +-- apps/web/public/r/forme/invoice-minimal.json | 8 +-- apps/web/public/r/forme/invoice-modern.json | 8 +-- apps/web/public/r/forme/keep-together.json | 6 +- apps/web/public/r/forme/key-value.json | 6 +- apps/web/public/r/forme/lesson-plan.json | 8 +-- apps/web/public/r/forme/link.json | 6 +- apps/web/public/r/forme/list.json | 10 +-- .../public/r/forme/medical-intake-form.json | 8 +-- apps/web/public/r/forme/meeting-minutes.json | 8 +-- apps/web/public/r/forme/packing-slip.json | 8 +-- apps/web/public/r/forme/page-break.json | 6 +- apps/web/public/r/forme/page-footer.json | 6 +- apps/web/public/r/forme/page-header.json | 6 +- apps/web/public/r/forme/page-number.json | 6 +- apps/web/public/r/forme/pdf-image.json | 6 +- apps/web/public/r/forme/press-release.json | 8 +-- apps/web/public/r/forme/qrcode.json | 4 +- apps/web/public/r/forme/report-financial.json | 10 +-- apps/web/public/r/forme/report-marketing.json | 10 +-- .../web/public/r/forme/report-operations.json | 10 +-- apps/web/public/r/forme/report-security.json | 10 +-- apps/web/public/r/forme/section.json | 6 +- apps/web/public/r/forme/shipping-label.json | 6 +- apps/web/public/r/forme/signature.json | 6 +- apps/web/public/r/forme/stack.json | 6 +- apps/web/public/r/forme/table.json | 10 +-- apps/web/public/r/forme/text.json | 6 +- apps/web/public/r/forme/theme-provider.json | 5 +- apps/web/public/r/forme/utils.json | 14 ++-- apps/web/public/r/forme/watermark.json | 6 +- apps/web/public/r/forme/work-order.json | 8 +-- apps/web/public/r/registry.json | 67 ++----------------- apps/web/public/r/takumi/alert.json | 2 +- apps/web/public/r/takumi/badge.json | 2 +- apps/web/public/r/takumi/card.json | 2 +- apps/web/public/r/takumi/data-table.json | 6 +- apps/web/public/r/takumi/divider.json | 2 +- apps/web/public/r/takumi/event-agenda.json | 6 +- apps/web/public/r/takumi/event-ticket.json | 4 +- apps/web/public/r/takumi/form.json | 6 +- .../web/public/r/takumi/gift-certificate.json | 5 +- apps/web/public/r/takumi/graph.json | 8 +-- apps/web/public/r/takumi/heading.json | 2 +- apps/web/public/r/takumi/invoice-classic.json | 4 +- .../public/r/takumi/invoice-consultant.json | 4 +- .../public/r/takumi/invoice-corporate.json | 4 +- .../web/public/r/takumi/invoice-creative.json | 4 +- apps/web/public/r/takumi/invoice-minimal.json | 4 +- apps/web/public/r/takumi/invoice-modern.json | 4 +- apps/web/public/r/takumi/keep-together.json | 2 +- apps/web/public/r/takumi/key-value.json | 2 +- apps/web/public/r/takumi/lesson-plan.json | 4 +- apps/web/public/r/takumi/link.json | 2 +- apps/web/public/r/takumi/list.json | 6 +- .../public/r/takumi/medical-intake-form.json | 4 +- apps/web/public/r/takumi/meeting-minutes.json | 4 +- apps/web/public/r/takumi/packing-slip.json | 4 +- apps/web/public/r/takumi/page-break.json | 2 +- apps/web/public/r/takumi/page-footer.json | 2 +- apps/web/public/r/takumi/page-header.json | 2 +- apps/web/public/r/takumi/page-number.json | 2 +- apps/web/public/r/takumi/pdf-image.json | 2 +- apps/web/public/r/takumi/press-release.json | 4 +- apps/web/public/r/takumi/qrcode.json | 2 +- .../web/public/r/takumi/report-financial.json | 6 +- .../web/public/r/takumi/report-marketing.json | 6 +- .../public/r/takumi/report-operations.json | 6 +- apps/web/public/r/takumi/report-security.json | 6 +- apps/web/public/r/takumi/section.json | 2 +- apps/web/public/r/takumi/shipping-label.json | 4 +- apps/web/public/r/takumi/signature.json | 2 +- apps/web/public/r/takumi/stack.json | 2 +- apps/web/public/r/takumi/table.json | 6 +- apps/web/public/r/takumi/text.json | 2 +- apps/web/public/r/takumi/theme-provider.json | 2 +- apps/web/public/r/takumi/utils.json | 10 +-- apps/web/public/r/takumi/watermark.json | 2 +- apps/web/public/r/takumi/work-order.json | 4 +- apps/web/public/r/theme-blueprint.json | 8 +-- apps/web/public/r/theme-corporate.json | 8 +-- apps/web/public/r/theme-elegant.json | 8 +-- apps/web/public/r/theme-executive.json | 8 +-- apps/web/public/r/theme-forest.json | 8 +-- apps/web/public/r/theme-minimal.json | 8 +-- apps/web/public/r/theme-modern.json | 8 +-- apps/web/public/r/theme-professional.json | 8 +-- apps/web/public/r/theme-vivid.json | 8 +-- apps/web/registry.json | 67 ++----------------- apps/web/scripts/build-registry.ts | 24 +++++-- apps/web/scripts/check-install.ts | 14 +++- pnpm-lock.yaml | 20 +++--- 111 files changed, 313 insertions(+), 553 deletions(-) diff --git a/apps/web/content/docs/(root)/installation.md b/apps/web/content/docs/(root)/installation.md index 5da2e74..425d1ff 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,59 @@ 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 { port1, port2 } = new MessageChannel(); port1.onmessage = ({ data }) => data.error ? reject(data.error) : resolve(data.pdf); worker.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 { port1, port2 } = new MessageChannel(); port1.onmessage = ({ data }) => data.error ? reject(data.error) : resolve(data.pdf); worker.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 +263,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"] }, }); @@ -265,7 +280,7 @@ const pdf = await renderInWorker({ :::tab{value="forme" label="Forme"} ```ts -const doc = renderFormeDocument(Invoice, { inputs: { theme } }); +const doc = renderFormeDocument(Invoice); doc.fonts = [ ...(doc.fonts ?? []), { @@ -275,10 +290,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. +For Forme, `family` must match the font family that your theme's typography 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..33ea9ce 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. Content 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..10cf9d0 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 last line of every installed file, as the MIT License requires. `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;\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\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/key-value/key-value.ts" } diff --git a/apps/web/public/r/forme/lesson-plan.json b/apps/web/public/r/forme/lesson-plan.json index 7a965f0..3bcdf54 100644 --- a/apps/web/public/r/forme/lesson-plan.json +++ b/apps/web/public/r/forme/lesson-plan.json @@ -3,10 +3,6 @@ "name": "forme/lesson-plan", "title": "Lesson Plan", "description": "Lesson Plan PDF block (forme)", - "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0" - ], "registryDependencies": [ "@angular-pdfcn/forme/utils", "@angular-pdfcn/forme/page-footer", @@ -18,13 +14,13 @@ "files": [ { "path": "registry/bases/forme/blocks/lesson-plan/lesson-plan.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\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 { LessonPlanProps } from \"./lesson-plan.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: LessonPlanProps = {\n accentColor: \"#7c3aed\",\n assessment: {\n formative: [\"Exit ticket\", \"Observation during guided practice\"],\n summative: [\"Chapter quiz\"],\n },\n date: \"September 15, 2026\",\n differentiation: [\n \"Provide equation mats for visual learners\",\n \"Allow calculator use for students with processing difficulties\",\n \"Offer extension problems for advanced learners\",\n ],\n duration: \"50 minutes\",\n essentialQuestion:\n \"How can we represent real-world relationships using linear equations?\",\n gradeLevel: \"8th Grade\",\n homework: \"Complete worksheet problems 11-20\",\n lessonTitle: \"Introduction to Linear Equations\",\n materials: [\"Graph paper\", \"Rulers\", \"Calculator\", \"Whiteboard markers\"],\n objectives: [\n \"Define linear equations\",\n \"Graph linear equations on a coordinate plane\",\n \"Solve simple linear equations\",\n ],\n sequence: [\n {\n activity: \"Warm-up\",\n description: \"Review solving one-step equations\",\n notes: \"5 problems on the board\",\n time: \"5 min\",\n },\n {\n activity: \"Introduction\",\n description: \"Define linear equations, show examples\",\n notes: \"Use real-world context\",\n time: \"10 min\",\n },\n {\n activity: \"Guided Practice\",\n description: \"Work through 3 examples together\",\n notes: \"Check for understanding\",\n time: \"15 min\",\n },\n {\n activity: \"Independent Practice\",\n description: \"Complete worksheet problems 1-10\",\n notes: \"Circulate and support\",\n time: \"15 min\",\n },\n {\n activity: \"Closure\",\n description: \"Exit ticket: solve one linear equation\",\n notes: \"Collect before dismissal\",\n time: \"5 min\",\n },\n ],\n standards: [\"CCSS.MATH.8.EE.B.6\", \"CCSS.MATH.8.EE.C.7\"],\n subject: \"Mathematics\",\n teacherName: \"Ms. Johnson\",\n topic: \"Linear Equations\",\n};\n\nconst REFLECTION_LINE_KEYS = Array.from(\n { length: 8 },\n (_, line) => `reflection-line-${line}`\n);\n\nconst COLUMN_WIDTHS = { activity: 104, notes: 140, time: 56 };\n\nconst lessonPlanLayout = (theme: PdfcnTheme, data: LessonPlanProps) => {\n const rule = {\n borderBottomColor: theme.colors.border,\n borderBottomStyle: \"solid\" as const,\n borderBottomWidth: 1,\n };\n\n const styles = StyleSheet.create({\n block: {\n marginBottom: 16,\n },\n colHalf: {\n flex: 2,\n paddingRight: 20,\n },\n colQuarter: {\n flex: 1,\n paddingRight: 10,\n },\n infoRow: {\n ...rule,\n flexDirection: \"row\",\n marginBottom: 16,\n paddingBottom: 12,\n },\n intro: {\n marginBottom: 3,\n },\n label: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 4,\n },\n listMarker: {\n width: 12,\n },\n listRow: {\n flexDirection: \"row\",\n marginBottom: 3,\n },\n listText: {\n flex: 1,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n reflectionLine: {\n ...rule,\n height: 24,\n },\n row: {\n flexDirection: \"row\",\n },\n });\n\n const pageMargin = {\n bottom: theme.spacing.page.marginBottom,\n left: theme.spacing.page.marginLeft,\n right: theme.spacing.page.marginRight,\n top: theme.spacing.page.marginTop,\n };\n\n const info = [\n { label: \"Subject\", value: data.subject },\n { label: \"Grade Level\", value: data.gradeLevel },\n { label: \"Teacher\", value: data.teacherName },\n { label: \"Duration\", value: data.duration },\n ];\n\n const footerText = `${data.subject} · ${data.gradeLevel} · ${data.lessonTitle}`;\n\n return { footerText, info, pageMargin, styles };\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n NgTemplateOutlet,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-lesson-plan-content\",\n template: `\n @let data = this.data();\n @let styles = layout().styles;\n \n {{ label }}\n \n \n @let list = items ?? [];\n @if (list.length > 0) {\n @for (item of list; track $index; let index = $index) {\n \n \n {{\n numbered ? index + 1 + \".\" : \"•\"\n }}\n \n \n {{ item }}\n \n \n }\n } @else {\n —\n }\n \n \n \n \n \n \n\n \n @for (item of layout().info; track item.label) {\n \n \n {{\n item.value\n }}\n \n }\n \n\n @if (data.essentialQuestion) {\n \n \n {{\n data.essentialQuestion\n }}\n \n }\n\n \n \n \n Students will be able to (SWBAT):\n \n \n @if (data.standards?.length) {\n \n \n \n \n }\n \n \n \n \n \n\n \n \n \n \n \n Time\n Activity\n Description\n Notes\n \n \n \n @for (item of data.sequence; track $index) {\n \n {{\n item.time\n }}\n {{\n item.activity\n }}\n {{ item.description }}\n {{\n item.notes ?? \"—\"\n }}\n \n }\n \n \n \n \n \n\n \n \n \n @if (data.differentiation?.length) {\n \n \n \n \n }\n\n \n \n \n \n \n \n \n \n \n \n\n @if (data.homework) {\n \n \n {{ data.homework }}\n \n }\n\n \n \n @if (data.reflection) {\n {{ data.reflection }}\n }\n @for (key of REFLECTION_LINE_KEYS; track key) {\n \n }\n \n \n \n \n `,\n})\nexport class LessonPlanContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly COLUMN_WIDTHS = COLUMN_WIDTHS;\n protected readonly REFLECTION_LINE_KEYS = REFLECTION_LINE_KEYS;\n\n protected readonly layout = computed(() =>\n lessonPlanLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [LessonPlanContent, PdfcnThemeProvider],\n selector: \"pdf-lesson-plan\",\n template: `\n \n \n \n `,\n})\nexport class LessonPlanDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly mergedData = computed(\n (): LessonPlanProps => ({ ...sampleData, ...this.data() })\n );\n}\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\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 { LessonPlanProps } from \"./lesson-plan.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: LessonPlanProps = {\n accentColor: \"#7c3aed\",\n assessment: {\n formative: [\"Exit ticket\", \"Observation during guided practice\"],\n summative: [\"Chapter quiz\"],\n },\n date: \"September 15, 2026\",\n differentiation: [\n \"Provide equation mats for visual learners\",\n \"Allow calculator use for students with processing difficulties\",\n \"Offer extension problems for advanced learners\",\n ],\n duration: \"50 minutes\",\n essentialQuestion:\n \"How can we represent real-world relationships using linear equations?\",\n gradeLevel: \"8th Grade\",\n homework: \"Complete worksheet problems 11-20\",\n lessonTitle: \"Introduction to Linear Equations\",\n materials: [\"Graph paper\", \"Rulers\", \"Calculator\", \"Whiteboard markers\"],\n objectives: [\n \"Define linear equations\",\n \"Graph linear equations on a coordinate plane\",\n \"Solve simple linear equations\",\n ],\n sequence: [\n {\n activity: \"Warm-up\",\n description: \"Review solving one-step equations\",\n notes: \"5 problems on the board\",\n time: \"5 min\",\n },\n {\n activity: \"Introduction\",\n description: \"Define linear equations, show examples\",\n notes: \"Use real-world context\",\n time: \"10 min\",\n },\n {\n activity: \"Guided Practice\",\n description: \"Work through 3 examples together\",\n notes: \"Check for understanding\",\n time: \"15 min\",\n },\n {\n activity: \"Independent Practice\",\n description: \"Complete worksheet problems 1-10\",\n notes: \"Circulate and support\",\n time: \"15 min\",\n },\n {\n activity: \"Closure\",\n description: \"Exit ticket: solve one linear equation\",\n notes: \"Collect before dismissal\",\n time: \"5 min\",\n },\n ],\n standards: [\"CCSS.MATH.8.EE.B.6\", \"CCSS.MATH.8.EE.C.7\"],\n subject: \"Mathematics\",\n teacherName: \"Ms. Johnson\",\n topic: \"Linear Equations\",\n};\n\nconst REFLECTION_LINE_KEYS = Array.from(\n { length: 8 },\n (_, line) => `reflection-line-${line}`\n);\n\nconst COLUMN_WIDTHS = { activity: 104, notes: 140, time: 56 };\n\nconst lessonPlanLayout = (theme: PdfcnTheme, data: LessonPlanProps) => {\n const rule = {\n borderBottomColor: theme.colors.border,\n borderBottomStyle: \"solid\" as const,\n borderBottomWidth: 1,\n };\n\n const styles = StyleSheet.create({\n block: {\n marginBottom: 16,\n },\n colHalf: {\n flex: 2,\n paddingRight: 20,\n },\n colQuarter: {\n flex: 1,\n paddingRight: 10,\n },\n infoRow: {\n ...rule,\n flexDirection: \"row\",\n marginBottom: 16,\n paddingBottom: 12,\n },\n intro: {\n marginBottom: 3,\n },\n label: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 4,\n },\n listMarker: {\n width: 12,\n },\n listRow: {\n flexDirection: \"row\",\n marginBottom: 3,\n },\n listText: {\n flex: 1,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n reflectionLine: {\n ...rule,\n height: 24,\n },\n row: {\n flexDirection: \"row\",\n },\n });\n\n const pageMargin = {\n bottom: theme.spacing.page.marginBottom,\n left: theme.spacing.page.marginLeft,\n right: theme.spacing.page.marginRight,\n top: theme.spacing.page.marginTop,\n };\n\n const info = [\n { label: \"Subject\", value: data.subject },\n { label: \"Grade Level\", value: data.gradeLevel },\n { label: \"Teacher\", value: data.teacherName },\n { label: \"Duration\", value: data.duration },\n ];\n\n const footerText = `${data.subject} · ${data.gradeLevel} · ${data.lessonTitle}`;\n\n return { footerText, info, pageMargin, styles };\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n NgTemplateOutlet,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-lesson-plan-content\",\n template: `\n @let data = this.data();\n @let styles = layout().styles;\n \n {{ label }}\n \n \n @let list = items ?? [];\n @if (list.length > 0) {\n @for (item of list; track $index; let index = $index) {\n \n \n {{\n numbered ? index + 1 + \".\" : \"•\"\n }}\n \n \n {{ item }}\n \n \n }\n } @else {\n —\n }\n \n \n \n \n \n \n\n \n @for (item of layout().info; track item.label) {\n \n \n {{\n item.value\n }}\n \n }\n \n\n @if (data.essentialQuestion) {\n \n \n {{\n data.essentialQuestion\n }}\n \n }\n\n \n \n \n Students will be able to (SWBAT):\n \n \n @if (data.standards?.length) {\n \n \n \n \n }\n \n \n \n \n \n\n \n \n \n \n \n Time\n Activity\n Description\n Notes\n \n \n \n @for (item of data.sequence; track $index) {\n \n {{\n item.time\n }}\n {{\n item.activity\n }}\n {{ item.description }}\n {{\n item.notes ?? \"—\"\n }}\n \n }\n \n \n \n \n \n\n \n \n \n @if (data.differentiation?.length) {\n \n \n \n \n }\n\n \n \n \n \n \n \n \n \n \n \n\n @if (data.homework) {\n \n \n {{ data.homework }}\n \n }\n\n \n \n @if (data.reflection) {\n {{ data.reflection }}\n }\n @for (key of REFLECTION_LINE_KEYS; track key) {\n \n }\n \n \n \n \n `,\n})\nexport class LessonPlanContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly COLUMN_WIDTHS = COLUMN_WIDTHS;\n protected readonly REFLECTION_LINE_KEYS = REFLECTION_LINE_KEYS;\n\n protected readonly layout = computed(() =>\n lessonPlanLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [LessonPlanContent, PdfcnThemeProvider],\n selector: \"pdf-lesson-plan\",\n template: `\n \n \n \n `,\n})\nexport class LessonPlanDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly mergedData = computed(\n (): LessonPlanProps => ({ ...sampleData, ...this.data() })\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:block", "target": "components/pdf/blocks/lesson-plan/lesson-plan.ts" }, { "path": "registry/bases/forme/blocks/lesson-plan/lesson-plan.types.ts", - "content": "export interface LessonPlanSequenceItem {\n time: string;\n activity: string;\n description: string;\n notes?: string;\n}\n\nexport interface LessonPlanAssessment {\n formative?: string[];\n summative?: string[];\n}\n\nexport interface LessonPlanProps {\n subject: string;\n gradeLevel: string;\n lessonTitle: string;\n date: string;\n teacherName: string;\n duration: string;\n topic?: string;\n essentialQuestion?: string;\n objectives: string[];\n standards?: string[];\n materials: string[];\n sequence: LessonPlanSequenceItem[];\n differentiation?: string[];\n assessment: LessonPlanAssessment;\n homework?: string;\n reflection?: string;\n accentColor?: string;\n renderingBase?: \"takumi\" | \"forme\";\n}\n", + "content": "export interface LessonPlanSequenceItem {\n time: string;\n activity: string;\n description: string;\n notes?: string;\n}\n\nexport interface LessonPlanAssessment {\n formative?: string[];\n summative?: string[];\n}\n\nexport interface LessonPlanProps {\n subject: string;\n gradeLevel: string;\n lessonTitle: string;\n date: string;\n teacherName: string;\n duration: string;\n topic?: string;\n essentialQuestion?: string;\n objectives: string[];\n standards?: string[];\n materials: string[];\n sequence: LessonPlanSequenceItem[];\n differentiation?: string[];\n assessment: LessonPlanAssessment;\n homework?: string;\n reflection?: 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/lesson-plan/lesson-plan.types.ts" } diff --git a/apps/web/public/r/forme/link.json b/apps/web/public/r/forme/link.json index 6c94947..a537661 100644 --- a/apps/web/public/r/forme/link.json +++ b/apps/web/public/r/forme/link.json @@ -3,17 +3,13 @@ "name": "forme/link", "title": "Link", "description": "Link 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/link/link.ts", - "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } 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 LinkVariant = \"default\" | \"muted\" | \"primary\";\nexport type LinkUnderline = \"always\" | \"none\";\n\n/**\n * Clickable hyperlink for PDF documents.\n * Props - `href` | `children` | `align` | `color` | `variant` | `underline` | `style`\n * @see {@link LinkProps}\n */\nexport interface LinkProps extends PDFComponentProps {\n href: string;\n /**\n * @default 'left'\n */\n align?: \"left\" | \"center\" | \"right\";\n color?: string;\n /**\n * @default 'default'\n */\n variant?: LinkVariant;\n /**\n * @default 'always'\n */\n underline?: LinkUnderline;\n}\n\nconst createLinkStyles = (t: PdfcnTheme) => {\n const { fontWeights } = t.primitives;\n const base = {\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n lineHeight: t.typography.body.lineHeight,\n marginBottom: t.spacing.paragraphGap,\n };\n return StyleSheet.create({\n default: {\n ...base,\n color: t.colors.accent,\n fontWeight: fontWeights.medium,\n textDecoration: \"underline\",\n },\n muted: {\n ...base,\n color: t.colors.mutedForeground,\n fontWeight: fontWeights.regular,\n textDecoration: \"underline\",\n },\n primary: {\n ...base,\n color: t.colors.primary,\n fontWeight: fontWeights.semibold,\n textDecoration: \"underline\",\n },\n underlineAlways: { textDecoration: \"underline\" },\n underlineNone: { textDecoration: \"none\" },\n });\n};\n\nconst linkStyle = (\n theme: PdfcnTheme,\n {\n align,\n color,\n variant = \"default\",\n underline,\n style,\n }: Omit\n) => {\n const styles = createLinkStyles(theme);\n const variantMap = {\n default: styles.default,\n muted: styles.muted,\n primary: styles.primary,\n };\n const underlineMap = {\n always: styles.underlineAlways,\n none: styles.underlineNone,\n };\n const styleArray: Style[] = [variantMap[variant]];\n if (underline && underline in underlineMap) {\n styleArray.push(underlineMap[underline]);\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 styleArray;\n};\n\n// The Forme serializer flattens a link inside text to plain text, so `href` does not reach the document.\n@Component({\n imports: [FormeText],\n selector: \"pdf-link\",\n template: ``,\n})\nexport class PdfLink {\n readonly href = input.required();\n readonly align = input();\n readonly color = input();\n readonly variant = input(\"default\");\n readonly underline = input();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly linkStyle = computed(() =>\n linkStyle(this.theme(), {\n align: this.align(),\n color: this.color(),\n style: this.style(),\n underline: this.underline(),\n variant: this.variant(),\n })\n );\n}\n", + "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } 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 LinkVariant = \"default\" | \"muted\" | \"primary\";\nexport type LinkUnderline = \"always\" | \"none\";\n\n/**\n * Clickable hyperlink for PDF documents.\n * Props - `href` | `children` | `align` | `color` | `variant` | `underline` | `style`\n * @see {@link LinkProps}\n */\nexport interface LinkProps extends PDFComponentProps {\n href: string;\n /**\n * @default 'left'\n */\n align?: \"left\" | \"center\" | \"right\";\n color?: string;\n /**\n * @default 'default'\n */\n variant?: LinkVariant;\n /**\n * @default 'always'\n */\n underline?: LinkUnderline;\n}\n\nconst createLinkStyles = (t: PdfcnTheme) => {\n const { fontWeights } = t.primitives;\n const base = {\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n lineHeight: t.typography.body.lineHeight,\n marginBottom: t.spacing.paragraphGap,\n };\n return StyleSheet.create({\n default: {\n ...base,\n color: t.colors.accent,\n fontWeight: fontWeights.medium,\n textDecoration: \"underline\",\n },\n muted: {\n ...base,\n color: t.colors.mutedForeground,\n fontWeight: fontWeights.regular,\n textDecoration: \"underline\",\n },\n primary: {\n ...base,\n color: t.colors.primary,\n fontWeight: fontWeights.semibold,\n textDecoration: \"underline\",\n },\n underlineAlways: { textDecoration: \"underline\" },\n underlineNone: { textDecoration: \"none\" },\n });\n};\n\nconst linkStyle = (\n theme: PdfcnTheme,\n {\n align,\n color,\n variant = \"default\",\n underline,\n style,\n }: Omit\n) => {\n const styles = createLinkStyles(theme);\n const variantMap = {\n default: styles.default,\n muted: styles.muted,\n primary: styles.primary,\n };\n const underlineMap = {\n always: styles.underlineAlways,\n none: styles.underlineNone,\n };\n const styleArray: Style[] = [variantMap[variant]];\n if (underline && underline in underlineMap) {\n styleArray.push(underlineMap[underline]);\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 styleArray;\n};\n\n// The Forme serializer flattens a link inside text to plain text, so `href` does not reach the document.\n@Component({\n imports: [FormeText],\n selector: \"pdf-link\",\n template: ``,\n})\nexport class PdfLink {\n readonly href = input.required();\n readonly align = input();\n readonly color = input();\n readonly variant = input(\"default\");\n readonly underline = input();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly linkStyle = computed(() =>\n linkStyle(this.theme(), {\n align: this.align(),\n color: this.color(),\n style: this.style(),\n underline: this.underline(),\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/link/link.ts" } diff --git a/apps/web/public/r/forme/list.json b/apps/web/public/r/forme/list.json index 2737b53..417fa67 100644 --- a/apps/web/public/r/forme/list.json +++ b/apps/web/public/r/forme/list.json @@ -3,29 +3,25 @@ "name": "forme/list", "title": "List", "description": "List 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/list/list.styles.ts", - "content": "import { StyleSheet } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Creates all list styles derived from the active theme.\n * @param t - The resolved PdfcnTheme instance.\n */\nexport const createListStyles = (t: PdfcnTheme) => {\n const { borderRadius, spacing, fontWeights, typography } = t.primitives;\n\n return StyleSheet.create({\n checkBox: {\n alignItems: \"center\",\n backgroundColor: t.colors.background,\n borderColor: t.colors.border,\n borderRadius: 3,\n borderStyle: \"solid\",\n borderWidth: 1.5,\n height: spacing[4],\n justifyContent: \"center\",\n marginRight: spacing[2],\n width: spacing[4],\n },\n checkBoxChecked: {\n backgroundColor: t.colors.success,\n borderColor: t.colors.success,\n },\n checklistTextWrap: {\n flex: 1,\n marginLeft: spacing[2],\n },\n childrenContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n marginLeft: spacing[5],\n marginTop: spacing[1],\n },\n container: {\n display: \"flex\",\n flexDirection: \"column\",\n marginBottom: t.spacing.componentGap,\n width: \"100%\",\n },\n descriptiveAccent: {\n backgroundColor: t.colors.primary,\n borderRadius: borderRadius.sm,\n marginRight: spacing[3],\n minHeight: spacing[4],\n width: 3,\n },\n descriptiveContent: {\n flex: 1,\n },\n descriptiveDesc: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n lineHeight: t.typography.body.lineHeight,\n marginTop: 1,\n },\n descriptiveTitle: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: t.typography.body.lineHeight,\n },\n iconBox: {\n alignItems: \"center\",\n backgroundColor: t.colors.primary,\n borderRadius: borderRadius.md,\n height: spacing[5],\n justifyContent: \"center\",\n marginRight: spacing[2],\n width: spacing[5],\n },\n iconMark: {\n color: t.colors.primaryForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: 9,\n fontWeight: fontWeights.bold,\n },\n itemRow: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n },\n itemRowCenter: {\n alignItems: \"center\",\n flexDirection: \"row\",\n },\n itemRowGapMd: { marginBottom: spacing[3] },\n itemRowGapSm: { marginBottom: spacing[2] },\n itemRowGapXs: { marginBottom: spacing[1] },\n itemText: {\n // No flex here — Text nodes with flex shorthand get flexBasis:0, which causes\n // Yoga to under-measure multi-line text height → overlapping rows.\n // flex:1 must live on the wrapping View, not on the Text itself.\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 itemTextBold: {\n fontWeight: fontWeights.semibold,\n },\n itemTextSub: {\n // Same: no flex — see itemText comment.\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize - 0.5,\n lineHeight: t.typography.body.lineHeight,\n },\n itemTextWrap: {\n // Companion to itemText / itemTextSub. Apply this to the View that wraps\n // the Text so flex expansion happens at the View level, not the Text level.\n flex: 1,\n },\n markerBulletDot: {\n backgroundColor: t.colors.primary,\n borderRadius: 3,\n height: 5,\n width: 5,\n },\n markerBulletSubDot: {\n backgroundColor: \"transparent\",\n borderColor: t.colors.mutedForeground,\n borderRadius: 2,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 4,\n width: 4,\n },\n markerBulletSubWrap: {\n alignItems: \"center\",\n justifyContent: \"flex-start\",\n marginTop: spacing[1],\n width: spacing[4],\n },\n markerBulletWrap: {\n alignItems: \"center\",\n justifyContent: \"flex-start\",\n marginTop: spacing[1],\n width: spacing[4],\n },\n markerNumberBadge: {\n alignItems: \"center\",\n backgroundColor: t.colors.primary,\n borderRadius: spacing[5],\n height: spacing[5],\n justifyContent: \"center\",\n marginRight: spacing[2],\n width: spacing[5],\n },\n markerNumberText: {\n color: t.colors.primaryForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.bold,\n },\n });\n};\n", + "content": "import { StyleSheet } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Creates all list styles derived from the active theme.\n * @param t - The resolved PdfcnTheme instance.\n */\nexport const createListStyles = (t: PdfcnTheme) => {\n const { borderRadius, spacing, fontWeights, typography } = t.primitives;\n\n return StyleSheet.create({\n checkBox: {\n alignItems: \"center\",\n backgroundColor: t.colors.background,\n borderColor: t.colors.border,\n borderRadius: 3,\n borderStyle: \"solid\",\n borderWidth: 1.5,\n height: spacing[4],\n justifyContent: \"center\",\n marginRight: spacing[2],\n width: spacing[4],\n },\n checkBoxChecked: {\n backgroundColor: t.colors.success,\n borderColor: t.colors.success,\n },\n checklistTextWrap: {\n flex: 1,\n marginLeft: spacing[2],\n },\n childrenContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n marginLeft: spacing[5],\n marginTop: spacing[1],\n },\n container: {\n display: \"flex\",\n flexDirection: \"column\",\n marginBottom: t.spacing.componentGap,\n width: \"100%\",\n },\n descriptiveAccent: {\n backgroundColor: t.colors.primary,\n borderRadius: borderRadius.sm,\n marginRight: spacing[3],\n minHeight: spacing[4],\n width: 3,\n },\n descriptiveContent: {\n flex: 1,\n },\n descriptiveDesc: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n lineHeight: t.typography.body.lineHeight,\n marginTop: 1,\n },\n descriptiveTitle: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: t.typography.body.lineHeight,\n },\n iconBox: {\n alignItems: \"center\",\n backgroundColor: t.colors.primary,\n borderRadius: borderRadius.md,\n height: spacing[5],\n justifyContent: \"center\",\n marginRight: spacing[2],\n width: spacing[5],\n },\n iconMark: {\n color: t.colors.primaryForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: 9,\n fontWeight: fontWeights.bold,\n },\n itemRow: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n },\n itemRowCenter: {\n alignItems: \"center\",\n flexDirection: \"row\",\n },\n itemRowGapMd: { marginBottom: spacing[3] },\n itemRowGapSm: { marginBottom: spacing[2] },\n itemRowGapXs: { marginBottom: spacing[1] },\n itemText: {\n // No flex here — Text nodes with flex shorthand get flexBasis:0, which causes\n // Yoga to under-measure multi-line text height → overlapping rows.\n // flex:1 must live on the wrapping View, not on the Text itself.\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 itemTextBold: {\n fontWeight: fontWeights.semibold,\n },\n itemTextSub: {\n // Same: no flex — see itemText comment.\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize - 0.5,\n lineHeight: t.typography.body.lineHeight,\n },\n itemTextWrap: {\n // Companion to itemText / itemTextSub. Apply this to the View that wraps\n // the Text so flex expansion happens at the View level, not the Text level.\n flex: 1,\n },\n markerBulletDot: {\n backgroundColor: t.colors.primary,\n borderRadius: 3,\n height: 5,\n width: 5,\n },\n markerBulletSubDot: {\n backgroundColor: \"transparent\",\n borderColor: t.colors.mutedForeground,\n borderRadius: 2,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 4,\n width: 4,\n },\n markerBulletSubWrap: {\n alignItems: \"center\",\n justifyContent: \"flex-start\",\n marginTop: spacing[1],\n width: spacing[4],\n },\n markerBulletWrap: {\n alignItems: \"center\",\n justifyContent: \"flex-start\",\n marginTop: spacing[1],\n width: spacing[4],\n },\n markerNumberBadge: {\n alignItems: \"center\",\n backgroundColor: t.colors.primary,\n borderRadius: spacing[5],\n height: spacing[5],\n justifyContent: \"center\",\n marginRight: spacing[2],\n width: spacing[5],\n },\n markerNumberText: {\n color: t.colors.primaryForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.bold,\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/list/list.styles.ts" }, { "path": "registry/bases/forme/components/list/list.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 { createListStyles } from \"./list.styles\";\nimport type { ListItem, ListVariant, PdfListProps } from \"./list.types\";\n\ntype Styles = ReturnType;\ntype GapProp = \"xs\" | \"sm\" | \"md\";\n\n/** One rendered row. Bullet and multi-level rows carry a marker and nested rows. */\ninterface ListRow {\n variant: ListVariant;\n item: ListItem;\n rowStyle: Style[];\n label?: string;\n boxStyle?: Style[];\n marker?: { wrap: Style; dot: Style };\n textStyle?: Style[];\n children?: { style: Style | undefined; rows: (ListRow | null)[] } | null;\n}\n\nconst getGapStyle = (gap: GapProp, styles: Styles): Style => {\n if (gap === \"xs\") {\n return styles.itemRowGapXs;\n }\n if (gap === \"md\") {\n return styles.itemRowGapMd;\n }\n return styles.itemRowGapSm;\n};\n\nconst buildRowStyles = (\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles,\n align: \"start\" | \"center\" = \"start\"\n): Style[] => {\n const row: Style[] = [\n align === \"center\" ? styles.itemRowCenter : styles.itemRow,\n ];\n if (index !== total - 1) {\n row.push(getGapStyle(gap, styles));\n }\n return row;\n};\n\n/** Bullet dot marker — solid filled for level 0, outline ring for nested levels. */\nconst dotMarker = (level: number, styles: Styles) =>\n level === 0\n ? { dot: styles.markerBulletDot, wrap: styles.markerBulletWrap }\n : { dot: styles.markerBulletSubDot, wrap: styles.markerBulletSubWrap };\n\n// eslint-disable-next-line no-use-before-define, prefer-const\nlet renderBulletItem: (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles,\n level: number\n) => ListRow;\n// eslint-disable-next-line no-use-before-define, prefer-const\nlet renderMultiLevelItem: (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles,\n level: number\n) => ListRow;\n\nconst renderNumberedItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => ({\n item,\n label: `${index + 1}`,\n rowStyle: buildRowStyles(index, total, gap, styles, \"center\"),\n variant: \"numbered\",\n});\n\nconst renderChecklistItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => {\n const isChecked = item.checked ?? true;\n return {\n boxStyle: [styles.checkBox, isChecked ? styles.checkBoxChecked : {}],\n item,\n rowStyle: buildRowStyles(index, total, gap, styles, \"center\"),\n variant: \"checklist\",\n };\n};\n\nconst renderIconItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => ({\n item,\n rowStyle: buildRowStyles(index, total, gap, styles, \"center\"),\n variant: \"icon\",\n});\n\nconst renderDescriptiveItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => ({\n item,\n rowStyle: buildRowStyles(index, total, gap, styles),\n variant: \"descriptive\",\n});\n\nconst renderItem = (\n item: ListItem,\n index: number,\n total: number,\n variant: ListVariant,\n gap: GapProp,\n styles: Styles,\n level: number\n): ListRow | null => {\n switch (variant) {\n case \"bullet\": {\n return renderBulletItem(item, index, total, gap, styles, level);\n }\n case \"numbered\": {\n return renderNumberedItem(item, index, total, gap, styles);\n }\n case \"checklist\": {\n return renderChecklistItem(item, index, total, gap, styles);\n }\n case \"icon\": {\n return renderIconItem(item, index, total, gap, styles);\n }\n case \"multi-level\": {\n return renderMultiLevelItem(item, index, total, gap, styles, level);\n }\n case \"descriptive\": {\n return renderDescriptiveItem(item, index, total, gap, styles);\n }\n default: {\n break;\n }\n }\n return null;\n};\n\nconst renderItemList = (\n items: ListItem[],\n variant: ListVariant,\n gap: GapProp,\n styles: Styles,\n level: number\n) => ({\n rows: items.map((item, index) =>\n renderItem(item, index, items.length, variant, gap, styles, level)\n ),\n style: level > 0 ? styles.childrenContainer : undefined,\n});\n\nrenderBulletItem = (item, index, total, gap, styles, level) => ({\n children:\n item.children && item.children.length > 0\n ? renderItemList(item.children, \"bullet\", gap, styles, level + 1)\n : null,\n item,\n marker: dotMarker(level, styles),\n rowStyle: buildRowStyles(index, total, gap, styles),\n textStyle: [styles.itemText],\n variant: \"bullet\",\n});\n\nrenderMultiLevelItem = (item, index, total, gap, styles, level) => ({\n children:\n item.children && item.children.length > 0\n ? renderItemList(item.children, \"multi-level\", gap, styles, level + 1)\n : null,\n item,\n marker: dotMarker(level, styles),\n rowStyle: buildRowStyles(index, total, gap, styles),\n textStyle: [\n level === 0 ? styles.itemText : styles.itemTextSub,\n level === 0 ? styles.itemTextBold : {},\n ],\n variant: \"multi-level\",\n});\n\nconst listLayout = (\n theme: PdfcnTheme,\n { items, variant = \"bullet\", gap = \"sm\", style, _level = 0 }: PdfListProps\n) => {\n const styles = createListStyles(theme);\n\n const containerStyles: Style[] = [styles.container];\n if (_level > 0) {\n containerStyles.push(styles.childrenContainer);\n }\n const styleArray = style ? [...containerStyles, style] : containerStyles;\n\n return {\n container: styleArray,\n rows: items.map((item, index) =>\n renderItem(item, index, items.length, variant, gap, styles, _level)\n ),\n styles,\n };\n};\n\n/** List of items with multiple style variants including bullet, numbered, checklist, and descriptive. */\n@Component({\n imports: [FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-list\",\n template: `\n @let s = layout().styles;\n \n \n \n \n @for (row of asRows(rows); track $index) {\n @if (row) {\n @switch (row.variant) {\n @case (\"numbered\") {\n \n \n {{\n row.label\n }}\n \n \n {{\n row.item.text\n }}\n \n \n }\n @case (\"checklist\") {\n \n \n \n {{\n row.item.text\n }}\n \n \n }\n @case (\"icon\") {\n \n \n ★\n \n \n {{\n row.item.text\n }}\n \n \n }\n @case (\"descriptive\") {\n \n \n \n {{\n row.item.text\n }}\n @if (row.item.description) {\n {{\n row.item.description\n }}\n }\n \n \n }\n @default {\n \n \n \n \n \n \n {{\n row.item.text\n }}\n \n \n @if (row.children) {\n \n \n \n }\n \n }\n }\n }\n }\n \n `,\n})\nexport class PdfList {\n readonly items = input.required();\n readonly variant = input(\"bullet\");\n readonly gap = input(\"sm\");\n /** Part of the props API but unused, as in the original. */\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n readonly _level = input(0);\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n listLayout(this.theme(), {\n _level: this._level(),\n gap: this.gap(),\n items: this.items(),\n style: this.style(),\n variant: this.variant(),\n })\n );\n\n protected readonly asRows = (rows: (ListRow | null)[]) => rows;\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 { createListStyles } from \"./list.styles\";\nimport type { ListItem, ListVariant, PdfListProps } from \"./list.types\";\n\ntype Styles = ReturnType;\ntype GapProp = \"xs\" | \"sm\" | \"md\";\n\n/** One rendered row. Bullet and multi-level rows carry a marker and nested rows. */\ninterface ListRow {\n variant: ListVariant;\n item: ListItem;\n rowStyle: Style[];\n label?: string;\n boxStyle?: Style[];\n marker?: { wrap: Style; dot: Style };\n textStyle?: Style[];\n children?: { style: Style | undefined; rows: (ListRow | null)[] } | null;\n}\n\nconst getGapStyle = (gap: GapProp, styles: Styles): Style => {\n if (gap === \"xs\") {\n return styles.itemRowGapXs;\n }\n if (gap === \"md\") {\n return styles.itemRowGapMd;\n }\n return styles.itemRowGapSm;\n};\n\nconst buildRowStyles = (\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles,\n align: \"start\" | \"center\" = \"start\"\n): Style[] => {\n const row: Style[] = [\n align === \"center\" ? styles.itemRowCenter : styles.itemRow,\n ];\n if (index !== total - 1) {\n row.push(getGapStyle(gap, styles));\n }\n return row;\n};\n\n/** Bullet dot marker — solid filled for level 0, outline ring for nested levels. */\nconst dotMarker = (level: number, styles: Styles) =>\n level === 0\n ? { dot: styles.markerBulletDot, wrap: styles.markerBulletWrap }\n : { dot: styles.markerBulletSubDot, wrap: styles.markerBulletSubWrap };\n\n// eslint-disable-next-line no-use-before-define, prefer-const\nlet renderBulletItem: (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles,\n level: number\n) => ListRow;\n// eslint-disable-next-line no-use-before-define, prefer-const\nlet renderMultiLevelItem: (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles,\n level: number\n) => ListRow;\n\nconst renderNumberedItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => ({\n item,\n label: `${index + 1}`,\n rowStyle: buildRowStyles(index, total, gap, styles, \"center\"),\n variant: \"numbered\",\n});\n\nconst renderChecklistItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => {\n const isChecked = item.checked ?? true;\n return {\n boxStyle: [styles.checkBox, isChecked ? styles.checkBoxChecked : {}],\n item,\n rowStyle: buildRowStyles(index, total, gap, styles, \"center\"),\n variant: \"checklist\",\n };\n};\n\nconst renderIconItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => ({\n item,\n rowStyle: buildRowStyles(index, total, gap, styles, \"center\"),\n variant: \"icon\",\n});\n\nconst renderDescriptiveItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => ({\n item,\n rowStyle: buildRowStyles(index, total, gap, styles),\n variant: \"descriptive\",\n});\n\nconst renderItem = (\n item: ListItem,\n index: number,\n total: number,\n variant: ListVariant,\n gap: GapProp,\n styles: Styles,\n level: number\n): ListRow | null => {\n switch (variant) {\n case \"bullet\": {\n return renderBulletItem(item, index, total, gap, styles, level);\n }\n case \"numbered\": {\n return renderNumberedItem(item, index, total, gap, styles);\n }\n case \"checklist\": {\n return renderChecklistItem(item, index, total, gap, styles);\n }\n case \"icon\": {\n return renderIconItem(item, index, total, gap, styles);\n }\n case \"multi-level\": {\n return renderMultiLevelItem(item, index, total, gap, styles, level);\n }\n case \"descriptive\": {\n return renderDescriptiveItem(item, index, total, gap, styles);\n }\n default: {\n break;\n }\n }\n return null;\n};\n\nconst renderItemList = (\n items: ListItem[],\n variant: ListVariant,\n gap: GapProp,\n styles: Styles,\n level: number\n) => ({\n rows: items.map((item, index) =>\n renderItem(item, index, items.length, variant, gap, styles, level)\n ),\n style: level > 0 ? styles.childrenContainer : undefined,\n});\n\nrenderBulletItem = (item, index, total, gap, styles, level) => ({\n children:\n item.children && item.children.length > 0\n ? renderItemList(item.children, \"bullet\", gap, styles, level + 1)\n : null,\n item,\n marker: dotMarker(level, styles),\n rowStyle: buildRowStyles(index, total, gap, styles),\n textStyle: [styles.itemText],\n variant: \"bullet\",\n});\n\nrenderMultiLevelItem = (item, index, total, gap, styles, level) => ({\n children:\n item.children && item.children.length > 0\n ? renderItemList(item.children, \"multi-level\", gap, styles, level + 1)\n : null,\n item,\n marker: dotMarker(level, styles),\n rowStyle: buildRowStyles(index, total, gap, styles),\n textStyle: [\n level === 0 ? styles.itemText : styles.itemTextSub,\n level === 0 ? styles.itemTextBold : {},\n ],\n variant: \"multi-level\",\n});\n\nconst listLayout = (\n theme: PdfcnTheme,\n { items, variant = \"bullet\", gap = \"sm\", style, _level = 0 }: PdfListProps\n) => {\n const styles = createListStyles(theme);\n\n const containerStyles: Style[] = [styles.container];\n if (_level > 0) {\n containerStyles.push(styles.childrenContainer);\n }\n const styleArray = style ? [...containerStyles, style] : containerStyles;\n\n return {\n container: styleArray,\n rows: items.map((item, index) =>\n renderItem(item, index, items.length, variant, gap, styles, _level)\n ),\n styles,\n };\n};\n\n/** List of items with multiple style variants including bullet, numbered, checklist, and descriptive. */\n@Component({\n imports: [FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-list\",\n template: `\n @let s = layout().styles;\n \n \n \n \n @for (row of asRows(rows); track $index) {\n @if (row) {\n @switch (row.variant) {\n @case (\"numbered\") {\n \n \n {{\n row.label\n }}\n \n \n {{\n row.item.text\n }}\n \n \n }\n @case (\"checklist\") {\n \n \n \n {{\n row.item.text\n }}\n \n \n }\n @case (\"icon\") {\n \n \n ★\n \n \n {{\n row.item.text\n }}\n \n \n }\n @case (\"descriptive\") {\n \n \n \n {{\n row.item.text\n }}\n @if (row.item.description) {\n {{\n row.item.description\n }}\n }\n \n \n }\n @default {\n \n \n \n \n \n \n {{\n row.item.text\n }}\n \n \n @if (row.children) {\n \n \n \n }\n \n }\n }\n }\n }\n \n `,\n})\nexport class PdfList {\n readonly items = input.required();\n readonly variant = input(\"bullet\");\n readonly gap = input(\"sm\");\n /** Part of the props API but unused, as in the original. */\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n readonly _level = input(0);\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n listLayout(this.theme(), {\n _level: this._level(),\n gap: this.gap(),\n items: this.items(),\n style: this.style(),\n variant: this.variant(),\n })\n );\n\n protected readonly asRows = (rows: (ListRow | null)[]) => rows;\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/list/list.ts" }, { "path": "registry/bases/forme/components/list/list.types.ts", - "content": "import type { Style } from \"@/lib/pdf-primitives\";\n\n/** List visual style variant. */\nexport type ListVariant =\n | \"bullet\"\n | \"numbered\"\n | \"checklist\"\n | \"icon\"\n | \"multi-level\"\n | \"descriptive\";\n\n/**\n * A single list item, optionally with nested children.\n * Props - `text` | `description` | `checked` | `children`\n * @see {@link ListItem}\n */\nexport interface ListItem {\n text: string;\n description?: string;\n checked?: boolean;\n children?: ListItem[];\n}\n\n/**\n * List of items with multiple style variants including bullet, numbered, checklist, and descriptive.\n * Props - `items` | `variant` | `gap` | `style` | `_level` | `noWrap`\n * @see {@link PdfListProps}\n */\nexport interface PdfListProps {\n items: ListItem[];\n /**\n * @default 'bullet'\n */\n variant?: ListVariant;\n /**\n * @default 'sm'\n */\n gap?: \"xs\" | \"sm\" | \"md\";\n style?: Style;\n _level?: number;\n /**\n * @default false\n */\n noWrap?: boolean;\n}\n", + "content": "import type { Style } from \"@/lib/pdf-primitives\";\n\n/** List visual style variant. */\nexport type ListVariant =\n | \"bullet\"\n | \"numbered\"\n | \"checklist\"\n | \"icon\"\n | \"multi-level\"\n | \"descriptive\";\n\n/**\n * A single list item, optionally with nested children.\n * Props - `text` | `description` | `checked` | `children`\n * @see {@link ListItem}\n */\nexport interface ListItem {\n text: string;\n description?: string;\n checked?: boolean;\n children?: ListItem[];\n}\n\n/**\n * List of items with multiple style variants including bullet, numbered, checklist, and descriptive.\n * Props - `items` | `variant` | `gap` | `style` | `_level` | `noWrap`\n * @see {@link PdfListProps}\n */\nexport interface PdfListProps {\n items: ListItem[];\n /**\n * @default 'bullet'\n */\n variant?: ListVariant;\n /**\n * @default 'sm'\n */\n gap?: \"xs\" | \"sm\" | \"md\";\n style?: Style;\n _level?: number;\n /**\n * @default false\n */\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/list/list.types.ts" } diff --git a/apps/web/public/r/forme/medical-intake-form.json b/apps/web/public/r/forme/medical-intake-form.json index 2a59a8a..7593e2d 100644 --- a/apps/web/public/r/forme/medical-intake-form.json +++ b/apps/web/public/r/forme/medical-intake-form.json @@ -3,10 +3,6 @@ "name": "forme/medical-intake-form", "title": "Medical Intake Form", "description": "Medical Intake Form PDF block (forme)", - "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0" - ], "registryDependencies": [ "@angular-pdfcn/forme/utils", "@angular-pdfcn/forme/form", @@ -22,13 +18,13 @@ "files": [ { "path": "registry/bases/forme/blocks/medical-intake-form/medical-intake-form.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { PdfForm } from \"@/components/pdf/form/form\";\nimport type { PdfFormGroup } from \"@/components/pdf/form/form.types\";\nimport { PdfList } from \"@/components/pdf/list/list\";\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 { PdfSignatureBlock } from \"@/components/pdf/signature/signature\";\nimport type { SignatureSigner } from \"@/components/pdf/signature/signature\";\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 { resolveColor } from \"@/lib/resolve-color\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { MedicalIntakeFormProps } from \"./medical-intake-form.types\";\n\nconst FORM_VERSION = \"Form v1.0 · Revised 09/2026\";\nconst FORM_STYLE = { marginBottom: 0 };\n\nconst SECOND_PAGE_MARGIN_BOTTOM = 44;\nconst SECOND_PAGE_MARGIN_TOP = 24;\n\nconst MEDICAL_CONDITIONS = [\n \"Diabetes\",\n \"High Blood Pressure\",\n \"Heart Disease\",\n \"Asthma\",\n \"COPD\",\n \"Cancer\",\n \"Stroke\",\n \"Thyroid Disorder\",\n \"Kidney Disease\",\n \"Liver Disease\",\n \"Seizures / Epilepsy\",\n \"Other\",\n];\n\nconst CONSENT_ACKNOWLEDGMENTS = [\n { checked: false, text: \"I have read and understand the consent above.\" },\n { checked: false, text: \"I have received the Notice of Privacy Practices.\" },\n];\n\nconst MEDICATION_ROWS = [\n \"medication-1\",\n \"medication-2\",\n \"medication-3\",\n \"medication-4\",\n];\n\nconst ALLERGY_ROWS = [\"allergy-1\", \"allergy-2\", \"allergy-3\"];\n\nconst blankChecklist = (labels: string[]) =>\n labels.map((text) => ({ checked: false, text }));\n\nconst PERSONAL_INFO_GROUPS: PdfFormGroup[] = [\n {\n fields: [\n { height: 14, label: \"Full Name\" },\n { height: 14, hint: \"DD / MM / YYYY\", label: \"Date of Birth\" },\n { height: 14, label: \"Gender\" },\n { height: 14, hint: \"+1 (555) 000-0000\", label: \"Phone Number\" },\n { height: 14, label: \"Email Address\" },\n ],\n layout: \"two-column\",\n title: \"Patient Information\",\n },\n {\n fields: [\n { height: 14, label: \"Street Address\", width: \"100%\" },\n { height: 14, label: \"City\" },\n { height: 14, label: \"State / Province\" },\n { height: 14, label: \"Postal Code\" },\n ],\n layout: \"two-column\",\n title: \"Address\",\n },\n];\n\nconst EMERGENCY_CONTACT_GROUPS: PdfFormGroup[] = [\n {\n fields: [\n { height: 14, label: \"Emergency Contact Name\" },\n { height: 14, label: \"Relationship\" },\n { height: 14, label: \"Phone Number\" },\n ],\n layout: \"two-column\",\n title: \"Emergency Contact\",\n },\n];\n\nconst INSURANCE_GROUPS: PdfFormGroup[] = [\n {\n fields: [\n { height: 14, label: \"Insurance Provider\" },\n { height: 14, label: \"Policy Number\" },\n { height: 14, label: \"Group Number\" },\n { height: 14, label: \"Subscriber Name\" },\n ],\n layout: \"two-column\",\n title: \"Insurance\",\n },\n];\n\nconst MEDICAL_HISTORY_COLUMNS = [\n blankChecklist(MEDICAL_CONDITIONS.slice(0, 4)),\n blankChecklist(MEDICAL_CONDITIONS.slice(4, 8)),\n blankChecklist(MEDICAL_CONDITIONS.slice(8)),\n];\n\nconst CONSENT_SIGNERS: [SignatureSigner, SignatureSigner] = [\n { label: \"Patient / Guardian Signature\" },\n { label: \"Date\" },\n];\n\nconst createIntakeStyles = (t: PdfcnTheme) =>\n StyleSheet.create({\n column: { flex: 1 },\n consentText: {\n fontSize: t.primitives.typography.xs,\n lineHeight: 1.4,\n marginBottom: 6,\n },\n labelText: { fontSize: 9, fontWeight: \"bold\", letterSpacing: 0.6 },\n page: { backgroundColor: t.colors.background },\n pageTwoHeader: {\n alignItems: \"flex-end\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n },\n reasonBox: {\n borderColor: t.colors.border,\n borderRadius: t.primitives.borderRadius.sm,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 40,\n minHeight: 40,\n },\n row: { flexDirection: \"row\", gap: 20 },\n section: { marginBottom: 4 },\n sectionRule: {\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n marginBottom: 4,\n paddingBottom: 2,\n },\n signature: { marginBottom: 0, marginTop: 8 },\n title: { fontSize: 13, fontWeight: \"bold\" },\n });\n\ntype IntakeSections = Required<\n Pick<\n MedicalIntakeFormProps,\n | \"allergies\"\n | \"consent\"\n | \"emergencyContact\"\n | \"insurance\"\n | \"medicalHistory\"\n | \"medications\"\n | \"personalInfo\"\n | \"reasonForVisit\"\n >\n>;\n\nconst resolveSections = (props: MedicalIntakeFormProps): IntakeSections => ({\n allergies: props.allergies ?? true,\n consent: props.consent ?? true,\n emergencyContact: props.emergencyContact ?? true,\n insurance: props.insurance ?? true,\n medicalHistory: props.medicalHistory ?? true,\n medications: props.medications ?? true,\n personalInfo: props.personalInfo ?? true,\n reasonForVisit: props.reasonForVisit ?? true,\n});\n\nconst hasSecondPage = (sections: IntakeSections) =>\n sections.allergies ||\n sections.consent ||\n sections.medications ||\n sections.reasonForVisit;\n\nconst intakeLayout = (theme: PdfcnTheme, props: MedicalIntakeFormProps) => {\n const styles = createIntakeStyles(theme);\n const sections = resolveSections(props);\n const accent = props.accentColor\n ? resolveColor(props.accentColor, theme.colors)\n : theme.colors.primary;\n const totalPages = hasSecondPage(sections) ? 2 : 1;\n\n const firstMargin = {\n bottom: theme.spacing.page.marginBottom,\n left: theme.spacing.page.marginLeft,\n right: theme.spacing.page.marginRight,\n top: theme.spacing.page.marginTop,\n };\n const secondMargin = {\n bottom: SECOND_PAGE_MARGIN_BOTTOM,\n left: theme.spacing.page.marginLeft,\n right: theme.spacing.page.marginRight,\n top: SECOND_PAGE_MARGIN_TOP,\n };\n\n return {\n accent,\n firstMargin,\n secondMargin,\n sectionRule: { ...styles.sectionRule, borderBottomColor: accent },\n sections,\n styles,\n totalPages,\n };\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n NgTemplateOutlet,\n PdfForm,\n PdfImage,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfSignatureBlock,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-medical-intake-form-content\",\n template: `\n @let props = this.props();\n @let l = layout();\n @let styles = l.styles;\n \n \n {{\n label\n }}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n @if (l.sections.personalInfo) {\n \n }\n @if (l.sections.emergencyContact) {\n \n }\n @if (l.sections.insurance) {\n \n }\n \n \n @if (l.totalPages > 1) {\n \n \n \n \n {{\n props.clinicName + \" — Patient Intake Form (continued)\"\n }}\n {{\n props.clinicPhone\n }}\n \n @if (l.sections.medicalHistory) {\n \n \n \n @for (items of MEDICAL_HISTORY_COLUMNS; track $index) {\n \n \n \n }\n \n \n }\n @if (l.sections.medications) {\n \n \n \n \n \n Medication\n Dosage\n Frequency\n Prescribing Doctor\n \n \n \n @for (row of MEDICATION_ROWS; track row) {\n \n \n \n \n \n \n }\n \n \n \n }\n @if (l.sections.allergies) {\n \n \n \n \n \n Allergen\n Reaction\n Severity\n \n \n \n @for (row of ALLERGY_ROWS; track row) {\n \n \n \n \n \n }\n \n \n \n }\n @if (l.sections.reasonForVisit) {\n \n \n \n \n }\n @if (l.sections.consent) {\n \n \n \n {{ consentText() }}\n \n \n \n \n }\n \n \n }\n \n `,\n})\nexport class MedicalIntakeFormContent {\n readonly props = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly ALLERGY_ROWS = ALLERGY_ROWS;\n protected readonly CONSENT_ACKNOWLEDGMENTS = CONSENT_ACKNOWLEDGMENTS;\n protected readonly CONSENT_SIGNERS = CONSENT_SIGNERS;\n protected readonly EMERGENCY_CONTACT_GROUPS = EMERGENCY_CONTACT_GROUPS;\n protected readonly FORM_STYLE = FORM_STYLE;\n protected readonly FORM_VERSION = FORM_VERSION;\n protected readonly INSURANCE_GROUPS = INSURANCE_GROUPS;\n protected readonly MEDICAL_HISTORY_COLUMNS = MEDICAL_HISTORY_COLUMNS;\n protected readonly MEDICATION_ROWS = MEDICATION_ROWS;\n protected readonly PERSONAL_INFO_GROUPS = PERSONAL_INFO_GROUPS;\n\n protected readonly layout = computed(() =>\n intakeLayout(this.theme(), this.props())\n );\n\n protected readonly consentText = computed(\n () =>\n `I authorize ${this.props().clinicName} to provide treatment and to release the information required to process insurance claims for this visit, and I acknowledge that I have received the Notice of Privacy Practices (HIPAA) explaining how my health information may be used.`\n );\n}\n\n/**\n * Print-ready medical intake form with patient, emergency contact, insurance,\n * medical history, medication, allergy, reason for visit, and consent\n * sections. Every section can be hidden through its boolean prop, and all\n * fields are left blank for the patient to complete by hand.\n */\n@Component({\n imports: [MedicalIntakeFormContent, PdfcnThemeProvider],\n selector: \"pdf-medical-intake-form\",\n template: `\n \n \n \n `,\n})\nexport class MedicalIntakeFormDocument {\n readonly clinicName = input.required();\n readonly clinicLogo = input();\n readonly clinicAddress = input();\n readonly clinicPhone = input();\n readonly personalInfo = input(true, { transform: booleanAttribute });\n readonly emergencyContact = input(true, { transform: booleanAttribute });\n readonly insurance = input(true, { transform: booleanAttribute });\n readonly medicalHistory = input(true, { transform: booleanAttribute });\n readonly medications = input(true, { transform: booleanAttribute });\n readonly allergies = input(true, { transform: booleanAttribute });\n readonly reasonForVisit = input(true, { transform: booleanAttribute });\n readonly consent = input(true, { transform: booleanAttribute });\n readonly accentColor = input();\n readonly theme = input();\n\n protected readonly props = computed(\n (): MedicalIntakeFormProps => ({\n accentColor: this.accentColor(),\n allergies: this.allergies(),\n clinicAddress: this.clinicAddress(),\n clinicLogo: this.clinicLogo(),\n clinicName: this.clinicName(),\n clinicPhone: this.clinicPhone(),\n consent: this.consent(),\n emergencyContact: this.emergencyContact(),\n insurance: this.insurance(),\n medicalHistory: this.medicalHistory(),\n medications: this.medications(),\n personalInfo: this.personalInfo(),\n reasonForVisit: this.reasonForVisit(),\n })\n );\n}\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { PdfForm } from \"@/components/pdf/form/form\";\nimport type { PdfFormGroup } from \"@/components/pdf/form/form.types\";\nimport { PdfList } from \"@/components/pdf/list/list\";\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 { PdfSignatureBlock } from \"@/components/pdf/signature/signature\";\nimport type { SignatureSigner } from \"@/components/pdf/signature/signature\";\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 { resolveColor } from \"@/lib/resolve-color\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { MedicalIntakeFormProps } from \"./medical-intake-form.types\";\n\nconst FORM_VERSION = \"Form v1.0 · Revised 09/2026\";\nconst FORM_STYLE = { marginBottom: 0 };\n\nconst SECOND_PAGE_MARGIN_BOTTOM = 44;\nconst SECOND_PAGE_MARGIN_TOP = 24;\n\nconst MEDICAL_CONDITIONS = [\n \"Diabetes\",\n \"High Blood Pressure\",\n \"Heart Disease\",\n \"Asthma\",\n \"COPD\",\n \"Cancer\",\n \"Stroke\",\n \"Thyroid Disorder\",\n \"Kidney Disease\",\n \"Liver Disease\",\n \"Seizures / Epilepsy\",\n \"Other\",\n];\n\nconst CONSENT_ACKNOWLEDGMENTS = [\n { checked: false, text: \"I have read and understand the consent above.\" },\n { checked: false, text: \"I have received the Notice of Privacy Practices.\" },\n];\n\nconst MEDICATION_ROWS = [\n \"medication-1\",\n \"medication-2\",\n \"medication-3\",\n \"medication-4\",\n];\n\nconst ALLERGY_ROWS = [\"allergy-1\", \"allergy-2\", \"allergy-3\"];\n\nconst blankChecklist = (labels: string[]) =>\n labels.map((text) => ({ checked: false, text }));\n\nconst PERSONAL_INFO_GROUPS: PdfFormGroup[] = [\n {\n fields: [\n { height: 14, label: \"Full Name\" },\n { height: 14, hint: \"DD / MM / YYYY\", label: \"Date of Birth\" },\n { height: 14, label: \"Gender\" },\n { height: 14, hint: \"+1 (555) 000-0000\", label: \"Phone Number\" },\n { height: 14, label: \"Email Address\" },\n ],\n layout: \"two-column\",\n title: \"Patient Information\",\n },\n {\n fields: [\n { height: 14, label: \"Street Address\", width: \"100%\" },\n { height: 14, label: \"City\" },\n { height: 14, label: \"State / Province\" },\n { height: 14, label: \"Postal Code\" },\n ],\n layout: \"two-column\",\n title: \"Address\",\n },\n];\n\nconst EMERGENCY_CONTACT_GROUPS: PdfFormGroup[] = [\n {\n fields: [\n { height: 14, label: \"Emergency Contact Name\" },\n { height: 14, label: \"Relationship\" },\n { height: 14, label: \"Phone Number\" },\n ],\n layout: \"two-column\",\n title: \"Emergency Contact\",\n },\n];\n\nconst INSURANCE_GROUPS: PdfFormGroup[] = [\n {\n fields: [\n { height: 14, label: \"Insurance Provider\" },\n { height: 14, label: \"Policy Number\" },\n { height: 14, label: \"Group Number\" },\n { height: 14, label: \"Subscriber Name\" },\n ],\n layout: \"two-column\",\n title: \"Insurance\",\n },\n];\n\nconst MEDICAL_HISTORY_COLUMNS = [\n blankChecklist(MEDICAL_CONDITIONS.slice(0, 4)),\n blankChecklist(MEDICAL_CONDITIONS.slice(4, 8)),\n blankChecklist(MEDICAL_CONDITIONS.slice(8)),\n];\n\nconst CONSENT_SIGNERS: [SignatureSigner, SignatureSigner] = [\n { label: \"Patient / Guardian Signature\" },\n { label: \"Date\" },\n];\n\nconst createIntakeStyles = (t: PdfcnTheme) =>\n StyleSheet.create({\n column: { flex: 1 },\n consentText: {\n fontSize: t.primitives.typography.xs,\n lineHeight: 1.4,\n marginBottom: 6,\n },\n labelText: { fontSize: 9, fontWeight: \"bold\", letterSpacing: 0.6 },\n page: { backgroundColor: t.colors.background },\n pageTwoHeader: {\n alignItems: \"flex-end\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n },\n reasonBox: {\n borderColor: t.colors.border,\n borderRadius: t.primitives.borderRadius.sm,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 40,\n minHeight: 40,\n },\n row: { flexDirection: \"row\", gap: 20 },\n section: { marginBottom: 4 },\n sectionRule: {\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n marginBottom: 4,\n paddingBottom: 2,\n },\n signature: { marginBottom: 0, marginTop: 8 },\n title: { fontSize: 13, fontWeight: \"bold\" },\n });\n\ntype IntakeSections = Required<\n Pick<\n MedicalIntakeFormProps,\n | \"allergies\"\n | \"consent\"\n | \"emergencyContact\"\n | \"insurance\"\n | \"medicalHistory\"\n | \"medications\"\n | \"personalInfo\"\n | \"reasonForVisit\"\n >\n>;\n\nconst resolveSections = (props: MedicalIntakeFormProps): IntakeSections => ({\n allergies: props.allergies ?? true,\n consent: props.consent ?? true,\n emergencyContact: props.emergencyContact ?? true,\n insurance: props.insurance ?? true,\n medicalHistory: props.medicalHistory ?? true,\n medications: props.medications ?? true,\n personalInfo: props.personalInfo ?? true,\n reasonForVisit: props.reasonForVisit ?? true,\n});\n\nconst hasSecondPage = (sections: IntakeSections) =>\n sections.allergies ||\n sections.consent ||\n sections.medications ||\n sections.reasonForVisit;\n\nconst intakeLayout = (theme: PdfcnTheme, props: MedicalIntakeFormProps) => {\n const styles = createIntakeStyles(theme);\n const sections = resolveSections(props);\n const accent = props.accentColor\n ? resolveColor(props.accentColor, theme.colors)\n : theme.colors.primary;\n const totalPages = hasSecondPage(sections) ? 2 : 1;\n\n const firstMargin = {\n bottom: theme.spacing.page.marginBottom,\n left: theme.spacing.page.marginLeft,\n right: theme.spacing.page.marginRight,\n top: theme.spacing.page.marginTop,\n };\n const secondMargin = {\n bottom: SECOND_PAGE_MARGIN_BOTTOM,\n left: theme.spacing.page.marginLeft,\n right: theme.spacing.page.marginRight,\n top: SECOND_PAGE_MARGIN_TOP,\n };\n\n return {\n accent,\n firstMargin,\n secondMargin,\n sectionRule: { ...styles.sectionRule, borderBottomColor: accent },\n sections,\n styles,\n totalPages,\n };\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n NgTemplateOutlet,\n PdfForm,\n PdfImage,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfSignatureBlock,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-medical-intake-form-content\",\n template: `\n @let props = this.props();\n @let l = layout();\n @let styles = l.styles;\n \n \n {{\n label\n }}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n @if (l.sections.personalInfo) {\n \n }\n @if (l.sections.emergencyContact) {\n \n }\n @if (l.sections.insurance) {\n \n }\n \n \n @if (l.totalPages > 1) {\n \n \n \n \n {{\n props.clinicName + \" — Patient Intake Form (continued)\"\n }}\n {{\n props.clinicPhone\n }}\n \n @if (l.sections.medicalHistory) {\n \n \n \n @for (items of MEDICAL_HISTORY_COLUMNS; track $index) {\n \n \n \n }\n \n \n }\n @if (l.sections.medications) {\n \n \n \n \n \n Medication\n Dosage\n Frequency\n Prescribing Doctor\n \n \n \n @for (row of MEDICATION_ROWS; track row) {\n \n \n \n \n \n \n }\n \n \n \n }\n @if (l.sections.allergies) {\n \n \n \n \n \n Allergen\n Reaction\n Severity\n \n \n \n @for (row of ALLERGY_ROWS; track row) {\n \n \n \n \n \n }\n \n \n \n }\n @if (l.sections.reasonForVisit) {\n \n \n \n \n }\n @if (l.sections.consent) {\n \n \n \n {{ consentText() }}\n \n \n \n \n }\n \n \n }\n \n `,\n})\nexport class MedicalIntakeFormContent {\n readonly props = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly ALLERGY_ROWS = ALLERGY_ROWS;\n protected readonly CONSENT_ACKNOWLEDGMENTS = CONSENT_ACKNOWLEDGMENTS;\n protected readonly CONSENT_SIGNERS = CONSENT_SIGNERS;\n protected readonly EMERGENCY_CONTACT_GROUPS = EMERGENCY_CONTACT_GROUPS;\n protected readonly FORM_STYLE = FORM_STYLE;\n protected readonly FORM_VERSION = FORM_VERSION;\n protected readonly INSURANCE_GROUPS = INSURANCE_GROUPS;\n protected readonly MEDICAL_HISTORY_COLUMNS = MEDICAL_HISTORY_COLUMNS;\n protected readonly MEDICATION_ROWS = MEDICATION_ROWS;\n protected readonly PERSONAL_INFO_GROUPS = PERSONAL_INFO_GROUPS;\n\n protected readonly layout = computed(() =>\n intakeLayout(this.theme(), this.props())\n );\n\n protected readonly consentText = computed(\n () =>\n `I authorize ${this.props().clinicName} to provide treatment and to release the information required to process insurance claims for this visit, and I acknowledge that I have received the Notice of Privacy Practices (HIPAA) explaining how my health information may be used.`\n );\n}\n\n/**\n * Print-ready medical intake form with patient, emergency contact, insurance,\n * medical history, medication, allergy, reason for visit, and consent\n * sections. Every section can be hidden through its boolean prop, and all\n * fields are left blank for the patient to complete by hand.\n */\n@Component({\n imports: [MedicalIntakeFormContent, PdfcnThemeProvider],\n selector: \"pdf-medical-intake-form\",\n template: `\n \n \n \n `,\n})\nexport class MedicalIntakeFormDocument {\n readonly clinicName = input.required();\n readonly clinicLogo = input();\n readonly clinicAddress = input();\n readonly clinicPhone = input();\n readonly personalInfo = input(true, { transform: booleanAttribute });\n readonly emergencyContact = input(true, { transform: booleanAttribute });\n readonly insurance = input(true, { transform: booleanAttribute });\n readonly medicalHistory = input(true, { transform: booleanAttribute });\n readonly medications = input(true, { transform: booleanAttribute });\n readonly allergies = input(true, { transform: booleanAttribute });\n readonly reasonForVisit = input(true, { transform: booleanAttribute });\n readonly consent = input(true, { transform: booleanAttribute });\n readonly accentColor = input();\n readonly theme = input();\n\n protected readonly props = computed(\n (): MedicalIntakeFormProps => ({\n accentColor: this.accentColor(),\n allergies: this.allergies(),\n clinicAddress: this.clinicAddress(),\n clinicLogo: this.clinicLogo(),\n clinicName: this.clinicName(),\n clinicPhone: this.clinicPhone(),\n consent: this.consent(),\n emergencyContact: this.emergencyContact(),\n insurance: this.insurance(),\n medicalHistory: this.medicalHistory(),\n medications: this.medications(),\n personalInfo: this.personalInfo(),\n reasonForVisit: this.reasonForVisit(),\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:block", "target": "components/pdf/blocks/medical-intake-form/medical-intake-form.ts" }, { "path": "registry/bases/forme/blocks/medical-intake-form/medical-intake-form.types.ts", - "content": "import type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Medical intake form properties.\n * Props - `clinicName` | `clinicLogo` | `clinicAddress` | `clinicPhone` |\n * `personalInfo` | `emergencyContact` | `insurance` | `medicalHistory` |\n * `medications` | `allergies` | `reasonForVisit` | `consent` | `accentColor` | `theme`\n * @see {@link MedicalIntakeFormDocument}\n */\nexport interface MedicalIntakeFormProps {\n clinicName: string;\n clinicLogo?: string;\n clinicAddress?: string;\n clinicPhone?: string;\n /**\n * @default true\n */\n personalInfo?: boolean;\n /**\n * @default true\n */\n emergencyContact?: boolean;\n /**\n * @default true\n */\n insurance?: boolean;\n /**\n * @default true\n */\n medicalHistory?: boolean;\n /**\n * @default true\n */\n medications?: boolean;\n /**\n * @default true\n */\n allergies?: boolean;\n /**\n * @default true\n */\n reasonForVisit?: boolean;\n /**\n * @default true\n */\n consent?: boolean;\n /**\n * Theme color token (e.g. `\"primary\"`) or raw CSS color (e.g. `\"#0d9488\"`)\n * applied to section rules, table accents, and the consent callout.\n */\n accentColor?: string;\n theme?: PdfcnTheme;\n}\n", + "content": "import type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Medical intake form properties.\n * Props - `clinicName` | `clinicLogo` | `clinicAddress` | `clinicPhone` |\n * `personalInfo` | `emergencyContact` | `insurance` | `medicalHistory` |\n * `medications` | `allergies` | `reasonForVisit` | `consent` | `accentColor` | `theme`\n * @see {@link MedicalIntakeFormDocument}\n */\nexport interface MedicalIntakeFormProps {\n clinicName: string;\n clinicLogo?: string;\n clinicAddress?: string;\n clinicPhone?: string;\n /**\n * @default true\n */\n personalInfo?: boolean;\n /**\n * @default true\n */\n emergencyContact?: boolean;\n /**\n * @default true\n */\n insurance?: boolean;\n /**\n * @default true\n */\n medicalHistory?: boolean;\n /**\n * @default true\n */\n medications?: boolean;\n /**\n * @default true\n */\n allergies?: boolean;\n /**\n * @default true\n */\n reasonForVisit?: boolean;\n /**\n * @default true\n */\n consent?: boolean;\n /**\n * Theme color token (e.g. `\"primary\"`) or raw CSS color (e.g. `\"#0d9488\"`)\n * applied to section rules, table accents, and the consent callout.\n */\n accentColor?: string;\n theme?: PdfcnTheme;\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/medical-intake-form/medical-intake-form.types.ts" } diff --git a/apps/web/public/r/forme/meeting-minutes.json b/apps/web/public/r/forme/meeting-minutes.json index 387f542..06355a4 100644 --- a/apps/web/public/r/forme/meeting-minutes.json +++ b/apps/web/public/r/forme/meeting-minutes.json @@ -3,10 +3,6 @@ "name": "forme/meeting-minutes", "title": "Meeting Minutes", "description": "Meeting Minutes PDF block (forme)", - "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0" - ], "registryDependencies": [ "@angular-pdfcn/forme/utils", "@angular-pdfcn/forme/badge", @@ -20,13 +16,13 @@ "files": [ { "path": "registry/bases/forme/blocks/meeting-minutes/meeting-minutes.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfList } from \"@/components/pdf/list/list\";\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 {\n MeetingMinutesActionStatus,\n MeetingMinutesProps,\n} from \"./meeting-minutes.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: MeetingMinutesProps = {\n absent: [{ name: \"Casey Wu\", role: \"QA Lead\" }],\n accentColor: \"#0891b2\",\n actionItems: [\n {\n dueDate: \"Sep 19, 2026\",\n owner: \"Jordan Lee\",\n status: \"In Progress\",\n task: \"Create pdfme integration RFC\",\n },\n {\n dueDate: \"Sep 22, 2026\",\n owner: \"Sam Patel\",\n status: \"Not Started\",\n task: \"Design community page wireframes\",\n },\n {\n dueDate: \"Sep 26, 2026\",\n owner: \"Alex Kim\",\n status: \"Complete\",\n task: \"Share Q2 outcomes deck with stakeholders\",\n },\n ],\n agenda: [\n \"Review Q2 outcomes\",\n \"Q3 feature priorities\",\n \"Resource allocation\",\n \"Timeline and milestones\",\n ],\n attendees: [\n { name: \"Alex Kim\", role: \"Product Lead\" },\n { name: \"Jordan Lee\", role: \"Engineering Lead\" },\n { name: \"Sam Patel\", role: \"Design Lead\" },\n ],\n date: \"September 12, 2026\",\n decisions: [\n {\n decision: \"Proceed with pdfme as second rendering base\",\n number: 1,\n rationale: \"Better JSX support\",\n },\n {\n decision: \"Allocate 2 engineers to PDF module full-time\",\n number: 2,\n },\n ],\n discussions: [\n {\n notes: [\n \"Shipped 4 of 5 planned features\",\n \"Customer satisfaction up 12%\",\n ],\n speaker: \"Alex Kim\",\n topic: \"Q2 Outcomes\",\n },\n {\n notes: [\n \"PDF generation module is top priority\",\n \"Community page scheduled for late Q3\",\n ],\n speaker: \"Jordan Lee\",\n topic: \"Q3 Feature Priorities\",\n },\n ],\n distributionList: [\"product-team@acme.com\", \"eng-leads@acme.com\"],\n guests: [\"Riya Shah (Advisor)\"],\n location: \"Conference Room B / Zoom\",\n meetingTitle: \"Q3 Product Roadmap Review\",\n nextMeeting: {\n agenda: [\"Review action items\", \"pdfme RFC walkthrough\"],\n date: \"September 19, 2026\",\n time: \"2:00 PM\",\n },\n organizer: \"Alex Kim\",\n preparedBy: \"Alex Kim\",\n time: \"2:00 PM - 3:30 PM\",\n};\n\nconst STATUS_VARIANT: Record<\n MeetingMinutesActionStatus,\n \"success\" | \"info\" | \"default\"\n> = {\n Complete: \"success\",\n \"In Progress\": \"info\",\n \"Not Started\": \"default\",\n};\n\nconst formatAttendee = (a: { name: string; role?: string }) =>\n `${a.name}${a.role ? ` — ${a.role}` : \"\"}`;\n\nconst meetingMinutesLayout = (theme: PdfcnTheme, data: MeetingMinutesProps) => {\n const styles = StyleSheet.create({\n columnHeading: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\n },\n discussionTopic: {\n marginBottom: theme.primitives.spacing[2],\n },\n listItem: {\n marginBottom: theme.primitives.spacing[1],\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n });\n\n const attendeeColumns = [\n { heading: \"Attendees\", names: data.attendees.map(formatAttendee) },\n ...(data.absent?.length\n ? [{ heading: \"Absent\", names: data.absent.map(formatAttendee) }]\n : []),\n ...(data.guests?.length ? [{ heading: \"Guests\", names: data.guests }] : []),\n ];\n\n const footerRightText = data.distributionList?.length\n ? `Distribution: ${data.distributionList.join(\", \")}`\n : undefined;\n\n const discussions = data.discussions.map((discussion) => ({\n ...discussion,\n items: discussion.notes.map((text) => ({ text })),\n }));\n\n const nextMeetingAgenda = data.nextMeeting?.agenda?.map((text) => ({\n text,\n }));\n\n return {\n attendeeColumns,\n discussions,\n footerRightText,\n nextMeetingAgenda,\n styles,\n };\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n NgTemplateOutlet,\n PdfBadge,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-meeting-minutes-content\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n {{ text }}\n \n \n \n \n \n \n \n \n \n \n @for (column of l.attendeeColumns; track column.heading) {\n \n \n @for (name of column.names; track name) {\n {{ name }}\n }\n \n }\n \n \n \n @for (item of data.agenda; track item; let index = $index) {\n {{\n index + 1 + \". \" + item\n }}\n }\n \n \n \n @for (discussion of l.discussions; track discussion.topic) {\n \n {{\n discussion.topic\n }}\n @if (discussion.speaker) {\n {{\n \"— \" + discussion.speaker\n }}\n }\n \n \n }\n \n \n \n \n \n \n \n \n @for (d of data.decisions; track d.number) {\n \n {{\n d.number + \". \" + d.decision\n }}\n @if (d.rationale) {\n {{\n d.rationale\n }}\n }\n \n }\n \n \n \n \n \n \n Task\n Owner\n Due Date\n Status\n \n \n \n @for (item of data.actionItems; track item.task) {\n \n {{ item.task }}\n {{\n item.owner\n }}\n {{\n item.dueDate\n }}\n \n \n \n \n }\n \n \n \n @if (data.nextMeeting) {\n \n \n {{\n data.nextMeeting.date + \" · \" + data.nextMeeting.time\n }}\n @if (l.nextMeetingAgenda) {\n \n }\n \n }\n \n \n \n `,\n})\nexport class MeetingMinutesContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly STATUS_VARIANT = STATUS_VARIANT;\n\n protected readonly layout = computed(() =>\n meetingMinutesLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [MeetingMinutesContent, PdfcnThemeProvider],\n selector: \"pdf-meeting-minutes\",\n template: `\n \n \n \n `,\n})\nexport class MeetingMinutesDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly mergedData = computed(\n (): MeetingMinutesProps => ({ ...sampleData, ...this.data() })\n );\n}\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfList } from \"@/components/pdf/list/list\";\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 {\n MeetingMinutesActionStatus,\n MeetingMinutesProps,\n} from \"./meeting-minutes.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: MeetingMinutesProps = {\n absent: [{ name: \"Casey Wu\", role: \"QA Lead\" }],\n accentColor: \"#0891b2\",\n actionItems: [\n {\n dueDate: \"Sep 19, 2026\",\n owner: \"Jordan Lee\",\n status: \"In Progress\",\n task: \"Create pdfme integration RFC\",\n },\n {\n dueDate: \"Sep 22, 2026\",\n owner: \"Sam Patel\",\n status: \"Not Started\",\n task: \"Design community page wireframes\",\n },\n {\n dueDate: \"Sep 26, 2026\",\n owner: \"Alex Kim\",\n status: \"Complete\",\n task: \"Share Q2 outcomes deck with stakeholders\",\n },\n ],\n agenda: [\n \"Review Q2 outcomes\",\n \"Q3 feature priorities\",\n \"Resource allocation\",\n \"Timeline and milestones\",\n ],\n attendees: [\n { name: \"Alex Kim\", role: \"Product Lead\" },\n { name: \"Jordan Lee\", role: \"Engineering Lead\" },\n { name: \"Sam Patel\", role: \"Design Lead\" },\n ],\n date: \"September 12, 2026\",\n decisions: [\n {\n decision: \"Proceed with pdfme as second rendering base\",\n number: 1,\n rationale: \"Better JSX support\",\n },\n {\n decision: \"Allocate 2 engineers to PDF module full-time\",\n number: 2,\n },\n ],\n discussions: [\n {\n notes: [\n \"Shipped 4 of 5 planned features\",\n \"Customer satisfaction up 12%\",\n ],\n speaker: \"Alex Kim\",\n topic: \"Q2 Outcomes\",\n },\n {\n notes: [\n \"PDF generation module is top priority\",\n \"Community page scheduled for late Q3\",\n ],\n speaker: \"Jordan Lee\",\n topic: \"Q3 Feature Priorities\",\n },\n ],\n distributionList: [\"product-team@acme.com\", \"eng-leads@acme.com\"],\n guests: [\"Riya Shah (Advisor)\"],\n location: \"Conference Room B / Zoom\",\n meetingTitle: \"Q3 Product Roadmap Review\",\n nextMeeting: {\n agenda: [\"Review action items\", \"pdfme RFC walkthrough\"],\n date: \"September 19, 2026\",\n time: \"2:00 PM\",\n },\n organizer: \"Alex Kim\",\n preparedBy: \"Alex Kim\",\n time: \"2:00 PM - 3:30 PM\",\n};\n\nconst STATUS_VARIANT: Record<\n MeetingMinutesActionStatus,\n \"success\" | \"info\" | \"default\"\n> = {\n Complete: \"success\",\n \"In Progress\": \"info\",\n \"Not Started\": \"default\",\n};\n\nconst formatAttendee = (a: { name: string; role?: string }) =>\n `${a.name}${a.role ? ` — ${a.role}` : \"\"}`;\n\nconst meetingMinutesLayout = (theme: PdfcnTheme, data: MeetingMinutesProps) => {\n const styles = StyleSheet.create({\n columnHeading: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\n },\n discussionTopic: {\n marginBottom: theme.primitives.spacing[2],\n },\n listItem: {\n marginBottom: theme.primitives.spacing[1],\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n });\n\n const attendeeColumns = [\n { heading: \"Attendees\", names: data.attendees.map(formatAttendee) },\n ...(data.absent?.length\n ? [{ heading: \"Absent\", names: data.absent.map(formatAttendee) }]\n : []),\n ...(data.guests?.length ? [{ heading: \"Guests\", names: data.guests }] : []),\n ];\n\n const footerRightText = data.distributionList?.length\n ? `Distribution: ${data.distributionList.join(\", \")}`\n : undefined;\n\n const discussions = data.discussions.map((discussion) => ({\n ...discussion,\n items: discussion.notes.map((text) => ({ text })),\n }));\n\n const nextMeetingAgenda = data.nextMeeting?.agenda?.map((text) => ({\n text,\n }));\n\n return {\n attendeeColumns,\n discussions,\n footerRightText,\n nextMeetingAgenda,\n styles,\n };\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n NgTemplateOutlet,\n PdfBadge,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-meeting-minutes-content\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n {{ text }}\n \n \n \n \n \n \n \n \n \n \n @for (column of l.attendeeColumns; track column.heading) {\n \n \n @for (name of column.names; track name) {\n {{ name }}\n }\n \n }\n \n \n \n @for (item of data.agenda; track item; let index = $index) {\n {{\n index + 1 + \". \" + item\n }}\n }\n \n \n \n @for (discussion of l.discussions; track discussion.topic) {\n \n {{\n discussion.topic\n }}\n @if (discussion.speaker) {\n {{\n \"— \" + discussion.speaker\n }}\n }\n \n \n }\n \n \n \n \n \n \n \n \n @for (d of data.decisions; track d.number) {\n \n {{\n d.number + \". \" + d.decision\n }}\n @if (d.rationale) {\n {{\n d.rationale\n }}\n }\n \n }\n \n \n \n \n \n \n Task\n Owner\n Due Date\n Status\n \n \n \n @for (item of data.actionItems; track item.task) {\n \n {{ item.task }}\n {{\n item.owner\n }}\n {{\n item.dueDate\n }}\n \n \n \n \n }\n \n \n \n @if (data.nextMeeting) {\n \n \n {{\n data.nextMeeting.date + \" · \" + data.nextMeeting.time\n }}\n @if (l.nextMeetingAgenda) {\n \n }\n \n }\n \n \n \n `,\n})\nexport class MeetingMinutesContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly STATUS_VARIANT = STATUS_VARIANT;\n\n protected readonly layout = computed(() =>\n meetingMinutesLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [MeetingMinutesContent, PdfcnThemeProvider],\n selector: \"pdf-meeting-minutes\",\n template: `\n \n \n \n `,\n})\nexport class MeetingMinutesDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly mergedData = computed(\n (): MeetingMinutesProps => ({ ...sampleData, ...this.data() })\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:block", "target": "components/pdf/blocks/meeting-minutes/meeting-minutes.ts" }, { "path": "registry/bases/forme/blocks/meeting-minutes/meeting-minutes.types.ts", - "content": "export interface MeetingMinutesAttendee {\n name: string;\n role?: string;\n}\n\nexport interface MeetingMinutesDiscussion {\n topic: string;\n notes: string[];\n speaker?: string;\n}\n\nexport interface MeetingMinutesDecision {\n number: number;\n decision: string;\n rationale?: string;\n}\n\nexport type MeetingMinutesActionStatus =\n | \"Not Started\"\n | \"In Progress\"\n | \"Complete\";\n\nexport interface MeetingMinutesActionItem {\n task: string;\n owner: string;\n dueDate: string;\n status: MeetingMinutesActionStatus;\n}\n\nexport interface MeetingMinutesNextMeeting {\n date: string;\n time: string;\n agenda?: string[];\n}\n\nexport interface MeetingMinutesProps {\n meetingTitle: string;\n date: string;\n time: string;\n location: string;\n organizer: string;\n attendees: MeetingMinutesAttendee[];\n absent?: MeetingMinutesAttendee[];\n guests?: string[];\n agenda: string[];\n discussions: MeetingMinutesDiscussion[];\n decisions: MeetingMinutesDecision[];\n actionItems: MeetingMinutesActionItem[];\n nextMeeting?: MeetingMinutesNextMeeting;\n preparedBy: string;\n distributionList?: string[];\n accentColor?: string;\n renderingBase?: \"takumi\" | \"forme\";\n}\n", + "content": "export interface MeetingMinutesAttendee {\n name: string;\n role?: string;\n}\n\nexport interface MeetingMinutesDiscussion {\n topic: string;\n notes: string[];\n speaker?: string;\n}\n\nexport interface MeetingMinutesDecision {\n number: number;\n decision: string;\n rationale?: string;\n}\n\nexport type MeetingMinutesActionStatus =\n | \"Not Started\"\n | \"In Progress\"\n | \"Complete\";\n\nexport interface MeetingMinutesActionItem {\n task: string;\n owner: string;\n dueDate: string;\n status: MeetingMinutesActionStatus;\n}\n\nexport interface MeetingMinutesNextMeeting {\n date: string;\n time: string;\n agenda?: string[];\n}\n\nexport interface MeetingMinutesProps {\n meetingTitle: string;\n date: string;\n time: string;\n location: string;\n organizer: string;\n attendees: MeetingMinutesAttendee[];\n absent?: MeetingMinutesAttendee[];\n guests?: string[];\n agenda: string[];\n discussions: MeetingMinutesDiscussion[];\n decisions: MeetingMinutesDecision[];\n actionItems: MeetingMinutesActionItem[];\n nextMeeting?: MeetingMinutesNextMeeting;\n preparedBy: string;\n distributionList?: 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/meeting-minutes/meeting-minutes.types.ts" } diff --git a/apps/web/public/r/forme/packing-slip.json b/apps/web/public/r/forme/packing-slip.json index 2d787eb..28bd0fc 100644 --- a/apps/web/public/r/forme/packing-slip.json +++ b/apps/web/public/r/forme/packing-slip.json @@ -3,10 +3,6 @@ "name": "forme/packing-slip", "title": "Packing Slip", "description": "Packing Slip 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/packing-slip/packing-slip.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 { PackingSlipProps, PackingSlipSender } from \"./packing-slip.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: PackingSlipProps = {\n accentColor: \"#059669\",\n companyName: \"Acme Store\",\n customerService: \"support@acme-store.com\",\n items: [\n {\n name: \"Widget Pro\",\n qtyOrdered: 2,\n qtyPacked: 2,\n sku: \"WP-001\",\n unitPrice: 49.99,\n },\n {\n name: \"Gadget Lite\",\n qtyOrdered: 1,\n qtyPacked: 1,\n sku: \"GL-010\",\n unitPrice: 29.99,\n },\n {\n name: \"Cable Kit\",\n qtyOrdered: 3,\n qtyPacked: 2,\n sku: \"CK-204\",\n unitPrice: 9.5,\n },\n ],\n orderDate: \"Sep 10, 2026\",\n orderNumber: \"ORD-2026-0891\",\n poNumber: \"PO-4471\",\n returnsPolicy: \"Returns accepted within 30 days with original packaging.\",\n shipFrom: {\n address: \"100 Industrial Blvd\",\n city: \"Seattle\",\n name: \"Acme Warehouse\",\n state: \"WA\",\n zip: \"98101\",\n },\n shipTo: {\n address: \"456 Oak Ave\",\n city: \"Portland\",\n name: \"Jane Doe\",\n phone: \"(503) 555-0142\",\n state: \"OR\",\n zip: \"97201\",\n },\n shipping: {\n carrier: \"UPS\",\n estimatedDelivery: \"Sep 15, 2026\",\n method: \"Ground\",\n trackingNumber: \"1Z999AA10123456784\",\n },\n thankYouMessage: \"Thank you for your order!\",\n totalPackages: 1,\n totalWeight: \"3.2 kg\",\n};\n\nconst formatAddress = (a: PackingSlipSender & { country?: string }) =>\n `${a.address}, ${a.city}, ${a.state} ${a.zip}${a.country ? `, ${a.country}` : \"\"}`;\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-packing-slip-content\",\n template: `\n @let data = this.data();\n @let styles = this.styles();\n \n \n \n \n \n \n \n \n \n \n Ship To\n {{ data.shipTo.name }}\n {{\n formatAddress(data.shipTo)\n }}\n @if (data.shipTo.phone) {\n {{\n data.shipTo.phone\n }}\n }\n \n \n From\n {{\n data.shipFrom.name\n }}\n {{\n formatAddress(data.shipFrom)\n }}\n \n \n Order\n {{ data.orderNumber }}\n @if (data.poNumber) {\n {{\n \"PO: \" + data.poNumber\n }}\n }\n \n \n \n \n \n Item\n SKU\n Packed\n Ordered\n Unit Price\n Total\n \n \n \n @for (item of data.items; track item.sku) {\n \n {{ item.name }}\n {{ item.sku }}\n {{\n item.qtyPacked\n }}\n {{\n item.qtyOrdered\n }}\n {{\n \"$\" + item.unitPrice.toFixed(2)\n }}\n {{\n \"$\" + (item.qtyPacked * item.unitPrice).toFixed(2)\n }}\n \n }\n \n \n \n \n Shipping\n {{\n data.shipping.carrier + \" — \" + data.shipping.method\n }}\n {{\n \"Tracking: \" + data.shipping.trackingNumber\n }}\n @if (data.shipping.estimatedDelivery) {\n {{\n \"Est. Delivery: \" + data.shipping.estimatedDelivery\n }}\n }\n \n \n \n \n \n @if (data.thankYouMessage || data.returnsPolicy) {\n \n @if (data.thankYouMessage) {\n {{\n data.thankYouMessage\n }}\n }\n @if (data.returnsPolicy) {\n {{\n data.returnsPolicy\n }}\n }\n \n }\n \n \n \n `,\n})\nexport class PackingSlipContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly formatAddress = formatAddress;\n\n protected readonly styles = computed(() => {\n const theme = this.theme();\n const styles = StyleSheet.create({\n columnHeading: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\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 const totalPacked = data.items.reduce(\n (sum, item) => sum + item.qtyPacked,\n 0\n );\n const totalOrdered = data.items.reduce(\n (sum, item) => sum + item.qtyOrdered,\n 0\n );\n\n const summaryItems = [\n { key: \"Items Packed\", value: `${totalPacked} of ${totalOrdered}` },\n ...(data.totalPackages === undefined\n ? []\n : [{ key: \"Packages\", value: `${data.totalPackages}` }]),\n ...(data.totalWeight\n ? [{ key: \"Total Weight\", value: data.totalWeight }]\n : []),\n ];\n return summaryItems;\n });\n}\n\n@Component({\n imports: [PackingSlipContent, PdfcnThemeProvider],\n selector: \"pdf-packing-slip\",\n template: `\n \n \n \n `,\n})\nexport class PackingSlipDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly merged = computed(\n (): PackingSlipProps => ({ ...sampleData, ...this.data() })\n );\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 { PackingSlipProps, PackingSlipSender } from \"./packing-slip.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: PackingSlipProps = {\n accentColor: \"#059669\",\n companyName: \"Acme Store\",\n customerService: \"support@acme-store.com\",\n items: [\n {\n name: \"Widget Pro\",\n qtyOrdered: 2,\n qtyPacked: 2,\n sku: \"WP-001\",\n unitPrice: 49.99,\n },\n {\n name: \"Gadget Lite\",\n qtyOrdered: 1,\n qtyPacked: 1,\n sku: \"GL-010\",\n unitPrice: 29.99,\n },\n {\n name: \"Cable Kit\",\n qtyOrdered: 3,\n qtyPacked: 2,\n sku: \"CK-204\",\n unitPrice: 9.5,\n },\n ],\n orderDate: \"Sep 10, 2026\",\n orderNumber: \"ORD-2026-0891\",\n poNumber: \"PO-4471\",\n returnsPolicy: \"Returns accepted within 30 days with original packaging.\",\n shipFrom: {\n address: \"100 Industrial Blvd\",\n city: \"Seattle\",\n name: \"Acme Warehouse\",\n state: \"WA\",\n zip: \"98101\",\n },\n shipTo: {\n address: \"456 Oak Ave\",\n city: \"Portland\",\n name: \"Jane Doe\",\n phone: \"(503) 555-0142\",\n state: \"OR\",\n zip: \"97201\",\n },\n shipping: {\n carrier: \"UPS\",\n estimatedDelivery: \"Sep 15, 2026\",\n method: \"Ground\",\n trackingNumber: \"1Z999AA10123456784\",\n },\n thankYouMessage: \"Thank you for your order!\",\n totalPackages: 1,\n totalWeight: \"3.2 kg\",\n};\n\nconst formatAddress = (a: PackingSlipSender & { country?: string }) =>\n `${a.address}, ${a.city}, ${a.state} ${a.zip}${a.country ? `, ${a.country}` : \"\"}`;\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-packing-slip-content\",\n template: `\n @let data = this.data();\n @let styles = this.styles();\n \n \n \n \n \n \n \n \n \n \n Ship To\n {{ data.shipTo.name }}\n {{\n formatAddress(data.shipTo)\n }}\n @if (data.shipTo.phone) {\n {{\n data.shipTo.phone\n }}\n }\n \n \n From\n {{\n data.shipFrom.name\n }}\n {{\n formatAddress(data.shipFrom)\n }}\n \n \n Order\n {{ data.orderNumber }}\n @if (data.poNumber) {\n {{\n \"PO: \" + data.poNumber\n }}\n }\n \n \n \n \n \n Item\n SKU\n Packed\n Ordered\n Unit Price\n Total\n \n \n \n @for (item of data.items; track item.sku) {\n \n {{ item.name }}\n {{ item.sku }}\n {{\n item.qtyPacked\n }}\n {{\n item.qtyOrdered\n }}\n {{\n \"$\" + item.unitPrice.toFixed(2)\n }}\n {{\n \"$\" + (item.qtyPacked * item.unitPrice).toFixed(2)\n }}\n \n }\n \n \n \n \n Shipping\n {{\n data.shipping.carrier + \" — \" + data.shipping.method\n }}\n {{\n \"Tracking: \" + data.shipping.trackingNumber\n }}\n @if (data.shipping.estimatedDelivery) {\n {{\n \"Est. Delivery: \" + data.shipping.estimatedDelivery\n }}\n }\n \n \n \n \n \n @if (data.thankYouMessage || data.returnsPolicy) {\n \n @if (data.thankYouMessage) {\n {{\n data.thankYouMessage\n }}\n }\n @if (data.returnsPolicy) {\n {{\n data.returnsPolicy\n }}\n }\n \n }\n \n \n \n `,\n})\nexport class PackingSlipContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly formatAddress = formatAddress;\n\n protected readonly styles = computed(() => {\n const theme = this.theme();\n const styles = StyleSheet.create({\n columnHeading: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\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 const totalPacked = data.items.reduce(\n (sum, item) => sum + item.qtyPacked,\n 0\n );\n const totalOrdered = data.items.reduce(\n (sum, item) => sum + item.qtyOrdered,\n 0\n );\n\n const summaryItems = [\n { key: \"Items Packed\", value: `${totalPacked} of ${totalOrdered}` },\n ...(data.totalPackages === undefined\n ? []\n : [{ key: \"Packages\", value: `${data.totalPackages}` }]),\n ...(data.totalWeight\n ? [{ key: \"Total Weight\", value: data.totalWeight }]\n : []),\n ];\n return summaryItems;\n });\n}\n\n@Component({\n imports: [PackingSlipContent, PdfcnThemeProvider],\n selector: \"pdf-packing-slip\",\n template: `\n \n \n \n `,\n})\nexport class PackingSlipDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly merged = computed(\n (): PackingSlipProps => ({ ...sampleData, ...this.data() })\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:block", "target": "components/pdf/blocks/packing-slip/packing-slip.ts" }, { "path": "registry/bases/forme/blocks/packing-slip/packing-slip.types.ts", - "content": "export interface PackingSlipRecipient {\n name: string;\n address: string;\n city: string;\n state: string;\n zip: string;\n country?: string;\n phone?: string;\n}\n\nexport interface PackingSlipSender {\n name: string;\n address: string;\n city: string;\n state: string;\n zip: string;\n}\n\nexport interface PackingSlipItem {\n name: string;\n sku: string;\n qtyPacked: number;\n qtyOrdered: number;\n unitPrice: number;\n}\n\nexport interface PackingSlipShipping {\n carrier: string;\n trackingNumber: string;\n method: string;\n estimatedDelivery?: string;\n}\n\nexport interface PackingSlipProps {\n companyName: string;\n companyLogo?: string;\n orderNumber: string;\n orderDate: string;\n poNumber?: string;\n shipTo: PackingSlipRecipient;\n shipFrom: PackingSlipSender;\n items: PackingSlipItem[];\n shipping: PackingSlipShipping;\n totalPackages?: number;\n totalWeight?: string;\n returnsPolicy?: string;\n customerService?: string;\n thankYouMessage?: string;\n accentColor?: string;\n renderingBase?: \"takumi\" | \"forme\";\n}\n", + "content": "export interface PackingSlipRecipient {\n name: string;\n address: string;\n city: string;\n state: string;\n zip: string;\n country?: string;\n phone?: string;\n}\n\nexport interface PackingSlipSender {\n name: string;\n address: string;\n city: string;\n state: string;\n zip: string;\n}\n\nexport interface PackingSlipItem {\n name: string;\n sku: string;\n qtyPacked: number;\n qtyOrdered: number;\n unitPrice: number;\n}\n\nexport interface PackingSlipShipping {\n carrier: string;\n trackingNumber: string;\n method: string;\n estimatedDelivery?: string;\n}\n\nexport interface PackingSlipProps {\n companyName: string;\n companyLogo?: string;\n orderNumber: string;\n orderDate: string;\n poNumber?: string;\n shipTo: PackingSlipRecipient;\n shipFrom: PackingSlipSender;\n items: PackingSlipItem[];\n shipping: PackingSlipShipping;\n totalPackages?: number;\n totalWeight?: string;\n returnsPolicy?: string;\n customerService?: string;\n thankYouMessage?: 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/packing-slip/packing-slip.types.ts" } diff --git a/apps/web/public/r/forme/page-break.json b/apps/web/public/r/forme/page-break.json index bd619af..eb3946b 100644 --- a/apps/web/public/r/forme/page-break.json +++ b/apps/web/public/r/forme/page-break.json @@ -3,17 +3,13 @@ "name": "forme/page-break", "title": "Page Break", "description": "Page Break 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/page-break/page-break.ts", - "content": "import { Component, input } from \"@angular/core\";\n\nimport { FormePageBreak } from \"@/lib/pdf-primitives\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\n\nexport interface PageBreakProps extends Omit {\n children?: never;\n}\n\n@Component({\n imports: [FormePageBreak],\n selector: \"pdf-page-break\",\n template: \"\",\n})\nexport class PdfPageBreak {\n readonly style = input();\n}\n", + "content": "import { Component, input } from \"@angular/core\";\n\nimport { FormePageBreak } from \"@/lib/pdf-primitives\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\n\nexport interface PageBreakProps extends Omit {\n children?: never;\n}\n\n@Component({\n imports: [FormePageBreak],\n selector: \"pdf-page-break\",\n template: \"\",\n})\nexport class PdfPageBreak {\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/page-break/page-break.ts" } diff --git a/apps/web/public/r/forme/page-footer.json b/apps/web/public/r/forme/page-footer.json index bd9e3dc..5074072 100644 --- a/apps/web/public/r/forme/page-footer.json +++ b/apps/web/public/r/forme/page-footer.json @@ -3,17 +3,13 @@ "name": "forme/page-footer", "title": "Page Footer", "description": "Page Footer 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/page-footer/page-footer.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport {\n booleanAttribute,\n Component,\n computed,\n input,\n TemplateRef,\n inject,\n Injector,\n} from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeFixed,\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 PageFooterVariant =\n | \"simple\"\n | \"centered\"\n | \"branded\"\n | \"minimal\"\n | \"three-column\"\n | \"detailed\";\n\n/**\n * Footer row with layout variants, optional sticky or fixed positioning, and contact info support.\n * Props - `leftText` | `rightText` | `centerText` | `variant` | `background` | `textColor` | `marginTop` | `address` | `phone` | `email` | `website` | `fixed` | `sticky` | `pagePadding` | `noWrap` | `style`\n * @see {@link PageFooterProps}\n */\n/** Plain text, or a template for richer content such as a page number. */\nexport type FooterSlot = string | TemplateRef;\n\nexport interface PageFooterProps extends PDFComponentProps {\n leftText?: FooterSlot;\n rightText?: FooterSlot;\n centerText?: FooterSlot;\n /**\n * @default 'simple'\n */\n variant?: PageFooterVariant;\n background?: string;\n textColor?: string;\n marginTop?: number;\n address?: string;\n phone?: string;\n email?: string;\n website?: string;\n /**\n * @default false\n */\n fixed?: boolean;\n /**\n * @default false\n */\n sticky?: boolean;\n /**\n * @default 0\n */\n pagePadding?: number;\n /**\n * @default true\n */\n noWrap?: boolean;\n}\n\nconst createPageFooterStyles = (t: PdfcnTheme) => {\n const { spacing, fontWeights } = t.primitives;\n const c = t.colors;\n const { body } = t.typography;\n\n const textBase = {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: t.primitives.typography.xs,\n lineHeight: body.lineHeight,\n };\n\n return StyleSheet.create({\n brandedContainer: {\n alignItems: \"center\",\n backgroundColor: c.primary,\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingHorizontal: spacing[4],\n paddingVertical: spacing[3],\n },\n\n centeredContainer: {\n alignItems: \"center\",\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"column\",\n paddingTop: spacing[3],\n },\n\n companyBold: {\n ...textBase,\n color: c.foreground,\n fontWeight: fontWeights.bold,\n },\n\n companyName: {\n ...textBase,\n color: c.foreground,\n fontWeight: fontWeights.medium,\n },\n\n contactInfoCenter: {\n ...textBase,\n fontSize: t.primitives.typography.xs - 1,\n marginTop: spacing[0.5],\n textAlign: \"center\",\n },\n detailedContainer: {\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[1],\n display: \"flex\",\n flexDirection: \"column\",\n paddingTop: spacing[3],\n },\n detailedLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n detailedPageNumber: {\n ...textBase,\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n paddingTop: spacing[2],\n textAlign: \"center\",\n },\n detailedRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flexDirection: \"column\",\n },\n detailedTopRow: {\n alignItems: \"flex-start\",\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: spacing[2],\n },\n\n minimalContainer: {\n alignItems: \"center\",\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[1],\n paddingTop: spacing[1],\n },\n simpleContainer: {\n alignItems: \"center\",\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingTop: spacing[3],\n },\n simpleTextCenter: {\n ...textBase,\n textAlign: \"center\",\n },\n simpleTextLeft: {\n ...textBase,\n },\n simpleTextRight: {\n ...textBase,\n textAlign: \"right\",\n },\n textBranded: {\n ...textBase,\n color: c.primaryForeground,\n fontWeight: fontWeights.medium,\n },\n textBrandedRight: {\n ...textBase,\n color: c.primaryForeground,\n textAlign: \"right\",\n },\n textCenter: {\n ...textBase,\n flex: 1,\n textAlign: \"center\",\n },\n textCenteredVariant: {\n ...textBase,\n marginBottom: spacing[1],\n textAlign: \"center\",\n },\n\n textLeft: {\n ...textBase,\n flex: 1,\n },\n textRight: {\n ...textBase,\n textAlign: \"right\",\n },\n threeColumnCenter: {\n alignItems: \"center\",\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n threeColumnContainer: {\n alignItems: \"flex-start\",\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingTop: spacing[3],\n },\n threeColumnLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n threeColumnRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n });\n};\n\nconst applyTextColor = (\n styles: Style[],\n color: string | undefined\n): Style[] => {\n if (!color) {\n return styles;\n }\n return [...styles, { color }];\n};\n\n/** Container and slot styles of each variant. */\nconst pageFooterStyles = (\n theme: PdfcnTheme,\n {\n centerText,\n variant = \"simple\",\n background,\n textColor,\n marginTop,\n sticky = false,\n pagePadding = 0,\n style,\n }: PageFooterProps\n) => {\n const styles = createPageFooterStyles(theme);\n const mt = sticky ? 0 : (marginTop ?? theme.spacing.sectionGap);\n const resolvedTextColor = textColor\n ? resolveColor(textColor, theme.colors)\n : undefined;\n const stickyStyle: Style = {};\n\n const applyOverrides = (base: Style[]): Style[] => {\n if (background) {\n base.push({ backgroundColor: resolveColor(background, theme.colors) });\n }\n if (style) {\n base.push(style);\n }\n if (sticky) {\n base.push(stickyStyle);\n }\n return base;\n };\n\n const variantRenderers: Record Style[][]> = {\n branded: () => [\n applyOverrides([styles.brandedContainer, { marginTop: mt }]),\n applyTextColor([styles.textBranded], resolvedTextColor),\n applyTextColor([styles.textBrandedRight], resolvedTextColor),\n ],\n centered: () => [\n applyOverrides([styles.centeredContainer, { marginTop: mt }]),\n applyTextColor([styles.textCenteredVariant], resolvedTextColor),\n ],\n detailed: () => [\n applyOverrides([styles.detailedContainer, { marginTop: mt }]),\n applyTextColor([styles.companyBold], resolvedTextColor),\n applyTextColor([styles.textLeft], resolvedTextColor),\n applyTextColor([styles.textRight], resolvedTextColor),\n applyTextColor([styles.detailedPageNumber], resolvedTextColor),\n ],\n minimal: () => [\n applyOverrides([styles.minimalContainer, { marginTop: mt }]),\n applyTextColor([styles.textLeft], resolvedTextColor),\n applyTextColor([styles.textRight], resolvedTextColor),\n ],\n simple: () => [\n applyOverrides([styles.simpleContainer, { marginTop: mt }]),\n applyTextColor(\n [styles.simpleTextLeft, { width: centerText ? 160 : 360 }],\n resolvedTextColor\n ),\n applyTextColor(\n [styles.simpleTextCenter, { width: 160 }],\n resolvedTextColor\n ),\n applyTextColor(\n [styles.simpleTextRight, { width: centerText ? 160 : 120 }],\n resolvedTextColor\n ),\n ],\n \"three-column\": () => [\n applyOverrides([styles.threeColumnContainer, { marginTop: mt }]),\n applyTextColor([styles.companyName], resolvedTextColor),\n applyTextColor([styles.contactInfoCenter], resolvedTextColor),\n applyTextColor([styles.textRight], resolvedTextColor),\n ],\n };\n\n const [container, ...slots] = variantRenderers[variant]();\n const footerOffset = sticky\n ? Math.max(theme.spacing.page.marginBottom - pagePadding, 0)\n : 0;\n return {\n container,\n fixedStyle: [\n container,\n footerOffset ? { marginBottom: -footerOffset } : undefined,\n ],\n slots,\n styles,\n };\n};\n\n/** Footer row with layout variants, optional sticky or fixed positioning, and contact info support. */\n@Component({\n imports: [FormeFixed, FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-page-footer\",\n template: `\n @let l = layout();\n @let s = l.styles;\n @if (fixed() || sticky()) {\n \n } @else {\n \n }\n \n @switch (variant()) {\n @case (\"three-column\") {\n \n \n @if (address()) {\n {{ address() }}\n }\n \n \n @if (phone()) {\n {{ phone() }}\n }\n @if (email()) {\n {{ email() }}\n }\n @if (website()) {\n {{ website() }}\n }\n \n \n \n \n }\n @case (\"detailed\") {\n \n \n \n @if (address()) {\n {{ address() }}\n }\n \n \n @if (phone()) {\n {{\n \"Phone: \" + phone()\n }}\n }\n @if (email()) {\n {{\n \"Email: \" + email()\n }}\n }\n @if (website()) {\n {{\n \"Web: \" + website()\n }}\n }\n \n \n \n }\n @case (\"simple\") {\n \n \n \n }\n @case (\"centered\") {\n \n \n }\n @default {\n \n \n }\n }\n \n \n @if (isTemplate(value)) {\n \n } @else if (value) {\n {{ value }}\n }\n \n `,\n})\nexport class PdfPageFooter {\n /** Templates passed in resolve the theme from where they render, not where they are declared. */\n protected readonly injector = inject(Injector);\n readonly leftText = input();\n readonly rightText = input();\n readonly centerText = input();\n readonly variant = input(\"simple\");\n readonly background = input();\n readonly textColor = input();\n readonly marginTop = input();\n readonly address = input();\n readonly phone = input();\n readonly email = input();\n readonly website = input();\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly sticky = input(false, { transform: booleanAttribute });\n readonly pagePadding = input(0);\n readonly noWrap = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n protected readonly isTemplate = (value: unknown) =>\n value instanceof TemplateRef;\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n pageFooterStyles(this.theme(), {\n background: this.background(),\n centerText: this.centerText(),\n marginTop: this.marginTop(),\n pagePadding: this.pagePadding(),\n sticky: this.sticky(),\n style: this.style(),\n textColor: this.textColor(),\n variant: this.variant(),\n })\n );\n}\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport {\n booleanAttribute,\n Component,\n computed,\n input,\n TemplateRef,\n inject,\n Injector,\n} from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeFixed,\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 PageFooterVariant =\n | \"simple\"\n | \"centered\"\n | \"branded\"\n | \"minimal\"\n | \"three-column\"\n | \"detailed\";\n\n/**\n * Footer row with layout variants, optional sticky or fixed positioning, and contact info support.\n * Props - `leftText` | `rightText` | `centerText` | `variant` | `background` | `textColor` | `marginTop` | `address` | `phone` | `email` | `website` | `fixed` | `sticky` | `pagePadding` | `noWrap` | `style`\n * @see {@link PageFooterProps}\n */\n/** Plain text, or a template for richer content such as a page number. */\nexport type FooterSlot = string | TemplateRef;\n\nexport interface PageFooterProps extends PDFComponentProps {\n leftText?: FooterSlot;\n rightText?: FooterSlot;\n centerText?: FooterSlot;\n /**\n * @default 'simple'\n */\n variant?: PageFooterVariant;\n background?: string;\n textColor?: string;\n marginTop?: number;\n address?: string;\n phone?: string;\n email?: string;\n website?: string;\n /**\n * @default false\n */\n fixed?: boolean;\n /**\n * @default false\n */\n sticky?: boolean;\n /**\n * @default 0\n */\n pagePadding?: number;\n /**\n * @default true\n */\n noWrap?: boolean;\n}\n\nconst createPageFooterStyles = (t: PdfcnTheme) => {\n const { spacing, fontWeights } = t.primitives;\n const c = t.colors;\n const { body } = t.typography;\n\n const textBase = {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: t.primitives.typography.xs,\n lineHeight: body.lineHeight,\n };\n\n return StyleSheet.create({\n brandedContainer: {\n alignItems: \"center\",\n backgroundColor: c.primary,\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingHorizontal: spacing[4],\n paddingVertical: spacing[3],\n },\n\n centeredContainer: {\n alignItems: \"center\",\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"column\",\n paddingTop: spacing[3],\n },\n\n companyBold: {\n ...textBase,\n color: c.foreground,\n fontWeight: fontWeights.bold,\n },\n\n companyName: {\n ...textBase,\n color: c.foreground,\n fontWeight: fontWeights.medium,\n },\n\n contactInfoCenter: {\n ...textBase,\n fontSize: t.primitives.typography.xs - 1,\n marginTop: spacing[0.5],\n textAlign: \"center\",\n },\n detailedContainer: {\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[1],\n display: \"flex\",\n flexDirection: \"column\",\n paddingTop: spacing[3],\n },\n detailedLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n detailedPageNumber: {\n ...textBase,\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n paddingTop: spacing[2],\n textAlign: \"center\",\n },\n detailedRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flexDirection: \"column\",\n },\n detailedTopRow: {\n alignItems: \"flex-start\",\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: spacing[2],\n },\n\n minimalContainer: {\n alignItems: \"center\",\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[1],\n paddingTop: spacing[1],\n },\n simpleContainer: {\n alignItems: \"center\",\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingTop: spacing[3],\n },\n simpleTextCenter: {\n ...textBase,\n textAlign: \"center\",\n },\n simpleTextLeft: {\n ...textBase,\n },\n simpleTextRight: {\n ...textBase,\n textAlign: \"right\",\n },\n textBranded: {\n ...textBase,\n color: c.primaryForeground,\n fontWeight: fontWeights.medium,\n },\n textBrandedRight: {\n ...textBase,\n color: c.primaryForeground,\n textAlign: \"right\",\n },\n textCenter: {\n ...textBase,\n flex: 1,\n textAlign: \"center\",\n },\n textCenteredVariant: {\n ...textBase,\n marginBottom: spacing[1],\n textAlign: \"center\",\n },\n\n textLeft: {\n ...textBase,\n flex: 1,\n },\n textRight: {\n ...textBase,\n textAlign: \"right\",\n },\n threeColumnCenter: {\n alignItems: \"center\",\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n threeColumnContainer: {\n alignItems: \"flex-start\",\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingTop: spacing[3],\n },\n threeColumnLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n threeColumnRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n });\n};\n\nconst applyTextColor = (\n styles: Style[],\n color: string | undefined\n): Style[] => {\n if (!color) {\n return styles;\n }\n return [...styles, { color }];\n};\n\n/** Container and slot styles of each variant. */\nconst pageFooterStyles = (\n theme: PdfcnTheme,\n {\n centerText,\n variant = \"simple\",\n background,\n textColor,\n marginTop,\n sticky = false,\n pagePadding = 0,\n style,\n }: PageFooterProps\n) => {\n const styles = createPageFooterStyles(theme);\n const mt = sticky ? 0 : (marginTop ?? theme.spacing.sectionGap);\n const resolvedTextColor = textColor\n ? resolveColor(textColor, theme.colors)\n : undefined;\n const stickyStyle: Style = {};\n\n const applyOverrides = (base: Style[]): Style[] => {\n if (background) {\n base.push({ backgroundColor: resolveColor(background, theme.colors) });\n }\n if (style) {\n base.push(style);\n }\n if (sticky) {\n base.push(stickyStyle);\n }\n return base;\n };\n\n const variantRenderers: Record Style[][]> = {\n branded: () => [\n applyOverrides([styles.brandedContainer, { marginTop: mt }]),\n applyTextColor([styles.textBranded], resolvedTextColor),\n applyTextColor([styles.textBrandedRight], resolvedTextColor),\n ],\n centered: () => [\n applyOverrides([styles.centeredContainer, { marginTop: mt }]),\n applyTextColor([styles.textCenteredVariant], resolvedTextColor),\n ],\n detailed: () => [\n applyOverrides([styles.detailedContainer, { marginTop: mt }]),\n applyTextColor([styles.companyBold], resolvedTextColor),\n applyTextColor([styles.textLeft], resolvedTextColor),\n applyTextColor([styles.textRight], resolvedTextColor),\n applyTextColor([styles.detailedPageNumber], resolvedTextColor),\n ],\n minimal: () => [\n applyOverrides([styles.minimalContainer, { marginTop: mt }]),\n applyTextColor([styles.textLeft], resolvedTextColor),\n applyTextColor([styles.textRight], resolvedTextColor),\n ],\n simple: () => [\n applyOverrides([styles.simpleContainer, { marginTop: mt }]),\n applyTextColor(\n [styles.simpleTextLeft, { width: centerText ? 160 : 360 }],\n resolvedTextColor\n ),\n applyTextColor(\n [styles.simpleTextCenter, { width: 160 }],\n resolvedTextColor\n ),\n applyTextColor(\n [styles.simpleTextRight, { width: centerText ? 160 : 120 }],\n resolvedTextColor\n ),\n ],\n \"three-column\": () => [\n applyOverrides([styles.threeColumnContainer, { marginTop: mt }]),\n applyTextColor([styles.companyName], resolvedTextColor),\n applyTextColor([styles.contactInfoCenter], resolvedTextColor),\n applyTextColor([styles.textRight], resolvedTextColor),\n ],\n };\n\n const [container, ...slots] = variantRenderers[variant]();\n const footerOffset = sticky\n ? Math.max(theme.spacing.page.marginBottom - pagePadding, 0)\n : 0;\n return {\n container,\n fixedStyle: [\n container,\n footerOffset ? { marginBottom: -footerOffset } : undefined,\n ],\n slots,\n styles,\n };\n};\n\n/** Footer row with layout variants, optional sticky or fixed positioning, and contact info support. */\n@Component({\n imports: [FormeFixed, FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-page-footer\",\n template: `\n @let l = layout();\n @let s = l.styles;\n @if (fixed() || sticky()) {\n \n } @else {\n \n }\n \n @switch (variant()) {\n @case (\"three-column\") {\n \n \n @if (address()) {\n {{ address() }}\n }\n \n \n @if (phone()) {\n {{ phone() }}\n }\n @if (email()) {\n {{ email() }}\n }\n @if (website()) {\n {{ website() }}\n }\n \n \n \n \n }\n @case (\"detailed\") {\n \n \n \n @if (address()) {\n {{ address() }}\n }\n \n \n @if (phone()) {\n {{\n \"Phone: \" + phone()\n }}\n }\n @if (email()) {\n {{\n \"Email: \" + email()\n }}\n }\n @if (website()) {\n {{\n \"Web: \" + website()\n }}\n }\n \n \n \n }\n @case (\"simple\") {\n \n \n \n }\n @case (\"centered\") {\n \n \n }\n @default {\n \n \n }\n }\n \n \n @if (isTemplate(value)) {\n \n } @else if (value) {\n {{ value }}\n }\n \n `,\n})\nexport class PdfPageFooter {\n /** Templates passed in resolve the theme from where they render, not where they are declared. */\n protected readonly injector = inject(Injector);\n readonly leftText = input();\n readonly rightText = input();\n readonly centerText = input();\n readonly variant = input(\"simple\");\n readonly background = input();\n readonly textColor = input();\n readonly marginTop = input();\n readonly address = input();\n readonly phone = input();\n readonly email = input();\n readonly website = input();\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly sticky = input(false, { transform: booleanAttribute });\n readonly pagePadding = input(0);\n readonly noWrap = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n protected readonly isTemplate = (value: unknown) =>\n value instanceof TemplateRef;\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n pageFooterStyles(this.theme(), {\n background: this.background(),\n centerText: this.centerText(),\n marginTop: this.marginTop(),\n pagePadding: this.pagePadding(),\n sticky: this.sticky(),\n style: this.style(),\n textColor: this.textColor(),\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/page-footer/page-footer.ts" } diff --git a/apps/web/public/r/forme/page-header.json b/apps/web/public/r/forme/page-header.json index 22d281a..5dbdbee 100644 --- a/apps/web/public/r/forme/page-header.json +++ b/apps/web/public/r/forme/page-header.json @@ -3,17 +3,13 @@ "name": "forme/page-header", "title": "Page Header", "description": "Page Header 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/page-header/page-header.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport {\n booleanAttribute,\n Component,\n computed,\n input,\n inject,\n Injector,\n} from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeFixed,\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 PageHeaderVariant =\n | \"simple\"\n | \"centered\"\n | \"minimal\"\n | \"branded\"\n | \"logo-left\"\n | \"logo-right\"\n | \"two-column\";\n\n/**\n * Header row with layout variants, logo support, and optional fixed positioning.\n * Props - `title` | `subtitle` | `rightText` | `rightSubText` | `variant` | `background` | `titleColor` | `marginBottom` | `address` | `phone` | `email` | `logo` | `fixed` | `noWrap` | `style`\n * @see {@link PageHeaderProps}\n */\nexport interface PageHeaderProps extends PDFComponentProps {\n title: string;\n subtitle?: string;\n rightText?: string;\n rightSubText?: string;\n /**\n * @default 'simple'\n */\n variant?: PageHeaderVariant;\n background?: string;\n titleColor?: string;\n marginBottom?: number;\n address?: string;\n phone?: string;\n email?: string;\n logo?: TemplateRef;\n /**\n * @default false\n */\n fixed?: boolean;\n /**\n * @default true\n */\n noWrap?: boolean;\n}\n\nconst createPageHeaderStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius, fontWeights } = t.primitives;\n const c = t.colors;\n const { heading, body } = t.typography;\n\n return StyleSheet.create({\n brandedContainer: {\n alignItems: \"center\",\n backgroundColor: c.primary,\n borderRadius: borderRadius.sm,\n display: \"flex\",\n flexDirection: \"column\",\n padding: spacing[6],\n },\n centeredContainer: {\n alignItems: \"center\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"column\",\n paddingBottom: spacing[4],\n },\n contactInfo: {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[0.5],\n textAlign: \"right\",\n },\n\n logoContainer: {\n flexShrink: 0,\n height: 48,\n marginRight: spacing[4],\n width: 48,\n },\n\n logoContent: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n paddingLeft: spacing[4],\n },\n logoLeftContainer: {\n alignItems: \"center\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n paddingBottom: spacing[4],\n },\n logoRightContainer: {\n alignItems: \"center\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[4],\n },\n\n logoRightContent: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n\n logoRightLogoContainer: {\n flexShrink: 0,\n height: 48,\n marginLeft: spacing[4],\n width: 48,\n },\n minimalContainer: {\n alignItems: \"center\",\n borderBottomColor: c.primary,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[1],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[3],\n },\n minimalLeft: {\n flex: 1,\n },\n minimalRight: {\n alignItems: \"flex-end\",\n },\n\n rightSubText: {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[1],\n textAlign: \"right\",\n },\n rightText: {\n color: c.foreground,\n fontFamily: body.fontFamily,\n fontSize: body.fontSize,\n fontWeight: fontWeights.medium,\n textAlign: \"right\",\n },\n simpleContainer: {\n alignItems: \"flex-start\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[4],\n },\n\n simpleLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n simpleRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flexDirection: \"column\",\n },\n\n subtitle: {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: body.fontSize,\n lineHeight: body.lineHeight,\n marginTop: spacing[1],\n },\n subtitleBranded: {\n color: c.primaryForeground,\n marginTop: spacing[1],\n },\n subtitleCentered: {\n textAlign: \"center\",\n },\n\n title: {\n color: c.foreground,\n fontFamily: heading.fontFamily,\n fontSize: heading.fontSize.h3,\n fontWeight: fontWeights.bold,\n lineHeight: heading.lineHeight,\n marginBottom: 0,\n },\n titleBranded: {\n color: c.primaryForeground,\n },\n titleCentered: {\n textAlign: \"center\",\n },\n\n titleMinimal: {\n fontSize: heading.fontSize.h3,\n fontWeight: fontWeights.bold,\n },\n twoColumnContainer: {\n alignItems: \"flex-start\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[4],\n },\n twoColumnLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n twoColumnRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flexDirection: \"column\",\n },\n });\n};\n\nconst buildContainerStyles = (\n base: Style,\n mb: number,\n background: string | undefined,\n theme: PdfcnTheme,\n style: Style | undefined,\n ...extras: Style[]\n): Style[] => {\n const result: Style[] = [base, { marginBottom: mb }, ...extras];\n if (background) {\n result.push({ backgroundColor: resolveColor(background, theme.colors) });\n }\n if (style) {\n result.push(style);\n }\n return result;\n};\n\nconst buildTitleStyles = (\n base: Style[],\n titleColor: string | undefined,\n theme: PdfcnTheme\n): Style[] => {\n if (!titleColor) {\n return base;\n }\n return [...base, { color: resolveColor(titleColor, theme.colors) }];\n};\n\n/** Container and title styles of each variant. */\nconst pageHeaderStyles = (\n theme: PdfcnTheme,\n {\n variant = \"simple\",\n background,\n titleColor,\n marginBottom,\n style,\n }: Omit\n) => {\n const styles = createPageHeaderStyles(theme);\n const mb = marginBottom ?? theme.spacing.sectionGap;\n\n const variantRenderers: Record<\n PageHeaderVariant,\n () => { container: Style[]; title: Style[] }\n > = {\n branded: () => ({\n container: buildContainerStyles(\n styles.brandedContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles(\n [styles.title, styles.titleBranded, styles.titleCentered],\n titleColor,\n theme\n ),\n }),\n centered: () => ({\n container: buildContainerStyles(\n styles.centeredContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles(\n [styles.title, styles.titleCentered],\n titleColor,\n theme\n ),\n }),\n \"logo-left\": () => ({\n container: buildContainerStyles(\n styles.logoLeftContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n \"logo-right\": () => ({\n container: buildContainerStyles(\n styles.logoRightContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n minimal: () => ({\n container: buildContainerStyles(\n styles.minimalContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles(\n [styles.title, styles.titleMinimal],\n titleColor,\n theme\n ),\n }),\n simple: () => ({\n container: buildContainerStyles(\n styles.simpleContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n \"two-column\": () => ({\n container: buildContainerStyles(\n styles.twoColumnContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n };\n\n return { ...variantRenderers[variant](), styles };\n};\n\n/** Header row with layout variants, logo support, and optional fixed positioning. */\n@Component({\n imports: [FormeFixed, FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-page-header\",\n template: `\n @if (fixed()) {\n \n } @else {\n \n }\n \n @let s = layout().styles;\n \n @switch (variant()) {\n @case (\"branded\") {\n {{ title() }}\n @if (subtitle()) {\n {{\n subtitle()\n }}\n }\n }\n @case (\"centered\") {\n {{ title() }}\n @if (subtitle()) {\n {{\n subtitle()\n }}\n }\n }\n @case (\"logo-right\") {\n \n \n \n @if (logo(); as logo) {\n \n }\n }\n @case (\"logo-left\") {\n @if (logo(); as logo) {\n \n }\n \n \n \n \n }\n @case (\"two-column\") {\n \n \n \n @if (address() || phone() || email()) {\n \n @if (address()) {\n {{\n address()\n }}\n }\n @if (phone()) {\n {{ phone() }}\n }\n @if (email()) {\n {{ email() }}\n }\n \n }\n }\n @case (\"minimal\") {\n \n \n \n \n }\n @default {\n \n \n \n \n }\n }\n \n \n {{ title() }}\n @if (subtitle()) {\n {{ subtitle() }}\n }\n \n \n @if (rightText() || rightSubText()) {\n \n @if (rightText()) {\n {{ rightText() }}\n }\n @if (rightSubText()) {\n {{\n rightSubText()\n }}\n }\n \n }\n \n \n `,\n})\nexport class PdfPageHeader {\n /** Templates passed in resolve the theme from where they render, not where they are declared. */\n protected readonly injector = inject(Injector);\n readonly title = input.required();\n readonly subtitle = input();\n readonly rightText = input();\n readonly rightSubText = input();\n readonly variant = input(\"simple\");\n readonly background = input();\n readonly titleColor = input();\n readonly marginBottom = input();\n readonly address = input();\n readonly phone = input();\n readonly email = input();\n readonly logo = input>();\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly noWrap = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n pageHeaderStyles(this.theme(), {\n background: this.background(),\n marginBottom: this.marginBottom(),\n style: this.style(),\n titleColor: this.titleColor(),\n variant: this.variant(),\n })\n );\n}\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport {\n booleanAttribute,\n Component,\n computed,\n input,\n inject,\n Injector,\n} from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeFixed,\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 PageHeaderVariant =\n | \"simple\"\n | \"centered\"\n | \"minimal\"\n | \"branded\"\n | \"logo-left\"\n | \"logo-right\"\n | \"two-column\";\n\n/**\n * Header row with layout variants, logo support, and optional fixed positioning.\n * Props - `title` | `subtitle` | `rightText` | `rightSubText` | `variant` | `background` | `titleColor` | `marginBottom` | `address` | `phone` | `email` | `logo` | `fixed` | `noWrap` | `style`\n * @see {@link PageHeaderProps}\n */\nexport interface PageHeaderProps extends PDFComponentProps {\n title: string;\n subtitle?: string;\n rightText?: string;\n rightSubText?: string;\n /**\n * @default 'simple'\n */\n variant?: PageHeaderVariant;\n background?: string;\n titleColor?: string;\n marginBottom?: number;\n address?: string;\n phone?: string;\n email?: string;\n logo?: TemplateRef;\n /**\n * @default false\n */\n fixed?: boolean;\n /**\n * @default true\n */\n noWrap?: boolean;\n}\n\nconst createPageHeaderStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius, fontWeights } = t.primitives;\n const c = t.colors;\n const { heading, body } = t.typography;\n\n return StyleSheet.create({\n brandedContainer: {\n alignItems: \"center\",\n backgroundColor: c.primary,\n borderRadius: borderRadius.sm,\n display: \"flex\",\n flexDirection: \"column\",\n padding: spacing[6],\n },\n centeredContainer: {\n alignItems: \"center\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"column\",\n paddingBottom: spacing[4],\n },\n contactInfo: {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[0.5],\n textAlign: \"right\",\n },\n\n logoContainer: {\n flexShrink: 0,\n height: 48,\n marginRight: spacing[4],\n width: 48,\n },\n\n logoContent: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n paddingLeft: spacing[4],\n },\n logoLeftContainer: {\n alignItems: \"center\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n paddingBottom: spacing[4],\n },\n logoRightContainer: {\n alignItems: \"center\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[4],\n },\n\n logoRightContent: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n\n logoRightLogoContainer: {\n flexShrink: 0,\n height: 48,\n marginLeft: spacing[4],\n width: 48,\n },\n minimalContainer: {\n alignItems: \"center\",\n borderBottomColor: c.primary,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[1],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[3],\n },\n minimalLeft: {\n flex: 1,\n },\n minimalRight: {\n alignItems: \"flex-end\",\n },\n\n rightSubText: {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[1],\n textAlign: \"right\",\n },\n rightText: {\n color: c.foreground,\n fontFamily: body.fontFamily,\n fontSize: body.fontSize,\n fontWeight: fontWeights.medium,\n textAlign: \"right\",\n },\n simpleContainer: {\n alignItems: \"flex-start\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[4],\n },\n\n simpleLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n simpleRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flexDirection: \"column\",\n },\n\n subtitle: {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: body.fontSize,\n lineHeight: body.lineHeight,\n marginTop: spacing[1],\n },\n subtitleBranded: {\n color: c.primaryForeground,\n marginTop: spacing[1],\n },\n subtitleCentered: {\n textAlign: \"center\",\n },\n\n title: {\n color: c.foreground,\n fontFamily: heading.fontFamily,\n fontSize: heading.fontSize.h3,\n fontWeight: fontWeights.bold,\n lineHeight: heading.lineHeight,\n marginBottom: 0,\n },\n titleBranded: {\n color: c.primaryForeground,\n },\n titleCentered: {\n textAlign: \"center\",\n },\n\n titleMinimal: {\n fontSize: heading.fontSize.h3,\n fontWeight: fontWeights.bold,\n },\n twoColumnContainer: {\n alignItems: \"flex-start\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[4],\n },\n twoColumnLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n twoColumnRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flexDirection: \"column\",\n },\n });\n};\n\nconst buildContainerStyles = (\n base: Style,\n mb: number,\n background: string | undefined,\n theme: PdfcnTheme,\n style: Style | undefined,\n ...extras: Style[]\n): Style[] => {\n const result: Style[] = [base, { marginBottom: mb }, ...extras];\n if (background) {\n result.push({ backgroundColor: resolveColor(background, theme.colors) });\n }\n if (style) {\n result.push(style);\n }\n return result;\n};\n\nconst buildTitleStyles = (\n base: Style[],\n titleColor: string | undefined,\n theme: PdfcnTheme\n): Style[] => {\n if (!titleColor) {\n return base;\n }\n return [...base, { color: resolveColor(titleColor, theme.colors) }];\n};\n\n/** Container and title styles of each variant. */\nconst pageHeaderStyles = (\n theme: PdfcnTheme,\n {\n variant = \"simple\",\n background,\n titleColor,\n marginBottom,\n style,\n }: Omit\n) => {\n const styles = createPageHeaderStyles(theme);\n const mb = marginBottom ?? theme.spacing.sectionGap;\n\n const variantRenderers: Record<\n PageHeaderVariant,\n () => { container: Style[]; title: Style[] }\n > = {\n branded: () => ({\n container: buildContainerStyles(\n styles.brandedContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles(\n [styles.title, styles.titleBranded, styles.titleCentered],\n titleColor,\n theme\n ),\n }),\n centered: () => ({\n container: buildContainerStyles(\n styles.centeredContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles(\n [styles.title, styles.titleCentered],\n titleColor,\n theme\n ),\n }),\n \"logo-left\": () => ({\n container: buildContainerStyles(\n styles.logoLeftContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n \"logo-right\": () => ({\n container: buildContainerStyles(\n styles.logoRightContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n minimal: () => ({\n container: buildContainerStyles(\n styles.minimalContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles(\n [styles.title, styles.titleMinimal],\n titleColor,\n theme\n ),\n }),\n simple: () => ({\n container: buildContainerStyles(\n styles.simpleContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n \"two-column\": () => ({\n container: buildContainerStyles(\n styles.twoColumnContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n };\n\n return { ...variantRenderers[variant](), styles };\n};\n\n/** Header row with layout variants, logo support, and optional fixed positioning. */\n@Component({\n imports: [FormeFixed, FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-page-header\",\n template: `\n @if (fixed()) {\n \n } @else {\n \n }\n \n @let s = layout().styles;\n \n @switch (variant()) {\n @case (\"branded\") {\n {{ title() }}\n @if (subtitle()) {\n {{\n subtitle()\n }}\n }\n }\n @case (\"centered\") {\n {{ title() }}\n @if (subtitle()) {\n {{\n subtitle()\n }}\n }\n }\n @case (\"logo-right\") {\n \n \n \n @if (logo(); as logo) {\n \n }\n }\n @case (\"logo-left\") {\n @if (logo(); as logo) {\n \n }\n \n \n \n \n }\n @case (\"two-column\") {\n \n \n \n @if (address() || phone() || email()) {\n \n @if (address()) {\n {{\n address()\n }}\n }\n @if (phone()) {\n {{ phone() }}\n }\n @if (email()) {\n {{ email() }}\n }\n \n }\n }\n @case (\"minimal\") {\n \n \n \n \n }\n @default {\n \n \n \n \n }\n }\n \n \n {{ title() }}\n @if (subtitle()) {\n {{ subtitle() }}\n }\n \n \n @if (rightText() || rightSubText()) {\n \n @if (rightText()) {\n {{ rightText() }}\n }\n @if (rightSubText()) {\n {{\n rightSubText()\n }}\n }\n \n }\n \n \n `,\n})\nexport class PdfPageHeader {\n /** Templates passed in resolve the theme from where they render, not where they are declared. */\n protected readonly injector = inject(Injector);\n readonly title = input.required();\n readonly subtitle = input();\n readonly rightText = input();\n readonly rightSubText = input();\n readonly variant = input(\"simple\");\n readonly background = input();\n readonly titleColor = input();\n readonly marginBottom = input();\n readonly address = input();\n readonly phone = input();\n readonly email = input();\n readonly logo = input>();\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly noWrap = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n pageHeaderStyles(this.theme(), {\n background: this.background(),\n marginBottom: this.marginBottom(),\n style: this.style(),\n titleColor: this.titleColor(),\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/page-header/page-header.ts" } diff --git a/apps/web/public/r/forme/page-number.json b/apps/web/public/r/forme/page-number.json index 466604c..74987e5 100644 --- a/apps/web/public/r/forme/page-number.json +++ b/apps/web/public/r/forme/page-number.json @@ -3,17 +3,13 @@ "name": "forme/page-number", "title": "Page Number", "description": "Page Number 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/page-number/page-number.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 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 PageNumberAlign = \"left\" | \"center\" | \"right\";\nexport type PageNumberSize = \"xs\" | \"sm\" | \"md\";\n\n/**\n * Auto page number rendered with a configurable format string at a or inline position.\n * Props - `format` | `align` | `size` | `fixed` | `muted` | `style`\n * @see {@link PageNumberProps}\n */\nexport interface PageNumberProps extends Omit {\n /**\n * Format string — use `{page}` for current page and `{total}` for total page count.\n * @default 'Page {page} of {total}'\n */\n format?: string;\n /**\n * @default 'center'\n */\n align?: PageNumberAlign;\n /**\n * @default 'sm'\n */\n size?: PageNumberSize;\n /**\n * @default false\n */\n fixed?: boolean;\n /**\n * @default true\n */\n muted?: boolean;\n children?: never;\n}\n\nconst createPageNumberStyles = (t: PdfcnTheme) => {\n const { typography, colors, primitives } = t;\n return StyleSheet.create({\n alignCenter: { textAlign: \"center\" },\n alignLeft: { textAlign: \"left\" },\n alignRight: { textAlign: \"right\" },\n colorForeground: { color: colors.foreground },\n colorMuted: { color: colors.mutedForeground },\n container: { width: \"100%\" },\n sizeMd: { fontSize: primitives.typography.base },\n sizeSm: { fontSize: primitives.typography.sm },\n sizeXs: { fontSize: primitives.typography.xs },\n text: { fontFamily: typography.body.fontFamily },\n });\n};\n\nconst pageNumberLayout = (\n theme: PdfcnTheme,\n {\n format = \"Page {page} of {total}\",\n align = \"center\",\n size = \"sm\",\n muted = true,\n style,\n }: PageNumberProps\n) => {\n const styles = createPageNumberStyles(theme);\n const alignMap = {\n center: styles.alignCenter,\n left: styles.alignLeft,\n right: styles.alignRight,\n } as Record;\n const sizeMap = {\n md: styles.sizeMd,\n sm: styles.sizeSm,\n xs: styles.sizeXs,\n } as Record;\n const textStyles: Style[] = [\n styles.text,\n alignMap[align],\n sizeMap[size],\n muted ? styles.colorMuted : styles.colorForeground,\n ];\n if (style) {\n textStyles.push(...[style].flat());\n }\n return {\n container: styles.container,\n content: format\n .replace(\"{page}\", \"{{pageNumber}}\")\n .replace(\"{total}\", \"{{totalPages}}\"),\n text: mergePdfStyles(textStyles),\n };\n};\n\n@Component({\n imports: [FormeText, FormeView],\n selector: \"pdf-page-number\",\n template: `\n @let l = layout();\n {{ l.content }}\n `,\n})\nexport class PdfPageNumber {\n readonly format = input(\"Page {page} of {total}\");\n readonly align = input(\"center\");\n readonly size = input(\"sm\");\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly muted = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n pageNumberLayout(this.theme(), {\n align: this.align(),\n format: this.format(),\n muted: this.muted(),\n size: this.size(),\n style: this.style(),\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 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 PageNumberAlign = \"left\" | \"center\" | \"right\";\nexport type PageNumberSize = \"xs\" | \"sm\" | \"md\";\n\n/**\n * Auto page number rendered with a configurable format string at a or inline position.\n * Props - `format` | `align` | `size` | `fixed` | `muted` | `style`\n * @see {@link PageNumberProps}\n */\nexport interface PageNumberProps extends Omit {\n /**\n * Format string — use `{page}` for current page and `{total}` for total page count.\n * @default 'Page {page} of {total}'\n */\n format?: string;\n /**\n * @default 'center'\n */\n align?: PageNumberAlign;\n /**\n * @default 'sm'\n */\n size?: PageNumberSize;\n /**\n * @default false\n */\n fixed?: boolean;\n /**\n * @default true\n */\n muted?: boolean;\n children?: never;\n}\n\nconst createPageNumberStyles = (t: PdfcnTheme) => {\n const { typography, colors, primitives } = t;\n return StyleSheet.create({\n alignCenter: { textAlign: \"center\" },\n alignLeft: { textAlign: \"left\" },\n alignRight: { textAlign: \"right\" },\n colorForeground: { color: colors.foreground },\n colorMuted: { color: colors.mutedForeground },\n container: { width: \"100%\" },\n sizeMd: { fontSize: primitives.typography.base },\n sizeSm: { fontSize: primitives.typography.sm },\n sizeXs: { fontSize: primitives.typography.xs },\n text: { fontFamily: typography.body.fontFamily },\n });\n};\n\nconst pageNumberLayout = (\n theme: PdfcnTheme,\n {\n format = \"Page {page} of {total}\",\n align = \"center\",\n size = \"sm\",\n muted = true,\n style,\n }: PageNumberProps\n) => {\n const styles = createPageNumberStyles(theme);\n const alignMap = {\n center: styles.alignCenter,\n left: styles.alignLeft,\n right: styles.alignRight,\n } as Record;\n const sizeMap = {\n md: styles.sizeMd,\n sm: styles.sizeSm,\n xs: styles.sizeXs,\n } as Record;\n const textStyles: Style[] = [\n styles.text,\n alignMap[align],\n sizeMap[size],\n muted ? styles.colorMuted : styles.colorForeground,\n ];\n if (style) {\n textStyles.push(...[style].flat());\n }\n return {\n container: styles.container,\n content: format\n .replace(\"{page}\", \"{{pageNumber}}\")\n .replace(\"{total}\", \"{{totalPages}}\"),\n text: mergePdfStyles(textStyles),\n };\n};\n\n@Component({\n imports: [FormeText, FormeView],\n selector: \"pdf-page-number\",\n template: `\n @let l = layout();\n {{ l.content }}\n `,\n})\nexport class PdfPageNumber {\n readonly format = input(\"Page {page} of {total}\");\n readonly align = input(\"center\");\n readonly size = input(\"sm\");\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly muted = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n pageNumberLayout(this.theme(), {\n align: this.align(),\n format: this.format(),\n muted: this.muted(),\n size: this.size(),\n style: this.style(),\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/page-number/page-number.ts" } diff --git a/apps/web/public/r/forme/pdf-image.json b/apps/web/public/r/forme/pdf-image.json index 27f5a7d..a09ad8b 100644 --- a/apps/web/public/r/forme/pdf-image.json +++ b/apps/web/public/r/forme/pdf-image.json @@ -3,17 +3,13 @@ "name": "forme/pdf-image", "title": "PDF Image", "description": "Image 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/pdf-image/pdf-image.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 FormeImage,\n FormeText,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/** HTTP method used when fetching the image from a URL. */\nexport type PdfImageHTTPMethod =\n | \"GET\"\n | \"HEAD\"\n | \"POST\"\n | \"PUT\"\n | \"DELETE\"\n | \"PATCH\";\n\nexport type PdfImageSrc =\n | string\n | {\n uri: string;\n method?: PdfImageHTTPMethod;\n headers?: Record;\n body?: string;\n };\n\nexport type PdfImageFit = \"cover\" | \"contain\" | \"fill\" | \"none\";\n\nexport type PdfImageVariant =\n | \"default\"\n | \"full-width\"\n | \"thumbnail\"\n | \"avatar\"\n | \"cover\"\n | \"bordered\"\n | \"rounded\";\n\n/**\n * Image element with layout presets, caption, and aspect ratio support.\n * Props - `src` | `variant` | `width` | `height` | `fit` | `position` | `caption` | `aspectRatio` | `borderRadius` | `noWrap` | `style`\n * @see {@link PdfImageProps}\n */\nexport interface PdfImageProps {\n src: PdfImageSrc;\n /**\n * @default 'default'\n */\n variant?: PdfImageVariant;\n width?: number | string;\n height?: number | string;\n fit?: PdfImageFit;\n /**\n * @default '50% 50%'\n */\n position?: string;\n caption?: string;\n aspectRatio?: number;\n borderRadius?: number;\n /**\n * @default true\n */\n noWrap?: boolean;\n style?: Style;\n}\n\ninterface VariantDefaults {\n width?: number | string;\n height?: number | string;\n fit: PdfImageFit;\n borderRadius?: number;\n}\n\nconst VARIANT_DEFAULTS: Record = {\n avatar: { borderRadius: 999, fit: \"cover\", height: 48, width: 48 },\n bordered: { fit: \"contain\", width: \"100%\" },\n cover: { fit: \"cover\", height: 160, width: \"100%\" },\n default: { fit: \"contain\" },\n \"full-width\": { fit: \"cover\", width: \"100%\" },\n rounded: { borderRadius: 8, fit: \"contain\", width: 200 },\n thumbnail: { fit: \"cover\", height: 80, width: 80 },\n};\n\nconst UNSUPPORTED_FORMATS = new Set([\"webp\", \"avif\", \"heic\", \"heif\", \"ico\"]);\n\nconst detectFormat = (src: PdfImageSrc): string | null => {\n if (typeof src !== \"string\") {\n return null;\n }\n const dataMatch = src.match(/^data:image\\/([a-zA-Z0-9+.-]+)/);\n if (dataMatch) {\n return dataMatch[1].toLowerCase();\n }\n return src.split(\"?\")[0].split(\".\").pop()?.toLowerCase() ?? null;\n};\n\nconst warnIfUnsupported = (src: PdfImageSrc): void => {\n const fmt = detectFormat(src);\n if (fmt && UNSUPPORTED_FORMATS.has(fmt)) {\n console.warn(\n `[PdfImage] Unsupported format \"${fmt}\" detected. Forme supports: JPEG, PNG, GIF (first frame), BMP, SVG. Convert to PNG or JPEG before use.`\n );\n }\n};\n\nconst createImageStyles = (t: PdfcnTheme) => {\n const { spacing } = t.primitives;\n return StyleSheet.create({\n caption: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[1],\n textAlign: \"center\",\n },\n container: { flexDirection: \"column\" },\n image: {},\n imageBordered: {\n borderColor: t.colors.border,\n borderStyle: \"solid\",\n borderWidth: 1,\n },\n });\n};\n\nconst pdfImageStyles = (\n theme: PdfcnTheme,\n {\n variant = \"default\",\n width,\n height,\n fit,\n position = \"50% 50%\",\n aspectRatio,\n borderRadius,\n style,\n }: Omit\n) => {\n const styles = createImageStyles(theme);\n const defaults = VARIANT_DEFAULTS[variant];\n\n const resolvedWidth = width ?? defaults.width;\n const resolvedHeight: number | string | undefined = (() => {\n if (height !== undefined) {\n return height;\n }\n if (defaults.height !== undefined) {\n return defaults.height;\n }\n return aspectRatio !== undefined && typeof resolvedWidth === \"number\"\n ? resolvedWidth / aspectRatio\n : undefined;\n })();\n\n const resolvedFit = fit ?? defaults.fit;\n const resolvedRadius = borderRadius ?? defaults.borderRadius;\n\n const imageStyles: Style[] = [styles.image];\n if (resolvedWidth !== undefined) {\n imageStyles.push({ width: resolvedWidth } as Style);\n }\n if (resolvedHeight !== undefined) {\n imageStyles.push({ height: resolvedHeight } as Style);\n }\n imageStyles.push({\n objectFit: resolvedFit,\n objectPosition: position,\n } as Style);\n if (resolvedRadius !== undefined) {\n imageStyles.push({ borderRadius: resolvedRadius } as Style);\n }\n if (variant === \"bordered\") {\n imageStyles.push(styles.imageBordered);\n }\n if (style) {\n imageStyles.push(style);\n }\n\n return {\n caption: styles.caption,\n container: styles.container,\n image: imageStyles,\n };\n};\n\n/** Image element with layout presets, caption, and aspect ratio support. */\n@Component({\n imports: [FormeImage, FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-image\",\n template: `\n @if (noWrap()) {\n \n \n \n } @else {\n \n }\n \n \n \n @if (caption()) {\n {{ caption() }}\n }\n \n \n `,\n})\nexport class PdfImage {\n readonly src = input.required();\n readonly variant = input(\"default\");\n readonly width = input();\n readonly height = input();\n readonly fit = input();\n readonly position = input(\"50% 50%\");\n readonly caption = input();\n readonly aspectRatio = input();\n readonly borderRadius = input();\n readonly noWrap = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly styles = computed(() => {\n warnIfUnsupported(this.src());\n return pdfImageStyles(this.theme(), {\n aspectRatio: this.aspectRatio(),\n borderRadius: this.borderRadius(),\n fit: this.fit(),\n height: this.height(),\n position: this.position(),\n style: this.style(),\n variant: this.variant(),\n width: this.width(),\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 FormeImage,\n FormeText,\n FormeView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/** HTTP method used when fetching the image from a URL. */\nexport type PdfImageHTTPMethod =\n | \"GET\"\n | \"HEAD\"\n | \"POST\"\n | \"PUT\"\n | \"DELETE\"\n | \"PATCH\";\n\nexport type PdfImageSrc =\n | string\n | {\n uri: string;\n method?: PdfImageHTTPMethod;\n headers?: Record;\n body?: string;\n };\n\nexport type PdfImageFit = \"cover\" | \"contain\" | \"fill\" | \"none\";\n\nexport type PdfImageVariant =\n | \"default\"\n | \"full-width\"\n | \"thumbnail\"\n | \"avatar\"\n | \"cover\"\n | \"bordered\"\n | \"rounded\";\n\n/**\n * Image element with layout presets, caption, and aspect ratio support.\n * Props - `src` | `variant` | `width` | `height` | `fit` | `position` | `caption` | `aspectRatio` | `borderRadius` | `noWrap` | `style`\n * @see {@link PdfImageProps}\n */\nexport interface PdfImageProps {\n src: PdfImageSrc;\n /**\n * @default 'default'\n */\n variant?: PdfImageVariant;\n width?: number | string;\n height?: number | string;\n fit?: PdfImageFit;\n /**\n * @default '50% 50%'\n */\n position?: string;\n caption?: string;\n aspectRatio?: number;\n borderRadius?: number;\n /**\n * @default true\n */\n noWrap?: boolean;\n style?: Style;\n}\n\ninterface VariantDefaults {\n width?: number | string;\n height?: number | string;\n fit: PdfImageFit;\n borderRadius?: number;\n}\n\nconst VARIANT_DEFAULTS: Record = {\n avatar: { borderRadius: 999, fit: \"cover\", height: 48, width: 48 },\n bordered: { fit: \"contain\", width: \"100%\" },\n cover: { fit: \"cover\", height: 160, width: \"100%\" },\n default: { fit: \"contain\" },\n \"full-width\": { fit: \"cover\", width: \"100%\" },\n rounded: { borderRadius: 8, fit: \"contain\", width: 200 },\n thumbnail: { fit: \"cover\", height: 80, width: 80 },\n};\n\nconst UNSUPPORTED_FORMATS = new Set([\"webp\", \"avif\", \"heic\", \"heif\", \"ico\"]);\n\nconst detectFormat = (src: PdfImageSrc): string | null => {\n if (typeof src !== \"string\") {\n return null;\n }\n const dataMatch = src.match(/^data:image\\/([a-zA-Z0-9+.-]+)/);\n if (dataMatch) {\n return dataMatch[1].toLowerCase();\n }\n return src.split(\"?\")[0].split(\".\").pop()?.toLowerCase() ?? null;\n};\n\nconst warnIfUnsupported = (src: PdfImageSrc): void => {\n const fmt = detectFormat(src);\n if (fmt && UNSUPPORTED_FORMATS.has(fmt)) {\n console.warn(\n `[PdfImage] Unsupported format \"${fmt}\" detected. Forme supports: JPEG, PNG, GIF (first frame), BMP, SVG. Convert to PNG or JPEG before use.`\n );\n }\n};\n\nconst createImageStyles = (t: PdfcnTheme) => {\n const { spacing } = t.primitives;\n return StyleSheet.create({\n caption: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[1],\n textAlign: \"center\",\n },\n container: { flexDirection: \"column\" },\n image: {},\n imageBordered: {\n borderColor: t.colors.border,\n borderStyle: \"solid\",\n borderWidth: 1,\n },\n });\n};\n\nconst pdfImageStyles = (\n theme: PdfcnTheme,\n {\n variant = \"default\",\n width,\n height,\n fit,\n position = \"50% 50%\",\n aspectRatio,\n borderRadius,\n style,\n }: Omit\n) => {\n const styles = createImageStyles(theme);\n const defaults = VARIANT_DEFAULTS[variant];\n\n const resolvedWidth = width ?? defaults.width;\n const resolvedHeight: number | string | undefined = (() => {\n if (height !== undefined) {\n return height;\n }\n if (defaults.height !== undefined) {\n return defaults.height;\n }\n return aspectRatio !== undefined && typeof resolvedWidth === \"number\"\n ? resolvedWidth / aspectRatio\n : undefined;\n })();\n\n const resolvedFit = fit ?? defaults.fit;\n const resolvedRadius = borderRadius ?? defaults.borderRadius;\n\n const imageStyles: Style[] = [styles.image];\n if (resolvedWidth !== undefined) {\n imageStyles.push({ width: resolvedWidth } as Style);\n }\n if (resolvedHeight !== undefined) {\n imageStyles.push({ height: resolvedHeight } as Style);\n }\n imageStyles.push({\n objectFit: resolvedFit,\n objectPosition: position,\n } as Style);\n if (resolvedRadius !== undefined) {\n imageStyles.push({ borderRadius: resolvedRadius } as Style);\n }\n if (variant === \"bordered\") {\n imageStyles.push(styles.imageBordered);\n }\n if (style) {\n imageStyles.push(style);\n }\n\n return {\n caption: styles.caption,\n container: styles.container,\n image: imageStyles,\n };\n};\n\n/** Image element with layout presets, caption, and aspect ratio support. */\n@Component({\n imports: [FormeImage, FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-image\",\n template: `\n @if (noWrap()) {\n \n \n \n } @else {\n \n }\n \n \n \n @if (caption()) {\n {{ caption() }}\n }\n \n \n `,\n})\nexport class PdfImage {\n readonly src = input.required();\n readonly variant = input(\"default\");\n readonly width = input();\n readonly height = input();\n readonly fit = input();\n readonly position = input(\"50% 50%\");\n readonly caption = input();\n readonly aspectRatio = input();\n readonly borderRadius = input();\n readonly noWrap = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly styles = computed(() => {\n warnIfUnsupported(this.src());\n return pdfImageStyles(this.theme(), {\n aspectRatio: this.aspectRatio(),\n borderRadius: this.borderRadius(),\n fit: this.fit(),\n height: this.height(),\n position: this.position(),\n style: this.style(),\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/pdf-image/pdf-image.ts" } diff --git a/apps/web/public/r/forme/press-release.json b/apps/web/public/r/forme/press-release.json index ca9be86..3ec3ea9 100644 --- a/apps/web/public/r/forme/press-release.json +++ b/apps/web/public/r/forme/press-release.json @@ -3,10 +3,6 @@ "name": "forme/press-release", "title": "Press Release", "description": "Press Release PDF block (forme)", - "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0" - ], "registryDependencies": [ "@angular-pdfcn/forme/utils", "@angular-pdfcn/forme/page-footer", @@ -18,13 +14,13 @@ "files": [ { "path": "registry/bases/forme/blocks/press-release/press-release.ts", - "content": "import { Component, computed, input } from \"@angular/core\";\n\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 { 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 { PressReleaseProps } from \"./press-release.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: PressReleaseProps = {\n accentColor: \"#1e40af\",\n address: \"123 Market St, San Francisco, CA 94103\",\n body: [\n \"Acme Corp today announced the launch of pdfcn, an open-source React component library for generating professional PDF documents.\",\n \"pdfcn is designed to work seamlessly with shadcn/ui and follows the same registry-based distribution model, letting developers add print-ready document blocks with a single CLI command.\",\n ],\n boilerplate:\n \"Acme Corp is a leading provider of developer tools and open-source software.\",\n companyName: \"Acme Corp\",\n date: \"September 10, 2026\",\n dateline: { city: \"San Francisco\", state: \"CA\" },\n headline: \"Acme Corp Launches Revolutionary PDF Toolkit for Developers\",\n mediaContact: {\n email: \"press@acme.com\",\n name: \"Press Team\",\n phone: \"(555) 123-4567\",\n },\n quotes: [\n {\n author: \"Jane Doe\",\n text: \"We built pdfcn because generating PDFs in React was unnecessarily painful. Now it feels like writing any other component.\",\n title: \"CTO, Acme Corp\",\n },\n ],\n socialLinks: [\n { platform: \"GitHub\", url: \"https://github.com/acme\" },\n { platform: \"X\", url: \"https://x.com/acme\" },\n ],\n subheadline:\n \"New open-source library makes generating professional PDFs in React effortless\",\n};\n\nconst pressReleaseStyles = (theme: PdfcnTheme) =>\n StyleSheet.create({\n columnHeading: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n });\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfImage,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n ],\n selector: \"pdf-press-release-content\",\n template: `\n @let data = this.data();\n \n \n \n \n \n \n \n \n \n For Immediate Release\n {{\n data.headline\n }}\n @if (data.subheadline) {\n {{\n data.subheadline\n }}\n }\n \n \n {{\n data.dateline.city +\n \", \" +\n data.dateline.state +\n \" — \" +\n data.date\n }}\n @for (paragraph of data.body; track $index) {\n {{ paragraph }}\n }\n \n @for (quote of data.quotes ?? []; track quote.author) {\n \n {{\n \"“\" + quote.text + \"”\"\n }}\n {{\n \"— \" + quote.author + \", \" + quote.title\n }}\n \n }\n \n {{ \"About \" + data.companyName }}\n {{ data.boilerplate }}\n \n \n Media Contact\n {{\n data.mediaContact.name\n }}\n {{\n data.mediaContact.email\n }}\n {{\n data.mediaContact.phone\n }}\n @if (data.mediaContact.website) {\n {{\n data.mediaContact.website\n }}\n }\n \n ###\n \n \n \n `,\n})\nexport class PressReleaseContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() => pressReleaseStyles(this.theme()));\n\n protected readonly footerRightText = computed(() => {\n const data = this.data();\n return data.socialLinks?.length\n ? data.socialLinks.map((link) => link.platform).join(\" · \")\n : undefined;\n });\n}\n\n@Component({\n imports: [PdfcnThemeProvider, PressReleaseContent],\n selector: \"pdf-press-release\",\n template: `\n \n \n \n `,\n})\nexport class PressReleaseDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly mergedData = computed(\n (): PressReleaseProps => ({ ...sampleData, ...this.data() })\n );\n}\n", + "content": "import { Component, computed, input } from \"@angular/core\";\n\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 { 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 { PressReleaseProps } from \"./press-release.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: PressReleaseProps = {\n accentColor: \"#1e40af\",\n address: \"123 Market St, San Francisco, CA 94103\",\n body: [\n \"Acme Corp today announced the launch of pdfcn, an open-source React component library for generating professional PDF documents.\",\n \"pdfcn is designed to work seamlessly with shadcn/ui and follows the same registry-based distribution model, letting developers add print-ready document blocks with a single CLI command.\",\n ],\n boilerplate:\n \"Acme Corp is a leading provider of developer tools and open-source software.\",\n companyName: \"Acme Corp\",\n date: \"September 10, 2026\",\n dateline: { city: \"San Francisco\", state: \"CA\" },\n headline: \"Acme Corp Launches Revolutionary PDF Toolkit for Developers\",\n mediaContact: {\n email: \"press@acme.com\",\n name: \"Press Team\",\n phone: \"(555) 123-4567\",\n },\n quotes: [\n {\n author: \"Jane Doe\",\n text: \"We built pdfcn because generating PDFs in React was unnecessarily painful. Now it feels like writing any other component.\",\n title: \"CTO, Acme Corp\",\n },\n ],\n socialLinks: [\n { platform: \"GitHub\", url: \"https://github.com/acme\" },\n { platform: \"X\", url: \"https://x.com/acme\" },\n ],\n subheadline:\n \"New open-source library makes generating professional PDFs in React effortless\",\n};\n\nconst pressReleaseStyles = (theme: PdfcnTheme) =>\n StyleSheet.create({\n columnHeading: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n });\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfImage,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n ],\n selector: \"pdf-press-release-content\",\n template: `\n @let data = this.data();\n \n \n \n \n \n \n \n \n \n For Immediate Release\n {{\n data.headline\n }}\n @if (data.subheadline) {\n {{\n data.subheadline\n }}\n }\n \n \n {{\n data.dateline.city +\n \", \" +\n data.dateline.state +\n \" — \" +\n data.date\n }}\n @for (paragraph of data.body; track $index) {\n {{ paragraph }}\n }\n \n @for (quote of data.quotes ?? []; track quote.author) {\n \n {{\n \"“\" + quote.text + \"”\"\n }}\n {{\n \"— \" + quote.author + \", \" + quote.title\n }}\n \n }\n \n {{ \"About \" + data.companyName }}\n {{ data.boilerplate }}\n \n \n Media Contact\n {{\n data.mediaContact.name\n }}\n {{\n data.mediaContact.email\n }}\n {{\n data.mediaContact.phone\n }}\n @if (data.mediaContact.website) {\n {{\n data.mediaContact.website\n }}\n }\n \n ###\n \n \n \n `,\n})\nexport class PressReleaseContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() => pressReleaseStyles(this.theme()));\n\n protected readonly footerRightText = computed(() => {\n const data = this.data();\n return data.socialLinks?.length\n ? data.socialLinks.map((link) => link.platform).join(\" · \")\n : undefined;\n });\n}\n\n@Component({\n imports: [PdfcnThemeProvider, PressReleaseContent],\n selector: \"pdf-press-release\",\n template: `\n \n \n \n `,\n})\nexport class PressReleaseDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly mergedData = computed(\n (): PressReleaseProps => ({ ...sampleData, ...this.data() })\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:block", "target": "components/pdf/blocks/press-release/press-release.ts" }, { "path": "registry/bases/forme/blocks/press-release/press-release.types.ts", - "content": "export interface PressReleaseDateline {\n city: string;\n state: string;\n}\n\nexport interface PressReleaseQuote {\n text: string;\n author: string;\n title: string;\n}\n\nexport interface PressReleaseMediaContact {\n name: string;\n email: string;\n phone: string;\n website?: string;\n}\n\nexport interface PressReleaseSocialLink {\n platform: string;\n url: string;\n}\n\nexport interface PressReleaseProps {\n companyName: string;\n companyLogo?: string;\n date: string;\n headline: string;\n subheadline?: string;\n dateline: PressReleaseDateline;\n body: string[];\n quotes?: PressReleaseQuote[];\n boilerplate: string;\n mediaContact: PressReleaseMediaContact;\n address?: string;\n socialLinks?: PressReleaseSocialLink[];\n accentColor?: string;\n renderingBase?: \"takumi\" | \"forme\";\n}\n", + "content": "export interface PressReleaseDateline {\n city: string;\n state: string;\n}\n\nexport interface PressReleaseQuote {\n text: string;\n author: string;\n title: string;\n}\n\nexport interface PressReleaseMediaContact {\n name: string;\n email: string;\n phone: string;\n website?: string;\n}\n\nexport interface PressReleaseSocialLink {\n platform: string;\n url: string;\n}\n\nexport interface PressReleaseProps {\n companyName: string;\n companyLogo?: string;\n date: string;\n headline: string;\n subheadline?: string;\n dateline: PressReleaseDateline;\n body: string[];\n quotes?: PressReleaseQuote[];\n boilerplate: string;\n mediaContact: PressReleaseMediaContact;\n address?: string;\n socialLinks?: PressReleaseSocialLink[];\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/press-release/press-release.types.ts" } diff --git a/apps/web/public/r/forme/qrcode.json b/apps/web/public/r/forme/qrcode.json index b673948..4e04734 100644 --- a/apps/web/public/r/forme/qrcode.json +++ b/apps/web/public/r/forme/qrcode.json @@ -4,8 +4,6 @@ "title": "QR Code", "description": "QR code PDF component (forme)", "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0", "qrcode@^1.5.4" ], "devDependencies": [ @@ -17,7 +15,7 @@ "files": [ { "path": "registry/bases/forme/components/qrcode/qrcode.ts", - "content": "import { Component, computed, input } from \"@angular/core\";\nimport QRCode from \"qrcode\";\n\nimport {\n injectPdfcnTheme,\n mergePdfStyles,\n} from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n FormeSvg,\n FormeText,\n FormeView,\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 QRCodeErrorLevel = \"L\" | \"M\" | \"Q\" | \"H\";\n\n/**\n * QR code rendered as an SVG grid for use in PDF documents.\n * Props - `value` | `size` | `color` | `backgroundColor` | `errorLevel` | `margin` | `caption` | `style`\n * @see {@link PdfQRCodeProps}\n */\nexport interface PdfQRCodeProps extends Omit {\n value: string;\n size?: number;\n color?: string;\n backgroundColor?: string;\n errorLevel?: QRCodeErrorLevel;\n margin?: number;\n caption?: string;\n children?: never;\n}\n\nconst createQRCodeStyles = (t: PdfcnTheme) => {\n const { spacing } = t.primitives;\n return StyleSheet.create({\n caption: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[1],\n textAlign: \"center\",\n },\n container: { alignItems: \"center\" },\n });\n};\n\nconst generateQRMatrix = (\n value: string,\n errorLevel: QRCodeErrorLevel,\n margin: number\n): boolean[][] => {\n const qr = QRCode.create(value, { errorCorrectionLevel: errorLevel });\n const { size, data } = qr.modules;\n const totalSize = size + margin * 2;\n const matrix: boolean[][] = [];\n for (let row = 0; row < totalSize; row += 1) {\n const rowData: boolean[] = [];\n for (let col = 0; col < totalSize; col += 1) {\n const isInMargin =\n row < margin ||\n row >= size + margin ||\n col < margin ||\n col >= size + margin;\n if (isInMargin) {\n rowData.push(false);\n } else {\n rowData.push(data[(row - margin) * size + (col - margin)] === 1);\n }\n }\n matrix.push(rowData);\n }\n return matrix;\n};\n\nconst qrCodeLayout = (\n theme: PdfcnTheme,\n {\n value,\n size = 100,\n color = \"#000000\",\n backgroundColor = \"#ffffff\",\n errorLevel = \"M\",\n margin = 2,\n style,\n }: Omit\n) => {\n const styles = createQRCodeStyles(theme);\n const matrix = generateQRMatrix(value, errorLevel, margin);\n const moduleSize = size / matrix.length;\n const resolvedColor = resolveColor(color, theme.colors);\n const resolvedBgColor =\n backgroundColor === \"transparent\"\n ? undefined\n : resolveColor(backgroundColor, theme.colors);\n const containerStyles: Style[] = [styles.container];\n if (style) {\n containerStyles.push(...[style].flat());\n }\n\n return {\n caption: styles.caption,\n container: mergePdfStyles(containerStyles),\n moduleSize,\n modules: matrix\n .flatMap((row, y) =>\n row\n .map((isDark, x) => (isDark ? { x, y } : null))\n .filter((pos): pos is { x: number; y: number } => pos !== null)\n )\n .map((pos) => ({ x: pos.x * moduleSize, y: pos.y * moduleSize })),\n resolvedBgColor,\n resolvedColor,\n viewBox: `0 0 ${size} ${size}`,\n };\n};\n\n@Component({\n imports: [FormeSvg, FormeText, FormeView],\n selector: \"pdf-qrcode\",\n template: `\n @let l = layout();\n \n \n @if (l.resolvedBgColor !== undefined) {\n \n }\n @for (pos of l.modules; track $index) {\n \n }\n \n @if (caption()) {\n {{ caption() }}\n }\n \n `,\n})\nexport class PdfQRCode {\n readonly value = input.required();\n readonly size = input(100);\n readonly color = input(\"#000000\");\n readonly backgroundColor = input(\"#ffffff\");\n readonly errorLevel = input(\"M\");\n readonly margin = input(2);\n readonly caption = input();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n qrCodeLayout(this.theme(), {\n backgroundColor: this.backgroundColor(),\n color: this.color(),\n errorLevel: this.errorLevel(),\n margin: this.margin(),\n size: this.size(),\n style: this.style(),\n value: this.value(),\n })\n );\n}\n", + "content": "import { Component, computed, input } from \"@angular/core\";\nimport QRCode from \"qrcode\";\n\nimport {\n injectPdfcnTheme,\n mergePdfStyles,\n} from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n FormeSvg,\n FormeText,\n FormeView,\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 QRCodeErrorLevel = \"L\" | \"M\" | \"Q\" | \"H\";\n\n/**\n * QR code rendered as an SVG grid for use in PDF documents.\n * Props - `value` | `size` | `color` | `backgroundColor` | `errorLevel` | `margin` | `caption` | `style`\n * @see {@link PdfQRCodeProps}\n */\nexport interface PdfQRCodeProps extends Omit {\n value: string;\n size?: number;\n color?: string;\n backgroundColor?: string;\n errorLevel?: QRCodeErrorLevel;\n margin?: number;\n caption?: string;\n children?: never;\n}\n\nconst createQRCodeStyles = (t: PdfcnTheme) => {\n const { spacing } = t.primitives;\n return StyleSheet.create({\n caption: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[1],\n textAlign: \"center\",\n },\n container: { alignItems: \"center\" },\n });\n};\n\nconst generateQRMatrix = (\n value: string,\n errorLevel: QRCodeErrorLevel,\n margin: number\n): boolean[][] => {\n const qr = QRCode.create(value, { errorCorrectionLevel: errorLevel });\n const { size, data } = qr.modules;\n const totalSize = size + margin * 2;\n const matrix: boolean[][] = [];\n for (let row = 0; row < totalSize; row += 1) {\n const rowData: boolean[] = [];\n for (let col = 0; col < totalSize; col += 1) {\n const isInMargin =\n row < margin ||\n row >= size + margin ||\n col < margin ||\n col >= size + margin;\n if (isInMargin) {\n rowData.push(false);\n } else {\n rowData.push(data[(row - margin) * size + (col - margin)] === 1);\n }\n }\n matrix.push(rowData);\n }\n return matrix;\n};\n\nconst qrCodeLayout = (\n theme: PdfcnTheme,\n {\n value,\n size = 100,\n color = \"#000000\",\n backgroundColor = \"#ffffff\",\n errorLevel = \"M\",\n margin = 2,\n style,\n }: Omit\n) => {\n const styles = createQRCodeStyles(theme);\n const matrix = generateQRMatrix(value, errorLevel, margin);\n const moduleSize = size / matrix.length;\n const resolvedColor = resolveColor(color, theme.colors);\n const resolvedBgColor =\n backgroundColor === \"transparent\"\n ? undefined\n : resolveColor(backgroundColor, theme.colors);\n const containerStyles: Style[] = [styles.container];\n if (style) {\n containerStyles.push(...[style].flat());\n }\n\n return {\n caption: styles.caption,\n container: mergePdfStyles(containerStyles),\n moduleSize,\n modules: matrix\n .flatMap((row, y) =>\n row\n .map((isDark, x) => (isDark ? { x, y } : null))\n .filter((pos): pos is { x: number; y: number } => pos !== null)\n )\n .map((pos) => ({ x: pos.x * moduleSize, y: pos.y * moduleSize })),\n resolvedBgColor,\n resolvedColor,\n viewBox: `0 0 ${size} ${size}`,\n };\n};\n\n@Component({\n imports: [FormeSvg, FormeText, FormeView],\n selector: \"pdf-qrcode\",\n template: `\n @let l = layout();\n \n \n @if (l.resolvedBgColor !== undefined) {\n \n }\n @for (pos of l.modules; track $index) {\n \n }\n \n @if (caption()) {\n {{ caption() }}\n }\n \n `,\n})\nexport class PdfQRCode {\n readonly value = input.required();\n readonly size = input(100);\n readonly color = input(\"#000000\");\n readonly backgroundColor = input(\"#ffffff\");\n readonly errorLevel = input(\"M\");\n readonly margin = input(2);\n readonly caption = input();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n qrCodeLayout(this.theme(), {\n backgroundColor: this.backgroundColor(),\n color: this.color(),\n errorLevel: this.errorLevel(),\n margin: this.margin(),\n size: this.size(),\n style: this.style(),\n value: this.value(),\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/qrcode/qrcode.ts" } diff --git a/apps/web/public/r/forme/report-financial.json b/apps/web/public/r/forme/report-financial.json index 96b9a4b..710dc47 100644 --- a/apps/web/public/r/forme/report-financial.json +++ b/apps/web/public/r/forme/report-financial.json @@ -3,10 +3,6 @@ "name": "forme/report-financial", "title": "Report Financial", "description": "Report Financial PDF block (forme)", - "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0" - ], "registryDependencies": [ "@angular-pdfcn/forme/utils", "@angular-pdfcn/forme/badge", @@ -23,19 +19,19 @@ "files": [ { "path": "registry/bases/forme/blocks/report-financial/report-financial.ts", - "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleFinancialData: BaseReportData = {\n author: \"Finance Ops\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"Revenue accelerated after enterprise expansion campaign launch.\",\n \"Gross margin improved due to infrastructure cost renegotiation.\",\n \"Collections requires executive follow-up on two overdue accounts.\",\n ],\n period: \"Q1 2026\",\n rows: [\n {\n label: \"Enterprise Sales\",\n owner: \"A. Patel\",\n progress: 88,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"SMB Sales\",\n owner: \"L. Khan\",\n progress: 79,\n risk: \"Medium\",\n status: \"On Track\",\n },\n {\n label: \"Collections\",\n owner: \"J. Reyes\",\n progress: 63,\n risk: \"High\",\n status: \"At Risk\",\n },\n {\n label: \"Cost Optimization\",\n owner: \"K. Singh\",\n progress: 82,\n risk: \"Low\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 72 },\n { label: \"W2\", value: 74 },\n { label: \"W3\", value: 76 },\n { label: \"W4\", value: 77 },\n { label: \"W5\", value: 79 },\n { label: \"W6\", value: 80 },\n { label: \"W7\", value: 81 },\n { label: \"W8\", value: 83 },\n { label: \"W9\", value: 82 },\n { label: \"W10\", value: 84 },\n { label: \"W11\", value: 86 },\n { label: \"W12\", value: 88 },\n ],\n subtitle: \"Revenue, margin, and expense control overview\",\n summary: [\n { label: \"Revenue\", tone: \"success\", trend: \"+14.2% QoQ\", value: \"$2.48M\" },\n {\n label: \"Gross Margin\",\n tone: \"success\",\n trend: \"+2.1 pts\",\n value: \"61.8%\",\n },\n { label: \"Opex\", tone: \"success\", trend: \"-3.4% QoQ\", value: \"$0.93M\" },\n { label: \"Runway\", tone: \"info\", trend: \"Stable\", value: \"22 months\" },\n ],\n title: \"Quarterly Financial Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-financial\",\n template: `\n \n `,\n})\nexport class FinancialReportDocument {\n readonly theme = input();\n readonly data = input(sampleFinancialData);\n}\n", + "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleFinancialData: BaseReportData = {\n author: \"Finance Ops\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"Revenue accelerated after enterprise expansion campaign launch.\",\n \"Gross margin improved due to infrastructure cost renegotiation.\",\n \"Collections requires executive follow-up on two overdue accounts.\",\n ],\n period: \"Q1 2026\",\n rows: [\n {\n label: \"Enterprise Sales\",\n owner: \"A. Patel\",\n progress: 88,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"SMB Sales\",\n owner: \"L. Khan\",\n progress: 79,\n risk: \"Medium\",\n status: \"On Track\",\n },\n {\n label: \"Collections\",\n owner: \"J. Reyes\",\n progress: 63,\n risk: \"High\",\n status: \"At Risk\",\n },\n {\n label: \"Cost Optimization\",\n owner: \"K. Singh\",\n progress: 82,\n risk: \"Low\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 72 },\n { label: \"W2\", value: 74 },\n { label: \"W3\", value: 76 },\n { label: \"W4\", value: 77 },\n { label: \"W5\", value: 79 },\n { label: \"W6\", value: 80 },\n { label: \"W7\", value: 81 },\n { label: \"W8\", value: 83 },\n { label: \"W9\", value: 82 },\n { label: \"W10\", value: 84 },\n { label: \"W11\", value: 86 },\n { label: \"W12\", value: 88 },\n ],\n subtitle: \"Revenue, margin, and expense control overview\",\n summary: [\n { label: \"Revenue\", tone: \"success\", trend: \"+14.2% QoQ\", value: \"$2.48M\" },\n {\n label: \"Gross Margin\",\n tone: \"success\",\n trend: \"+2.1 pts\",\n value: \"61.8%\",\n },\n { label: \"Opex\", tone: \"success\", trend: \"-3.4% QoQ\", value: \"$0.93M\" },\n { label: \"Runway\", tone: \"info\", trend: \"Stable\", value: \"22 months\" },\n ],\n title: \"Quarterly Financial Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-financial\",\n template: `\n \n `,\n})\nexport class FinancialReportDocument {\n readonly theme = input();\n readonly data = input(sampleFinancialData);\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/report-financial/report-financial.ts" }, { "path": "registry/bases/forme/blocks/report-financial/report-layout.ts", - "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const graphHeight: Record = {\n area: 191,\n bar: 181,\n donut: 191,\n \"horizontal-bar\": 148,\n line: 191,\n pie: 191,\n };\n const deliveryOffset: Record = {\n area: 0,\n bar: 59,\n donut: -3,\n \"horizontal-bar\": -4,\n line: -30,\n pie: 0,\n };\n const sectionOffset: Record = {\n area: 0,\n bar: 32,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const titleOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n\n const styles = StyleSheet.create({\n col: {\n width: 225,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n alignItems: \"flex-start\",\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 75,\n padding: 8,\n width: 225,\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"column\",\n gap: 8,\n },\n metricsRow: {\n flexDirection: \"row\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n width: 499,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: {\n ...styles.graphShell,\n paddingBottom: graphVariant === \"horizontal-bar\" ? 56 : 12,\n },\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metricRows: [0, 2].map((startIndex) =>\n data.summary.slice(startIndex, startIndex + 2).map((metric) => ({\n badgeStyle: metric.trend\n ? {\n height: 16,\n width: metric.trend.endsWith(\"QoQ\")\n ? metric.trend.length * 6.5 + 10\n : metric.trend.length * 5 + 18,\n }\n : undefined,\n cardStyle: {\n ...styles.metricCard,\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n metric,\n }))\n ),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle: {\n position: \"relative\" as const,\n top: sectionOffset[graphVariant],\n },\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n titleStyle: {\n position: \"relative\" as const,\n top: titleOffset[graphVariant],\n },\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (row of l.metricRows; track $index) {\n \n @for (card of row; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n }\n \n \n \n \n\n \n \n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n \n \n\n \n \n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n}\n", + "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const graphHeight: Record = {\n area: 191,\n bar: 181,\n donut: 191,\n \"horizontal-bar\": 148,\n line: 191,\n pie: 191,\n };\n const deliveryOffset: Record = {\n area: 0,\n bar: 59,\n donut: -3,\n \"horizontal-bar\": -4,\n line: -30,\n pie: 0,\n };\n const sectionOffset: Record = {\n area: 0,\n bar: 32,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const titleOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n\n const styles = StyleSheet.create({\n col: {\n width: 225,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n alignItems: \"flex-start\",\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 75,\n padding: 8,\n width: 225,\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"column\",\n gap: 8,\n },\n metricsRow: {\n flexDirection: \"row\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n width: 499,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: {\n ...styles.graphShell,\n paddingBottom: graphVariant === \"horizontal-bar\" ? 56 : 12,\n },\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metricRows: [0, 2].map((startIndex) =>\n data.summary.slice(startIndex, startIndex + 2).map((metric) => ({\n badgeStyle: metric.trend\n ? {\n height: 16,\n width: metric.trend.endsWith(\"QoQ\")\n ? metric.trend.length * 6.5 + 10\n : metric.trend.length * 5 + 18,\n }\n : undefined,\n cardStyle: {\n ...styles.metricCard,\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n metric,\n }))\n ),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle: {\n position: \"relative\" as const,\n top: sectionOffset[graphVariant],\n },\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n titleStyle: {\n position: \"relative\" as const,\n top: titleOffset[graphVariant],\n },\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (row of l.metricRows; track $index) {\n \n @for (card of row; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n }\n \n \n \n \n\n \n \n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n \n \n\n \n \n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\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/report-financial/report-layout.ts" }, { "path": "registry/bases/forme/blocks/report-financial/report.types.ts", - "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: string[];\n}\n", + "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: 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/report-financial/report.types.ts" } diff --git a/apps/web/public/r/forme/report-marketing.json b/apps/web/public/r/forme/report-marketing.json index aa023f0..567537a 100644 --- a/apps/web/public/r/forme/report-marketing.json +++ b/apps/web/public/r/forme/report-marketing.json @@ -3,10 +3,6 @@ "name": "forme/report-marketing", "title": "Report Marketing", "description": "Report Marketing PDF block (forme)", - "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0" - ], "registryDependencies": [ "@angular-pdfcn/forme/utils", "@angular-pdfcn/forme/badge", @@ -23,19 +19,19 @@ "files": [ { "path": "registry/bases/forme/blocks/report-marketing/report-layout.ts", - "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const graphHeight: Record = {\n area: 191,\n bar: 181,\n donut: 191,\n \"horizontal-bar\": 148,\n line: 191,\n pie: 191,\n };\n const deliveryOffset: Record = {\n area: 0,\n bar: 59,\n donut: -3,\n \"horizontal-bar\": -4,\n line: -30,\n pie: 0,\n };\n const sectionOffset: Record = {\n area: 0,\n bar: 32,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const titleOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n\n const styles = StyleSheet.create({\n col: {\n width: 225,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n alignItems: \"flex-start\",\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 75,\n padding: 8,\n width: 225,\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"column\",\n gap: 8,\n },\n metricsRow: {\n flexDirection: \"row\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n width: 499,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: {\n ...styles.graphShell,\n paddingBottom: graphVariant === \"horizontal-bar\" ? 56 : 12,\n },\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metricRows: [0, 2].map((startIndex) =>\n data.summary.slice(startIndex, startIndex + 2).map((metric) => ({\n badgeStyle: metric.trend\n ? {\n height: 16,\n width: metric.trend.endsWith(\"QoQ\")\n ? metric.trend.length * 6.5 + 10\n : metric.trend.length * 5 + 18,\n }\n : undefined,\n cardStyle: {\n ...styles.metricCard,\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n metric,\n }))\n ),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle: {\n position: \"relative\" as const,\n top: sectionOffset[graphVariant],\n },\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n titleStyle: {\n position: \"relative\" as const,\n top: titleOffset[graphVariant],\n },\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (row of l.metricRows; track $index) {\n \n @for (card of row; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n }\n \n \n \n \n\n \n \n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n \n \n\n \n \n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n}\n", + "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const graphHeight: Record = {\n area: 191,\n bar: 181,\n donut: 191,\n \"horizontal-bar\": 148,\n line: 191,\n pie: 191,\n };\n const deliveryOffset: Record = {\n area: 0,\n bar: 59,\n donut: -3,\n \"horizontal-bar\": -4,\n line: -30,\n pie: 0,\n };\n const sectionOffset: Record = {\n area: 0,\n bar: 32,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const titleOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n\n const styles = StyleSheet.create({\n col: {\n width: 225,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n alignItems: \"flex-start\",\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 75,\n padding: 8,\n width: 225,\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"column\",\n gap: 8,\n },\n metricsRow: {\n flexDirection: \"row\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n width: 499,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: {\n ...styles.graphShell,\n paddingBottom: graphVariant === \"horizontal-bar\" ? 56 : 12,\n },\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metricRows: [0, 2].map((startIndex) =>\n data.summary.slice(startIndex, startIndex + 2).map((metric) => ({\n badgeStyle: metric.trend\n ? {\n height: 16,\n width: metric.trend.endsWith(\"QoQ\")\n ? metric.trend.length * 6.5 + 10\n : metric.trend.length * 5 + 18,\n }\n : undefined,\n cardStyle: {\n ...styles.metricCard,\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n metric,\n }))\n ),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle: {\n position: \"relative\" as const,\n top: sectionOffset[graphVariant],\n },\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n titleStyle: {\n position: \"relative\" as const,\n top: titleOffset[graphVariant],\n },\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (row of l.metricRows; track $index) {\n \n @for (card of row; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n }\n \n \n \n \n\n \n \n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n \n \n\n \n \n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\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/report-marketing/report-layout.ts" }, { "path": "registry/bases/forme/blocks/report-marketing/report-marketing.ts", - "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleMarketingData: BaseReportData = {\n author: \"Growth Team\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"Channel mix improved CAC while maintaining lead quality.\",\n \"Lifecycle email workflow has deliverability issues under investigation.\",\n \"Referral program is producing higher-intent pipeline with lower cost.\",\n ],\n period: \"Campaign Cycle 2026-02\",\n rows: [\n {\n label: \"SEO\",\n owner: \"H. Evans\",\n progress: 84,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Paid Search\",\n owner: \"K. Martin\",\n progress: 80,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Lifecycle Email\",\n owner: \"V. Lee\",\n progress: 64,\n risk: \"Medium\",\n status: \"At Risk\",\n },\n {\n label: \"Partner Referrals\",\n owner: \"J. Gomez\",\n progress: 75,\n risk: \"Medium\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 55 },\n { label: \"W2\", value: 57 },\n { label: \"W3\", value: 59 },\n { label: \"W4\", value: 60 },\n { label: \"W5\", value: 62 },\n { label: \"W6\", value: 63 },\n { label: \"W7\", value: 65 },\n { label: \"W8\", value: 67 },\n { label: \"W9\", value: 66 },\n { label: \"W10\", value: 68 },\n { label: \"W11\", value: 70 },\n { label: \"W12\", value: 72 },\n ],\n subtitle: \"Pipeline, conversion efficiency, and channel performance\",\n summary: [\n { label: \"MQLs\", tone: \"success\", trend: \"+22.1% cycle\", value: \"3,940\" },\n { label: \"CAC\", tone: \"success\", trend: \"-7.4%\", value: \"$118\" },\n { label: \"Win Rate\", tone: \"info\", trend: \"+1.1 pts\", value: \"28.6%\" },\n { label: \"Churn Risk\", tone: \"warning\", trend: \"+0.8 pts\", value: \"6.2%\" },\n ],\n title: \"Growth & Marketing Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-marketing\",\n template: `\n \n `,\n})\nexport class MarketingReportDocument {\n readonly theme = input();\n readonly data = input(sampleMarketingData);\n}\n", + "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleMarketingData: BaseReportData = {\n author: \"Growth Team\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"Channel mix improved CAC while maintaining lead quality.\",\n \"Lifecycle email workflow has deliverability issues under investigation.\",\n \"Referral program is producing higher-intent pipeline with lower cost.\",\n ],\n period: \"Campaign Cycle 2026-02\",\n rows: [\n {\n label: \"SEO\",\n owner: \"H. Evans\",\n progress: 84,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Paid Search\",\n owner: \"K. Martin\",\n progress: 80,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Lifecycle Email\",\n owner: \"V. Lee\",\n progress: 64,\n risk: \"Medium\",\n status: \"At Risk\",\n },\n {\n label: \"Partner Referrals\",\n owner: \"J. Gomez\",\n progress: 75,\n risk: \"Medium\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 55 },\n { label: \"W2\", value: 57 },\n { label: \"W3\", value: 59 },\n { label: \"W4\", value: 60 },\n { label: \"W5\", value: 62 },\n { label: \"W6\", value: 63 },\n { label: \"W7\", value: 65 },\n { label: \"W8\", value: 67 },\n { label: \"W9\", value: 66 },\n { label: \"W10\", value: 68 },\n { label: \"W11\", value: 70 },\n { label: \"W12\", value: 72 },\n ],\n subtitle: \"Pipeline, conversion efficiency, and channel performance\",\n summary: [\n { label: \"MQLs\", tone: \"success\", trend: \"+22.1% cycle\", value: \"3,940\" },\n { label: \"CAC\", tone: \"success\", trend: \"-7.4%\", value: \"$118\" },\n { label: \"Win Rate\", tone: \"info\", trend: \"+1.1 pts\", value: \"28.6%\" },\n { label: \"Churn Risk\", tone: \"warning\", trend: \"+0.8 pts\", value: \"6.2%\" },\n ],\n title: \"Growth & Marketing Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-marketing\",\n template: `\n \n `,\n})\nexport class MarketingReportDocument {\n readonly theme = input();\n readonly data = input(sampleMarketingData);\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/report-marketing/report-marketing.ts" }, { "path": "registry/bases/forme/blocks/report-marketing/report.types.ts", - "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: string[];\n}\n", + "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: 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/report-marketing/report.types.ts" } diff --git a/apps/web/public/r/forme/report-operations.json b/apps/web/public/r/forme/report-operations.json index 638145a..f5a3bd1 100644 --- a/apps/web/public/r/forme/report-operations.json +++ b/apps/web/public/r/forme/report-operations.json @@ -3,10 +3,6 @@ "name": "forme/report-operations", "title": "Report Operations", "description": "Report Operations PDF block (forme)", - "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0" - ], "registryDependencies": [ "@angular-pdfcn/forme/utils", "@angular-pdfcn/forme/badge", @@ -23,19 +19,19 @@ "files": [ { "path": "registry/bases/forme/blocks/report-operations/report-layout.ts", - "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const graphHeight: Record = {\n area: 191,\n bar: 181,\n donut: 191,\n \"horizontal-bar\": 148,\n line: 191,\n pie: 191,\n };\n const deliveryOffset: Record = {\n area: 0,\n bar: 59,\n donut: -3,\n \"horizontal-bar\": -4,\n line: -30,\n pie: 0,\n };\n const sectionOffset: Record = {\n area: 0,\n bar: 32,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const titleOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n\n const styles = StyleSheet.create({\n col: {\n width: 225,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n alignItems: \"flex-start\",\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 75,\n padding: 8,\n width: 225,\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"column\",\n gap: 8,\n },\n metricsRow: {\n flexDirection: \"row\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n width: 499,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: {\n ...styles.graphShell,\n paddingBottom: graphVariant === \"horizontal-bar\" ? 56 : 12,\n },\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metricRows: [0, 2].map((startIndex) =>\n data.summary.slice(startIndex, startIndex + 2).map((metric) => ({\n badgeStyle: metric.trend\n ? {\n height: 16,\n width: metric.trend.endsWith(\"QoQ\")\n ? metric.trend.length * 6.5 + 10\n : metric.trend.length * 5 + 18,\n }\n : undefined,\n cardStyle: {\n ...styles.metricCard,\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n metric,\n }))\n ),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle: {\n position: \"relative\" as const,\n top: sectionOffset[graphVariant],\n },\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n titleStyle: {\n position: \"relative\" as const,\n top: titleOffset[graphVariant],\n },\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (row of l.metricRows; track $index) {\n \n @for (card of row; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n }\n \n \n \n \n\n \n \n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n \n \n\n \n \n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n}\n", + "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const graphHeight: Record = {\n area: 191,\n bar: 181,\n donut: 191,\n \"horizontal-bar\": 148,\n line: 191,\n pie: 191,\n };\n const deliveryOffset: Record = {\n area: 0,\n bar: 59,\n donut: -3,\n \"horizontal-bar\": -4,\n line: -30,\n pie: 0,\n };\n const sectionOffset: Record = {\n area: 0,\n bar: 32,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const titleOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n\n const styles = StyleSheet.create({\n col: {\n width: 225,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n alignItems: \"flex-start\",\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 75,\n padding: 8,\n width: 225,\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"column\",\n gap: 8,\n },\n metricsRow: {\n flexDirection: \"row\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n width: 499,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: {\n ...styles.graphShell,\n paddingBottom: graphVariant === \"horizontal-bar\" ? 56 : 12,\n },\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metricRows: [0, 2].map((startIndex) =>\n data.summary.slice(startIndex, startIndex + 2).map((metric) => ({\n badgeStyle: metric.trend\n ? {\n height: 16,\n width: metric.trend.endsWith(\"QoQ\")\n ? metric.trend.length * 6.5 + 10\n : metric.trend.length * 5 + 18,\n }\n : undefined,\n cardStyle: {\n ...styles.metricCard,\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n metric,\n }))\n ),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle: {\n position: \"relative\" as const,\n top: sectionOffset[graphVariant],\n },\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n titleStyle: {\n position: \"relative\" as const,\n top: titleOffset[graphVariant],\n },\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (row of l.metricRows; track $index) {\n \n @for (card of row; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n }\n \n \n \n \n\n \n \n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n \n \n\n \n \n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\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/report-operations/report-layout.ts" }, { "path": "registry/bases/forme/blocks/report-operations/report-operations.ts", - "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleOperationsData: BaseReportData = {\n author: \"Delivery Office\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"SLA improved after shift rebalancing and incident triage changes.\",\n \"Backlog grew in week 4 due to release-related ticket surge.\",\n \"Incident queue remediation plan has executive sponsorship and budget.\",\n ],\n period: \"February 2026\",\n rows: [\n {\n label: \"L1 Support\",\n owner: \"N. Mehta\",\n progress: 91,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"L2 Support\",\n owner: \"D. Chen\",\n progress: 85,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Incident Queue\",\n owner: \"R. Walker\",\n progress: 66,\n risk: \"High\",\n status: \"At Risk\",\n },\n {\n label: \"Automation Rollout\",\n owner: \"M. Roy\",\n progress: 77,\n risk: \"Medium\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 69 },\n { label: \"W2\", value: 71 },\n { label: \"W3\", value: 73 },\n { label: \"W4\", value: 74 },\n { label: \"W5\", value: 75 },\n { label: \"W6\", value: 76 },\n { label: \"W7\", value: 78 },\n { label: \"W8\", value: 79 },\n { label: \"W9\", value: 78 },\n { label: \"W10\", value: 80 },\n { label: \"W11\", value: 81 },\n { label: \"W12\", value: 83 },\n ],\n subtitle: \"Delivery throughput, SLA adherence, and backlog visibility\",\n summary: [\n {\n label: \"Tickets Closed\",\n tone: \"success\",\n trend: \"+9.8% MoM\",\n value: \"1,284\",\n },\n {\n label: \"SLA Hit Rate\",\n tone: \"success\",\n trend: \"+1.4 pts\",\n value: \"96.1%\",\n },\n { label: \"Backlog\", tone: \"warning\", trend: \"+6.0%\", value: \"214\" },\n { label: \"Escalations\", tone: \"success\", trend: \"-18.5%\", value: \"17\" },\n ],\n title: \"Monthly Operations Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-operations\",\n template: `\n \n `,\n})\nexport class OperationsReportDocument {\n readonly theme = input();\n readonly data = input(sampleOperationsData);\n\n protected readonly graphColors = [\"#2563EB\"];\n protected readonly graphData = [\n { label: \"Incident\", value: 66 },\n { label: \"Automation\", value: 77 },\n { label: \"L2 Support\", value: 85 },\n { label: \"L1 Support\", value: 91 },\n ];\n}\n", + "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleOperationsData: BaseReportData = {\n author: \"Delivery Office\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"SLA improved after shift rebalancing and incident triage changes.\",\n \"Backlog grew in week 4 due to release-related ticket surge.\",\n \"Incident queue remediation plan has executive sponsorship and budget.\",\n ],\n period: \"February 2026\",\n rows: [\n {\n label: \"L1 Support\",\n owner: \"N. Mehta\",\n progress: 91,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"L2 Support\",\n owner: \"D. Chen\",\n progress: 85,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Incident Queue\",\n owner: \"R. Walker\",\n progress: 66,\n risk: \"High\",\n status: \"At Risk\",\n },\n {\n label: \"Automation Rollout\",\n owner: \"M. Roy\",\n progress: 77,\n risk: \"Medium\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 69 },\n { label: \"W2\", value: 71 },\n { label: \"W3\", value: 73 },\n { label: \"W4\", value: 74 },\n { label: \"W5\", value: 75 },\n { label: \"W6\", value: 76 },\n { label: \"W7\", value: 78 },\n { label: \"W8\", value: 79 },\n { label: \"W9\", value: 78 },\n { label: \"W10\", value: 80 },\n { label: \"W11\", value: 81 },\n { label: \"W12\", value: 83 },\n ],\n subtitle: \"Delivery throughput, SLA adherence, and backlog visibility\",\n summary: [\n {\n label: \"Tickets Closed\",\n tone: \"success\",\n trend: \"+9.8% MoM\",\n value: \"1,284\",\n },\n {\n label: \"SLA Hit Rate\",\n tone: \"success\",\n trend: \"+1.4 pts\",\n value: \"96.1%\",\n },\n { label: \"Backlog\", tone: \"warning\", trend: \"+6.0%\", value: \"214\" },\n { label: \"Escalations\", tone: \"success\", trend: \"-18.5%\", value: \"17\" },\n ],\n title: \"Monthly Operations Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-operations\",\n template: `\n \n `,\n})\nexport class OperationsReportDocument {\n readonly theme = input();\n readonly data = input(sampleOperationsData);\n\n protected readonly graphColors = [\"#2563EB\"];\n protected readonly graphData = [\n { label: \"Incident\", value: 66 },\n { label: \"Automation\", value: 77 },\n { label: \"L2 Support\", value: 85 },\n { label: \"L1 Support\", value: 91 },\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:block", "target": "components/pdf/blocks/report-operations/report-operations.ts" }, { "path": "registry/bases/forme/blocks/report-operations/report.types.ts", - "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: string[];\n}\n", + "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: 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/report-operations/report.types.ts" } diff --git a/apps/web/public/r/forme/report-security.json b/apps/web/public/r/forme/report-security.json index f35552d..c965422 100644 --- a/apps/web/public/r/forme/report-security.json +++ b/apps/web/public/r/forme/report-security.json @@ -3,10 +3,6 @@ "name": "forme/report-security", "title": "Report Security", "description": "Report Security PDF block (forme)", - "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0" - ], "registryDependencies": [ "@angular-pdfcn/forme/utils", "@angular-pdfcn/forme/badge", @@ -23,19 +19,19 @@ "files": [ { "path": "registry/bases/forme/blocks/report-security/report-layout.ts", - "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const graphHeight: Record = {\n area: 191,\n bar: 181,\n donut: 191,\n \"horizontal-bar\": 148,\n line: 191,\n pie: 191,\n };\n const deliveryOffset: Record = {\n area: 0,\n bar: 59,\n donut: -3,\n \"horizontal-bar\": -4,\n line: -30,\n pie: 0,\n };\n const sectionOffset: Record = {\n area: 0,\n bar: 32,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const titleOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n\n const styles = StyleSheet.create({\n col: {\n width: 225,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n alignItems: \"flex-start\",\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 75,\n padding: 8,\n width: 225,\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"column\",\n gap: 8,\n },\n metricsRow: {\n flexDirection: \"row\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n width: 499,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: {\n ...styles.graphShell,\n paddingBottom: graphVariant === \"horizontal-bar\" ? 56 : 12,\n },\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metricRows: [0, 2].map((startIndex) =>\n data.summary.slice(startIndex, startIndex + 2).map((metric) => ({\n badgeStyle: metric.trend\n ? {\n height: 16,\n width: metric.trend.endsWith(\"QoQ\")\n ? metric.trend.length * 6.5 + 10\n : metric.trend.length * 5 + 18,\n }\n : undefined,\n cardStyle: {\n ...styles.metricCard,\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n metric,\n }))\n ),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle: {\n position: \"relative\" as const,\n top: sectionOffset[graphVariant],\n },\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n titleStyle: {\n position: \"relative\" as const,\n top: titleOffset[graphVariant],\n },\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (row of l.metricRows; track $index) {\n \n @for (card of row; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n }\n \n \n \n \n\n \n \n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n \n \n\n \n \n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n}\n", + "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const graphHeight: Record = {\n area: 191,\n bar: 181,\n donut: 191,\n \"horizontal-bar\": 148,\n line: 191,\n pie: 191,\n };\n const deliveryOffset: Record = {\n area: 0,\n bar: 59,\n donut: -3,\n \"horizontal-bar\": -4,\n line: -30,\n pie: 0,\n };\n const sectionOffset: Record = {\n area: 0,\n bar: 32,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const titleOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n\n const styles = StyleSheet.create({\n col: {\n width: 225,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n alignItems: \"flex-start\",\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 75,\n padding: 8,\n width: 225,\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"column\",\n gap: 8,\n },\n metricsRow: {\n flexDirection: \"row\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n width: 499,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: {\n ...styles.graphShell,\n paddingBottom: graphVariant === \"horizontal-bar\" ? 56 : 12,\n },\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metricRows: [0, 2].map((startIndex) =>\n data.summary.slice(startIndex, startIndex + 2).map((metric) => ({\n badgeStyle: metric.trend\n ? {\n height: 16,\n width: metric.trend.endsWith(\"QoQ\")\n ? metric.trend.length * 6.5 + 10\n : metric.trend.length * 5 + 18,\n }\n : undefined,\n cardStyle: {\n ...styles.metricCard,\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n metric,\n }))\n ),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle: {\n position: \"relative\" as const,\n top: sectionOffset[graphVariant],\n },\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n titleStyle: {\n position: \"relative\" as const,\n top: titleOffset[graphVariant],\n },\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (row of l.metricRows; track $index) {\n \n @for (card of row; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n }\n \n \n \n \n\n \n \n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n \n \n\n \n \n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\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/report-security/report-layout.ts" }, { "path": "registry/bases/forme/blocks/report-security/report-security.ts", - "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleSecurityData: BaseReportData = {\n author: \"Security Engineering\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"Critical vulnerabilities reduced through mandatory patch windows.\",\n \"Secrets rotation remains the highest-risk stream and needs additional staffing.\",\n \"External penetration test scheduled for next sprint to validate fixes.\",\n ],\n period: \"Sprint 05, 2026\",\n rows: [\n {\n label: \"Identity Hardening\",\n owner: \"E. Brown\",\n progress: 87,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Secrets Rotation\",\n owner: \"P. Nair\",\n progress: 58,\n risk: \"High\",\n status: \"At Risk\",\n },\n {\n label: \"Dependency Scanning\",\n owner: \"I. Shah\",\n progress: 81,\n risk: \"Medium\",\n status: \"On Track\",\n },\n {\n label: \"WAF Policy\",\n owner: \"S. Reed\",\n progress: 76,\n risk: \"Low\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 61 },\n { label: \"W2\", value: 63 },\n { label: \"W3\", value: 64 },\n { label: \"W4\", value: 66 },\n { label: \"W5\", value: 67 },\n { label: \"W6\", value: 68 },\n { label: \"W7\", value: 69 },\n { label: \"W8\", value: 71 },\n { label: \"W9\", value: 72 },\n { label: \"W10\", value: 74 },\n { label: \"W11\", value: 76 },\n { label: \"W12\", value: 78 },\n ],\n subtitle: \"Vulnerability trends, control maturity, and remediation health\",\n summary: [\n {\n label: \"Critical Vulns\",\n tone: \"success\",\n trend: \"-3 from last sprint\",\n value: \"2\",\n },\n { label: \"Patch SLA\", tone: \"success\", trend: \"+5.3 pts\", value: \"92.0%\" },\n { label: \"Open Findings\", tone: \"warning\", trend: \"+4\", value: \"41\" },\n { label: \"Control Score\", tone: \"info\", trend: \"+2 pts\", value: \"84/100\" },\n ],\n title: \"Security Posture Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-security\",\n template: `\n \n `,\n})\nexport class SecurityReportDocument {\n readonly theme = input();\n readonly data = input(sampleSecurityData);\n\n protected readonly graphColors = [\"#DC2626\", \"#F59E0B\", \"#16A34A\", \"#0EA5E9\"];\n protected readonly graphData = [\n { label: \"High Risk\", value: 14 },\n { label: \"Medium Risk\", value: 17 },\n { label: \"Low Risk\", value: 8 },\n { label: \"Info\", value: 4 },\n ];\n}\n", + "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleSecurityData: BaseReportData = {\n author: \"Security Engineering\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"Critical vulnerabilities reduced through mandatory patch windows.\",\n \"Secrets rotation remains the highest-risk stream and needs additional staffing.\",\n \"External penetration test scheduled for next sprint to validate fixes.\",\n ],\n period: \"Sprint 05, 2026\",\n rows: [\n {\n label: \"Identity Hardening\",\n owner: \"E. Brown\",\n progress: 87,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Secrets Rotation\",\n owner: \"P. Nair\",\n progress: 58,\n risk: \"High\",\n status: \"At Risk\",\n },\n {\n label: \"Dependency Scanning\",\n owner: \"I. Shah\",\n progress: 81,\n risk: \"Medium\",\n status: \"On Track\",\n },\n {\n label: \"WAF Policy\",\n owner: \"S. Reed\",\n progress: 76,\n risk: \"Low\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 61 },\n { label: \"W2\", value: 63 },\n { label: \"W3\", value: 64 },\n { label: \"W4\", value: 66 },\n { label: \"W5\", value: 67 },\n { label: \"W6\", value: 68 },\n { label: \"W7\", value: 69 },\n { label: \"W8\", value: 71 },\n { label: \"W9\", value: 72 },\n { label: \"W10\", value: 74 },\n { label: \"W11\", value: 76 },\n { label: \"W12\", value: 78 },\n ],\n subtitle: \"Vulnerability trends, control maturity, and remediation health\",\n summary: [\n {\n label: \"Critical Vulns\",\n tone: \"success\",\n trend: \"-3 from last sprint\",\n value: \"2\",\n },\n { label: \"Patch SLA\", tone: \"success\", trend: \"+5.3 pts\", value: \"92.0%\" },\n { label: \"Open Findings\", tone: \"warning\", trend: \"+4\", value: \"41\" },\n { label: \"Control Score\", tone: \"info\", trend: \"+2 pts\", value: \"84/100\" },\n ],\n title: \"Security Posture Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-security\",\n template: `\n \n `,\n})\nexport class SecurityReportDocument {\n readonly theme = input();\n readonly data = input(sampleSecurityData);\n\n protected readonly graphColors = [\"#DC2626\", \"#F59E0B\", \"#16A34A\", \"#0EA5E9\"];\n protected readonly graphData = [\n { label: \"High Risk\", value: 14 },\n { label: \"Medium Risk\", value: 17 },\n { label: \"Low Risk\", value: 8 },\n { label: \"Info\", value: 4 },\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:block", "target": "components/pdf/blocks/report-security/report-security.ts" }, { "path": "registry/bases/forme/blocks/report-security/report.types.ts", - "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: string[];\n}\n", + "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: 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/report-security/report.types.ts" } diff --git a/apps/web/public/r/forme/section.json b/apps/web/public/r/forme/section.json index 1072284..7463c6f 100644 --- a/apps/web/public/r/forme/section.json +++ b/apps/web/public/r/forme/section.json @@ -3,17 +3,13 @@ "name": "forme/section", "title": "Section", "description": "Section 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/section/section.ts", - "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport {\n injectPdfcnTheme,\n mergePdfStyles,\n} from \"@/components/pdf/theme-provider\";\nimport {\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 SectionSpacing = \"none\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type SectionPadding = \"none\" | \"sm\" | \"md\" | \"lg\";\nexport type SectionVariant = \"default\" | \"callout\" | \"highlight\" | \"card\";\n\n/**\n * Layout container with spacing, padding, and visual style variants.\n * Props - `spacing` | `padding` | `background` | `border` | `variant` | `accentColor` | `noWrap` | `children` | `style`\n * @see {@link SectionProps}\n */\nexport interface SectionProps extends PDFComponentProps {\n /**\n * @default 'md'\n */\n spacing?: SectionSpacing;\n padding?: SectionPadding;\n background?: string;\n /**\n * @default false\n */\n border?: boolean;\n /**\n * @default 'default'\n */\n variant?: SectionVariant;\n accentColor?: string;\n /**\n * @default false\n */\n noWrap?: boolean;\n}\n\nconst createSectionStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius } = t.primitives;\n return StyleSheet.create({\n base: { flexDirection: \"column\" },\n border: {\n borderColor: t.colors.border,\n borderRadius: borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: spacing[0.5],\n },\n callout: {\n borderLeftColor: t.colors.primary,\n borderLeftStyle: \"solid\",\n borderLeftWidth: spacing[1],\n paddingLeft: spacing[4],\n paddingVertical: spacing[2],\n },\n card: {\n borderColor: t.colors.border,\n borderRadius: borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: spacing[0.5],\n padding: spacing[4],\n },\n highlight: {\n backgroundColor: t.colors.muted,\n borderLeftColor: t.colors.primary,\n borderLeftStyle: \"solid\",\n borderLeftWidth: spacing[1],\n padding: spacing[4],\n },\n paddingLg: { padding: spacing[6] },\n paddingMd: { padding: spacing[4] },\n paddingNone: { padding: spacing[0] },\n paddingSm: { padding: spacing[3] },\n spacingLg: { marginVertical: spacing[8] },\n spacingMd: { marginVertical: t.spacing.sectionGap },\n spacingNone: { marginVertical: spacing[0] },\n spacingSm: { marginVertical: spacing[4] },\n spacingXl: { marginVertical: spacing[12] },\n });\n};\n\nconst sectionStyle = (\n theme: PdfcnTheme,\n {\n spacing = \"md\",\n padding,\n background,\n border,\n variant = \"default\",\n accentColor,\n style,\n }: SectionProps\n) => {\n const styles = createSectionStyles(theme);\n const spacingMap = {\n lg: styles.spacingLg,\n md: styles.spacingMd,\n none: styles.spacingNone,\n sm: styles.spacingSm,\n xl: styles.spacingXl,\n };\n const paddingMap = {\n lg: styles.paddingLg,\n md: styles.paddingMd,\n none: styles.paddingNone,\n sm: styles.paddingSm,\n };\n const variantMap: Record = {\n callout: styles.callout,\n card: styles.card,\n default: null,\n highlight: styles.highlight,\n };\n const styleArray: Style[] = [styles.base, spacingMap[spacing]];\n const variantStyle = variantMap[variant];\n if (variantStyle) {\n styleArray.push(variantStyle);\n }\n if (accentColor && (variant === \"callout\" || variant === \"highlight\")) {\n styleArray.push({\n borderLeftColor: resolveColor(accentColor, theme.colors),\n });\n }\n if (padding && padding in paddingMap) {\n styleArray.push(paddingMap[padding]);\n }\n if (border && variant === \"default\") {\n styleArray.push(styles.border);\n }\n if (background) {\n styleArray.push({\n backgroundColor: resolveColor(background, theme.colors),\n });\n }\n if (style) {\n styleArray.push(...[style].flat());\n }\n return mergePdfStyles(styleArray);\n};\n\n@Component({\n imports: [FormeView],\n selector: \"pdf-section\",\n template: ``,\n})\nexport class PdfSection {\n readonly spacing = input(\"md\");\n readonly padding = input();\n readonly background = input();\n readonly border = input(false, { transform: booleanAttribute });\n readonly variant = input(\"default\");\n readonly accentColor = input();\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly sectionStyle = computed(() =>\n sectionStyle(this.theme(), {\n accentColor: this.accentColor(),\n background: this.background(),\n border: this.border(),\n padding: this.padding(),\n spacing: this.spacing(),\n style: this.style(),\n variant: this.variant(),\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 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 SectionSpacing = \"none\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type SectionPadding = \"none\" | \"sm\" | \"md\" | \"lg\";\nexport type SectionVariant = \"default\" | \"callout\" | \"highlight\" | \"card\";\n\n/**\n * Layout container with spacing, padding, and visual style variants.\n * Props - `spacing` | `padding` | `background` | `border` | `variant` | `accentColor` | `noWrap` | `children` | `style`\n * @see {@link SectionProps}\n */\nexport interface SectionProps extends PDFComponentProps {\n /**\n * @default 'md'\n */\n spacing?: SectionSpacing;\n padding?: SectionPadding;\n background?: string;\n /**\n * @default false\n */\n border?: boolean;\n /**\n * @default 'default'\n */\n variant?: SectionVariant;\n accentColor?: string;\n /**\n * @default false\n */\n noWrap?: boolean;\n}\n\nconst createSectionStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius } = t.primitives;\n return StyleSheet.create({\n base: { flexDirection: \"column\" },\n border: {\n borderColor: t.colors.border,\n borderRadius: borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: spacing[0.5],\n },\n callout: {\n borderLeftColor: t.colors.primary,\n borderLeftStyle: \"solid\",\n borderLeftWidth: spacing[1],\n paddingLeft: spacing[4],\n paddingVertical: spacing[2],\n },\n card: {\n borderColor: t.colors.border,\n borderRadius: borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: spacing[0.5],\n padding: spacing[4],\n },\n highlight: {\n backgroundColor: t.colors.muted,\n borderLeftColor: t.colors.primary,\n borderLeftStyle: \"solid\",\n borderLeftWidth: spacing[1],\n padding: spacing[4],\n },\n paddingLg: { padding: spacing[6] },\n paddingMd: { padding: spacing[4] },\n paddingNone: { padding: spacing[0] },\n paddingSm: { padding: spacing[3] },\n spacingLg: { marginVertical: spacing[8] },\n spacingMd: { marginVertical: t.spacing.sectionGap },\n spacingNone: { marginVertical: spacing[0] },\n spacingSm: { marginVertical: spacing[4] },\n spacingXl: { marginVertical: spacing[12] },\n });\n};\n\nconst sectionStyle = (\n theme: PdfcnTheme,\n {\n spacing = \"md\",\n padding,\n background,\n border,\n variant = \"default\",\n accentColor,\n style,\n }: SectionProps\n) => {\n const styles = createSectionStyles(theme);\n const spacingMap = {\n lg: styles.spacingLg,\n md: styles.spacingMd,\n none: styles.spacingNone,\n sm: styles.spacingSm,\n xl: styles.spacingXl,\n };\n const paddingMap = {\n lg: styles.paddingLg,\n md: styles.paddingMd,\n none: styles.paddingNone,\n sm: styles.paddingSm,\n };\n const variantMap: Record = {\n callout: styles.callout,\n card: styles.card,\n default: null,\n highlight: styles.highlight,\n };\n const styleArray: Style[] = [styles.base, spacingMap[spacing]];\n const variantStyle = variantMap[variant];\n if (variantStyle) {\n styleArray.push(variantStyle);\n }\n if (accentColor && (variant === \"callout\" || variant === \"highlight\")) {\n styleArray.push({\n borderLeftColor: resolveColor(accentColor, theme.colors),\n });\n }\n if (padding && padding in paddingMap) {\n styleArray.push(paddingMap[padding]);\n }\n if (border && variant === \"default\") {\n styleArray.push(styles.border);\n }\n if (background) {\n styleArray.push({\n backgroundColor: resolveColor(background, theme.colors),\n });\n }\n if (style) {\n styleArray.push(...[style].flat());\n }\n return mergePdfStyles(styleArray);\n};\n\n@Component({\n imports: [FormeView],\n selector: \"pdf-section\",\n template: ``,\n})\nexport class PdfSection {\n readonly spacing = input(\"md\");\n readonly padding = input();\n readonly background = input();\n readonly border = input(false, { transform: booleanAttribute });\n readonly variant = input(\"default\");\n readonly accentColor = input();\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly sectionStyle = computed(() =>\n sectionStyle(this.theme(), {\n accentColor: this.accentColor(),\n background: this.background(),\n border: this.border(),\n padding: this.padding(),\n spacing: this.spacing(),\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/section/section.ts" } diff --git a/apps/web/public/r/forme/shipping-label.json b/apps/web/public/r/forme/shipping-label.json index c4f1ca3..92fa2bf 100644 --- a/apps/web/public/r/forme/shipping-label.json +++ b/apps/web/public/r/forme/shipping-label.json @@ -4,8 +4,6 @@ "title": "Shipping Label", "description": "Shipping Label PDF block (forme)", "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0", "qrcode@^1.5.4" ], "devDependencies": [ @@ -19,13 +17,13 @@ "files": [ { "path": "registry/bases/forme/blocks/shipping-label/shipping-label.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\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 FormeImage,\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 {\n ShippingLabelAddress,\n ShippingLabelData,\n} from \"./shipping-label.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: ShippingLabelData = {\n carrier: \"UPS\",\n dimensions: '12\" x 8\" x 6\"',\n from: {\n address: \"456 Industrial Blvd\",\n city: \"Los Angeles\",\n country: \"USA\",\n name: \"ACME Corporation\",\n state: \"CA\",\n zip: \"90001\",\n },\n handlingLabels: [\"FRAGILE\", \"THIS SIDE UP\"],\n packageCount: 1,\n postage: \"$18.40\",\n serviceLevel: \"Ground\",\n to: {\n address: \"123 Main Street, Apt 4B\",\n city: \"New York\",\n country: \"USA\",\n name: \"John Doe\",\n phone: \"(503) 555-0142\",\n state: \"NY\",\n zip: \"10001\",\n },\n trackingNumber: \"TRACK123456789US\",\n weight: \"2.5 kg\",\n};\n\n// Standard 4\" x 6\" shipping label, expressed in PDF points (72 dpi)\nconst LABEL_SIZE = { height: 432, width: 288 };\n\n// Quiet zone kept clear of the printed label frame, plus the frame itself\nconst LABEL_MARGIN = 8;\nconst LABEL_BORDER = 2;\nconst LABEL_PADDING = 10;\n\n// Forme scales an image with the Image element's own width/height (style\n// dimensions only size the box), so the barcode is measured in points from\n// the label's content box instead of a percentage width.\nconst BARCODE_WIDTH =\n LABEL_SIZE.width - 2 * (LABEL_MARGIN + LABEL_BORDER + LABEL_PADDING);\nconst BARCODE_HEIGHT = 72;\n\nconst formatCityLine = (party: ShippingLabelAddress) => {\n const cityStateZip = `${party.city}, ${party.state} ${party.zip}`;\n return party.country ? `${cityStateZip}, ${party.country}` : cityStateZip;\n};\n\nconst shippingLabelLayout = (theme: PdfcnTheme, data: ShippingLabelData) => {\n const accent = resolveColor(\n data.accentColor ?? theme.colors.primary,\n theme.colors\n );\n\n const detailRows = [\n ...(data.weight ? [{ key: \"Weight\", value: data.weight }] : []),\n ...(data.dimensions ? [{ key: \"Dimensions\", value: data.dimensions }] : []),\n ...(typeof data.packageCount === \"number\"\n ? [{ key: \"Packages\", value: `${data.packageCount}` }]\n : []),\n { key: \"Postage\", value: data.postage ?? \"PAID\" },\n ];\n\n const styles = StyleSheet.create({\n addresses: { flex: 1, flexDirection: \"row\" },\n badgesRow: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 6,\n marginTop: 8,\n },\n barcodeArea: { alignItems: \"center\", marginTop: 10 },\n carrierName: { fontSize: 16, fontWeight: \"bold\" },\n fromColumn: { flex: 1, paddingLeft: 12 },\n handlingTag: {\n alignItems: \"center\",\n backgroundColor: theme.colors.foreground,\n justifyContent: \"center\",\n paddingHorizontal: 8,\n paddingVertical: 4,\n },\n handlingTagText: {\n color: theme.colors.background,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1,\n textTransform: \"uppercase\",\n },\n headerRow: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n },\n label: {\n borderColor: theme.colors.foreground,\n borderWidth: LABEL_BORDER,\n flex: 1,\n padding: LABEL_PADDING,\n },\n page: {\n backgroundColor: theme.colors.background,\n flex: 1,\n flexDirection: \"column\",\n height: LABEL_SIZE.height - LABEL_MARGIN * 2,\n overflow: \"hidden\",\n },\n rule: {\n backgroundColor: theme.colors.foreground,\n height: 2,\n marginVertical: 6,\n },\n sectionLabel: {\n color: accent,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1,\n marginBottom: 4,\n textTransform: \"uppercase\",\n },\n serviceRight: { alignItems: \"flex-end\" },\n shipToColumn: {\n borderRightColor: theme.colors.foreground,\n borderRightWidth: 2,\n flex: 1.4,\n paddingRight: 12,\n },\n table: {\n borderColor: theme.colors.foreground,\n borderWidth: 2,\n },\n tableKey: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 0.5,\n textTransform: \"uppercase\",\n width: 84,\n },\n tableRow: {\n alignItems: \"center\",\n borderBottomColor: theme.colors.border,\n borderBottomWidth: 1,\n flexDirection: \"row\",\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n tableRowLast: {\n alignItems: \"center\",\n flexDirection: \"row\",\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n tableValue: { flex: 1 },\n trackingText: {\n fontWeight: \"bold\",\n letterSpacing: 2,\n marginTop: 6,\n textTransform: \"uppercase\",\n },\n });\n\n return { detailRows, styles };\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormeImage,\n FormePage,\n FormeView,\n NgTemplateOutlet,\n PdfQRCode,\n PdfText,\n ],\n selector: \"pdf-shipping-label-content\",\n template: `\n @let data = this.data();\n @let styles = this.layout().styles;\n @let detailRows = this.layout().detailRows;\n \n \n \n {{\n party.name\n }}\n {{ party.address }}\n {{ formatCityLine(party) }}\n @if (party.phone) {\n {{\n party.phone\n }}\n }\n \n \n \n \n \n \n \n {{\n data.carrier\n }}\n \n {{\n data.serviceLevel\n }}\n \n \n\n \n\n \n \n Ship To\n \n \n \n From\n \n \n \n\n \n\n \n @for (row of detailRows; track row.key; let index = $index) {\n \n {{\n row.key\n }}\n {{\n row.value\n }}\n \n }\n \n\n @if (data.handlingLabels && data.handlingLabels.length > 0) {\n \n @for (label of data.handlingLabels; track $index) {\n \n {{\n label\n }}\n \n }\n \n }\n\n \n @if (data.barcodeUrl) {\n \n } @else {\n \n }\n {{ data.trackingNumber }}\n \n \n \n \n \n `,\n})\nexport class ShippingLabelContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly LABEL_SIZE = LABEL_SIZE;\n protected readonly LABEL_MARGIN = LABEL_MARGIN;\n protected readonly BARCODE_WIDTH = BARCODE_WIDTH;\n protected readonly BARCODE_HEIGHT = BARCODE_HEIGHT;\n protected readonly formatCityLine = formatCityLine;\n\n protected readonly layout = computed(() =>\n shippingLabelLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ShippingLabelContent],\n selector: \"pdf-shipping-label\",\n template: `\n \n \n \n `,\n})\nexport class ShippingLabelDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\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 FormeImage,\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 {\n ShippingLabelAddress,\n ShippingLabelData,\n} from \"./shipping-label.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: ShippingLabelData = {\n carrier: \"UPS\",\n dimensions: '12\" x 8\" x 6\"',\n from: {\n address: \"456 Industrial Blvd\",\n city: \"Los Angeles\",\n country: \"USA\",\n name: \"ACME Corporation\",\n state: \"CA\",\n zip: \"90001\",\n },\n handlingLabels: [\"FRAGILE\", \"THIS SIDE UP\"],\n packageCount: 1,\n postage: \"$18.40\",\n serviceLevel: \"Ground\",\n to: {\n address: \"123 Main Street, Apt 4B\",\n city: \"New York\",\n country: \"USA\",\n name: \"John Doe\",\n phone: \"(503) 555-0142\",\n state: \"NY\",\n zip: \"10001\",\n },\n trackingNumber: \"TRACK123456789US\",\n weight: \"2.5 kg\",\n};\n\n// Standard 4\" x 6\" shipping label, expressed in PDF points (72 dpi)\nconst LABEL_SIZE = { height: 432, width: 288 };\n\n// Quiet zone kept clear of the printed label frame, plus the frame itself\nconst LABEL_MARGIN = 8;\nconst LABEL_BORDER = 2;\nconst LABEL_PADDING = 10;\n\n// Forme scales an image with the Image element's own width/height (style\n// dimensions only size the box), so the barcode is measured in points from\n// the label's content box instead of a percentage width.\nconst BARCODE_WIDTH =\n LABEL_SIZE.width - 2 * (LABEL_MARGIN + LABEL_BORDER + LABEL_PADDING);\nconst BARCODE_HEIGHT = 72;\n\nconst formatCityLine = (party: ShippingLabelAddress) => {\n const cityStateZip = `${party.city}, ${party.state} ${party.zip}`;\n return party.country ? `${cityStateZip}, ${party.country}` : cityStateZip;\n};\n\nconst shippingLabelLayout = (theme: PdfcnTheme, data: ShippingLabelData) => {\n const accent = resolveColor(\n data.accentColor ?? theme.colors.primary,\n theme.colors\n );\n\n const detailRows = [\n ...(data.weight ? [{ key: \"Weight\", value: data.weight }] : []),\n ...(data.dimensions ? [{ key: \"Dimensions\", value: data.dimensions }] : []),\n ...(typeof data.packageCount === \"number\"\n ? [{ key: \"Packages\", value: `${data.packageCount}` }]\n : []),\n { key: \"Postage\", value: data.postage ?? \"PAID\" },\n ];\n\n const styles = StyleSheet.create({\n addresses: { flex: 1, flexDirection: \"row\" },\n badgesRow: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 6,\n marginTop: 8,\n },\n barcodeArea: { alignItems: \"center\", marginTop: 10 },\n carrierName: { fontSize: 16, fontWeight: \"bold\" },\n fromColumn: { flex: 1, paddingLeft: 12 },\n handlingTag: {\n alignItems: \"center\",\n backgroundColor: theme.colors.foreground,\n justifyContent: \"center\",\n paddingHorizontal: 8,\n paddingVertical: 4,\n },\n handlingTagText: {\n color: theme.colors.background,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1,\n textTransform: \"uppercase\",\n },\n headerRow: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n },\n label: {\n borderColor: theme.colors.foreground,\n borderWidth: LABEL_BORDER,\n flex: 1,\n padding: LABEL_PADDING,\n },\n page: {\n backgroundColor: theme.colors.background,\n flex: 1,\n flexDirection: \"column\",\n height: LABEL_SIZE.height - LABEL_MARGIN * 2,\n overflow: \"hidden\",\n },\n rule: {\n backgroundColor: theme.colors.foreground,\n height: 2,\n marginVertical: 6,\n },\n sectionLabel: {\n color: accent,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1,\n marginBottom: 4,\n textTransform: \"uppercase\",\n },\n serviceRight: { alignItems: \"flex-end\" },\n shipToColumn: {\n borderRightColor: theme.colors.foreground,\n borderRightWidth: 2,\n flex: 1.4,\n paddingRight: 12,\n },\n table: {\n borderColor: theme.colors.foreground,\n borderWidth: 2,\n },\n tableKey: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 0.5,\n textTransform: \"uppercase\",\n width: 84,\n },\n tableRow: {\n alignItems: \"center\",\n borderBottomColor: theme.colors.border,\n borderBottomWidth: 1,\n flexDirection: \"row\",\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n tableRowLast: {\n alignItems: \"center\",\n flexDirection: \"row\",\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n tableValue: { flex: 1 },\n trackingText: {\n fontWeight: \"bold\",\n letterSpacing: 2,\n marginTop: 6,\n textTransform: \"uppercase\",\n },\n });\n\n return { detailRows, styles };\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormeImage,\n FormePage,\n FormeView,\n NgTemplateOutlet,\n PdfQRCode,\n PdfText,\n ],\n selector: \"pdf-shipping-label-content\",\n template: `\n @let data = this.data();\n @let styles = this.layout().styles;\n @let detailRows = this.layout().detailRows;\n \n \n \n {{\n party.name\n }}\n {{ party.address }}\n {{ formatCityLine(party) }}\n @if (party.phone) {\n {{\n party.phone\n }}\n }\n \n \n \n \n \n \n \n {{\n data.carrier\n }}\n \n {{\n data.serviceLevel\n }}\n \n \n\n \n\n \n \n Ship To\n \n \n \n From\n \n \n \n\n \n\n \n @for (row of detailRows; track row.key; let index = $index) {\n \n {{\n row.key\n }}\n {{\n row.value\n }}\n \n }\n \n\n @if (data.handlingLabels && data.handlingLabels.length > 0) {\n \n @for (label of data.handlingLabels; track $index) {\n \n {{\n label\n }}\n \n }\n \n }\n\n \n @if (data.barcodeUrl) {\n \n } @else {\n \n }\n {{ data.trackingNumber }}\n \n \n \n \n \n `,\n})\nexport class ShippingLabelContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly LABEL_SIZE = LABEL_SIZE;\n protected readonly LABEL_MARGIN = LABEL_MARGIN;\n protected readonly BARCODE_WIDTH = BARCODE_WIDTH;\n protected readonly BARCODE_HEIGHT = BARCODE_HEIGHT;\n protected readonly formatCityLine = formatCityLine;\n\n protected readonly layout = computed(() =>\n shippingLabelLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ShippingLabelContent],\n selector: \"pdf-shipping-label\",\n template: `\n \n \n \n `,\n})\nexport class ShippingLabelDocument {\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/shipping-label/shipping-label.ts" }, { "path": "registry/bases/forme/blocks/shipping-label/shipping-label.types.ts", - "content": "export interface ShippingLabelAddress {\n name: string;\n address: string;\n city: string;\n state: string;\n zip: string;\n country?: string;\n}\n\nexport interface ShippingLabelDestination extends ShippingLabelAddress {\n phone?: string;\n}\n\nexport interface ShippingLabelData {\n from: ShippingLabelAddress;\n to: ShippingLabelDestination;\n carrier: string;\n serviceLevel: string;\n trackingNumber: string;\n barcodeUrl?: string;\n weight?: string;\n dimensions?: string;\n packageCount?: number;\n handlingLabels?: string[];\n postage?: string;\n accentColor?: string;\n}\n", + "content": "export interface ShippingLabelAddress {\n name: string;\n address: string;\n city: string;\n state: string;\n zip: string;\n country?: string;\n}\n\nexport interface ShippingLabelDestination extends ShippingLabelAddress {\n phone?: string;\n}\n\nexport interface ShippingLabelData {\n from: ShippingLabelAddress;\n to: ShippingLabelDestination;\n carrier: string;\n serviceLevel: string;\n trackingNumber: string;\n barcodeUrl?: string;\n weight?: string;\n dimensions?: string;\n packageCount?: number;\n handlingLabels?: string[];\n postage?: string;\n accentColor?: 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/shipping-label/shipping-label.types.ts" } diff --git a/apps/web/public/r/forme/signature.json b/apps/web/public/r/forme/signature.json index fc4f8b3..bc7d053 100644 --- a/apps/web/public/r/forme/signature.json +++ b/apps/web/public/r/forme/signature.json @@ -3,17 +3,13 @@ "name": "forme/signature", "title": "Signature", "description": "Signature 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/signature/signature.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\nimport {\n injectPdfcnTheme,\n mergePdfStyles,\n} 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 { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type SignatureVariant = \"single\" | \"double\" | \"inline\";\n\n/**\n * Signature signer properties.\n * Props - `label` | `name` | `title` | `date`\n * @see {@link SignatureSigner}\n */\nexport interface SignatureSigner {\n label?: string;\n name?: string;\n title?: string;\n date?: string;\n}\n\n/**\n * Signature block properties.\n * Props - `variant` | `label` | `name` | `title` | `date` | `signers` | `style`\n * @see {@link PdfSignatureBlockProps}\n */\nexport interface PdfSignatureBlockProps {\n /**\n * Layout variant: [single, double, inline]\n * @default 'single'\n */\n variant?: SignatureVariant;\n label?: string;\n name?: string;\n title?: string;\n date?: string;\n signers?: [SignatureSigner, SignatureSigner];\n style?: Style;\n}\n\nconst createSignatureStyles = (t: PdfcnTheme) => {\n const { spacing, fontWeights, typography } = t.primitives;\n return StyleSheet.create({\n block: { flex: 1, minWidth: 140 },\n container: {\n marginBottom: t.spacing.componentGap,\n marginTop: t.spacing.sectionGap,\n },\n dateText: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n marginTop: 1,\n },\n doubleRow: {\n flexDirection: \"row\",\n gap: spacing[8],\n justifyContent: \"space-between\",\n },\n inlineLabel: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n },\n inlineLine: {\n borderBottomColor: t.colors.foreground,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n height: spacing[5],\n minWidth: 120,\n paddingHorizontal: spacing[2],\n },\n inlineName: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n },\n inlineRow: {\n alignItems: \"center\",\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: spacing[3],\n },\n label: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n marginBottom: spacing[1],\n },\n line: {\n borderBottomColor: t.colors.foreground,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n marginBottom: spacing[1],\n minHeight: spacing[6],\n },\n name: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n },\n titleText: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n },\n });\n};\n\nconst signatureLayout = (\n theme: PdfcnTheme,\n {\n variant = \"single\",\n label = \"Signature\",\n name,\n title,\n date,\n signers,\n style,\n }: PdfSignatureBlockProps\n) => {\n const styles = createSignatureStyles(theme);\n const containerStyles: Style[] = [styles.container];\n if (style) {\n containerStyles.push(style);\n }\n const container = mergePdfStyles(containerStyles);\n\n if (variant === \"inline\") {\n return { container, inlineLabel: `${label}:`, signers: [], styles };\n }\n\n if (variant === \"double\") {\n const [first, second] = signers ?? [\n { date: \"\", label: \"Authorized by\", name: \"\", title: \"\" },\n { date: \"\", label: \"Approved by\", name: \"\", title: \"\" },\n ];\n return { container, signers: [first, second], styles };\n }\n\n return { container, signers: [{ date, label, name, title }], styles };\n};\n\n@Component({\n imports: [FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-signature-block\",\n template: `\n @let l = layout();\n @let s = l.styles;\n \n @switch (variant()) {\n @case (\"inline\") {\n \n {{ l.inlineLabel }}\n \n @if (name()) {\n {{ name() }}\n }\n \n }\n @case (\"double\") {\n \n @for (signer of l.signers; track $index) {\n \n }\n \n }\n @default {\n \n }\n }\n \n \n \n @if (signer.label) {\n {{ signer.label }}\n }\n \n @if (signer.name) {\n {{ signer.name }}\n }\n @if (signer.title) {\n {{ signer.title }}\n }\n @if (signer.date) {\n {{ signer.date }}\n }\n \n \n `,\n})\nexport class PdfSignatureBlock {\n readonly variant = input(\"single\");\n readonly label = input(\"Signature\");\n readonly name = input();\n readonly title = input();\n readonly date = input();\n readonly signers = input<[SignatureSigner, SignatureSigner]>();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n signatureLayout(this.theme(), {\n date: this.date(),\n label: this.label(),\n name: this.name(),\n signers: this.signers(),\n style: this.style(),\n title: this.title(),\n variant: this.variant(),\n })\n );\n}\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\nimport {\n injectPdfcnTheme,\n mergePdfStyles,\n} 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 { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type SignatureVariant = \"single\" | \"double\" | \"inline\";\n\n/**\n * Signature signer properties.\n * Props - `label` | `name` | `title` | `date`\n * @see {@link SignatureSigner}\n */\nexport interface SignatureSigner {\n label?: string;\n name?: string;\n title?: string;\n date?: string;\n}\n\n/**\n * Signature block properties.\n * Props - `variant` | `label` | `name` | `title` | `date` | `signers` | `style`\n * @see {@link PdfSignatureBlockProps}\n */\nexport interface PdfSignatureBlockProps {\n /**\n * Layout variant: [single, double, inline]\n * @default 'single'\n */\n variant?: SignatureVariant;\n label?: string;\n name?: string;\n title?: string;\n date?: string;\n signers?: [SignatureSigner, SignatureSigner];\n style?: Style;\n}\n\nconst createSignatureStyles = (t: PdfcnTheme) => {\n const { spacing, fontWeights, typography } = t.primitives;\n return StyleSheet.create({\n block: { flex: 1, minWidth: 140 },\n container: {\n marginBottom: t.spacing.componentGap,\n marginTop: t.spacing.sectionGap,\n },\n dateText: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n marginTop: 1,\n },\n doubleRow: {\n flexDirection: \"row\",\n gap: spacing[8],\n justifyContent: \"space-between\",\n },\n inlineLabel: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n },\n inlineLine: {\n borderBottomColor: t.colors.foreground,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n height: spacing[5],\n minWidth: 120,\n paddingHorizontal: spacing[2],\n },\n inlineName: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n },\n inlineRow: {\n alignItems: \"center\",\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: spacing[3],\n },\n label: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n marginBottom: spacing[1],\n },\n line: {\n borderBottomColor: t.colors.foreground,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n marginBottom: spacing[1],\n minHeight: spacing[6],\n },\n name: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n },\n titleText: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n },\n });\n};\n\nconst signatureLayout = (\n theme: PdfcnTheme,\n {\n variant = \"single\",\n label = \"Signature\",\n name,\n title,\n date,\n signers,\n style,\n }: PdfSignatureBlockProps\n) => {\n const styles = createSignatureStyles(theme);\n const containerStyles: Style[] = [styles.container];\n if (style) {\n containerStyles.push(style);\n }\n const container = mergePdfStyles(containerStyles);\n\n if (variant === \"inline\") {\n return { container, inlineLabel: `${label}:`, signers: [], styles };\n }\n\n if (variant === \"double\") {\n const [first, second] = signers ?? [\n { date: \"\", label: \"Authorized by\", name: \"\", title: \"\" },\n { date: \"\", label: \"Approved by\", name: \"\", title: \"\" },\n ];\n return { container, signers: [first, second], styles };\n }\n\n return { container, signers: [{ date, label, name, title }], styles };\n};\n\n@Component({\n imports: [FormeText, FormeView, NgTemplateOutlet],\n selector: \"pdf-signature-block\",\n template: `\n @let l = layout();\n @let s = l.styles;\n \n @switch (variant()) {\n @case (\"inline\") {\n \n {{ l.inlineLabel }}\n \n @if (name()) {\n {{ name() }}\n }\n \n }\n @case (\"double\") {\n \n @for (signer of l.signers; track $index) {\n \n }\n \n }\n @default {\n \n }\n }\n \n \n \n @if (signer.label) {\n {{ signer.label }}\n }\n \n @if (signer.name) {\n {{ signer.name }}\n }\n @if (signer.title) {\n {{ signer.title }}\n }\n @if (signer.date) {\n {{ signer.date }}\n }\n \n \n `,\n})\nexport class PdfSignatureBlock {\n readonly variant = input(\"single\");\n readonly label = input(\"Signature\");\n readonly name = input();\n readonly title = input();\n readonly date = input();\n readonly signers = input<[SignatureSigner, SignatureSigner]>();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n signatureLayout(this.theme(), {\n date: this.date(),\n label: this.label(),\n name: this.name(),\n signers: this.signers(),\n style: this.style(),\n title: this.title(),\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/signature/signature.ts" } diff --git a/apps/web/public/r/forme/stack.json b/apps/web/public/r/forme/stack.json index b625e8b..08adf22 100644 --- a/apps/web/public/r/forme/stack.json +++ b/apps/web/public/r/forme/stack.json @@ -3,17 +3,13 @@ "name": "forme/stack", "title": "Stack", "description": "Stack 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/stack/stack.ts", - "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport {\n injectPdfcnTheme,\n mergePdfStyles,\n} from \"@/components/pdf/theme-provider\";\nimport {\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 StackGap = \"none\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type StackDirection = \"vertical\" | \"horizontal\";\nexport type StackAlign = \"start\" | \"center\" | \"end\" | \"stretch\";\nexport type StackJustify = \"start\" | \"center\" | \"end\" | \"between\" | \"around\";\n\n/**\n * Flex layout container with gap and direction control.\n * Props - `gap` | `direction` | `align` | `justify` | `wrap` | `noWrap` | `children` | `style`\n * @see {@link StackProps}\n */\nexport interface StackProps extends PDFComponentProps {\n /**\n * @default 'md'\n */\n gap?: StackGap;\n /**\n * @default 'vertical'\n */\n direction?: StackDirection;\n /**\n * @default 'start'\n */\n align?: StackAlign;\n /**\n * @default 'start'\n */\n justify?: StackJustify;\n /**\n * @default false\n */\n wrap?: boolean;\n /**\n * @default false\n */\n noWrap?: boolean;\n}\n\nconst createStackStyles = (t: PdfcnTheme) => {\n const { spacing } = t.primitives;\n return StyleSheet.create({\n alignCenter: { alignItems: \"center\" },\n alignEnd: { alignItems: \"flex-end\" },\n alignStart: { alignItems: \"flex-start\" },\n alignStretch: { alignItems: \"stretch\" },\n gapLg: { gap: spacing[6] },\n gapMd: { gap: spacing[4] },\n gapNone: { gap: spacing[0] },\n gapSm: { gap: spacing[2] },\n gapXl: { gap: spacing[8] },\n horizontal: { flexDirection: \"row\" },\n justifyAround: { justifyContent: \"space-around\" },\n justifyBetween: { justifyContent: \"space-between\" },\n justifyCenter: { justifyContent: \"center\" },\n justifyEnd: { justifyContent: \"flex-end\" },\n justifyStart: { justifyContent: \"flex-start\" },\n vertical: { flexDirection: \"column\" },\n wrap: { flexWrap: \"wrap\" },\n });\n};\n\nconst stackStyle = (\n theme: PdfcnTheme,\n {\n gap = \"md\",\n direction = \"vertical\",\n align,\n justify,\n wrap,\n style,\n }: Omit\n) => {\n const styles = createStackStyles(theme);\n const gapMap = {\n lg: styles.gapLg,\n md: styles.gapMd,\n none: styles.gapNone,\n sm: styles.gapSm,\n xl: styles.gapXl,\n };\n const alignMap = {\n center: styles.alignCenter,\n end: styles.alignEnd,\n start: styles.alignStart,\n stretch: styles.alignStretch,\n };\n const justifyMap = {\n around: styles.justifyAround,\n between: styles.justifyBetween,\n center: styles.justifyCenter,\n end: styles.justifyEnd,\n start: styles.justifyStart,\n };\n const styleArray: Style[] = [\n direction === \"horizontal\" ? styles.horizontal : styles.vertical,\n gapMap[gap],\n ];\n if (align && align in alignMap) {\n styleArray.push(alignMap[align]);\n }\n if (justify && justify in justifyMap) {\n styleArray.push(justifyMap[justify]);\n }\n if (wrap) {\n styleArray.push(styles.wrap);\n }\n if (style) {\n styleArray.push(...[style].flat());\n }\n return mergePdfStyles(styleArray);\n};\n\n@Component({\n imports: [FormeView],\n selector: \"pdf-stack\",\n template: ``,\n})\nexport class PdfStack {\n readonly gap = input(\"md\");\n readonly direction = input(\"vertical\");\n readonly align = input();\n readonly justify = input();\n readonly wrap = input(false, { transform: booleanAttribute });\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly stackStyle = computed(() =>\n stackStyle(this.theme(), {\n align: this.align(),\n direction: this.direction(),\n gap: this.gap(),\n justify: this.justify(),\n style: this.style(),\n wrap: this.wrap(),\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 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 StackGap = \"none\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type StackDirection = \"vertical\" | \"horizontal\";\nexport type StackAlign = \"start\" | \"center\" | \"end\" | \"stretch\";\nexport type StackJustify = \"start\" | \"center\" | \"end\" | \"between\" | \"around\";\n\n/**\n * Flex layout container with gap and direction control.\n * Props - `gap` | `direction` | `align` | `justify` | `wrap` | `noWrap` | `children` | `style`\n * @see {@link StackProps}\n */\nexport interface StackProps extends PDFComponentProps {\n /**\n * @default 'md'\n */\n gap?: StackGap;\n /**\n * @default 'vertical'\n */\n direction?: StackDirection;\n /**\n * @default 'start'\n */\n align?: StackAlign;\n /**\n * @default 'start'\n */\n justify?: StackJustify;\n /**\n * @default false\n */\n wrap?: boolean;\n /**\n * @default false\n */\n noWrap?: boolean;\n}\n\nconst createStackStyles = (t: PdfcnTheme) => {\n const { spacing } = t.primitives;\n return StyleSheet.create({\n alignCenter: { alignItems: \"center\" },\n alignEnd: { alignItems: \"flex-end\" },\n alignStart: { alignItems: \"flex-start\" },\n alignStretch: { alignItems: \"stretch\" },\n gapLg: { gap: spacing[6] },\n gapMd: { gap: spacing[4] },\n gapNone: { gap: spacing[0] },\n gapSm: { gap: spacing[2] },\n gapXl: { gap: spacing[8] },\n horizontal: { flexDirection: \"row\" },\n justifyAround: { justifyContent: \"space-around\" },\n justifyBetween: { justifyContent: \"space-between\" },\n justifyCenter: { justifyContent: \"center\" },\n justifyEnd: { justifyContent: \"flex-end\" },\n justifyStart: { justifyContent: \"flex-start\" },\n vertical: { flexDirection: \"column\" },\n wrap: { flexWrap: \"wrap\" },\n });\n};\n\nconst stackStyle = (\n theme: PdfcnTheme,\n {\n gap = \"md\",\n direction = \"vertical\",\n align,\n justify,\n wrap,\n style,\n }: Omit\n) => {\n const styles = createStackStyles(theme);\n const gapMap = {\n lg: styles.gapLg,\n md: styles.gapMd,\n none: styles.gapNone,\n sm: styles.gapSm,\n xl: styles.gapXl,\n };\n const alignMap = {\n center: styles.alignCenter,\n end: styles.alignEnd,\n start: styles.alignStart,\n stretch: styles.alignStretch,\n };\n const justifyMap = {\n around: styles.justifyAround,\n between: styles.justifyBetween,\n center: styles.justifyCenter,\n end: styles.justifyEnd,\n start: styles.justifyStart,\n };\n const styleArray: Style[] = [\n direction === \"horizontal\" ? styles.horizontal : styles.vertical,\n gapMap[gap],\n ];\n if (align && align in alignMap) {\n styleArray.push(alignMap[align]);\n }\n if (justify && justify in justifyMap) {\n styleArray.push(justifyMap[justify]);\n }\n if (wrap) {\n styleArray.push(styles.wrap);\n }\n if (style) {\n styleArray.push(...[style].flat());\n }\n return mergePdfStyles(styleArray);\n};\n\n@Component({\n imports: [FormeView],\n selector: \"pdf-stack\",\n template: ``,\n})\nexport class PdfStack {\n readonly gap = input(\"md\");\n readonly direction = input(\"vertical\");\n readonly align = input();\n readonly justify = input();\n readonly wrap = input(false, { transform: booleanAttribute });\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly stackStyle = computed(() =>\n stackStyle(this.theme(), {\n align: this.align(),\n direction: this.direction(),\n gap: this.gap(),\n justify: this.justify(),\n style: this.style(),\n wrap: this.wrap(),\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/stack/stack.ts" } diff --git a/apps/web/public/r/forme/table.json b/apps/web/public/r/forme/table.json index 942e026..e1f8c44 100644 --- a/apps/web/public/r/forme/table.json +++ b/apps/web/public/r/forme/table.json @@ -3,29 +3,25 @@ "name": "forme/table", "title": "Table", "description": "Table 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/table/table.styles.ts", - "content": "import { StyleSheet } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Creates all table styles derived from the active theme.\n * @param t - The resolved PdfcnTheme instance.\n */\nexport const createTableStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius, fontWeights, typography } = t.primitives;\n const borderColor = t.colors.border;\n\n const hairline = 0.5;\n const rule = 1;\n const thick = 1.5;\n\n const cellPadV = spacing[2] - 2;\n const cellPadH = spacing[2] + 2;\n // eslint-disable-next-line prefer-destructuring\n const cellPadVCompact = spacing[0.5];\n // eslint-disable-next-line prefer-destructuring\n const cellPadHCompact = spacing[2];\n\n const rowDivider = {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\" as const,\n borderBottomWidth: hairline,\n };\n\n return StyleSheet.create({\n cell: {\n flex: 1,\n justifyContent: \"center\",\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellBordered: {\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellBorderedBorder: {\n borderRightColor: borderColor,\n borderRightStyle: \"solid\",\n borderRightWidth: hairline,\n },\n\n cellCompact: {\n paddingHorizontal: cellPadHCompact,\n paddingVertical: cellPadVCompact,\n },\n\n cellFixed: {\n flexGrow: 0,\n flexShrink: 0,\n justifyContent: \"center\",\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellGridBorder: {\n borderRightColor: borderColor,\n borderRightStyle: \"solid\",\n borderRightWidth: hairline,\n },\n\n cellMinimal: {\n paddingHorizontal: spacing[2] - 2,\n paddingVertical: spacing[1] + 1,\n },\n\n cellPrimaryHeader: {\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellStriped: {\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellText: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n lineHeight: 1.2,\n },\n cellTextCompact: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n lineHeight: 1.2,\n },\n cellTextFooter: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n cellTextHeaderBordered: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.bold,\n lineHeight: 1.2,\n },\n cellTextHeaderCompact: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.semibold,\n letterSpacing: 0.6,\n lineHeight: 1.2,\n textTransform: \"uppercase\",\n },\n cellTextHeaderGrid: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n cellTextHeaderLine: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n\n cellTextHeaderMinimal: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.medium,\n lineHeight: 1.2,\n },\n cellTextHeaderPrimaryHeader: {\n color: t.colors.primaryForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.semibold,\n letterSpacing: 0.6,\n lineHeight: 1.2,\n textTransform: \"uppercase\",\n },\n cellTextHeaderStriped: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n row: {\n display: \"flex\",\n flexDirection: \"row\",\n },\n rowBordered: rowDivider,\n rowCompact: rowDivider,\n rowFooter: {\n borderTopColor: borderColor,\n borderTopStyle: \"solid\",\n borderTopWidth: rule,\n },\n\n rowFooterStriped: {\n backgroundColor: t.colors.muted,\n borderTopColor: borderColor,\n borderTopStyle: \"solid\",\n borderTopWidth: rule,\n },\n rowGrid: rowDivider,\n\n rowHeaderBordered: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n\n rowHeaderCompact: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowHeaderGrid: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n\n rowHeaderLine: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowHeaderMinimal: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowHeaderPrimaryHeader: {\n backgroundColor: t.colors.primary,\n },\n rowHeaderStriped: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowLine: rowDivider,\n\n rowMinimal: rowDivider,\n rowPrimaryHeader: rowDivider,\n\n rowStripe: {\n backgroundColor: t.colors.muted,\n },\n\n rowStriped: {},\n table: {\n display: \"flex\",\n flexDirection: \"column\",\n marginBottom: t.spacing.componentGap,\n width: \"100%\",\n },\n tableBordered: {\n borderBottomLeftRadius: borderRadius.sm,\n borderBottomRightRadius: borderRadius.sm,\n borderColor,\n borderStyle: \"solid\",\n borderTopLeftRadius: borderRadius.sm,\n borderTopRightRadius: borderRadius.sm,\n borderWidth: rule,\n overflow: \"hidden\" as const,\n },\n tableCompact: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n tableGrid: {\n borderBottomLeftRadius: borderRadius.md,\n borderBottomRightRadius: borderRadius.md,\n borderColor,\n borderStyle: \"solid\",\n borderTopLeftRadius: borderRadius.md,\n borderTopRightRadius: borderRadius.md,\n borderWidth: thick,\n overflow: \"hidden\" as const,\n },\n tableLine: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n tableMinimal: {\n paddingVertical: spacing[2],\n },\n\n tablePrimaryHeader: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n\n tableStriped: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n borderTopColor: borderColor,\n borderTopStyle: \"solid\",\n borderTopWidth: hairline,\n },\n });\n};\n", + "content": "import { StyleSheet } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Creates all table styles derived from the active theme.\n * @param t - The resolved PdfcnTheme instance.\n */\nexport const createTableStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius, fontWeights, typography } = t.primitives;\n const borderColor = t.colors.border;\n\n const hairline = 0.5;\n const rule = 1;\n const thick = 1.5;\n\n const cellPadV = spacing[2] - 2;\n const cellPadH = spacing[2] + 2;\n // eslint-disable-next-line prefer-destructuring\n const cellPadVCompact = spacing[0.5];\n // eslint-disable-next-line prefer-destructuring\n const cellPadHCompact = spacing[2];\n\n const rowDivider = {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\" as const,\n borderBottomWidth: hairline,\n };\n\n return StyleSheet.create({\n cell: {\n flex: 1,\n justifyContent: \"center\",\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellBordered: {\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellBorderedBorder: {\n borderRightColor: borderColor,\n borderRightStyle: \"solid\",\n borderRightWidth: hairline,\n },\n\n cellCompact: {\n paddingHorizontal: cellPadHCompact,\n paddingVertical: cellPadVCompact,\n },\n\n cellFixed: {\n flexGrow: 0,\n flexShrink: 0,\n justifyContent: \"center\",\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellGridBorder: {\n borderRightColor: borderColor,\n borderRightStyle: \"solid\",\n borderRightWidth: hairline,\n },\n\n cellMinimal: {\n paddingHorizontal: spacing[2] - 2,\n paddingVertical: spacing[1] + 1,\n },\n\n cellPrimaryHeader: {\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellStriped: {\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellText: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n lineHeight: 1.2,\n },\n cellTextCompact: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n lineHeight: 1.2,\n },\n cellTextFooter: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n cellTextHeaderBordered: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.bold,\n lineHeight: 1.2,\n },\n cellTextHeaderCompact: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.semibold,\n letterSpacing: 0.6,\n lineHeight: 1.2,\n textTransform: \"uppercase\",\n },\n cellTextHeaderGrid: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n cellTextHeaderLine: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n\n cellTextHeaderMinimal: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.medium,\n lineHeight: 1.2,\n },\n cellTextHeaderPrimaryHeader: {\n color: t.colors.primaryForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.semibold,\n letterSpacing: 0.6,\n lineHeight: 1.2,\n textTransform: \"uppercase\",\n },\n cellTextHeaderStriped: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n row: {\n display: \"flex\",\n flexDirection: \"row\",\n },\n rowBordered: rowDivider,\n rowCompact: rowDivider,\n rowFooter: {\n borderTopColor: borderColor,\n borderTopStyle: \"solid\",\n borderTopWidth: rule,\n },\n\n rowFooterStriped: {\n backgroundColor: t.colors.muted,\n borderTopColor: borderColor,\n borderTopStyle: \"solid\",\n borderTopWidth: rule,\n },\n rowGrid: rowDivider,\n\n rowHeaderBordered: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n\n rowHeaderCompact: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowHeaderGrid: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n\n rowHeaderLine: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowHeaderMinimal: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowHeaderPrimaryHeader: {\n backgroundColor: t.colors.primary,\n },\n rowHeaderStriped: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowLine: rowDivider,\n\n rowMinimal: rowDivider,\n rowPrimaryHeader: rowDivider,\n\n rowStripe: {\n backgroundColor: t.colors.muted,\n },\n\n rowStriped: {},\n table: {\n display: \"flex\",\n flexDirection: \"column\",\n marginBottom: t.spacing.componentGap,\n width: \"100%\",\n },\n tableBordered: {\n borderBottomLeftRadius: borderRadius.sm,\n borderBottomRightRadius: borderRadius.sm,\n borderColor,\n borderStyle: \"solid\",\n borderTopLeftRadius: borderRadius.sm,\n borderTopRightRadius: borderRadius.sm,\n borderWidth: rule,\n overflow: \"hidden\" as const,\n },\n tableCompact: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n tableGrid: {\n borderBottomLeftRadius: borderRadius.md,\n borderBottomRightRadius: borderRadius.md,\n borderColor,\n borderStyle: \"solid\",\n borderTopLeftRadius: borderRadius.md,\n borderTopRightRadius: borderRadius.md,\n borderWidth: thick,\n overflow: \"hidden\" as const,\n },\n tableLine: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n tableMinimal: {\n paddingVertical: spacing[2],\n },\n\n tablePrimaryHeader: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n\n tableStriped: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n borderTopColor: borderColor,\n borderTopStyle: \"solid\",\n borderTopWidth: hairline,\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/table/table.styles.ts" }, { "path": "registry/bases/forme/components/table/table.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport {\n Component,\n DestroyRef,\n booleanAttribute,\n computed,\n inject,\n input,\n signal,\n} from \"@angular/core\";\nimport type { WritableSignal } from \"@angular/core\";\n\nimport {\n injectPdfcnTheme,\n mergePdfStyles,\n} 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 { createTableStyles } from \"./table.styles\";\nimport type {\n TableCellProps,\n TableProps,\n TableRowProps,\n TableSectionProps,\n TableVariant,\n} from \"./table.types\";\n\nconst tableCellStyles = (\n theme: PdfcnTheme,\n {\n header,\n footer,\n align,\n width,\n style,\n variant = \"line\",\n _last,\n }: TableCellProps\n) => {\n const styles = createTableStyles(theme);\n const cellStyles: Style[] =\n width === undefined\n ? [styles.cell]\n : [styles.cellFixed, { width } as Style];\n\n const cellVariantStyle = (\n {\n bordered: styles.cellBordered,\n compact: styles.cellCompact,\n minimal: styles.cellMinimal,\n \"primary-header\": styles.cellPrimaryHeader,\n striped: styles.cellStriped,\n } as Partial>\n )[variant];\n if (cellVariantStyle) {\n cellStyles.push(cellVariantStyle);\n }\n\n if (variant === \"grid\" && !_last) {\n cellStyles.push(styles.cellGridBorder);\n } else if (variant === \"bordered\" && !_last) {\n cellStyles.push(styles.cellBorderedBorder);\n }\n\n if (align) {\n cellStyles.push({ textAlign: align } as Style);\n }\n\n const styleArray = style ? [...cellStyles, style] : cellStyles;\n\n let textStyle: Style = styles.cellText;\n if (header) {\n textStyle = {\n bordered: styles.cellTextHeaderBordered,\n compact: styles.cellTextHeaderCompact,\n grid: styles.cellTextHeaderGrid,\n line: styles.cellTextHeaderLine,\n minimal: styles.cellTextHeaderMinimal,\n \"primary-header\": styles.cellTextHeaderPrimaryHeader,\n striped: styles.cellTextHeaderStriped,\n }[variant];\n } else if (footer) {\n textStyle = styles.cellTextFooter;\n } else if (variant === \"compact\") {\n textStyle = styles.cellTextCompact;\n }\n\n return {\n cell: mergePdfStyles(styleArray),\n text: mergePdfStyles([\n textStyle,\n align ? { textAlign: align } : {},\n { margin: 0, padding: 0 },\n ]),\n };\n};\n\nconst rowStyle = (\n theme: PdfcnTheme,\n { header, footer, stripe, style, variant = \"line\" }: TableRowProps\n) => {\n const styles = createTableStyles(theme);\n const rowStyles: Style[] = [\n styles.row,\n {\n bordered: styles.rowBordered,\n compact: styles.rowCompact,\n grid: styles.rowGrid,\n line: styles.rowLine,\n minimal: styles.rowMinimal,\n \"primary-header\": styles.rowPrimaryHeader,\n striped: styles.rowStriped,\n }[variant],\n ];\n\n if (header) {\n rowStyles.push(\n {\n bordered: styles.rowHeaderBordered,\n compact: styles.rowHeaderCompact,\n grid: styles.rowHeaderGrid,\n line: styles.rowHeaderLine,\n minimal: styles.rowHeaderMinimal,\n \"primary-header\": styles.rowHeaderPrimaryHeader,\n striped: styles.rowHeaderStriped,\n }[variant]\n );\n }\n\n if (footer) {\n if (variant === \"striped\") {\n rowStyles.push(styles.rowFooterStriped);\n } else {\n rowStyles.push(styles.rowFooter);\n }\n }\n\n if (stripe && !header && !footer) {\n rowStyles.push(styles.rowStripe);\n }\n\n const styleArray = style ? [...rowStyles, style] : rowStyles;\n return mergePdfStyles(styleArray);\n};\n\nconst tableStyle = (\n theme: PdfcnTheme,\n { style, variant = \"line\" }: TableProps\n) => {\n const styles = createTableStyles(theme);\n const tableStyles: Style[] = [\n styles.table,\n {\n bordered: styles.tableBordered,\n compact: styles.tableCompact,\n grid: styles.tableGrid,\n line: styles.tableLine,\n minimal: styles.tableMinimal,\n \"primary-header\": styles.tablePrimaryHeader,\n striped: styles.tableStriped,\n }[variant],\n ];\n\n const styleArray = style ? [...tableStyles, style] : tableStyles;\n return mergePdfStyles(styleArray);\n};\n\n/** Adds `item` to `list` in creation order and removes it on destroy. */\nconst register = (list: WritableSignal, item: T) => {\n list.update((items) => [...items, item]);\n inject(DestroyRef).onDestroy(() =>\n list.update((items) => items.filter((entry) => entry !== item))\n );\n};\n\n@Component({\n imports: [FormeView, NgTemplateOutlet],\n selector: \"pdf-table\",\n template: `\n \n @if (noWrap()) {\n \n \n \n } @else {\n \n }\n `,\n})\nexport class PdfTable {\n readonly variant = input(\"line\");\n readonly zebraStripe = input(false, { transform: booleanAttribute });\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n /** Rows inside ``, in document order. */\n readonly bodyRows = signal([]);\n readonly zebra = computed(\n () => this.variant() === \"striped\" || this.zebraStripe()\n );\n\n private readonly theme = injectPdfcnTheme();\n protected readonly tableStyle = computed(() =>\n tableStyle(this.theme(), { style: this.style(), variant: this.variant() })\n );\n}\n\n@Component({\n imports: [FormeView],\n selector: \"pdf-table-header\",\n template: ``,\n})\nexport class PdfTableHeader {\n readonly style = input();\n}\n\n@Component({\n imports: [FormeView],\n selector: \"pdf-table-body\",\n template: ``,\n})\nexport class PdfTableBody {\n readonly style = input();\n}\n\n@Component({\n imports: [FormeView],\n selector: \"pdf-table-footer\",\n template: ``,\n})\nexport class PdfTableFooter {\n readonly style = input();\n}\n\n/** Inside a ``, the table's variant and zebra striping apply. */\n@Component({\n imports: [FormeView],\n selector: \"pdf-table-row\",\n template: ``,\n})\nexport class PdfTableRow {\n readonly header = input(false, { transform: booleanAttribute });\n readonly footer = input(false, { transform: booleanAttribute });\n readonly stripe = input(false, { transform: booleanAttribute });\n readonly variant = input(\"line\");\n readonly style = input();\n\n private readonly table = inject(PdfTable, { optional: true });\n readonly cells = signal([]);\n readonly resolvedVariant = computed(\n () => this.table?.variant() ?? this.variant()\n );\n\n constructor() {\n if (this.table && inject(PdfTableBody, { optional: true })) {\n register(this.table.bodyRows, this);\n }\n }\n\n private readonly theme = injectPdfcnTheme();\n protected readonly rowStyle = computed(() =>\n rowStyle(this.theme(), {\n footer: this.footer(),\n header: this.header(),\n stripe:\n this.stripe() ||\n (this.table !== null &&\n this.table.zebra() &&\n this.table.bodyRows().indexOf(this) % 2 === 1),\n style: this.style(),\n variant: this.resolvedVariant(),\n })\n );\n}\n\n/** Inside a ``, the row's `header`, `footer`, and variant apply. */\n@Component({\n imports: [FormeText, FormeView],\n selector: \"pdf-table-cell\",\n template: `\n \n \n \n `,\n})\nexport class PdfTableCell {\n readonly header = input(false, { transform: booleanAttribute });\n readonly footer = input(false, { transform: booleanAttribute });\n readonly align = input();\n readonly width = input();\n readonly variant = input(\"line\");\n readonly style = input();\n\n private readonly row = inject(PdfTableRow, { optional: true });\n\n constructor() {\n if (this.row) {\n register(this.row.cells, this);\n }\n }\n\n private readonly theme = injectPdfcnTheme();\n protected readonly styles = computed(() =>\n tableCellStyles(this.theme(), {\n _last: this.row?.cells().at(-1) === this,\n align: this.align(),\n footer: this.row ? this.row.footer() : this.footer(),\n header: this.row ? this.row.header() : this.header(),\n style: this.style(),\n variant: this.row ? this.row.resolvedVariant() : this.variant(),\n width: this.width(),\n })\n );\n}\n\nexport const TABLE = [\n PdfTable,\n PdfTableHeader,\n PdfTableBody,\n PdfTableFooter,\n PdfTableRow,\n PdfTableCell,\n] as const;\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport {\n Component,\n DestroyRef,\n booleanAttribute,\n computed,\n inject,\n input,\n signal,\n} from \"@angular/core\";\nimport type { WritableSignal } from \"@angular/core\";\n\nimport {\n injectPdfcnTheme,\n mergePdfStyles,\n} 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 { createTableStyles } from \"./table.styles\";\nimport type {\n TableCellProps,\n TableProps,\n TableRowProps,\n TableSectionProps,\n TableVariant,\n} from \"./table.types\";\n\nconst tableCellStyles = (\n theme: PdfcnTheme,\n {\n header,\n footer,\n align,\n width,\n style,\n variant = \"line\",\n _last,\n }: TableCellProps\n) => {\n const styles = createTableStyles(theme);\n const cellStyles: Style[] =\n width === undefined\n ? [styles.cell]\n : [styles.cellFixed, { width } as Style];\n\n const cellVariantStyle = (\n {\n bordered: styles.cellBordered,\n compact: styles.cellCompact,\n minimal: styles.cellMinimal,\n \"primary-header\": styles.cellPrimaryHeader,\n striped: styles.cellStriped,\n } as Partial>\n )[variant];\n if (cellVariantStyle) {\n cellStyles.push(cellVariantStyle);\n }\n\n if (variant === \"grid\" && !_last) {\n cellStyles.push(styles.cellGridBorder);\n } else if (variant === \"bordered\" && !_last) {\n cellStyles.push(styles.cellBorderedBorder);\n }\n\n if (align) {\n cellStyles.push({ textAlign: align } as Style);\n }\n\n const styleArray = style ? [...cellStyles, style] : cellStyles;\n\n let textStyle: Style = styles.cellText;\n if (header) {\n textStyle = {\n bordered: styles.cellTextHeaderBordered,\n compact: styles.cellTextHeaderCompact,\n grid: styles.cellTextHeaderGrid,\n line: styles.cellTextHeaderLine,\n minimal: styles.cellTextHeaderMinimal,\n \"primary-header\": styles.cellTextHeaderPrimaryHeader,\n striped: styles.cellTextHeaderStriped,\n }[variant];\n } else if (footer) {\n textStyle = styles.cellTextFooter;\n } else if (variant === \"compact\") {\n textStyle = styles.cellTextCompact;\n }\n\n return {\n cell: mergePdfStyles(styleArray),\n text: mergePdfStyles([\n textStyle,\n align ? { textAlign: align } : {},\n { margin: 0, padding: 0 },\n ]),\n };\n};\n\nconst rowStyle = (\n theme: PdfcnTheme,\n { header, footer, stripe, style, variant = \"line\" }: TableRowProps\n) => {\n const styles = createTableStyles(theme);\n const rowStyles: Style[] = [\n styles.row,\n {\n bordered: styles.rowBordered,\n compact: styles.rowCompact,\n grid: styles.rowGrid,\n line: styles.rowLine,\n minimal: styles.rowMinimal,\n \"primary-header\": styles.rowPrimaryHeader,\n striped: styles.rowStriped,\n }[variant],\n ];\n\n if (header) {\n rowStyles.push(\n {\n bordered: styles.rowHeaderBordered,\n compact: styles.rowHeaderCompact,\n grid: styles.rowHeaderGrid,\n line: styles.rowHeaderLine,\n minimal: styles.rowHeaderMinimal,\n \"primary-header\": styles.rowHeaderPrimaryHeader,\n striped: styles.rowHeaderStriped,\n }[variant]\n );\n }\n\n if (footer) {\n if (variant === \"striped\") {\n rowStyles.push(styles.rowFooterStriped);\n } else {\n rowStyles.push(styles.rowFooter);\n }\n }\n\n if (stripe && !header && !footer) {\n rowStyles.push(styles.rowStripe);\n }\n\n const styleArray = style ? [...rowStyles, style] : rowStyles;\n return mergePdfStyles(styleArray);\n};\n\nconst tableStyle = (\n theme: PdfcnTheme,\n { style, variant = \"line\" }: TableProps\n) => {\n const styles = createTableStyles(theme);\n const tableStyles: Style[] = [\n styles.table,\n {\n bordered: styles.tableBordered,\n compact: styles.tableCompact,\n grid: styles.tableGrid,\n line: styles.tableLine,\n minimal: styles.tableMinimal,\n \"primary-header\": styles.tablePrimaryHeader,\n striped: styles.tableStriped,\n }[variant],\n ];\n\n const styleArray = style ? [...tableStyles, style] : tableStyles;\n return mergePdfStyles(styleArray);\n};\n\n/** Adds `item` to `list` in creation order and removes it on destroy. */\nconst register = (list: WritableSignal, item: T) => {\n list.update((items) => [...items, item]);\n inject(DestroyRef).onDestroy(() =>\n list.update((items) => items.filter((entry) => entry !== item))\n );\n};\n\n@Component({\n imports: [FormeView, NgTemplateOutlet],\n selector: \"pdf-table\",\n template: `\n \n @if (noWrap()) {\n \n \n \n } @else {\n \n }\n `,\n})\nexport class PdfTable {\n readonly variant = input(\"line\");\n readonly zebraStripe = input(false, { transform: booleanAttribute });\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n /** Rows inside ``, in document order. */\n readonly bodyRows = signal([]);\n readonly zebra = computed(\n () => this.variant() === \"striped\" || this.zebraStripe()\n );\n\n private readonly theme = injectPdfcnTheme();\n protected readonly tableStyle = computed(() =>\n tableStyle(this.theme(), { style: this.style(), variant: this.variant() })\n );\n}\n\n@Component({\n imports: [FormeView],\n selector: \"pdf-table-header\",\n template: ``,\n})\nexport class PdfTableHeader {\n readonly style = input();\n}\n\n@Component({\n imports: [FormeView],\n selector: \"pdf-table-body\",\n template: ``,\n})\nexport class PdfTableBody {\n readonly style = input();\n}\n\n@Component({\n imports: [FormeView],\n selector: \"pdf-table-footer\",\n template: ``,\n})\nexport class PdfTableFooter {\n readonly style = input();\n}\n\n/** Inside a ``, the table's variant and zebra striping apply. */\n@Component({\n imports: [FormeView],\n selector: \"pdf-table-row\",\n template: ``,\n})\nexport class PdfTableRow {\n readonly header = input(false, { transform: booleanAttribute });\n readonly footer = input(false, { transform: booleanAttribute });\n readonly stripe = input(false, { transform: booleanAttribute });\n readonly variant = input(\"line\");\n readonly style = input();\n\n private readonly table = inject(PdfTable, { optional: true });\n readonly cells = signal([]);\n readonly resolvedVariant = computed(\n () => this.table?.variant() ?? this.variant()\n );\n\n constructor() {\n if (this.table && inject(PdfTableBody, { optional: true })) {\n register(this.table.bodyRows, this);\n }\n }\n\n private readonly theme = injectPdfcnTheme();\n protected readonly rowStyle = computed(() =>\n rowStyle(this.theme(), {\n footer: this.footer(),\n header: this.header(),\n stripe:\n this.stripe() ||\n (this.table !== null &&\n this.table.zebra() &&\n this.table.bodyRows().indexOf(this) % 2 === 1),\n style: this.style(),\n variant: this.resolvedVariant(),\n })\n );\n}\n\n/** Inside a ``, the row's `header`, `footer`, and variant apply. */\n@Component({\n imports: [FormeText, FormeView],\n selector: \"pdf-table-cell\",\n template: `\n \n \n \n `,\n})\nexport class PdfTableCell {\n readonly header = input(false, { transform: booleanAttribute });\n readonly footer = input(false, { transform: booleanAttribute });\n readonly align = input();\n readonly width = input();\n readonly variant = input(\"line\");\n readonly style = input();\n\n private readonly row = inject(PdfTableRow, { optional: true });\n\n constructor() {\n if (this.row) {\n register(this.row.cells, this);\n }\n }\n\n private readonly theme = injectPdfcnTheme();\n protected readonly styles = computed(() =>\n tableCellStyles(this.theme(), {\n _last: this.row?.cells().at(-1) === this,\n align: this.align(),\n footer: this.row ? this.row.footer() : this.footer(),\n header: this.row ? this.row.header() : this.header(),\n style: this.style(),\n variant: this.row ? this.row.resolvedVariant() : this.variant(),\n width: this.width(),\n })\n );\n}\n\nexport const TABLE = [\n PdfTable,\n PdfTableHeader,\n PdfTableBody,\n PdfTableFooter,\n PdfTableRow,\n PdfTableCell,\n] as const;\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/table/table.ts" }, { "path": "registry/bases/forme/components/table/table.types.ts", - "content": "import type { PDFComponentProps } from \"@/types/pdf-components\";\n\n/** Table visual style variant. */\nexport type TableVariant =\n | \"line\"\n | \"grid\"\n | \"minimal\"\n | \"striped\"\n | \"compact\"\n | \"bordered\"\n | \"primary-header\";\n\n/**\n * Table container with visual style variants and optional zebra striping.\n * Props - `variant` | `zebraStripe` | `noWrap` | `children` | `style`\n * @see {@link TableProps}\n */\nexport interface TableProps extends PDFComponentProps {\n /**\n * @default 'line'\n */\n variant?: TableVariant;\n /**\n * @default false\n */\n zebraStripe?: boolean;\n /**\n * @default false\n */\n noWrap?: boolean;\n}\n\nexport type TableSectionProps = PDFComponentProps;\n\n/**\n * Table row with optional header, footer, and stripe states.\n * Props - `header` | `footer` | `stripe` | `variant` | `children` | `style`\n * @see {@link TableRowProps}\n */\nexport interface TableRowProps extends PDFComponentProps {\n header?: boolean;\n footer?: boolean;\n stripe?: boolean;\n variant?: TableVariant;\n}\n\n/**\n * Table cell with alignment, width, and header or footer text styling.\n * Props - `header` | `footer` | `align` | `width` | `variant` | `_last` | `children` | `style`\n * @see {@link TableCellProps}\n */\nexport interface TableCellProps extends PDFComponentProps {\n header?: boolean;\n footer?: boolean;\n align?: \"left\" | \"center\" | \"right\";\n width?: string | number;\n variant?: TableVariant;\n _last?: boolean;\n}\n", + "content": "import type { PDFComponentProps } from \"@/types/pdf-components\";\n\n/** Table visual style variant. */\nexport type TableVariant =\n | \"line\"\n | \"grid\"\n | \"minimal\"\n | \"striped\"\n | \"compact\"\n | \"bordered\"\n | \"primary-header\";\n\n/**\n * Table container with visual style variants and optional zebra striping.\n * Props - `variant` | `zebraStripe` | `noWrap` | `children` | `style`\n * @see {@link TableProps}\n */\nexport interface TableProps extends PDFComponentProps {\n /**\n * @default 'line'\n */\n variant?: TableVariant;\n /**\n * @default false\n */\n zebraStripe?: boolean;\n /**\n * @default false\n */\n noWrap?: boolean;\n}\n\nexport type TableSectionProps = PDFComponentProps;\n\n/**\n * Table row with optional header, footer, and stripe states.\n * Props - `header` | `footer` | `stripe` | `variant` | `children` | `style`\n * @see {@link TableRowProps}\n */\nexport interface TableRowProps extends PDFComponentProps {\n header?: boolean;\n footer?: boolean;\n stripe?: boolean;\n variant?: TableVariant;\n}\n\n/**\n * Table cell with alignment, width, and header or footer text styling.\n * Props - `header` | `footer` | `align` | `width` | `variant` | `_last` | `children` | `style`\n * @see {@link TableCellProps}\n */\nexport interface TableCellProps extends PDFComponentProps {\n header?: boolean;\n footer?: boolean;\n align?: \"left\" | \"center\" | \"right\";\n width?: string | number;\n variant?: TableVariant;\n _last?: 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/table/table.types.ts" } diff --git a/apps/web/public/r/forme/text.json b/apps/web/public/r/forme/text.json index 8ac07cc..48101c0 100644 --- a/apps/web/public/r/forme/text.json +++ b/apps/web/public/r/forme/text.json @@ -3,17 +3,13 @@ "name": "forme/text", "title": "Text", "description": "Text 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/text/text.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 TextVariant = \"xs\" | \"sm\" | \"base\" | \"lg\" | \"xl\" | \"2xl\" | \"3xl\";\nexport type TextWeight = \"normal\" | \"medium\" | \"semibold\" | \"bold\";\nexport type TextDecoration = \"underline\" | \"line-through\" | \"none\";\n\n/**\n * Body text with typography scale, alignment, and decoration options.\n * Props - `variant` | `align` | `color` | `weight` | `italic` | `decoration` | `transform` | `noMargin` | `children` | `style`\n * @see {@link TextProps}\n */\nexport interface TextProps extends PDFComponentProps {\n /**\n * @default 'base'\n */\n variant?: TextVariant;\n /**\n * @default 'left'\n */\n align?: \"left\" | \"center\" | \"right\" | \"justify\";\n color?: string;\n /**\n * @default 'normal'\n */\n weight?: TextWeight;\n /**\n * @default false\n */\n italic?: boolean;\n /**\n * @default 'none'\n */\n decoration?: TextDecoration;\n transform?: \"uppercase\" | \"lowercase\" | \"capitalize\";\n /**\n * @default false\n */\n noMargin?: boolean;\n}\n\nconst createTextStyles = (t: PdfcnTheme) => {\n const { fontWeights, letterSpacing } = t.primitives;\n const base = {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n lineHeight: t.typography.body.lineHeight,\n marginBottom: t.spacing.paragraphGap,\n marginTop: 0,\n };\n return StyleSheet.create({\n \"2xl\": { ...base, fontSize: t.primitives.typography[\"2xl\"] },\n \"3xl\": { ...base, fontSize: t.primitives.typography[\"3xl\"] },\n base: { ...base, fontSize: t.primitives.typography.base },\n capitalize: { textTransform: \"capitalize\" },\n decorationNone: { textDecoration: \"none\" },\n italic: { fontStyle: \"italic\" },\n lg: { ...base, fontSize: t.primitives.typography.lg },\n lineThrough: { textDecoration: \"line-through\" },\n lowercase: { textTransform: \"lowercase\" },\n noMargin: { marginBottom: 0, marginTop: 0 },\n sm: { ...base, fontSize: t.primitives.typography.sm },\n text: { ...base, fontSize: t.typography.body.fontSize },\n underline: { textDecoration: \"underline\" },\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 xl: { ...base, fontSize: t.primitives.typography.xl },\n xs: { ...base, fontSize: t.primitives.typography.xs },\n });\n};\n\nconst textStyle = (\n theme: PdfcnTheme,\n {\n variant,\n align,\n color,\n weight,\n italic,\n decoration,\n transform,\n noMargin,\n style,\n }: TextProps\n) => {\n const styles = createTextStyles(theme);\n const weightMap = {\n bold: styles.weightBold,\n medium: styles.weightMedium,\n normal: styles.weightNormal,\n semibold: styles.weightSemibold,\n };\n const decorationMap = {\n \"line-through\": styles.lineThrough,\n none: styles.decorationNone,\n underline: styles.underline,\n };\n const transformMap = {\n capitalize: styles.capitalize,\n lowercase: styles.lowercase,\n uppercase: styles.uppercase,\n };\n const styleArray: Style[] = [variant ? styles[variant] : styles.text];\n if (weight && weight in weightMap) {\n styleArray.push(weightMap[weight]);\n }\n if (italic) {\n styleArray.push(styles.italic);\n }\n if (decoration && decoration in decorationMap) {\n styleArray.push(decorationMap[decoration]);\n }\n if (transform && transform in transformMap) {\n styleArray.push(transformMap[transform]);\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-text\",\n template: ``,\n})\nexport class PdfText {\n readonly variant = input();\n readonly align = input();\n readonly color = input();\n readonly weight = input();\n readonly italic = input(false, { transform: booleanAttribute });\n readonly decoration = input();\n readonly transform = input();\n readonly noMargin = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly textStyle = computed(() =>\n textStyle(this.theme(), {\n align: this.align(),\n color: this.color(),\n decoration: this.decoration(),\n italic: this.italic(),\n noMargin: this.noMargin(),\n style: this.style(),\n transform: this.transform(),\n variant: this.variant(),\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 TextVariant = \"xs\" | \"sm\" | \"base\" | \"lg\" | \"xl\" | \"2xl\" | \"3xl\";\nexport type TextWeight = \"normal\" | \"medium\" | \"semibold\" | \"bold\";\nexport type TextDecoration = \"underline\" | \"line-through\" | \"none\";\n\n/**\n * Body text with typography scale, alignment, and decoration options.\n * Props - `variant` | `align` | `color` | `weight` | `italic` | `decoration` | `transform` | `noMargin` | `children` | `style`\n * @see {@link TextProps}\n */\nexport interface TextProps extends PDFComponentProps {\n /**\n * @default 'base'\n */\n variant?: TextVariant;\n /**\n * @default 'left'\n */\n align?: \"left\" | \"center\" | \"right\" | \"justify\";\n color?: string;\n /**\n * @default 'normal'\n */\n weight?: TextWeight;\n /**\n * @default false\n */\n italic?: boolean;\n /**\n * @default 'none'\n */\n decoration?: TextDecoration;\n transform?: \"uppercase\" | \"lowercase\" | \"capitalize\";\n /**\n * @default false\n */\n noMargin?: boolean;\n}\n\nconst createTextStyles = (t: PdfcnTheme) => {\n const { fontWeights, letterSpacing } = t.primitives;\n const base = {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n lineHeight: t.typography.body.lineHeight,\n marginBottom: t.spacing.paragraphGap,\n marginTop: 0,\n };\n return StyleSheet.create({\n \"2xl\": { ...base, fontSize: t.primitives.typography[\"2xl\"] },\n \"3xl\": { ...base, fontSize: t.primitives.typography[\"3xl\"] },\n base: { ...base, fontSize: t.primitives.typography.base },\n capitalize: { textTransform: \"capitalize\" },\n decorationNone: { textDecoration: \"none\" },\n italic: { fontStyle: \"italic\" },\n lg: { ...base, fontSize: t.primitives.typography.lg },\n lineThrough: { textDecoration: \"line-through\" },\n lowercase: { textTransform: \"lowercase\" },\n noMargin: { marginBottom: 0, marginTop: 0 },\n sm: { ...base, fontSize: t.primitives.typography.sm },\n text: { ...base, fontSize: t.typography.body.fontSize },\n underline: { textDecoration: \"underline\" },\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 xl: { ...base, fontSize: t.primitives.typography.xl },\n xs: { ...base, fontSize: t.primitives.typography.xs },\n });\n};\n\nconst textStyle = (\n theme: PdfcnTheme,\n {\n variant,\n align,\n color,\n weight,\n italic,\n decoration,\n transform,\n noMargin,\n style,\n }: TextProps\n) => {\n const styles = createTextStyles(theme);\n const weightMap = {\n bold: styles.weightBold,\n medium: styles.weightMedium,\n normal: styles.weightNormal,\n semibold: styles.weightSemibold,\n };\n const decorationMap = {\n \"line-through\": styles.lineThrough,\n none: styles.decorationNone,\n underline: styles.underline,\n };\n const transformMap = {\n capitalize: styles.capitalize,\n lowercase: styles.lowercase,\n uppercase: styles.uppercase,\n };\n const styleArray: Style[] = [variant ? styles[variant] : styles.text];\n if (weight && weight in weightMap) {\n styleArray.push(weightMap[weight]);\n }\n if (italic) {\n styleArray.push(styles.italic);\n }\n if (decoration && decoration in decorationMap) {\n styleArray.push(decorationMap[decoration]);\n }\n if (transform && transform in transformMap) {\n styleArray.push(transformMap[transform]);\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-text\",\n template: ``,\n})\nexport class PdfText {\n readonly variant = input();\n readonly align = input();\n readonly color = input();\n readonly weight = input();\n readonly italic = input(false, { transform: booleanAttribute });\n readonly decoration = input();\n readonly transform = input();\n readonly noMargin = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly textStyle = computed(() =>\n textStyle(this.theme(), {\n align: this.align(),\n color: this.color(),\n decoration: this.decoration(),\n italic: this.italic(),\n noMargin: this.noMargin(),\n style: this.style(),\n transform: this.transform(),\n variant: this.variant(),\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/text/text.ts" } diff --git a/apps/web/public/r/forme/theme-provider.json b/apps/web/public/r/forme/theme-provider.json index 5423c7b..02631c1 100644 --- a/apps/web/public/r/forme/theme-provider.json +++ b/apps/web/public/r/forme/theme-provider.json @@ -4,8 +4,7 @@ "title": "Theme Provider", "description": "Theme provider for the forme base", "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0" + "@formepdf/shared@^0.32.0" ], "registryDependencies": [ "@angular-pdfcn/theme-professional" @@ -13,7 +12,7 @@ "files": [ { "path": "registry/bases/forme/components/theme-provider.ts", - "content": "import {\n Component,\n InjectionToken,\n inject,\n input,\n signal,\n} from \"@angular/core\";\nimport type { Signal } from \"@angular/core\";\nimport type { Style } from \"@formepdf/shared\";\n\nimport { professionalTheme } from \"@/lib/pdf-themes/professional\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type { PdfcnTheme };\n\nexport const PDFCN_THEME = new InjectionToken>(\n \"PDFCN_THEME\"\n);\n\nconst defaultTheme = signal(professionalTheme).asReadonly();\n\n/** The theme of the nearest ``, or the professional theme. */\nexport const injectPdfcnTheme = (): Signal =>\n inject(PDFCN_THEME, { optional: true }) ?? defaultTheme;\n\n/** Provides a theme to the components it wraps. */\n@Component({\n providers: [\n {\n provide: PDFCN_THEME,\n useFactory: () => inject(PdfcnThemeProvider).theme,\n },\n ],\n selector: \"pdf-theme-provider\",\n template: \"\",\n})\nexport class PdfcnThemeProvider {\n readonly theme = input(professionalTheme, {\n transform: (theme: PdfcnTheme | undefined) => theme ?? professionalTheme,\n });\n}\n\ntype PdfStyleInput = Style | PdfStyleInput[] | false | null | undefined;\n\nconst mergeStyleInput = (target: Style, value: PdfStyleInput): void => {\n if (Array.isArray(value)) {\n for (const item of value) {\n mergeStyleInput(target, item);\n }\n } else if (value) {\n Object.assign(target, value);\n }\n};\n\nexport const mergePdfStyles = (...inputs: PdfStyleInput[]): Style => {\n const merged: Style = {};\n for (const value of inputs) {\n mergeStyleInput(merged, value);\n }\n return merged;\n};\n", + "content": "import {\n Component,\n InjectionToken,\n inject,\n input,\n signal,\n} from \"@angular/core\";\nimport type { Signal } from \"@angular/core\";\nimport type { Style } from \"@formepdf/shared\";\n\nimport { professionalTheme } from \"@/lib/pdf-themes/professional\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type { PdfcnTheme };\n\nexport const PDFCN_THEME = new InjectionToken>(\n \"PDFCN_THEME\"\n);\n\nconst defaultTheme = signal(professionalTheme).asReadonly();\n\n/** The theme of the nearest ``, or the professional theme. */\nexport const injectPdfcnTheme = (): Signal =>\n inject(PDFCN_THEME, { optional: true }) ?? defaultTheme;\n\n/** Provides a theme to the components it wraps. */\n@Component({\n providers: [\n {\n provide: PDFCN_THEME,\n useFactory: () => inject(PdfcnThemeProvider).theme,\n },\n ],\n selector: \"pdf-theme-provider\",\n template: \"\",\n})\nexport class PdfcnThemeProvider {\n readonly theme = input(professionalTheme, {\n transform: (theme: PdfcnTheme | undefined) => theme ?? professionalTheme,\n });\n}\n\ntype PdfStyleInput = Style | PdfStyleInput[] | false | null | undefined;\n\nconst mergeStyleInput = (target: Style, value: PdfStyleInput): void => {\n if (Array.isArray(value)) {\n for (const item of value) {\n mergeStyleInput(target, item);\n }\n } else if (value) {\n Object.assign(target, value);\n }\n};\n\nexport const mergePdfStyles = (...inputs: PdfStyleInput[]): Style => {\n const merged: Style = {};\n for (const value of inputs) {\n mergeStyleInput(merged, value);\n }\n return merged;\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:lib", "target": "components/pdf/theme-provider.ts" } diff --git a/apps/web/public/r/forme/utils.json b/apps/web/public/r/forme/utils.json index 88c4705..1516238 100644 --- a/apps/web/public/r/forme/utils.json +++ b/apps/web/public/r/forme/utils.json @@ -4,8 +4,8 @@ "title": "Forme Utils", "description": "Theme context and helpers for the forme base", "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0" + "@formepdf/core@^0.32.0", + "@formepdf/shared@^0.32.0" ], "registryDependencies": [ "@angular-pdfcn/theme-professional" @@ -13,31 +13,31 @@ "files": [ { "path": "registry/bases/forme/lib/resolve-color.ts", - "content": "import type { ColorTokens } from \"@/types/pdf-themes\";\n\n/** Theme color token keys that can be used for the color prop */\nexport const THEME_COLOR_KEYS = [\n \"foreground\",\n \"background\",\n \"muted\",\n \"mutedForeground\",\n \"primary\",\n \"primaryForeground\",\n \"border\",\n \"accent\",\n \"destructive\",\n \"success\",\n \"warning\",\n \"info\",\n] as const satisfies (keyof ColorTokens)[];\n\n/** Resolves a color value: theme token key → hex, or raw CSS color as-is. */\nexport const resolveColor = (value: string, colors: ColorTokens): string => {\n const key = value as (typeof THEME_COLOR_KEYS)[number];\n return THEME_COLOR_KEYS.includes(key) ? colors[key] : value;\n};\n", + "content": "import type { ColorTokens } from \"@/types/pdf-themes\";\n\n/** Theme color token keys that can be used for the color prop */\nexport const THEME_COLOR_KEYS = [\n \"foreground\",\n \"background\",\n \"muted\",\n \"mutedForeground\",\n \"primary\",\n \"primaryForeground\",\n \"border\",\n \"accent\",\n \"destructive\",\n \"success\",\n \"warning\",\n \"info\",\n] as const satisfies (keyof ColorTokens)[];\n\n/** Resolves a color value: theme token key → hex, or raw CSS color as-is. */\nexport const resolveColor = (value: string, colors: ColorTokens): string => {\n const key = value as (typeof THEME_COLOR_KEYS)[number];\n return THEME_COLOR_KEYS.includes(key) ? colors[key] : 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:lib", "target": "lib/resolve-color.ts" }, { "path": "registry/bases/forme/components/theme-provider.ts", - "content": "import {\n Component,\n InjectionToken,\n inject,\n input,\n signal,\n} from \"@angular/core\";\nimport type { Signal } from \"@angular/core\";\nimport type { Style } from \"@formepdf/shared\";\n\nimport { professionalTheme } from \"@/lib/pdf-themes/professional\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type { PdfcnTheme };\n\nexport const PDFCN_THEME = new InjectionToken>(\n \"PDFCN_THEME\"\n);\n\nconst defaultTheme = signal(professionalTheme).asReadonly();\n\n/** The theme of the nearest ``, or the professional theme. */\nexport const injectPdfcnTheme = (): Signal =>\n inject(PDFCN_THEME, { optional: true }) ?? defaultTheme;\n\n/** Provides a theme to the components it wraps. */\n@Component({\n providers: [\n {\n provide: PDFCN_THEME,\n useFactory: () => inject(PdfcnThemeProvider).theme,\n },\n ],\n selector: \"pdf-theme-provider\",\n template: \"\",\n})\nexport class PdfcnThemeProvider {\n readonly theme = input(professionalTheme, {\n transform: (theme: PdfcnTheme | undefined) => theme ?? professionalTheme,\n });\n}\n\ntype PdfStyleInput = Style | PdfStyleInput[] | false | null | undefined;\n\nconst mergeStyleInput = (target: Style, value: PdfStyleInput): void => {\n if (Array.isArray(value)) {\n for (const item of value) {\n mergeStyleInput(target, item);\n }\n } else if (value) {\n Object.assign(target, value);\n }\n};\n\nexport const mergePdfStyles = (...inputs: PdfStyleInput[]): Style => {\n const merged: Style = {};\n for (const value of inputs) {\n mergeStyleInput(merged, value);\n }\n return merged;\n};\n", + "content": "import {\n Component,\n InjectionToken,\n inject,\n input,\n signal,\n} from \"@angular/core\";\nimport type { Signal } from \"@angular/core\";\nimport type { Style } from \"@formepdf/shared\";\n\nimport { professionalTheme } from \"@/lib/pdf-themes/professional\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type { PdfcnTheme };\n\nexport const PDFCN_THEME = new InjectionToken>(\n \"PDFCN_THEME\"\n);\n\nconst defaultTheme = signal(professionalTheme).asReadonly();\n\n/** The theme of the nearest ``, or the professional theme. */\nexport const injectPdfcnTheme = (): Signal =>\n inject(PDFCN_THEME, { optional: true }) ?? defaultTheme;\n\n/** Provides a theme to the components it wraps. */\n@Component({\n providers: [\n {\n provide: PDFCN_THEME,\n useFactory: () => inject(PdfcnThemeProvider).theme,\n },\n ],\n selector: \"pdf-theme-provider\",\n template: \"\",\n})\nexport class PdfcnThemeProvider {\n readonly theme = input(professionalTheme, {\n transform: (theme: PdfcnTheme | undefined) => theme ?? professionalTheme,\n });\n}\n\ntype PdfStyleInput = Style | PdfStyleInput[] | false | null | undefined;\n\nconst mergeStyleInput = (target: Style, value: PdfStyleInput): void => {\n if (Array.isArray(value)) {\n for (const item of value) {\n mergeStyleInput(target, item);\n }\n } else if (value) {\n Object.assign(target, value);\n }\n};\n\nexport const mergePdfStyles = (...inputs: PdfStyleInput[]): Style => {\n const merged: Style = {};\n for (const value of inputs) {\n mergeStyleInput(merged, value);\n }\n return merged;\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:lib", "target": "components/pdf/theme-provider.ts" }, { "path": "registry/lib/pdf-renderer.ts", - "content": "import {\n DOCUMENT,\n ElementRef,\n RendererFactory2,\n createComponent,\n createEnvironmentInjector,\n getPlatform,\n inject,\n platformCore,\n} from \"@angular/core\";\nimport type {\n EnvironmentInjector,\n Provider,\n Renderer2,\n Type,\n} from \"@angular/core\";\n\n/** An element in the tree an Angular component renders into. */\nexport class PdfElement {\n readonly name: string;\n readonly namespace: string | null;\n parent: PdfElement | null = null;\n readonly children: PdfNode[] = [];\n readonly attributes: Record = {};\n /** The primitive directive on this element. Elements without one are transparent. */\n primitive: PdfPrimitive | null = null;\n\n constructor(name: string, namespace: string | null) {\n this.name = name;\n this.namespace = namespace;\n }\n\n /** Angular reads hydration markers through this in apps with client hydration. */\n getAttribute(name: string): string | null {\n return this.attributes[name] ?? null;\n }\n}\n\nexport class PdfTextNode {\n parent: PdfElement | null = null;\n\n value: string;\n\n constructor(value: string) {\n this.value = value;\n }\n}\n\n/** Angular's anchor for control flow and projection. Serializers skip it. */\nexport class PdfComment {\n parent: PdfElement | null = null;\n}\n\nexport type PdfNode = PdfElement | PdfTextNode | PdfComment;\n\n/** Base class for the directives that map to engine nodes. */\nexport abstract class PdfPrimitive {\n readonly element: PdfElement =\n inject>(ElementRef).nativeElement;\n\n constructor() {\n this.element.primitive = this;\n }\n}\n\nconst detach = (node: PdfNode) => {\n if (node.parent) {\n node.parent.children.splice(node.parent.children.indexOf(node), 1);\n node.parent = null;\n }\n};\n\n// oxlint-disable-next-line no-empty-function -- Renderer2 hooks the PDF tree ignores\nconst noop = () => {};\n\nconst renderer: Renderer2 = {\n addClass: noop,\n appendChild(parent: PdfElement, child: PdfNode) {\n detach(child);\n child.parent = parent;\n parent.children.push(child);\n },\n createComment: () => new PdfComment(),\n createElement: (name: string, namespace?: string | null) =>\n new PdfElement(name, namespace ?? null),\n createText: (value: string) => new PdfTextNode(value),\n data: {},\n destroy: noop,\n destroyNode: null,\n insertBefore(parent: PdfElement, child: PdfNode, ref: PdfNode | null) {\n detach(child);\n child.parent = parent;\n const index = ref ? parent.children.indexOf(ref) : -1;\n parent.children.splice(\n index === -1 ? parent.children.length : index,\n 0,\n child\n );\n },\n listen: () => noop,\n nextSibling(node: PdfNode) {\n const siblings = node.parent?.children;\n return siblings?.[siblings.indexOf(node) + 1] ?? null;\n },\n parentNode: (node: PdfNode) => node.parent,\n removeAttribute(element: PdfElement, name: string) {\n Reflect.deleteProperty(element.attributes, name);\n },\n removeChild(_parent: PdfElement | null, child: PdfNode) {\n detach(child);\n },\n removeClass: noop,\n removeStyle: noop,\n selectRootElement: (node: PdfElement) => node,\n setAttribute(element: PdfElement, name: string, value: string) {\n element.attributes[name] = value;\n },\n setProperty: noop,\n setStyle: noop,\n setValue(node: PdfTextNode, value: string) {\n node.value = value;\n },\n};\n\nconst rendererFactory: RendererFactory2 = {\n createRenderer: () => renderer,\n};\n\nexport interface RenderOptions {\n /** Values for the component's inputs. */\n inputs?: Partial>;\n providers?: Provider[];\n}\n\n/** Renders a component once and reads its element tree before tearing it down. */\nexport const renderTree = (\n component: Type,\n { inputs = {}, providers = [] }: RenderOptions,\n read: (root: PdfElement) => R\n): R => {\n const environmentInjector = createEnvironmentInjector(\n [\n { provide: RendererFactory2, useValue: rendererFactory },\n // Angular looks up a style host on creation. PDF components have no styles.\n { provide: DOCUMENT, useValue: { head: null } },\n ...providers,\n ],\n // bootstrapApplication's platform lacks the marker platformCore() asserts in dev mode.\n (getPlatform() ?? platformCore()).injector as EnvironmentInjector\n );\n const ref = createComponent(component, { environmentInjector });\n try {\n for (const [name, value] of Object.entries(inputs)) {\n ref.setInput(name, value);\n }\n ref.changeDetectorRef.detectChanges();\n return read(ref.location.nativeElement as PdfElement);\n } finally {\n ref.destroy();\n environmentInjector.destroy();\n }\n};\n\n/** Elements without a primitive pass their children through, like component hosts. */\nexport const contentOf = (element: PdfElement): (PdfElement | PdfTextNode)[] =>\n element.children.flatMap((child) => {\n if (child instanceof PdfComment) {\n return [];\n }\n if (child instanceof PdfElement && !child.primitive && !child.namespace) {\n return contentOf(child);\n }\n return [child];\n });\n\n/** All text under a node, in document order. */\nexport const textOf = (node: PdfNode): string => {\n if (node instanceof PdfTextNode) {\n return node.value;\n }\n if (node instanceof PdfElement) {\n return node.children.map(textOf).join(\"\");\n }\n return \"\";\n};\n", + "content": "import {\n DOCUMENT,\n ElementRef,\n RendererFactory2,\n createComponent,\n createEnvironmentInjector,\n getPlatform,\n inject,\n platformCore,\n} from \"@angular/core\";\nimport type {\n EnvironmentInjector,\n Provider,\n Renderer2,\n Type,\n} from \"@angular/core\";\n\n/** An element in the tree an Angular component renders into. */\nexport class PdfElement {\n readonly name: string;\n readonly namespace: string | null;\n parent: PdfElement | null = null;\n readonly children: PdfNode[] = [];\n readonly attributes: Record = {};\n /** The primitive directive on this element. Elements without one are transparent. */\n primitive: PdfPrimitive | null = null;\n\n constructor(name: string, namespace: string | null) {\n this.name = name;\n this.namespace = namespace;\n }\n\n /** Angular reads hydration markers through this in apps with client hydration. */\n getAttribute(name: string): string | null {\n return this.attributes[name] ?? null;\n }\n}\n\nexport class PdfTextNode {\n parent: PdfElement | null = null;\n\n value: string;\n\n constructor(value: string) {\n this.value = value;\n }\n}\n\n/** Angular's anchor for control flow and projection. Serializers skip it. */\nexport class PdfComment {\n parent: PdfElement | null = null;\n}\n\nexport type PdfNode = PdfElement | PdfTextNode | PdfComment;\n\n/** Base class for the directives that map to engine nodes. */\nexport abstract class PdfPrimitive {\n readonly element: PdfElement =\n inject>(ElementRef).nativeElement;\n\n constructor() {\n this.element.primitive = this;\n }\n}\n\nconst detach = (node: PdfNode) => {\n if (node.parent) {\n node.parent.children.splice(node.parent.children.indexOf(node), 1);\n node.parent = null;\n }\n};\n\n// oxlint-disable-next-line no-empty-function -- Renderer2 hooks the PDF tree ignores\nconst noop = () => {};\n\nconst renderer: Renderer2 = {\n addClass: noop,\n appendChild(parent: PdfElement, child: PdfNode) {\n detach(child);\n child.parent = parent;\n parent.children.push(child);\n },\n createComment: () => new PdfComment(),\n createElement: (name: string, namespace?: string | null) =>\n new PdfElement(name, namespace ?? null),\n createText: (value: string) => new PdfTextNode(value),\n data: {},\n destroy: noop,\n destroyNode: null,\n insertBefore(parent: PdfElement, child: PdfNode, ref: PdfNode | null) {\n detach(child);\n child.parent = parent;\n const index = ref ? parent.children.indexOf(ref) : -1;\n parent.children.splice(\n index === -1 ? parent.children.length : index,\n 0,\n child\n );\n },\n listen: () => noop,\n nextSibling(node: PdfNode) {\n const siblings = node.parent?.children;\n return siblings?.[siblings.indexOf(node) + 1] ?? null;\n },\n parentNode: (node: PdfNode) => node.parent,\n removeAttribute(element: PdfElement, name: string) {\n Reflect.deleteProperty(element.attributes, name);\n },\n removeChild(_parent: PdfElement | null, child: PdfNode) {\n detach(child);\n },\n removeClass: noop,\n removeStyle: noop,\n selectRootElement: (node: PdfElement) => node,\n setAttribute(element: PdfElement, name: string, value: string) {\n element.attributes[name] = value;\n },\n setProperty: noop,\n setStyle: noop,\n setValue(node: PdfTextNode, value: string) {\n node.value = value;\n },\n};\n\nconst rendererFactory: RendererFactory2 = {\n createRenderer: () => renderer,\n};\n\nexport interface RenderOptions {\n /** Values for the component's inputs. */\n inputs?: Partial>;\n providers?: Provider[];\n}\n\n/** Renders a component once and reads its element tree before tearing it down. */\nexport const renderTree = (\n component: Type,\n { inputs = {}, providers = [] }: RenderOptions,\n read: (root: PdfElement) => R\n): R => {\n const environmentInjector = createEnvironmentInjector(\n [\n { provide: RendererFactory2, useValue: rendererFactory },\n // Angular looks up a style host on creation. PDF components have no styles.\n { provide: DOCUMENT, useValue: { head: null } },\n ...providers,\n ],\n // bootstrapApplication's platform lacks the marker platformCore() asserts in dev mode.\n (getPlatform() ?? platformCore()).injector as EnvironmentInjector\n );\n const ref = createComponent(component, { environmentInjector });\n try {\n for (const [name, value] of Object.entries(inputs)) {\n ref.setInput(name, value);\n }\n ref.changeDetectorRef.detectChanges();\n return read(ref.location.nativeElement as PdfElement);\n } finally {\n ref.destroy();\n environmentInjector.destroy();\n }\n};\n\n/** Elements without a primitive pass their children through, like component hosts. */\nexport const contentOf = (element: PdfElement): (PdfElement | PdfTextNode)[] =>\n element.children.flatMap((child) => {\n if (child instanceof PdfComment) {\n return [];\n }\n if (child instanceof PdfElement && !child.primitive && !child.namespace) {\n return contentOf(child);\n }\n return [child];\n });\n\n/** All text under a node, in document order. */\nexport const textOf = (node: PdfNode): string => {\n if (node instanceof PdfTextNode) {\n return node.value;\n }\n if (node instanceof PdfElement) {\n return node.children.map(textOf).join(\"\");\n }\n return \"\";\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:lib", "target": "lib/pdf-renderer.ts" }, { "path": "registry/bases/forme/lib/pdf-primitives.ts", - "content": "import { booleanAttribute, Directive, input } from \"@angular/core\";\nimport type { Edges, Style } from \"@formepdf/shared\";\n\nimport { PdfPrimitive } from \"@/lib/pdf-renderer\";\n\nexport type { Style };\n\nexport type FormeStyleInput =\n | Style\n | false\n | null\n | undefined\n | readonly FormeStyleInput[];\n\nexport const StyleSheet = {\n create: >(styles: T): T => styles,\n};\n\n/** Flattens nested style arrays, later entries winning. */\nexport const mergeFormeStyles = (value: FormeStyleInput): Style => {\n if (!value) {\n return {};\n }\n if (!Array.isArray(value)) {\n return value as Style;\n }\n const merged: Style = {};\n for (const entry of value) {\n Object.assign(merged, mergeFormeStyles(entry));\n }\n return merged;\n};\n\n@Directive({ selector: \"forme-document\" })\nexport class FormeDocument extends PdfPrimitive {\n readonly title = input();\n}\n\nexport type FormePageSize = string | { width: number; height: number };\n\n@Directive({ selector: \"forme-page\" })\nexport class FormePage extends PdfPrimitive {\n readonly size = input();\n readonly margin = input();\n readonly style = input();\n}\n\n@Directive({ selector: \"forme-view\" })\nexport class FormeView extends PdfPrimitive {\n readonly style = input();\n readonly wrap = input();\n}\n\n/**\n * Text node. With `ifString`, it only wraps plain text content and\n * passes element content through unchanged.\n */\n@Directive({ selector: \"forme-text\" })\nexport class FormeText extends PdfPrimitive {\n readonly style = input();\n readonly ifString = input(false, { transform: booleanAttribute });\n}\n\n@Directive({ selector: \"forme-fixed\" })\nexport class FormeFixed extends PdfPrimitive {\n readonly position = input.required<\"header\" | \"footer\">();\n readonly style = input();\n}\n\nexport type FormeImageSrc =\n | string\n | {\n uri: string;\n method?: string;\n headers?: Record;\n body?: string;\n };\n\n@Directive({ selector: \"forme-image\" })\nexport class FormeImage extends PdfPrimitive {\n readonly src = input.required();\n readonly width = input();\n readonly height = input();\n readonly style = input();\n}\n\n/** SVG graphic. Its children are plain `` elements. */\n@Directive({ selector: \"forme-svg\" })\nexport class FormeSvg extends PdfPrimitive {\n readonly width = input.required();\n readonly height = input.required();\n readonly viewBox = input();\n readonly style = input();\n}\n\n@Directive({ selector: \"forme-watermark\" })\nexport class FormeWatermark extends PdfPrimitive {\n readonly text = input.required();\n readonly fontSize = input(60);\n readonly angle = input(-45);\n readonly color = input(\"rgba(0,0,0,0.1)\");\n readonly style = input();\n}\n\n@Directive({ selector: \"forme-page-break\" })\nexport class FormePageBreak extends PdfPrimitive {}\n\nexport const FORME_PRIMITIVES = [\n FormeDocument,\n FormePage,\n FormeView,\n FormeText,\n FormeFixed,\n FormeImage,\n FormeSvg,\n FormeWatermark,\n FormePageBreak,\n] as const;\n", + "content": "import { booleanAttribute, Directive, input } from \"@angular/core\";\nimport type { Edges, Style } from \"@formepdf/shared\";\n\nimport { PdfPrimitive } from \"@/lib/pdf-renderer\";\n\nexport type { Style };\n\nexport type FormeStyleInput =\n | Style\n | false\n | null\n | undefined\n | readonly FormeStyleInput[];\n\nexport const StyleSheet = {\n create: >(styles: T): T => styles,\n};\n\n/** Flattens nested style arrays, later entries winning. */\nexport const mergeFormeStyles = (value: FormeStyleInput): Style => {\n if (!value) {\n return {};\n }\n if (!Array.isArray(value)) {\n return value as Style;\n }\n const merged: Style = {};\n for (const entry of value) {\n Object.assign(merged, mergeFormeStyles(entry));\n }\n return merged;\n};\n\n@Directive({ selector: \"forme-document\" })\nexport class FormeDocument extends PdfPrimitive {\n readonly title = input();\n}\n\nexport type FormePageSize = string | { width: number; height: number };\n\n@Directive({ selector: \"forme-page\" })\nexport class FormePage extends PdfPrimitive {\n readonly size = input();\n readonly margin = input();\n readonly style = input();\n}\n\n@Directive({ selector: \"forme-view\" })\nexport class FormeView extends PdfPrimitive {\n readonly style = input();\n readonly wrap = input();\n}\n\n/**\n * Text node. With `ifString`, it only wraps plain text content and\n * passes element content through unchanged.\n */\n@Directive({ selector: \"forme-text\" })\nexport class FormeText extends PdfPrimitive {\n readonly style = input();\n readonly ifString = input(false, { transform: booleanAttribute });\n}\n\n@Directive({ selector: \"forme-fixed\" })\nexport class FormeFixed extends PdfPrimitive {\n readonly position = input.required<\"header\" | \"footer\">();\n readonly style = input();\n}\n\nexport type FormeImageSrc =\n | string\n | {\n uri: string;\n method?: string;\n headers?: Record;\n body?: string;\n };\n\n@Directive({ selector: \"forme-image\" })\nexport class FormeImage extends PdfPrimitive {\n readonly src = input.required();\n readonly width = input();\n readonly height = input();\n readonly style = input();\n}\n\n/** SVG graphic. Its children are plain `` elements. */\n@Directive({ selector: \"forme-svg\" })\nexport class FormeSvg extends PdfPrimitive {\n readonly width = input.required();\n readonly height = input.required();\n readonly viewBox = input();\n readonly style = input();\n}\n\n@Directive({ selector: \"forme-watermark\" })\nexport class FormeWatermark extends PdfPrimitive {\n readonly text = input.required();\n readonly fontSize = input(60);\n readonly angle = input(-45);\n readonly color = input(\"rgba(0,0,0,0.1)\");\n readonly style = input();\n}\n\n@Directive({ selector: \"forme-page-break\" })\nexport class FormePageBreak extends PdfPrimitive {}\n\nexport const FORME_PRIMITIVES = [\n FormeDocument,\n FormePage,\n FormeView,\n FormeText,\n FormeFixed,\n FormeImage,\n FormeSvg,\n FormeWatermark,\n FormePageBreak,\n] as const;\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:lib", "target": "lib/pdf-primitives.ts" }, { "path": "registry/bases/forme/lib/render.ts", - "content": "import type { Type } from \"@angular/core\";\nimport { expandEdges, mapStyle, parseColor } from \"@formepdf/shared\";\nimport type {\n FormeDocument as FormeDocumentJson,\n FormeNode,\n} from \"@formepdf/shared\";\n\nimport {\n FormeDocument,\n FormeFixed,\n FormeImage,\n FormePage,\n FormePageBreak,\n FormeSvg,\n FormeText,\n FormeView,\n FormeWatermark,\n mergeFormeStyles,\n} from \"@/lib/pdf-primitives\";\nimport {\n PdfElement,\n PdfTextNode,\n contentOf,\n renderTree,\n textOf,\n} from \"@/lib/pdf-renderer\";\nimport type { PdfNode, RenderOptions } from \"@/lib/pdf-renderer\";\n\nconst DEFAULT_MARGIN = { bottom: 54, left: 54, right: 54, top: 54 };\n\nconst node = (\n kind: FormeNode[\"kind\"],\n style: FormeNode[\"style\"] = {},\n children: FormeNode[] = []\n): FormeNode => ({ children, kind, style });\n\nconst escapeXml = (value: string) =>\n value\n .replaceAll(\"&\", \"&\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\");\n\nconst svgMarkup = (child: PdfNode): string => {\n if (child instanceof PdfTextNode) {\n return escapeXml(child.value);\n }\n if (!(child instanceof PdfElement)) {\n return \"\";\n }\n const attributes = Object.entries(child.attributes)\n .map(\n ([name, value]) =>\n ` ${name}=\"${escapeXml(value).replaceAll('\"', \""\")}\"`\n )\n .join(\"\");\n const inner = child.children.map(svgMarkup).join(\"\");\n return inner\n ? `<${child.name}${attributes}>${inner}`\n : `<${child.name}${attributes}/>`;\n};\n\nconst serializeChildren = (element: PdfElement): FormeNode[] =>\n contentOf(element).flatMap((child) =>\n child instanceof PdfTextNode\n ? [node({ content: child.value, type: \"Text\" })]\n : // oxlint-disable-next-line no-use-before-define -- mutual recursion\n serializeElement(child)\n );\n\nconst serializePage = (element: PdfElement, page: FormePage): FormeNode => {\n const size = page.size() ?? \"A4\";\n const margin = page.margin();\n return node(\n {\n config: {\n margin: margin === undefined ? DEFAULT_MARGIN : expandEdges(margin),\n size:\n typeof size === \"string\"\n ? size\n : { Custom: { height: size.height, width: size.width } },\n wrap: true,\n },\n type: \"Page\",\n } as FormeNode[\"kind\"],\n mapStyle(mergeFormeStyles(page.style())),\n serializeChildren(element)\n );\n};\n\nconst serializeElement = (element: PdfElement): FormeNode[] => {\n const { primitive } = element;\n\n if (primitive instanceof FormeView) {\n const style = mapStyle(mergeFormeStyles(primitive.style()));\n const wrap = primitive.wrap();\n if (wrap !== undefined) {\n style.wrap = wrap;\n }\n return [node({ type: \"View\" }, style, serializeChildren(element))];\n }\n if (primitive instanceof FormeText) {\n const content = contentOf(element);\n if (\n primitive.ifString() &&\n (content.length === 0 ||\n content.some((child) => child instanceof PdfElement))\n ) {\n return serializeChildren(element);\n }\n return [\n node(\n { content: textOf(element), type: \"Text\" },\n mapStyle(mergeFormeStyles(primitive.style()))\n ),\n ];\n }\n if (primitive instanceof FormeFixed) {\n return [\n node(\n {\n position: primitive.position() === \"header\" ? \"Header\" : \"Footer\",\n type: \"Fixed\",\n },\n mapStyle(mergeFormeStyles(primitive.style())),\n serializeChildren(element)\n ),\n ];\n }\n if (primitive instanceof FormeImage) {\n return [\n node(\n {\n src: primitive.src() as string,\n type: \"Image\",\n ...(primitive.width() === undefined\n ? {}\n : { width: primitive.width() }),\n ...(primitive.height() === undefined\n ? {}\n : { height: primitive.height() }),\n },\n mapStyle(mergeFormeStyles(primitive.style()))\n ),\n ];\n }\n if (primitive instanceof FormeSvg) {\n const viewBox = primitive.viewBox();\n return [\n node(\n {\n content: element.children.map(svgMarkup).join(\"\"),\n height: primitive.height(),\n type: \"Svg\",\n width: primitive.width(),\n ...(viewBox ? { view_box: viewBox } : {}),\n },\n mapStyle(mergeFormeStyles(primitive.style()))\n ),\n ];\n }\n if (primitive instanceof FormeWatermark) {\n const color = parseColor(primitive.color());\n const style = mapStyle(mergeFormeStyles(primitive.style()));\n style.color = { a: 1, b: color.b, g: color.g, r: color.r };\n style.opacity = color.a * (style.opacity ?? 1);\n style.fontSize = primitive.fontSize();\n return [\n node(\n {\n angle: primitive.angle(),\n font_size: primitive.fontSize(),\n text: primitive.text(),\n type: \"Watermark\",\n },\n style\n ),\n ];\n }\n if (primitive instanceof FormePageBreak) {\n return [node({ type: \"PageBreak\" })];\n }\n if (primitive instanceof FormePage) {\n return [serializePage(element, primitive)];\n }\n return [];\n};\n\nconst serializeDocument = (root: PdfElement): FormeDocumentJson => {\n const [element] = contentOf(root);\n if (\n !(element instanceof PdfElement) ||\n !(element.primitive instanceof FormeDocument)\n ) {\n throw new Error(\"The component must render at its root.\");\n }\n\n const pages: FormeNode[] = [];\n const loose: FormeNode[] = [];\n for (const child of contentOf(element)) {\n if (child instanceof PdfElement && child.primitive instanceof FormePage) {\n pages.push(serializePage(child, child.primitive));\n } else {\n loose.push(\n ...(child instanceof PdfTextNode\n ? [node({ content: child.value, type: \"Text\" })]\n : serializeElement(child))\n );\n }\n }\n pages.at(-1)?.children.push(...loose);\n\n const title = element.primitive.title();\n return {\n children: pages.length > 0 ? pages : loose,\n defaultPage: { margin: DEFAULT_MARGIN, size: \"A4\", wrap: true },\n metadata: title === undefined ? {} : { title },\n } as FormeDocumentJson;\n};\n\n/** Renders an Angular component that uses `` to a Forme document. */\nexport const renderFormeDocument = (\n component: Type,\n options: RenderOptions = {}\n): FormeDocumentJson => renderTree(component, options, serializeDocument);\n", + "content": "import type { Type } from \"@angular/core\";\nimport { expandEdges, mapStyle, parseColor } from \"@formepdf/shared\";\nimport type {\n FormeDocument as FormeDocumentJson,\n FormeNode,\n} from \"@formepdf/shared\";\n\nimport {\n FormeDocument,\n FormeFixed,\n FormeImage,\n FormePage,\n FormePageBreak,\n FormeSvg,\n FormeText,\n FormeView,\n FormeWatermark,\n mergeFormeStyles,\n} from \"@/lib/pdf-primitives\";\nimport {\n PdfElement,\n PdfTextNode,\n contentOf,\n renderTree,\n textOf,\n} from \"@/lib/pdf-renderer\";\nimport type { PdfNode, RenderOptions } from \"@/lib/pdf-renderer\";\n\nconst DEFAULT_MARGIN = { bottom: 54, left: 54, right: 54, top: 54 };\n\nconst node = (\n kind: FormeNode[\"kind\"],\n style: FormeNode[\"style\"] = {},\n children: FormeNode[] = []\n): FormeNode => ({ children, kind, style });\n\nconst escapeXml = (value: string) =>\n value\n .replaceAll(\"&\", \"&\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\");\n\nconst svgMarkup = (child: PdfNode): string => {\n if (child instanceof PdfTextNode) {\n return escapeXml(child.value);\n }\n if (!(child instanceof PdfElement)) {\n return \"\";\n }\n const attributes = Object.entries(child.attributes)\n .map(\n ([name, value]) =>\n ` ${name}=\"${escapeXml(value).replaceAll('\"', \""\")}\"`\n )\n .join(\"\");\n const inner = child.children.map(svgMarkup).join(\"\");\n return inner\n ? `<${child.name}${attributes}>${inner}`\n : `<${child.name}${attributes}/>`;\n};\n\nconst serializeChildren = (element: PdfElement): FormeNode[] =>\n contentOf(element).flatMap((child) =>\n child instanceof PdfTextNode\n ? [node({ content: child.value, type: \"Text\" })]\n : // oxlint-disable-next-line no-use-before-define -- mutual recursion\n serializeElement(child)\n );\n\nconst serializePage = (element: PdfElement, page: FormePage): FormeNode => {\n const size = page.size() ?? \"A4\";\n const margin = page.margin();\n return node(\n {\n config: {\n margin: margin === undefined ? DEFAULT_MARGIN : expandEdges(margin),\n size:\n typeof size === \"string\"\n ? size\n : { Custom: { height: size.height, width: size.width } },\n wrap: true,\n },\n type: \"Page\",\n } as FormeNode[\"kind\"],\n mapStyle(mergeFormeStyles(page.style())),\n serializeChildren(element)\n );\n};\n\nconst serializeElement = (element: PdfElement): FormeNode[] => {\n const { primitive } = element;\n\n if (primitive instanceof FormeView) {\n const style = mapStyle(mergeFormeStyles(primitive.style()));\n const wrap = primitive.wrap();\n if (wrap !== undefined) {\n style.wrap = wrap;\n }\n return [node({ type: \"View\" }, style, serializeChildren(element))];\n }\n if (primitive instanceof FormeText) {\n const content = contentOf(element);\n if (\n primitive.ifString() &&\n (content.length === 0 ||\n content.some((child) => child instanceof PdfElement))\n ) {\n return serializeChildren(element);\n }\n return [\n node(\n { content: textOf(element), type: \"Text\" },\n mapStyle(mergeFormeStyles(primitive.style()))\n ),\n ];\n }\n if (primitive instanceof FormeFixed) {\n return [\n node(\n {\n position: primitive.position() === \"header\" ? \"Header\" : \"Footer\",\n type: \"Fixed\",\n },\n mapStyle(mergeFormeStyles(primitive.style())),\n serializeChildren(element)\n ),\n ];\n }\n if (primitive instanceof FormeImage) {\n return [\n node(\n {\n src: primitive.src() as string,\n type: \"Image\",\n ...(primitive.width() === undefined\n ? {}\n : { width: primitive.width() }),\n ...(primitive.height() === undefined\n ? {}\n : { height: primitive.height() }),\n },\n mapStyle(mergeFormeStyles(primitive.style()))\n ),\n ];\n }\n if (primitive instanceof FormeSvg) {\n const viewBox = primitive.viewBox();\n return [\n node(\n {\n content: element.children.map(svgMarkup).join(\"\"),\n height: primitive.height(),\n type: \"Svg\",\n width: primitive.width(),\n ...(viewBox ? { view_box: viewBox } : {}),\n },\n mapStyle(mergeFormeStyles(primitive.style()))\n ),\n ];\n }\n if (primitive instanceof FormeWatermark) {\n const color = parseColor(primitive.color());\n const style = mapStyle(mergeFormeStyles(primitive.style()));\n style.color = { a: 1, b: color.b, g: color.g, r: color.r };\n style.opacity = color.a * (style.opacity ?? 1);\n style.fontSize = primitive.fontSize();\n return [\n node(\n {\n angle: primitive.angle(),\n font_size: primitive.fontSize(),\n text: primitive.text(),\n type: \"Watermark\",\n },\n style\n ),\n ];\n }\n if (primitive instanceof FormePageBreak) {\n return [node({ type: \"PageBreak\" })];\n }\n if (primitive instanceof FormePage) {\n return [serializePage(element, primitive)];\n }\n return [];\n};\n\nconst serializeDocument = (root: PdfElement): FormeDocumentJson => {\n const [element] = contentOf(root);\n if (\n !(element instanceof PdfElement) ||\n !(element.primitive instanceof FormeDocument)\n ) {\n throw new Error(\"The component must render at its root.\");\n }\n\n const pages: FormeNode[] = [];\n const loose: FormeNode[] = [];\n for (const child of contentOf(element)) {\n if (child instanceof PdfElement && child.primitive instanceof FormePage) {\n pages.push(serializePage(child, child.primitive));\n } else {\n loose.push(\n ...(child instanceof PdfTextNode\n ? [node({ content: child.value, type: \"Text\" })]\n : serializeElement(child))\n );\n }\n }\n pages.at(-1)?.children.push(...loose);\n\n const title = element.primitive.title();\n return {\n children: pages.length > 0 ? pages : loose,\n defaultPage: { margin: DEFAULT_MARGIN, size: \"A4\", wrap: true },\n metadata: title === undefined ? {} : { title },\n } as FormeDocumentJson;\n};\n\n/** Renders an Angular component that uses `` to a Forme document. */\nexport const renderFormeDocument = (\n component: Type,\n options: RenderOptions = {}\n): FormeDocumentJson => renderTree(component, options, serializeDocument);\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:lib", "target": "lib/render.ts" } diff --git a/apps/web/public/r/forme/watermark.json b/apps/web/public/r/forme/watermark.json index d5c4d06..4c7a49d 100644 --- a/apps/web/public/r/forme/watermark.json +++ b/apps/web/public/r/forme/watermark.json @@ -3,17 +3,13 @@ "name": "forme/watermark", "title": "Watermark", "description": "Watermark 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/watermark/watermark.ts", - "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeWatermark,\n mergeFormeStyles,\n} 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 WatermarkPosition =\n | \"center\"\n | \"top-left\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-right\";\n\n/**\n * Diagonal watermark overlaid across the full page using absolute positioning.\n * Props - `text` | `opacity` | `fontSize` | `color` | `angle` | `position` | `fixed` | `style`\n * @see {@link PdfWatermarkProps}\n */\nexport interface PdfWatermarkProps extends Omit {\n text: string;\n opacity?: number;\n fontSize?: number;\n color?: string;\n angle?: number;\n position?: WatermarkPosition;\n /**\n * @default true\n */\n fixed?: boolean;\n children?: never;\n}\n\nconst withOpacity = (color: string, opacity: number): string => {\n const match = color.match(/^#([\\da-f]{2})([\\da-f]{2})([\\da-f]{2})$/i);\n if (!match) {\n return color;\n }\n\n const [, red, green, blue] = match;\n return `rgba(${Number.parseInt(red, 16)}, ${Number.parseInt(green, 16)}, ${Number.parseInt(blue, 16)}, ${opacity})`;\n};\n\nconst watermarkLayout = (\n theme: PdfcnTheme,\n {\n opacity = 0.15,\n color = \"mutedForeground\",\n style,\n }: Pick\n) => {\n const resolvedColor = resolveColor(color, theme.colors);\n\n return {\n color: withOpacity(resolvedColor, opacity),\n style: mergeFormeStyles(style),\n };\n};\n\n/** Diagonal watermark overlaid across the full page using absolute positioning. */\n@Component({\n imports: [FormeWatermark],\n selector: \"pdf-watermark\",\n template: `\n \n `,\n})\nexport class PdfWatermark {\n readonly text = input.required();\n readonly opacity = input(0.15);\n readonly fontSize = input(60);\n readonly color = input(\"mutedForeground\");\n readonly angle = input(-45);\n /** Part of the props API but unused, as in the original. */\n readonly position = input();\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n watermarkLayout(this.theme(), {\n color: this.color(),\n opacity: this.opacity(),\n style: this.style(),\n })\n );\n}\n", + "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n FormeWatermark,\n mergeFormeStyles,\n} 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 WatermarkPosition =\n | \"center\"\n | \"top-left\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-right\";\n\n/**\n * Diagonal watermark overlaid across the full page using absolute positioning.\n * Props - `text` | `opacity` | `fontSize` | `color` | `angle` | `position` | `fixed` | `style`\n * @see {@link PdfWatermarkProps}\n */\nexport interface PdfWatermarkProps extends Omit {\n text: string;\n opacity?: number;\n fontSize?: number;\n color?: string;\n angle?: number;\n position?: WatermarkPosition;\n /**\n * @default true\n */\n fixed?: boolean;\n children?: never;\n}\n\nconst withOpacity = (color: string, opacity: number): string => {\n const match = color.match(/^#([\\da-f]{2})([\\da-f]{2})([\\da-f]{2})$/i);\n if (!match) {\n return color;\n }\n\n const [, red, green, blue] = match;\n return `rgba(${Number.parseInt(red, 16)}, ${Number.parseInt(green, 16)}, ${Number.parseInt(blue, 16)}, ${opacity})`;\n};\n\nconst watermarkLayout = (\n theme: PdfcnTheme,\n {\n opacity = 0.15,\n color = \"mutedForeground\",\n style,\n }: Pick\n) => {\n const resolvedColor = resolveColor(color, theme.colors);\n\n return {\n color: withOpacity(resolvedColor, opacity),\n style: mergeFormeStyles(style),\n };\n};\n\n/** Diagonal watermark overlaid across the full page using absolute positioning. */\n@Component({\n imports: [FormeWatermark],\n selector: \"pdf-watermark\",\n template: `\n \n `,\n})\nexport class PdfWatermark {\n readonly text = input.required();\n readonly opacity = input(0.15);\n readonly fontSize = input(60);\n readonly color = input(\"mutedForeground\");\n readonly angle = input(-45);\n /** Part of the props API but unused, as in the original. */\n readonly position = input();\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n watermarkLayout(this.theme(), {\n color: this.color(),\n opacity: this.opacity(),\n style: this.style(),\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/watermark/watermark.ts" } diff --git a/apps/web/public/r/forme/work-order.json b/apps/web/public/r/forme/work-order.json index e97acbd..f61a2ed 100644 --- a/apps/web/public/r/forme/work-order.json +++ b/apps/web/public/r/forme/work-order.json @@ -3,10 +3,6 @@ "name": "forme/work-order", "title": "Work Order", "description": "Work Order PDF block (forme)", - "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0" - ], "registryDependencies": [ "@angular-pdfcn/forme/utils", "@angular-pdfcn/forme/badge", @@ -22,13 +18,13 @@ "files": [ { "path": "registry/bases/forme/blocks/work-order/work-order.ts", - "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport type { BadgeVariant } from \"@/components/pdf/badge/badge\";\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 { PdfSignatureBlock } from \"@/components/pdf/signature/signature\";\nimport type { SignatureSigner } from \"@/components/pdf/signature/signature\";\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 { WorkOrderData, WorkOrderPriority } from \"./work-order.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: WorkOrderData = {\n accentColor: \"#ea580c\",\n companyName: \"FixIt Pro Services\",\n customer: {\n accountNumber: \"ACC-10234\",\n address: \"789 Elm St, Austin, TX 78701\",\n name: \"Riverside Apartments\",\n phone: \"(512) 555-0199\",\n },\n customerNotes: \"Please service before end of month lease inspection.\",\n date: \"September 10, 2026\",\n equipment: {\n description: \"Commercial Dishwasher\",\n location: \"Kitchen — Unit 4B\",\n makeModel: \"Bosch SHP878ZD5N\",\n serialNumber: \"BSH-2024-88712\",\n },\n jobType: \"Repair\",\n labor: [\n {\n description: \"Diagnosis and repair\",\n hours: 2.5,\n rate: 95,\n technician: \"Mike Torres\",\n },\n ],\n parts: [\n {\n description: \"Drain Pump Assembly\",\n partNumber: \"PUMP-001\",\n qty: 1,\n unitPrice: 89.99,\n },\n {\n description: \"Drain Hose Kit\",\n partNumber: \"HOSE-012\",\n qty: 1,\n unitPrice: 24.5,\n },\n ],\n priority: \"High\",\n taxRate: 0.0825,\n technician: \"Mike Torres\",\n technicianNotes:\n \"Found clogged drain pump. Replaced pump and hose. Unit tested OK.\",\n warrantyInfo: \"90-day warranty on parts and labor.\",\n workOrderNumber: \"WO-2026-0452\",\n};\n\nconst PRIORITY_BADGE_VARIANT: Record = {\n High: \"warning\",\n Low: \"default\",\n Medium: \"info\",\n Urgent: \"destructive\",\n};\n\nconst workOrderLayout = (theme: PdfcnTheme, data: WorkOrderData) => {\n const styles = StyleSheet.create({\n checkbox: {\n borderColor: theme.colors.foreground,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 10,\n width: 10,\n },\n checkboxRow: {\n alignItems: \"center\",\n flexDirection: \"row\",\n gap: 6,\n marginTop: theme.spacing.componentGap,\n },\n col: {\n flex: 1,\n paddingRight: 15,\n },\n label: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n row: {\n flexDirection: \"row\",\n },\n section: {\n marginBottom: theme.spacing.componentGap,\n },\n sectionSpaced: {\n marginBottom: theme.spacing.componentGap,\n marginTop: theme.spacing.componentGap,\n },\n signature: {\n marginBottom: 0,\n marginTop: 0,\n },\n });\n\n const partsTotal = data.parts.reduce(\n (sum, part) => sum + part.qty * part.unitPrice,\n 0\n );\n const laborTotal = data.labor.reduce(\n (sum, item) => sum + item.hours * item.rate,\n 0\n );\n const taxRate = data.taxRate ?? 0;\n const tax = (partsTotal + laborTotal) * taxRate;\n const grandTotal = partsTotal + laborTotal + tax;\n\n const totals: KeyValueEntry[] = [\n { key: \"Parts Total\", value: `$${partsTotal.toFixed(2)}` },\n { key: \"Labor Total\", value: `$${laborTotal.toFixed(2)}` },\n {\n key: `Tax (${(taxRate * 100).toFixed(2)}%)`,\n value: `$${tax.toFixed(2)}`,\n },\n {\n key: \"Grand Total\",\n keyStyle: { fontSize: 12, fontWeight: \"bold\" },\n value: `$${grandTotal.toFixed(2)}`,\n valueStyle: { fontSize: 12, fontWeight: \"bold\" },\n },\n ];\n\n const signers: [SignatureSigner, SignatureSigner] = [\n { date: data.date, label: \"Customer Signature\" },\n {\n date: data.date,\n label: \"Technician Signature\",\n name: data.technician,\n },\n ];\n\n return {\n pageMargin: {\n bottom: theme.spacing.page.marginBottom,\n left: theme.spacing.page.marginLeft,\n right: theme.spacing.page.marginRight,\n top: theme.spacing.page.marginTop,\n },\n priorityRow: {\n ...styles.row,\n ...styles.section,\n alignItems: \"center\",\n justifyContent: \"space-between\",\n },\n rowSection: { ...styles.row, ...styles.section },\n signers,\n styles,\n totals,\n };\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfBadge,\n PdfImage,\n PdfKeyValue,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfSignatureBlock,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-work-order-content\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n \n \n \n \n \n\n \n \n Priority\n \n \n \n \n\n \n \n Customer\n {{\n data.customer.name\n }}\n {{\n data.customer.address\n }}\n {{\n data.customer.phone\n }}\n @if (data.customer.email) {\n {{\n data.customer.email\n }}\n }\n @if (data.customer.accountNumber) {\n {{\n \"Acct #: \" + data.customer.accountNumber\n }}\n }\n \n \n Job Info\n {{\n \"Technician: \" + data.technician\n }}\n {{\n \"Job Type: \" + data.jobType\n }}\n \n \n Equipment\n {{\n data.equipment.description\n }}\n @if (data.equipment.makeModel) {\n {{\n data.equipment.makeModel\n }}\n }\n @if (data.equipment.serialNumber) {\n {{\n \"S/N: \" + data.equipment.serialNumber\n }}\n }\n @if (data.equipment.location) {\n {{\n \"Location: \" + data.equipment.location\n }}\n }\n \n \n\n \n Parts Used\n \n \n \n Part #\n Description\n Qty\n Unit Price\n Total\n \n \n \n @for (part of data.parts; track $index) {\n \n {{ part.partNumber }}\n {{ part.description }}\n {{\n part.qty\n }}\n {{\n \"$\" + part.unitPrice.toFixed(2)\n }}\n {{\n \"$\" + (part.qty * part.unitPrice).toFixed(2)\n }}\n \n }\n \n \n \n\n \n Labor\n \n \n \n Description\n Technician\n Hours\n Rate\n Total\n \n \n \n @for (item of data.labor; track $index) {\n \n {{ item.description }}\n {{ item.technician }}\n {{\n item.hours\n }}\n {{\n \"$\" + item.rate.toFixed(2)\n }}\n {{\n \"$\" + (item.hours * item.rate).toFixed(2)\n }}\n \n }\n \n \n \n\n \n \n @if (data.technicianNotes) {\n \n Technician Notes\n {{\n data.technicianNotes\n }}\n \n }\n \n \n \n \n \n\n @if (data.customerNotes) {\n \n Customer Notes\n {{\n data.customerNotes\n }}\n \n }\n\n \n \n \n \n Customer approves work performed and charges above\n \n \n \n \n \n `,\n})\nexport class WorkOrderContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly PRIORITY_BADGE_VARIANT = PRIORITY_BADGE_VARIANT;\n\n protected readonly layout = computed(() =>\n workOrderLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, WorkOrderContent],\n selector: \"pdf-work-order\",\n template: `\n \n \n \n `,\n})\nexport class WorkOrderDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n", + "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport type { BadgeVariant } from \"@/components/pdf/badge/badge\";\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 { PdfSignatureBlock } from \"@/components/pdf/signature/signature\";\nimport type { SignatureSigner } from \"@/components/pdf/signature/signature\";\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 { WorkOrderData, WorkOrderPriority } from \"./work-order.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: WorkOrderData = {\n accentColor: \"#ea580c\",\n companyName: \"FixIt Pro Services\",\n customer: {\n accountNumber: \"ACC-10234\",\n address: \"789 Elm St, Austin, TX 78701\",\n name: \"Riverside Apartments\",\n phone: \"(512) 555-0199\",\n },\n customerNotes: \"Please service before end of month lease inspection.\",\n date: \"September 10, 2026\",\n equipment: {\n description: \"Commercial Dishwasher\",\n location: \"Kitchen — Unit 4B\",\n makeModel: \"Bosch SHP878ZD5N\",\n serialNumber: \"BSH-2024-88712\",\n },\n jobType: \"Repair\",\n labor: [\n {\n description: \"Diagnosis and repair\",\n hours: 2.5,\n rate: 95,\n technician: \"Mike Torres\",\n },\n ],\n parts: [\n {\n description: \"Drain Pump Assembly\",\n partNumber: \"PUMP-001\",\n qty: 1,\n unitPrice: 89.99,\n },\n {\n description: \"Drain Hose Kit\",\n partNumber: \"HOSE-012\",\n qty: 1,\n unitPrice: 24.5,\n },\n ],\n priority: \"High\",\n taxRate: 0.0825,\n technician: \"Mike Torres\",\n technicianNotes:\n \"Found clogged drain pump. Replaced pump and hose. Unit tested OK.\",\n warrantyInfo: \"90-day warranty on parts and labor.\",\n workOrderNumber: \"WO-2026-0452\",\n};\n\nconst PRIORITY_BADGE_VARIANT: Record = {\n High: \"warning\",\n Low: \"default\",\n Medium: \"info\",\n Urgent: \"destructive\",\n};\n\nconst workOrderLayout = (theme: PdfcnTheme, data: WorkOrderData) => {\n const styles = StyleSheet.create({\n checkbox: {\n borderColor: theme.colors.foreground,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 10,\n width: 10,\n },\n checkboxRow: {\n alignItems: \"center\",\n flexDirection: \"row\",\n gap: 6,\n marginTop: theme.spacing.componentGap,\n },\n col: {\n flex: 1,\n paddingRight: 15,\n },\n label: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\n },\n page: {\n backgroundColor: theme.colors.background,\n },\n row: {\n flexDirection: \"row\",\n },\n section: {\n marginBottom: theme.spacing.componentGap,\n },\n sectionSpaced: {\n marginBottom: theme.spacing.componentGap,\n marginTop: theme.spacing.componentGap,\n },\n signature: {\n marginBottom: 0,\n marginTop: 0,\n },\n });\n\n const partsTotal = data.parts.reduce(\n (sum, part) => sum + part.qty * part.unitPrice,\n 0\n );\n const laborTotal = data.labor.reduce(\n (sum, item) => sum + item.hours * item.rate,\n 0\n );\n const taxRate = data.taxRate ?? 0;\n const tax = (partsTotal + laborTotal) * taxRate;\n const grandTotal = partsTotal + laborTotal + tax;\n\n const totals: KeyValueEntry[] = [\n { key: \"Parts Total\", value: `$${partsTotal.toFixed(2)}` },\n { key: \"Labor Total\", value: `$${laborTotal.toFixed(2)}` },\n {\n key: `Tax (${(taxRate * 100).toFixed(2)}%)`,\n value: `$${tax.toFixed(2)}`,\n },\n {\n key: \"Grand Total\",\n keyStyle: { fontSize: 12, fontWeight: \"bold\" },\n value: `$${grandTotal.toFixed(2)}`,\n valueStyle: { fontSize: 12, fontWeight: \"bold\" },\n },\n ];\n\n const signers: [SignatureSigner, SignatureSigner] = [\n { date: data.date, label: \"Customer Signature\" },\n {\n date: data.date,\n label: \"Technician Signature\",\n name: data.technician,\n },\n ];\n\n return {\n pageMargin: {\n bottom: theme.spacing.page.marginBottom,\n left: theme.spacing.page.marginLeft,\n right: theme.spacing.page.marginRight,\n top: theme.spacing.page.marginTop,\n },\n priorityRow: {\n ...styles.row,\n ...styles.section,\n alignItems: \"center\",\n justifyContent: \"space-between\",\n },\n rowSection: { ...styles.row, ...styles.section },\n signers,\n styles,\n totals,\n };\n};\n\n@Component({\n imports: [\n FormeDocument,\n FormePage,\n FormeView,\n PdfBadge,\n PdfImage,\n PdfKeyValue,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfSignatureBlock,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-work-order-content\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n \n \n \n \n \n\n \n \n Priority\n \n \n \n \n\n \n \n Customer\n {{\n data.customer.name\n }}\n {{\n data.customer.address\n }}\n {{\n data.customer.phone\n }}\n @if (data.customer.email) {\n {{\n data.customer.email\n }}\n }\n @if (data.customer.accountNumber) {\n {{\n \"Acct #: \" + data.customer.accountNumber\n }}\n }\n \n \n Job Info\n {{\n \"Technician: \" + data.technician\n }}\n {{\n \"Job Type: \" + data.jobType\n }}\n \n \n Equipment\n {{\n data.equipment.description\n }}\n @if (data.equipment.makeModel) {\n {{\n data.equipment.makeModel\n }}\n }\n @if (data.equipment.serialNumber) {\n {{\n \"S/N: \" + data.equipment.serialNumber\n }}\n }\n @if (data.equipment.location) {\n {{\n \"Location: \" + data.equipment.location\n }}\n }\n \n \n\n \n Parts Used\n \n \n \n Part #\n Description\n Qty\n Unit Price\n Total\n \n \n \n @for (part of data.parts; track $index) {\n \n {{ part.partNumber }}\n {{ part.description }}\n {{\n part.qty\n }}\n {{\n \"$\" + part.unitPrice.toFixed(2)\n }}\n {{\n \"$\" + (part.qty * part.unitPrice).toFixed(2)\n }}\n \n }\n \n \n \n\n \n Labor\n \n \n \n Description\n Technician\n Hours\n Rate\n Total\n \n \n \n @for (item of data.labor; track $index) {\n \n {{ item.description }}\n {{ item.technician }}\n {{\n item.hours\n }}\n {{\n \"$\" + item.rate.toFixed(2)\n }}\n {{\n \"$\" + (item.hours * item.rate).toFixed(2)\n }}\n \n }\n \n \n \n\n \n \n @if (data.technicianNotes) {\n \n Technician Notes\n {{\n data.technicianNotes\n }}\n \n }\n \n \n \n \n \n\n @if (data.customerNotes) {\n \n Customer Notes\n {{\n data.customerNotes\n }}\n \n }\n\n \n \n \n \n Customer approves work performed and charges above\n \n \n \n \n \n `,\n})\nexport class WorkOrderContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly PRIORITY_BADGE_VARIANT = PRIORITY_BADGE_VARIANT;\n\n protected readonly layout = computed(() =>\n workOrderLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, WorkOrderContent],\n selector: \"pdf-work-order\",\n template: `\n \n \n \n `,\n})\nexport class WorkOrderDocument {\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/work-order/work-order.ts" }, { "path": "registry/bases/forme/blocks/work-order/work-order.types.ts", - "content": "export type WorkOrderPriority = \"Low\" | \"Medium\" | \"High\" | \"Urgent\";\n\nexport interface WorkOrderCustomer {\n name: string;\n address: string;\n phone: string;\n email?: string;\n accountNumber?: string;\n}\n\nexport type WorkOrderJobType =\n | \"Repair\"\n | \"Installation\"\n | \"Maintenance\"\n | \"Inspection\"\n | string;\n\nexport interface WorkOrderEquipment {\n description: string;\n makeModel?: string;\n serialNumber?: string;\n location?: string;\n}\n\nexport interface WorkOrderPart {\n partNumber: string;\n description: string;\n qty: number;\n unitPrice: number;\n}\n\nexport interface WorkOrderLabor {\n description: string;\n technician: string;\n hours: number;\n rate: number;\n}\n\nexport interface WorkOrderData {\n companyName: string;\n companyLogo?: string;\n workOrderNumber: string;\n date: string;\n priority: WorkOrderPriority;\n customer: WorkOrderCustomer;\n technician: string;\n jobType: WorkOrderJobType;\n equipment: WorkOrderEquipment;\n parts: WorkOrderPart[];\n labor: WorkOrderLabor[];\n taxRate?: number;\n technicianNotes?: string;\n customerNotes?: string;\n warrantyInfo?: string;\n accentColor?: string;\n renderingBase?: \"takumi\" | \"forme\";\n}\n", + "content": "export type WorkOrderPriority = \"Low\" | \"Medium\" | \"High\" | \"Urgent\";\n\nexport interface WorkOrderCustomer {\n name: string;\n address: string;\n phone: string;\n email?: string;\n accountNumber?: string;\n}\n\nexport type WorkOrderJobType =\n | \"Repair\"\n | \"Installation\"\n | \"Maintenance\"\n | \"Inspection\"\n | string;\n\nexport interface WorkOrderEquipment {\n description: string;\n makeModel?: string;\n serialNumber?: string;\n location?: string;\n}\n\nexport interface WorkOrderPart {\n partNumber: string;\n description: string;\n qty: number;\n unitPrice: number;\n}\n\nexport interface WorkOrderLabor {\n description: string;\n technician: string;\n hours: number;\n rate: number;\n}\n\nexport interface WorkOrderData {\n companyName: string;\n companyLogo?: string;\n workOrderNumber: string;\n date: string;\n priority: WorkOrderPriority;\n customer: WorkOrderCustomer;\n technician: string;\n jobType: WorkOrderJobType;\n equipment: WorkOrderEquipment;\n parts: WorkOrderPart[];\n labor: WorkOrderLabor[];\n taxRate?: number;\n technicianNotes?: string;\n customerNotes?: string;\n warrantyInfo?: 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/work-order/work-order.types.ts" } diff --git a/apps/web/public/r/registry.json b/apps/web/public/r/registry.json index 4d9e45c..0134f0a 100644 --- a/apps/web/public/r/registry.json +++ b/apps/web/public/r/registry.json @@ -523,8 +523,6 @@ "name": "takumi/event-agenda", "registryDependencies": [ "@angular-pdfcn/takumi/utils", - "@angular-pdfcn/takumi/badge", - "@angular-pdfcn/takumi/page-footer", "@angular-pdfcn/takumi/section", "@angular-pdfcn/takumi/text" ], @@ -717,7 +715,6 @@ "name": "takumi/gift-certificate", "registryDependencies": [ "@angular-pdfcn/takumi/utils", - "@angular-pdfcn/takumi/page-footer", "@angular-pdfcn/takumi/pdf-image", "@angular-pdfcn/takumi/section", "@angular-pdfcn/takumi/text" @@ -1330,7 +1327,7 @@ "type": "registry:theme" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], + "dependencies": ["@formepdf/shared@^0.32.0"], "description": "Theme provider for the forme base", "files": [ { @@ -1345,7 +1342,7 @@ "type": "registry:lib" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], + "dependencies": ["@formepdf/core@^0.32.0", "@formepdf/shared@^0.32.0"], "description": "Theme context and helpers for the forme base", "files": [ { @@ -1380,7 +1377,6 @@ "type": "registry:lib" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Alert PDF component (forme)", "files": [ { @@ -1395,7 +1391,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Badge PDF component (forme)", "files": [ { @@ -1410,7 +1405,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Card PDF component (forme)", "files": [ { @@ -1425,7 +1419,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Data Table PDF component (forme)", "files": [ { @@ -1453,7 +1446,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Divider PDF component (forme)", "files": [ { @@ -1468,7 +1460,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Form PDF component (forme)", "files": [ { @@ -1493,7 +1484,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Graph PDF component (forme)", "files": [ { @@ -1523,7 +1513,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Heading PDF component (forme)", "files": [ { @@ -1538,7 +1527,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Keep Together PDF component (forme)", "files": [ { @@ -1553,7 +1541,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Key Value PDF component (forme)", "files": [ { @@ -1568,7 +1555,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Link PDF component (forme)", "files": [ { @@ -1583,7 +1569,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "List PDF component (forme)", "files": [ { @@ -1608,7 +1593,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Page Break PDF component (forme)", "files": [ { @@ -1623,7 +1607,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Page Footer PDF component (forme)", "files": [ { @@ -1638,7 +1621,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Page Header PDF component (forme)", "files": [ { @@ -1653,7 +1635,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Page Number PDF component (forme)", "files": [ { @@ -1668,7 +1649,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Image PDF component (forme)", "files": [ { @@ -1683,11 +1663,7 @@ "type": "registry:ui" }, { - "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0", - "qrcode@^1.5.4" - ], + "dependencies": ["qrcode@^1.5.4"], "description": "QR code PDF component (forme)", "files": [ { @@ -1703,7 +1679,6 @@ "devDependencies": ["@types/qrcode@^1.5.6"] }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Section PDF component (forme)", "files": [ { @@ -1718,7 +1693,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Signature PDF component (forme)", "files": [ { @@ -1733,7 +1707,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Stack PDF component (forme)", "files": [ { @@ -1748,7 +1721,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Table PDF component (forme)", "files": [ { @@ -1773,7 +1745,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Text PDF component (forme)", "files": [ { @@ -1788,7 +1759,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Watermark PDF component (forme)", "files": [ { @@ -1803,7 +1773,6 @@ "type": "registry:ui" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Event Agenda PDF block (forme)", "files": [ { @@ -1820,7 +1789,6 @@ "name": "forme/event-agenda", "registryDependencies": [ "@angular-pdfcn/forme/utils", - "@angular-pdfcn/forme/page-footer", "@angular-pdfcn/forme/section", "@angular-pdfcn/forme/text" ], @@ -1828,7 +1796,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Invoice Classic PDF block (forme)", "files": [ { @@ -1857,7 +1824,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Invoice Consultant PDF block (forme)", "files": [ { @@ -1884,7 +1850,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Invoice Corporate PDF block (forme)", "files": [ { @@ -1912,7 +1877,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Invoice Creative PDF block (forme)", "files": [ { @@ -1940,7 +1904,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Invoice Minimal PDF block (forme)", "files": [ { @@ -1968,7 +1931,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Invoice Modern PDF block (forme)", "files": [ { @@ -1996,7 +1958,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Packing Slip PDF block (forme)", "files": [ { @@ -2025,7 +1986,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Meeting Minutes PDF block (forme)", "files": [ { @@ -2054,7 +2014,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Press Release PDF block (forme)", "files": [ { @@ -2081,7 +2040,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Gift Certificate PDF block (forme)", "files": [ { @@ -2106,7 +2064,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Medical Intake Form PDF block (forme)", "files": [ { @@ -2137,11 +2094,7 @@ "type": "registry:block" }, { - "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0", - "qrcode@^1.5.4" - ], + "dependencies": ["qrcode@^1.5.4"], "description": "Shipping Label PDF block (forme)", "files": [ { @@ -2166,11 +2119,7 @@ "devDependencies": ["@types/qrcode@^1.5.6"] }, { - "dependencies": [ - "@formepdf/core@^0.25.0", - "@formepdf/shared@^0.25.0", - "qrcode@^1.5.4" - ], + "dependencies": ["qrcode@^1.5.4"], "description": "Event Ticket PDF block (forme)", "files": [ { @@ -2196,7 +2145,6 @@ "devDependencies": ["@types/qrcode@^1.5.6"] }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Report Financial PDF block (forme)", "files": [ { @@ -2233,7 +2181,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Report Marketing PDF block (forme)", "files": [ { @@ -2270,7 +2217,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Report Operations PDF block (forme)", "files": [ { @@ -2307,7 +2253,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Report Security PDF block (forme)", "files": [ { @@ -2344,7 +2289,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Work Order PDF block (forme)", "files": [ { @@ -2375,7 +2319,6 @@ "type": "registry:block" }, { - "dependencies": ["@formepdf/core@^0.25.0", "@formepdf/shared@^0.25.0"], "description": "Lesson Plan PDF block (forme)", "files": [ { diff --git a/apps/web/public/r/takumi/alert.json b/apps/web/public/r/takumi/alert.json index 747da2d..8a76045 100644 --- a/apps/web/public/r/takumi/alert.json +++ b/apps/web/public/r/takumi/alert.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/alert/alert.ts", - "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n TakumiSvg,\n TakumiText,\n TakumiView,\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: [{ breakInside: \"avoid\" as const }, containerStyles]\n .flat()\n .filter(Boolean),\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: [TakumiSvg, TakumiText, TakumiView],\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 { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n TakumiSvg,\n TakumiText,\n TakumiView,\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: [{ breakInside: \"avoid\" as const }, containerStyles]\n .flat()\n .filter(Boolean),\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: [TakumiSvg, TakumiText, TakumiView],\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/takumi/badge.json b/apps/web/public/r/takumi/badge.json index 1fbcff2..8669123 100644 --- a/apps/web/public/r/takumi/badge.json +++ b/apps/web/public/r/takumi/badge.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/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 StyleSheet,\n TakumiText,\n TakumiView,\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: [TakumiText, TakumiView, 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 StyleSheet,\n TakumiText,\n TakumiView,\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: [TakumiText, TakumiView, 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/takumi/card.json b/apps/web/public/r/takumi/card.json index 17ef597..041d056 100644 --- a/apps/web/public/r/takumi/card.json +++ b/apps/web/public/r/takumi/card.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/card/card.ts", - "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n TakumiText,\n TakumiView,\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: [TakumiText, TakumiView],\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 TakumiText,\n TakumiView,\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: [TakumiText, TakumiView],\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/takumi/data-table.json b/apps/web/public/r/takumi/data-table.json index 0e2ed10..300fac3 100644 --- a/apps/web/public/r/takumi/data-table.json +++ b/apps/web/public/r/takumi/data-table.json @@ -14,19 +14,19 @@ "files": [ { "path": "registry/bases/takumi/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/takumi/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 {\n PdfTable,\n TABLE,\n} from \"@/components/pdf/table/table\";\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport { TakumiText } 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, TakumiText, 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 {\n PdfTable,\n TABLE,\n} from \"@/components/pdf/table/table\";\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport { TakumiText } 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, TakumiText, 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/takumi/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 takumi-* primitives (``,\n * ``, etc.), NOT HTML DOM elements.\n */\n render?: TemplateRef>;\n /**\n * Custom footer cell template. Same constraint: takumi-* 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 takumi-* primitives (``,\n * ``, etc.), NOT HTML DOM elements.\n */\n render?: TemplateRef>;\n /**\n * Custom footer cell template. Same constraint: takumi-* 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/takumi/divider.json b/apps/web/public/r/takumi/divider.json index a32885d..9af9622 100644 --- a/apps/web/public/r/takumi/divider.json +++ b/apps/web/public/r/takumi/divider.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/divider/divider.ts", - "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiText,\n TakumiView,\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\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 });\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({ borderBottomColor: resolveColor(color, theme.colors) });\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: [TakumiText, TakumiView],\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 StyleSheet,\n TakumiText,\n TakumiView,\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\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 });\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({ borderBottomColor: resolveColor(color, theme.colors) });\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: [TakumiText, TakumiView],\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/takumi/event-agenda.json b/apps/web/public/r/takumi/event-agenda.json index e78b15d..cdae88d 100644 --- a/apps/web/public/r/takumi/event-agenda.json +++ b/apps/web/public/r/takumi/event-agenda.json @@ -9,21 +9,19 @@ ], "registryDependencies": [ "@angular-pdfcn/takumi/utils", - "@angular-pdfcn/takumi/badge", - "@angular-pdfcn/takumi/page-footer", "@angular-pdfcn/takumi/section", "@angular-pdfcn/takumi/text" ], "files": [ { "path": "registry/bases/takumi/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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n padding: 32,\n position: \"relative\",\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 position: \"relative\",\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: [PdfSection, PdfText, TakumiDocument, TakumiPage, TakumiView],\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 Event Agenda\n {{ data.eventName }}\n {{ data.date }}{{ 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 {{ 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 @if (session.track) {\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})\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n padding: 32,\n position: \"relative\",\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 position: \"relative\",\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: [PdfSection, PdfText, TakumiDocument, TakumiPage, TakumiView],\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 Event Agenda\n {{ data.eventName }}\n {{ data.date }}{{ 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 {{ 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 @if (session.track) {\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})\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/takumi/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/takumi/event-ticket.json b/apps/web/public/r/takumi/event-ticket.json index 3d73193..70d4a05 100644 --- a/apps/web/public/r/takumi/event-ticket.json +++ b/apps/web/public/r/takumi/event-ticket.json @@ -20,13 +20,13 @@ "files": [ { "path": "registry/bases/takumi/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 TakumiDocument,\n TakumiPage,\n TakumiView,\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\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 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 notch: {\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 width: NOTCH_RADIUS * 2,\n },\n organizer: {\n color: quiet,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1.1,\n textTransform: \"uppercase\",\n },\n page: {\n backgroundColor: paper,\n boxSizing: \"border-box\",\n flexDirection: \"row\",\n height: TICKET_SIZE.height,\n overflow: \"hidden\",\n position: \"relative\",\n width: TICKET_SIZE.width,\n },\n pill: {\n backgroundColor: accent,\n borderRadius: 9,\n marginLeft: \"auto\",\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 width: STRIPE_WIDTH,\n },\n stub: {\n alignItems: \"center\",\n backgroundColor: accent,\n borderLeftColor: paper,\n borderLeftStyle: \"dashed\",\n borderLeftWidth: 1.5,\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: [\n PdfImage,\n PdfQRCode,\n PdfText,\n TakumiDocument,\n TakumiPage,\n TakumiView,\n ],\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 @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 \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 NOTCH_RADIUS = NOTCH_RADIUS;\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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\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 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 notch: {\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 width: NOTCH_RADIUS * 2,\n },\n organizer: {\n color: quiet,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1.1,\n textTransform: \"uppercase\",\n },\n page: {\n backgroundColor: paper,\n boxSizing: \"border-box\",\n flexDirection: \"row\",\n height: TICKET_SIZE.height,\n overflow: \"hidden\",\n position: \"relative\",\n width: TICKET_SIZE.width,\n },\n pill: {\n backgroundColor: accent,\n borderRadius: 9,\n marginLeft: \"auto\",\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 width: STRIPE_WIDTH,\n },\n stub: {\n alignItems: \"center\",\n backgroundColor: accent,\n borderLeftColor: paper,\n borderLeftStyle: \"dashed\",\n borderLeftWidth: 1.5,\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: [\n PdfImage,\n PdfQRCode,\n PdfText,\n TakumiDocument,\n TakumiPage,\n TakumiView,\n ],\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 @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 \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 NOTCH_RADIUS = NOTCH_RADIUS;\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/takumi/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/takumi/form.json b/apps/web/public/r/takumi/form.json index 62c992f..e0be4a1 100644 --- a/apps/web/public/r/takumi/form.json +++ b/apps/web/public/r/takumi/form.json @@ -13,19 +13,19 @@ "files": [ { "path": "registry/bases/takumi/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/takumi/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 TakumiText,\n TakumiView,\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: [TakumiText, TakumiView, 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 {{\n group.title\n }}\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 TakumiText,\n TakumiView,\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: [TakumiText, TakumiView, 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 {{\n group.title\n }}\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/takumi/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/takumi/gift-certificate.json b/apps/web/public/r/takumi/gift-certificate.json index 6a158ae..bdd1295 100644 --- a/apps/web/public/r/takumi/gift-certificate.json +++ b/apps/web/public/r/takumi/gift-certificate.json @@ -9,7 +9,6 @@ ], "registryDependencies": [ "@angular-pdfcn/takumi/utils", - "@angular-pdfcn/takumi/page-footer", "@angular-pdfcn/takumi/pdf-image", "@angular-pdfcn/takumi/section", "@angular-pdfcn/takumi/text" @@ -17,13 +16,13 @@ "files": [ { "path": "registry/bases/takumi/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 TakumiView,\n StyleSheet,\n TakumiDocument,\n TakumiPage,\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 boxSizing: \"border-box\",\n minHeight: 595,\n padding: 24,\n paddingBottom: 24,\n position: \"relative\",\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: [\n PdfImage,\n PdfSection,\n PdfText,\n TakumiDocument,\n TakumiPage,\n TakumiView,\n ],\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 @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})\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 TakumiView,\n StyleSheet,\n TakumiDocument,\n TakumiPage,\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 boxSizing: \"border-box\",\n minHeight: 595,\n padding: 24,\n paddingBottom: 24,\n position: \"relative\",\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: [\n PdfImage,\n PdfSection,\n PdfText,\n TakumiDocument,\n TakumiPage,\n TakumiView,\n ],\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 @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})\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/takumi/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/takumi/graph.json b/apps/web/public/r/takumi/graph.json index 4f7a325..c3b7105 100644 --- a/apps/web/public/r/takumi/graph.json +++ b/apps/web/public/r/takumi/graph.json @@ -13,25 +13,25 @@ "files": [ { "path": "registry/bases/takumi/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/takumi/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 TakumiSvg,\n TakumiText,\n TakumiView,\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 Takumi documents using SVG primitives.\n *\n * No external chart libraries are required or used — all rendering is done via\n * Takumi'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: [TakumiSvg, TakumiText, TakumiView, 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 {{\n g.subtitle\n }}\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 TakumiSvg,\n TakumiText,\n TakumiView,\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 Takumi documents using SVG primitives.\n *\n * No external chart libraries are required or used — all rendering is done via\n * Takumi'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: [TakumiSvg, TakumiText, TakumiView, 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 {{\n g.subtitle\n }}\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/takumi/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/takumi/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/takumi/heading.json b/apps/web/public/r/takumi/heading.json index 639b63c..8230dd1 100644 --- a/apps/web/public/r/takumi/heading.json +++ b/apps/web/public/r/takumi/heading.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/heading/heading.ts", - "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiText,\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 styleArray;\n};\n\n@Component({\n imports: [TakumiText],\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 { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiText,\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 styleArray;\n};\n\n@Component({\n imports: [TakumiText],\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/takumi/invoice-classic.json b/apps/web/public/r/takumi/invoice-classic.json index 33b16d1..27316f9 100644 --- a/apps/web/public/r/takumi/invoice-classic.json +++ b/apps/web/public/r/takumi/invoice-classic.json @@ -20,13 +20,13 @@ "files": [ { "path": "registry/bases/takumi/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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 From\n {{ data.companyName }}\n {{ data.companyAddress }}\n {{ data.companyEmail }}\n \n \n Bill To\n {{ data.billTo.name }}\n {{ data.billTo.address }}\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 const theme = this.theme();\n const styles = StyleSheet.create({\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\n },\n });\n return styles;\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 From\n {{ data.companyName }}\n {{ data.companyAddress }}\n {{ data.companyEmail }}\n \n \n Bill To\n {{ data.billTo.name }}\n {{ data.billTo.address }}\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 const theme = this.theme();\n const styles = StyleSheet.create({\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\n },\n });\n return styles;\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/takumi/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/takumi/invoice-consultant.json b/apps/web/public/r/takumi/invoice-consultant.json index 02a673a..13c7840 100644 --- a/apps/web/public/r/takumi/invoice-consultant.json +++ b/apps/web/public/r/takumi/invoice-consultant.json @@ -18,13 +18,13 @@ "files": [ { "path": "registry/bases/takumi/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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 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 boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 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 boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\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/takumi/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/takumi/invoice-corporate.json b/apps/web/public/r/takumi/invoice-corporate.json index 1d65f4a..2f83093 100644 --- a/apps/web/public/r/takumi/invoice-corporate.json +++ b/apps/web/public/r/takumi/invoice-corporate.json @@ -19,13 +19,13 @@ "files": [ { "path": "registry/bases/takumi/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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 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 boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 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 boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\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/takumi/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/takumi/invoice-creative.json b/apps/web/public/r/takumi/invoice-creative.json index d923717..9bf29fd 100644 --- a/apps/web/public/r/takumi/invoice-creative.json +++ b/apps/web/public/r/takumi/invoice-creative.json @@ -19,13 +19,13 @@ "files": [ { "path": "registry/bases/takumi/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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 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 boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 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 boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\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/takumi/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/takumi/invoice-minimal.json b/apps/web/public/r/takumi/invoice-minimal.json index d78761f..b9166cc 100644 --- a/apps/web/public/r/takumi/invoice-minimal.json +++ b/apps/web/public/r/takumi/invoice-minimal.json @@ -19,13 +19,13 @@ "files": [ { "path": "registry/bases/takumi/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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 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: theme.spacing.sectionGap,\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 boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 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: theme.spacing.sectionGap,\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 boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\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/takumi/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/takumi/invoice-modern.json b/apps/web/public/r/takumi/invoice-modern.json index afb4453..4333f98 100644 --- a/apps/web/public/r/takumi/invoice-modern.json +++ b/apps/web/public/r/takumi/invoice-modern.json @@ -19,13 +19,13 @@ "files": [ { "path": "registry/bases/takumi/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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 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 boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 TakumiDocument,\n TakumiPage,\n TakumiView,\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 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 boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\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/takumi/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/takumi/keep-together.json b/apps/web/public/r/takumi/keep-together.json index 417185c..f0ad2d5 100644 --- a/apps/web/public/r/takumi/keep-together.json +++ b/apps/web/public/r/takumi/keep-together.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/keep-together/keep-together.ts", - "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { TakumiView } 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: [TakumiView],\n selector: \"pdf-keep-together\",\n template: ``,\n})\nexport class PdfKeepTogether {\n readonly minPresenceAhead = input();\n readonly style = input();\n\n protected readonly keepTogetherStyle = computed(\n () => [{ breakInside: \"avoid\" }, this.style()].filter(Boolean) as never\n );\n}\n", + "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { TakumiView } 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: [TakumiView],\n selector: \"pdf-keep-together\",\n template: ``,\n})\nexport class PdfKeepTogether {\n readonly minPresenceAhead = input();\n readonly style = input();\n\n protected readonly keepTogetherStyle = computed(\n () => [{ breakInside: \"avoid\" }, this.style()].filter(Boolean) as never\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/keep-together/keep-together.ts" } diff --git a/apps/web/public/r/takumi/key-value.json b/apps/web/public/r/takumi/key-value.json index 46dabb4..aafa2da 100644 --- a/apps/web/public/r/takumi/key-value.json +++ b/apps/web/public/r/takumi/key-value.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/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 StyleSheet,\n TakumiText,\n TakumiView,\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\" },\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 rowHorizontal: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n paddingVertical: spacing[1],\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 && !isLast) {\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 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: [TakumiText, TakumiView],\n selector: \"pdf-key-value\",\n template: `\n \n @for (row of layout().rows; track row.item.key) {\n \n {{ row.item.key }}\n {{\n row.item.value\n }}\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 StyleSheet,\n TakumiText,\n TakumiView,\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\" },\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 rowHorizontal: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n paddingVertical: spacing[1],\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 && !isLast) {\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 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: [TakumiText, TakumiView],\n selector: \"pdf-key-value\",\n template: `\n \n @for (row of layout().rows; track row.item.key) {\n \n {{ row.item.key }}\n {{\n row.item.value\n }}\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\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/key-value/key-value.ts" } diff --git a/apps/web/public/r/takumi/lesson-plan.json b/apps/web/public/r/takumi/lesson-plan.json index f477981..23f5d37 100644 --- a/apps/web/public/r/takumi/lesson-plan.json +++ b/apps/web/public/r/takumi/lesson-plan.json @@ -18,13 +18,13 @@ "files": [ { "path": "registry/bases/takumi/blocks/lesson-plan/lesson-plan.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { LessonPlanProps } from \"./lesson-plan.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: LessonPlanProps = {\n accentColor: \"#7c3aed\",\n assessment: {\n formative: [\"Exit ticket\", \"Observation during guided practice\"],\n summative: [\"Chapter quiz\"],\n },\n date: \"September 15, 2026\",\n differentiation: [\n \"Provide equation mats for visual learners\",\n \"Allow calculator use for students with processing difficulties\",\n \"Offer extension problems for advanced learners\",\n ],\n duration: \"50 minutes\",\n essentialQuestion:\n \"How can we represent real-world relationships using linear equations?\",\n gradeLevel: \"8th Grade\",\n homework: \"Complete worksheet problems 11-20\",\n lessonTitle: \"Introduction to Linear Equations\",\n materials: [\"Graph paper\", \"Rulers\", \"Calculator\", \"Whiteboard markers\"],\n objectives: [\n \"Define linear equations\",\n \"Graph linear equations on a coordinate plane\",\n \"Solve simple linear equations\",\n ],\n sequence: [\n {\n activity: \"Warm-up\",\n description: \"Review solving one-step equations\",\n notes: \"5 problems on the board\",\n time: \"5 min\",\n },\n {\n activity: \"Introduction\",\n description: \"Define linear equations, show examples\",\n notes: \"Use real-world context\",\n time: \"10 min\",\n },\n {\n activity: \"Guided Practice\",\n description: \"Work through 3 examples together\",\n notes: \"Check for understanding\",\n time: \"15 min\",\n },\n {\n activity: \"Independent Practice\",\n description: \"Complete worksheet problems 1-10\",\n notes: \"Circulate and support\",\n time: \"15 min\",\n },\n {\n activity: \"Closure\",\n description: \"Exit ticket: solve one linear equation\",\n notes: \"Collect before dismissal\",\n time: \"5 min\",\n },\n ],\n standards: [\"CCSS.MATH.8.EE.B.6\", \"CCSS.MATH.8.EE.C.7\"],\n subject: \"Mathematics\",\n teacherName: \"Ms. Johnson\",\n topic: \"Linear Equations\",\n};\n\nconst REFLECTION_LINE_KEYS = Array.from(\n { length: 8 },\n (_, line) => `reflection-line-${line}`\n);\n\nconst COLUMN_WIDTHS = { activity: 104, notes: 140, time: 56 };\n\nconst lessonPlanLayout = (theme: PdfcnTheme, data: LessonPlanProps) => {\n const rule = {\n borderBottomColor: theme.colors.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n };\n\n const styles = StyleSheet.create({\n block: {\n marginBottom: 16,\n },\n colHalf: {\n flex: 2,\n paddingRight: 20,\n },\n colQuarter: {\n flex: 1,\n paddingRight: 10,\n },\n infoRow: {\n ...rule,\n flexDirection: \"row\",\n marginBottom: 16,\n paddingBottom: 12,\n },\n intro: {\n marginBottom: 3,\n },\n label: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 4,\n },\n listMarker: {\n width: 12,\n },\n listRow: {\n flexDirection: \"row\",\n marginBottom: 3,\n },\n listText: {\n flex: 1,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\n },\n reflectionLine: {\n ...rule,\n height: 24,\n },\n row: {\n flexDirection: \"row\",\n },\n });\n\n const info = [\n { label: \"Subject\", value: data.subject },\n { label: \"Grade Level\", value: data.gradeLevel },\n { label: \"Teacher\", value: data.teacherName },\n { label: \"Duration\", value: data.duration },\n ];\n\n const footerText = `${data.subject} · ${data.gradeLevel} · ${data.lessonTitle}`;\n\n return { footerText, info, styles };\n};\n\n@Component({\n imports: [\n TakumiDocument,\n TakumiPage,\n TakumiView,\n NgTemplateOutlet,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-lesson-plan-content\",\n template: `\n @let data = this.data();\n @let styles = layout().styles;\n \n {{ label }}\n \n \n @let list = items ?? [];\n @if (list.length > 0) {\n @for (item of list; track $index; let index = $index) {\n \n \n {{\n numbered ? index + 1 + \".\" : \"•\"\n }}\n \n \n {{ item }}\n \n \n }\n } @else {\n —\n }\n \n \n \n \n\n \n @for (item of layout().info; track item.label) {\n \n \n {{\n item.value\n }}\n \n }\n \n\n @if (data.essentialQuestion) {\n \n \n {{\n data.essentialQuestion\n }}\n \n }\n\n \n \n \n Students will be able to (SWBAT):\n \n \n @if (data.standards?.length) {\n \n \n \n \n }\n \n \n \n \n \n\n \n \n \n \n \n Time\n Activity\n Description\n Notes\n \n \n \n @for (item of data.sequence; track $index) {\n \n {{\n item.time\n }}\n {{\n item.activity\n }}\n {{ item.description }}\n {{\n item.notes ?? \"—\"\n }}\n \n }\n \n \n \n\n \n \n\n \n @if (data.differentiation?.length) {\n \n \n \n \n }\n\n \n \n \n \n \n \n \n \n \n \n\n @if (data.homework) {\n \n \n {{ data.homework }}\n \n }\n\n \n \n @if (data.reflection) {\n {{ data.reflection }}\n }\n @for (key of REFLECTION_LINE_KEYS; track key) {\n \n }\n \n\n \n \n \n `,\n})\nexport class LessonPlanContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly COLUMN_WIDTHS = COLUMN_WIDTHS;\n protected readonly REFLECTION_LINE_KEYS = REFLECTION_LINE_KEYS;\n\n protected readonly layout = computed(() =>\n lessonPlanLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [LessonPlanContent, PdfcnThemeProvider],\n selector: \"pdf-lesson-plan\",\n template: `\n \n \n \n `,\n})\nexport class LessonPlanDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly mergedData = computed(\n (): LessonPlanProps => ({ ...sampleData, ...this.data() })\n );\n}\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { LessonPlanProps } from \"./lesson-plan.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: LessonPlanProps = {\n accentColor: \"#7c3aed\",\n assessment: {\n formative: [\"Exit ticket\", \"Observation during guided practice\"],\n summative: [\"Chapter quiz\"],\n },\n date: \"September 15, 2026\",\n differentiation: [\n \"Provide equation mats for visual learners\",\n \"Allow calculator use for students with processing difficulties\",\n \"Offer extension problems for advanced learners\",\n ],\n duration: \"50 minutes\",\n essentialQuestion:\n \"How can we represent real-world relationships using linear equations?\",\n gradeLevel: \"8th Grade\",\n homework: \"Complete worksheet problems 11-20\",\n lessonTitle: \"Introduction to Linear Equations\",\n materials: [\"Graph paper\", \"Rulers\", \"Calculator\", \"Whiteboard markers\"],\n objectives: [\n \"Define linear equations\",\n \"Graph linear equations on a coordinate plane\",\n \"Solve simple linear equations\",\n ],\n sequence: [\n {\n activity: \"Warm-up\",\n description: \"Review solving one-step equations\",\n notes: \"5 problems on the board\",\n time: \"5 min\",\n },\n {\n activity: \"Introduction\",\n description: \"Define linear equations, show examples\",\n notes: \"Use real-world context\",\n time: \"10 min\",\n },\n {\n activity: \"Guided Practice\",\n description: \"Work through 3 examples together\",\n notes: \"Check for understanding\",\n time: \"15 min\",\n },\n {\n activity: \"Independent Practice\",\n description: \"Complete worksheet problems 1-10\",\n notes: \"Circulate and support\",\n time: \"15 min\",\n },\n {\n activity: \"Closure\",\n description: \"Exit ticket: solve one linear equation\",\n notes: \"Collect before dismissal\",\n time: \"5 min\",\n },\n ],\n standards: [\"CCSS.MATH.8.EE.B.6\", \"CCSS.MATH.8.EE.C.7\"],\n subject: \"Mathematics\",\n teacherName: \"Ms. Johnson\",\n topic: \"Linear Equations\",\n};\n\nconst REFLECTION_LINE_KEYS = Array.from(\n { length: 8 },\n (_, line) => `reflection-line-${line}`\n);\n\nconst COLUMN_WIDTHS = { activity: 104, notes: 140, time: 56 };\n\nconst lessonPlanLayout = (theme: PdfcnTheme, data: LessonPlanProps) => {\n const rule = {\n borderBottomColor: theme.colors.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n };\n\n const styles = StyleSheet.create({\n block: {\n marginBottom: 16,\n },\n colHalf: {\n flex: 2,\n paddingRight: 20,\n },\n colQuarter: {\n flex: 1,\n paddingRight: 10,\n },\n infoRow: {\n ...rule,\n flexDirection: \"row\",\n marginBottom: 16,\n paddingBottom: 12,\n },\n intro: {\n marginBottom: 3,\n },\n label: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 4,\n },\n listMarker: {\n width: 12,\n },\n listRow: {\n flexDirection: \"row\",\n marginBottom: 3,\n },\n listText: {\n flex: 1,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\n },\n reflectionLine: {\n ...rule,\n height: 24,\n },\n row: {\n flexDirection: \"row\",\n },\n });\n\n const info = [\n { label: \"Subject\", value: data.subject },\n { label: \"Grade Level\", value: data.gradeLevel },\n { label: \"Teacher\", value: data.teacherName },\n { label: \"Duration\", value: data.duration },\n ];\n\n const footerText = `${data.subject} · ${data.gradeLevel} · ${data.lessonTitle}`;\n\n return { footerText, info, styles };\n};\n\n@Component({\n imports: [\n TakumiDocument,\n TakumiPage,\n TakumiView,\n NgTemplateOutlet,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-lesson-plan-content\",\n template: `\n @let data = this.data();\n @let styles = layout().styles;\n \n {{ label }}\n \n \n @let list = items ?? [];\n @if (list.length > 0) {\n @for (item of list; track $index; let index = $index) {\n \n \n {{\n numbered ? index + 1 + \".\" : \"•\"\n }}\n \n \n {{ item }}\n \n \n }\n } @else {\n —\n }\n \n \n \n \n\n \n @for (item of layout().info; track item.label) {\n \n \n {{\n item.value\n }}\n \n }\n \n\n @if (data.essentialQuestion) {\n \n \n {{\n data.essentialQuestion\n }}\n \n }\n\n \n \n \n Students will be able to (SWBAT):\n \n \n @if (data.standards?.length) {\n \n \n \n \n }\n \n \n \n \n \n\n \n \n \n \n \n Time\n Activity\n Description\n Notes\n \n \n \n @for (item of data.sequence; track $index) {\n \n {{\n item.time\n }}\n {{\n item.activity\n }}\n {{ item.description }}\n {{\n item.notes ?? \"—\"\n }}\n \n }\n \n \n \n\n \n \n\n \n @if (data.differentiation?.length) {\n \n \n \n \n }\n\n \n \n \n \n \n \n \n \n \n \n\n @if (data.homework) {\n \n \n {{ data.homework }}\n \n }\n\n \n \n @if (data.reflection) {\n {{ data.reflection }}\n }\n @for (key of REFLECTION_LINE_KEYS; track key) {\n \n }\n \n\n \n \n \n `,\n})\nexport class LessonPlanContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly COLUMN_WIDTHS = COLUMN_WIDTHS;\n protected readonly REFLECTION_LINE_KEYS = REFLECTION_LINE_KEYS;\n\n protected readonly layout = computed(() =>\n lessonPlanLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [LessonPlanContent, PdfcnThemeProvider],\n selector: \"pdf-lesson-plan\",\n template: `\n \n \n \n `,\n})\nexport class LessonPlanDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly mergedData = computed(\n (): LessonPlanProps => ({ ...sampleData, ...this.data() })\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:block", "target": "components/pdf/blocks/lesson-plan/lesson-plan.ts" }, { "path": "registry/bases/takumi/blocks/lesson-plan/lesson-plan.types.ts", - "content": "export interface LessonPlanSequenceItem {\n time: string;\n activity: string;\n description: string;\n notes?: string;\n}\n\nexport interface LessonPlanAssessment {\n formative?: string[];\n summative?: string[];\n}\n\nexport interface LessonPlanProps {\n subject: string;\n gradeLevel: string;\n lessonTitle: string;\n date: string;\n teacherName: string;\n duration: string;\n topic?: string;\n essentialQuestion?: string;\n objectives: string[];\n standards?: string[];\n materials: string[];\n sequence: LessonPlanSequenceItem[];\n differentiation?: string[];\n assessment: LessonPlanAssessment;\n homework?: string;\n reflection?: string;\n accentColor?: string;\n renderingBase?: \"takumi\" | \"forme\";\n}\n", + "content": "export interface LessonPlanSequenceItem {\n time: string;\n activity: string;\n description: string;\n notes?: string;\n}\n\nexport interface LessonPlanAssessment {\n formative?: string[];\n summative?: string[];\n}\n\nexport interface LessonPlanProps {\n subject: string;\n gradeLevel: string;\n lessonTitle: string;\n date: string;\n teacherName: string;\n duration: string;\n topic?: string;\n essentialQuestion?: string;\n objectives: string[];\n standards?: string[];\n materials: string[];\n sequence: LessonPlanSequenceItem[];\n differentiation?: string[];\n assessment: LessonPlanAssessment;\n homework?: string;\n reflection?: 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/lesson-plan/lesson-plan.types.ts" } diff --git a/apps/web/public/r/takumi/link.json b/apps/web/public/r/takumi/link.json index 426a453..f340696 100644 --- a/apps/web/public/r/takumi/link.json +++ b/apps/web/public/r/takumi/link.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/link/link.ts", - "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiLink,\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 LinkVariant = \"default\" | \"muted\" | \"primary\";\nexport type LinkUnderline = \"always\" | \"none\";\n\n/**\n * Clickable hyperlink for PDF documents.\n * Props - `href` | `children` | `align` | `color` | `variant` | `underline` | `style`\n * @see {@link LinkProps}\n */\nexport interface LinkProps extends PDFComponentProps {\n href: string;\n /**\n * @default 'left'\n */\n align?: \"left\" | \"center\" | \"right\";\n color?: string;\n /**\n * @default 'default'\n */\n variant?: LinkVariant;\n /**\n * @default 'always'\n */\n underline?: LinkUnderline;\n}\n\nconst createLinkStyles = (t: PdfcnTheme) => {\n const { fontWeights } = t.primitives;\n const base = {\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n lineHeight: t.typography.body.lineHeight,\n marginBottom: t.spacing.paragraphGap,\n };\n return StyleSheet.create({\n default: {\n ...base,\n color: t.colors.accent,\n fontWeight: fontWeights.medium,\n textDecoration: \"underline\",\n },\n muted: {\n ...base,\n color: t.colors.mutedForeground,\n fontWeight: fontWeights.regular,\n textDecoration: \"underline\",\n },\n primary: {\n ...base,\n color: t.colors.primary,\n fontWeight: fontWeights.semibold,\n textDecoration: \"underline\",\n },\n underlineAlways: { textDecoration: \"underline\" },\n underlineNone: { textDecoration: \"none\" },\n });\n};\n\nconst linkStyle = (\n theme: PdfcnTheme,\n {\n align,\n color,\n variant = \"default\",\n underline,\n style,\n }: Omit\n) => {\n const styles = createLinkStyles(theme);\n const variantMap = {\n default: styles.default,\n muted: styles.muted,\n primary: styles.primary,\n };\n const underlineMap = {\n always: styles.underlineAlways,\n none: styles.underlineNone,\n };\n const styleArray: Style[] = [variantMap[variant]];\n if (underline && underline in underlineMap) {\n styleArray.push(underlineMap[underline]);\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 styleArray;\n};\n\n@Component({\n imports: [TakumiLink],\n selector: \"pdf-link\",\n template: ``,\n})\nexport class PdfLink {\n readonly href = input.required();\n readonly align = input();\n readonly color = input();\n readonly variant = input(\"default\");\n readonly underline = input();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly linkStyle = computed(() =>\n linkStyle(this.theme(), {\n align: this.align(),\n color: this.color(),\n style: this.style(),\n underline: this.underline(),\n variant: this.variant(),\n })\n );\n}\n", + "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiLink,\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 LinkVariant = \"default\" | \"muted\" | \"primary\";\nexport type LinkUnderline = \"always\" | \"none\";\n\n/**\n * Clickable hyperlink for PDF documents.\n * Props - `href` | `children` | `align` | `color` | `variant` | `underline` | `style`\n * @see {@link LinkProps}\n */\nexport interface LinkProps extends PDFComponentProps {\n href: string;\n /**\n * @default 'left'\n */\n align?: \"left\" | \"center\" | \"right\";\n color?: string;\n /**\n * @default 'default'\n */\n variant?: LinkVariant;\n /**\n * @default 'always'\n */\n underline?: LinkUnderline;\n}\n\nconst createLinkStyles = (t: PdfcnTheme) => {\n const { fontWeights } = t.primitives;\n const base = {\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n lineHeight: t.typography.body.lineHeight,\n marginBottom: t.spacing.paragraphGap,\n };\n return StyleSheet.create({\n default: {\n ...base,\n color: t.colors.accent,\n fontWeight: fontWeights.medium,\n textDecoration: \"underline\",\n },\n muted: {\n ...base,\n color: t.colors.mutedForeground,\n fontWeight: fontWeights.regular,\n textDecoration: \"underline\",\n },\n primary: {\n ...base,\n color: t.colors.primary,\n fontWeight: fontWeights.semibold,\n textDecoration: \"underline\",\n },\n underlineAlways: { textDecoration: \"underline\" },\n underlineNone: { textDecoration: \"none\" },\n });\n};\n\nconst linkStyle = (\n theme: PdfcnTheme,\n {\n align,\n color,\n variant = \"default\",\n underline,\n style,\n }: Omit\n) => {\n const styles = createLinkStyles(theme);\n const variantMap = {\n default: styles.default,\n muted: styles.muted,\n primary: styles.primary,\n };\n const underlineMap = {\n always: styles.underlineAlways,\n none: styles.underlineNone,\n };\n const styleArray: Style[] = [variantMap[variant]];\n if (underline && underline in underlineMap) {\n styleArray.push(underlineMap[underline]);\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 styleArray;\n};\n\n@Component({\n imports: [TakumiLink],\n selector: \"pdf-link\",\n template: ``,\n})\nexport class PdfLink {\n readonly href = input.required();\n readonly align = input();\n readonly color = input();\n readonly variant = input(\"default\");\n readonly underline = input();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly linkStyle = computed(() =>\n linkStyle(this.theme(), {\n align: this.align(),\n color: this.color(),\n style: this.style(),\n underline: this.underline(),\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/link/link.ts" } diff --git a/apps/web/public/r/takumi/list.json b/apps/web/public/r/takumi/list.json index 20a47e9..8182cd5 100644 --- a/apps/web/public/r/takumi/list.json +++ b/apps/web/public/r/takumi/list.json @@ -13,19 +13,19 @@ "files": [ { "path": "registry/bases/takumi/components/list/list.styles.ts", - "content": "import { StyleSheet } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Creates all list styles derived from the active theme.\n * @param t - The resolved PdfcnTheme instance.\n */\nexport const createListStyles = (t: PdfcnTheme) => {\n const { borderRadius, spacing, fontWeights, typography } = t.primitives;\n\n return StyleSheet.create({\n checkBox: {\n alignItems: \"center\",\n backgroundColor: t.colors.background,\n borderColor: t.colors.border,\n borderRadius: 3,\n borderStyle: \"solid\",\n borderWidth: 1.5,\n height: spacing[4],\n justifyContent: \"center\",\n marginRight: spacing[2],\n width: spacing[4],\n },\n checkBoxChecked: {\n backgroundColor: t.colors.success,\n borderColor: t.colors.success,\n },\n childrenContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n marginLeft: spacing[5],\n marginTop: spacing[1],\n },\n container: {\n display: \"flex\",\n flexDirection: \"column\",\n marginBottom: t.spacing.componentGap,\n width: \"100%\",\n },\n descriptiveAccent: {\n backgroundColor: t.colors.primary,\n borderRadius: borderRadius.sm,\n marginRight: spacing[3],\n minHeight: spacing[4],\n width: 3,\n },\n descriptiveContent: {\n flex: 1,\n },\n descriptiveDesc: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n lineHeight: t.typography.body.lineHeight,\n marginTop: 1,\n },\n descriptiveTitle: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: t.typography.body.lineHeight,\n },\n iconBox: {\n alignItems: \"center\",\n backgroundColor: t.colors.primary,\n borderRadius: borderRadius.md,\n height: spacing[5],\n justifyContent: \"center\",\n marginRight: spacing[2],\n width: spacing[5],\n },\n iconMark: {\n color: t.colors.primaryForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: 9,\n fontWeight: fontWeights.bold,\n },\n itemRow: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n },\n itemRowCenter: {\n alignItems: \"center\",\n flexDirection: \"row\",\n },\n itemRowGapMd: { marginBottom: spacing[3] },\n itemRowGapSm: { marginBottom: spacing[2] },\n itemRowGapXs: { marginBottom: spacing[1] },\n itemText: {\n // No flex here — Text nodes with flex shorthand get flexBasis:0, which causes\n // Yoga to under-measure multi-line text height → overlapping rows.\n // flex:1 must live on the wrapping View, not on the Text itself.\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 itemTextBold: {\n fontWeight: fontWeights.semibold,\n },\n itemTextSub: {\n // Same: no flex — see itemText comment.\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize - 0.5,\n lineHeight: t.typography.body.lineHeight,\n },\n itemTextWrap: {\n // Companion to itemText / itemTextSub. Apply this to the View that wraps\n // the Text so flex expansion happens at the View level, not the Text level.\n flex: 1,\n },\n markerBulletDot: {\n backgroundColor: t.colors.primary,\n borderRadius: 3,\n height: 5,\n width: 5,\n },\n markerBulletSubDot: {\n backgroundColor: \"transparent\",\n borderColor: t.colors.mutedForeground,\n borderRadius: 2,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 4,\n width: 4,\n },\n markerBulletSubWrap: {\n alignItems: \"center\",\n justifyContent: \"flex-start\",\n marginTop: spacing[1],\n width: spacing[4],\n },\n markerBulletWrap: {\n alignItems: \"center\",\n justifyContent: \"flex-start\",\n marginTop: spacing[1],\n width: spacing[4],\n },\n markerNumberBadge: {\n alignItems: \"center\",\n backgroundColor: t.colors.primary,\n borderRadius: spacing[5],\n height: spacing[5],\n justifyContent: \"center\",\n marginRight: spacing[2],\n width: spacing[5],\n },\n markerNumberText: {\n color: t.colors.primaryForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.bold,\n },\n });\n};\n", + "content": "import { StyleSheet } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Creates all list styles derived from the active theme.\n * @param t - The resolved PdfcnTheme instance.\n */\nexport const createListStyles = (t: PdfcnTheme) => {\n const { borderRadius, spacing, fontWeights, typography } = t.primitives;\n\n return StyleSheet.create({\n checkBox: {\n alignItems: \"center\",\n backgroundColor: t.colors.background,\n borderColor: t.colors.border,\n borderRadius: 3,\n borderStyle: \"solid\",\n borderWidth: 1.5,\n height: spacing[4],\n justifyContent: \"center\",\n marginRight: spacing[2],\n width: spacing[4],\n },\n checkBoxChecked: {\n backgroundColor: t.colors.success,\n borderColor: t.colors.success,\n },\n childrenContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n marginLeft: spacing[5],\n marginTop: spacing[1],\n },\n container: {\n display: \"flex\",\n flexDirection: \"column\",\n marginBottom: t.spacing.componentGap,\n width: \"100%\",\n },\n descriptiveAccent: {\n backgroundColor: t.colors.primary,\n borderRadius: borderRadius.sm,\n marginRight: spacing[3],\n minHeight: spacing[4],\n width: 3,\n },\n descriptiveContent: {\n flex: 1,\n },\n descriptiveDesc: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n lineHeight: t.typography.body.lineHeight,\n marginTop: 1,\n },\n descriptiveTitle: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: t.typography.body.lineHeight,\n },\n iconBox: {\n alignItems: \"center\",\n backgroundColor: t.colors.primary,\n borderRadius: borderRadius.md,\n height: spacing[5],\n justifyContent: \"center\",\n marginRight: spacing[2],\n width: spacing[5],\n },\n iconMark: {\n color: t.colors.primaryForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: 9,\n fontWeight: fontWeights.bold,\n },\n itemRow: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n },\n itemRowCenter: {\n alignItems: \"center\",\n flexDirection: \"row\",\n },\n itemRowGapMd: { marginBottom: spacing[3] },\n itemRowGapSm: { marginBottom: spacing[2] },\n itemRowGapXs: { marginBottom: spacing[1] },\n itemText: {\n // No flex here — Text nodes with flex shorthand get flexBasis:0, which causes\n // Yoga to under-measure multi-line text height → overlapping rows.\n // flex:1 must live on the wrapping View, not on the Text itself.\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 itemTextBold: {\n fontWeight: fontWeights.semibold,\n },\n itemTextSub: {\n // Same: no flex — see itemText comment.\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize - 0.5,\n lineHeight: t.typography.body.lineHeight,\n },\n itemTextWrap: {\n // Companion to itemText / itemTextSub. Apply this to the View that wraps\n // the Text so flex expansion happens at the View level, not the Text level.\n flex: 1,\n },\n markerBulletDot: {\n backgroundColor: t.colors.primary,\n borderRadius: 3,\n height: 5,\n width: 5,\n },\n markerBulletSubDot: {\n backgroundColor: \"transparent\",\n borderColor: t.colors.mutedForeground,\n borderRadius: 2,\n borderStyle: \"solid\",\n borderWidth: 1,\n height: 4,\n width: 4,\n },\n markerBulletSubWrap: {\n alignItems: \"center\",\n justifyContent: \"flex-start\",\n marginTop: spacing[1],\n width: spacing[4],\n },\n markerBulletWrap: {\n alignItems: \"center\",\n justifyContent: \"flex-start\",\n marginTop: spacing[1],\n width: spacing[4],\n },\n markerNumberBadge: {\n alignItems: \"center\",\n backgroundColor: t.colors.primary,\n borderRadius: spacing[5],\n height: spacing[5],\n justifyContent: \"center\",\n marginRight: spacing[2],\n width: spacing[5],\n },\n markerNumberText: {\n color: t.colors.primaryForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.bold,\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/list/list.styles.ts" }, { "path": "registry/bases/takumi/components/list/list.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 TakumiText,\n TakumiView,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { createListStyles } from \"./list.styles\";\nimport type { ListItem, ListVariant, PdfListProps } from \"./list.types\";\n\ntype Styles = ReturnType;\ntype GapProp = \"xs\" | \"sm\" | \"md\";\n\n/** One rendered row. Bullet and multi-level rows carry a marker and nested rows. */\ninterface ListRow {\n variant: ListVariant;\n item: ListItem;\n rowStyle: Style[];\n label?: string;\n boxStyle?: Style[];\n marker?: { wrap: Style; dot: Style };\n textStyle?: Style[];\n children?: { style: Style | undefined; rows: (ListRow | null)[] } | null;\n}\n\nconst getGapStyle = (gap: GapProp, styles: Styles): Style => {\n if (gap === \"xs\") {\n return styles.itemRowGapXs;\n }\n if (gap === \"md\") {\n return styles.itemRowGapMd;\n }\n return styles.itemRowGapSm;\n};\n\nconst buildRowStyles = (\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles,\n align: \"start\" | \"center\" = \"start\"\n): Style[] => {\n const row: Style[] = [\n align === \"center\" ? styles.itemRowCenter : styles.itemRow,\n ];\n if (index !== total - 1) {\n row.push(getGapStyle(gap, styles));\n }\n return row;\n};\n\n/** Bullet dot marker — solid filled for level 0, outline ring for nested levels. */\nconst dotMarker = (level: number, styles: Styles) =>\n level === 0\n ? { dot: styles.markerBulletDot, wrap: styles.markerBulletWrap }\n : { dot: styles.markerBulletSubDot, wrap: styles.markerBulletSubWrap };\n\n// eslint-disable-next-line no-use-before-define, prefer-const\nlet renderBulletItem: (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles,\n level: number\n) => ListRow;\n// eslint-disable-next-line no-use-before-define, prefer-const\nlet renderMultiLevelItem: (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles,\n level: number\n) => ListRow;\n\nconst renderNumberedItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => ({\n item,\n label: `${index + 1}`,\n rowStyle: buildRowStyles(index, total, gap, styles, \"center\"),\n variant: \"numbered\",\n});\n\nconst renderChecklistItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => {\n const isChecked = item.checked ?? true;\n return {\n boxStyle: [styles.checkBox, isChecked ? styles.checkBoxChecked : {}],\n item,\n rowStyle: buildRowStyles(index, total, gap, styles, \"center\"),\n variant: \"checklist\",\n };\n};\n\nconst renderIconItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => ({\n item,\n rowStyle: buildRowStyles(index, total, gap, styles, \"center\"),\n variant: \"icon\",\n});\n\nconst renderDescriptiveItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => ({\n item,\n rowStyle: buildRowStyles(index, total, gap, styles),\n variant: \"descriptive\",\n});\n\nconst renderItem = (\n item: ListItem,\n index: number,\n total: number,\n variant: ListVariant,\n gap: GapProp,\n styles: Styles,\n level: number\n): ListRow | null => {\n switch (variant) {\n case \"bullet\": {\n return renderBulletItem(item, index, total, gap, styles, level);\n }\n case \"numbered\": {\n return renderNumberedItem(item, index, total, gap, styles);\n }\n case \"checklist\": {\n return renderChecklistItem(item, index, total, gap, styles);\n }\n case \"icon\": {\n return renderIconItem(item, index, total, gap, styles);\n }\n case \"multi-level\": {\n return renderMultiLevelItem(item, index, total, gap, styles, level);\n }\n case \"descriptive\": {\n return renderDescriptiveItem(item, index, total, gap, styles);\n }\n default: {\n break;\n }\n }\n return null;\n};\n\nconst renderItemList = (\n items: ListItem[],\n variant: ListVariant,\n gap: GapProp,\n styles: Styles,\n level: number\n) => ({\n rows: items.map((item, index) =>\n renderItem(item, index, items.length, variant, gap, styles, level)\n ),\n style: level > 0 ? styles.childrenContainer : undefined,\n});\n\nrenderBulletItem = (item, index, total, gap, styles, level) => ({\n children:\n item.children && item.children.length > 0\n ? renderItemList(item.children, \"bullet\", gap, styles, level + 1)\n : null,\n item,\n marker: dotMarker(level, styles),\n rowStyle: buildRowStyles(index, total, gap, styles),\n textStyle: [styles.itemText],\n variant: \"bullet\",\n});\n\nrenderMultiLevelItem = (item, index, total, gap, styles, level) => ({\n children:\n item.children && item.children.length > 0\n ? renderItemList(item.children, \"multi-level\", gap, styles, level + 1)\n : null,\n item,\n marker: dotMarker(level, styles),\n rowStyle: buildRowStyles(index, total, gap, styles),\n textStyle: [\n level === 0 ? styles.itemText : styles.itemTextSub,\n level === 0 ? styles.itemTextBold : {},\n ],\n variant: \"multi-level\",\n});\n\nconst listLayout = (\n theme: PdfcnTheme,\n {\n items,\n variant = \"bullet\",\n gap = \"sm\",\n style,\n _level = 0,\n }: Omit\n) => {\n const styles = createListStyles(theme);\n\n const containerStyles: Style[] = [styles.container];\n if (_level > 0) {\n containerStyles.push(styles.childrenContainer);\n }\n const styleArray = style ? [...containerStyles, style] : containerStyles;\n\n return {\n container: styleArray,\n rows: items.map((item, index) =>\n renderItem(item, index, items.length, variant, gap, styles, _level)\n ),\n styles,\n };\n};\n\n/** List of items with multiple style variants including bullet, numbered, checklist, and descriptive. */\n@Component({\n imports: [TakumiText, TakumiView, NgTemplateOutlet],\n selector: \"pdf-list\",\n template: `\n @let s = layout().styles;\n \n \n \n \n @for (row of asRows(rows); track $index) {\n @if (row) {\n @switch (row.variant) {\n @case (\"numbered\") {\n \n \n {{\n row.label\n }}\n \n \n {{\n row.item.text\n }}\n \n \n }\n @case (\"checklist\") {\n \n \n \n {{\n row.item.text\n }}\n \n \n }\n @case (\"icon\") {\n \n \n ★\n \n \n {{\n row.item.text\n }}\n \n \n }\n @case (\"descriptive\") {\n \n \n \n {{\n row.item.text\n }}\n @if (row.item.description) {\n {{\n row.item.description\n }}\n }\n \n \n }\n @default {\n \n \n \n \n \n \n {{\n row.item.text\n }}\n \n \n @if (row.children) {\n \n \n \n }\n \n }\n }\n }\n }\n \n `,\n})\nexport class PdfList {\n readonly items = input.required();\n readonly variant = input(\"bullet\");\n readonly gap = input(\"sm\");\n readonly style = input();\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly _level = input(0);\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n listLayout(this.theme(), {\n _level: this._level(),\n gap: this.gap(),\n items: this.items(),\n style: this.style(),\n variant: this.variant(),\n })\n );\n\n protected readonly asRows = (rows: (ListRow | null)[]) => rows;\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 TakumiText,\n TakumiView,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { createListStyles } from \"./list.styles\";\nimport type { ListItem, ListVariant, PdfListProps } from \"./list.types\";\n\ntype Styles = ReturnType;\ntype GapProp = \"xs\" | \"sm\" | \"md\";\n\n/** One rendered row. Bullet and multi-level rows carry a marker and nested rows. */\ninterface ListRow {\n variant: ListVariant;\n item: ListItem;\n rowStyle: Style[];\n label?: string;\n boxStyle?: Style[];\n marker?: { wrap: Style; dot: Style };\n textStyle?: Style[];\n children?: { style: Style | undefined; rows: (ListRow | null)[] } | null;\n}\n\nconst getGapStyle = (gap: GapProp, styles: Styles): Style => {\n if (gap === \"xs\") {\n return styles.itemRowGapXs;\n }\n if (gap === \"md\") {\n return styles.itemRowGapMd;\n }\n return styles.itemRowGapSm;\n};\n\nconst buildRowStyles = (\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles,\n align: \"start\" | \"center\" = \"start\"\n): Style[] => {\n const row: Style[] = [\n align === \"center\" ? styles.itemRowCenter : styles.itemRow,\n ];\n if (index !== total - 1) {\n row.push(getGapStyle(gap, styles));\n }\n return row;\n};\n\n/** Bullet dot marker — solid filled for level 0, outline ring for nested levels. */\nconst dotMarker = (level: number, styles: Styles) =>\n level === 0\n ? { dot: styles.markerBulletDot, wrap: styles.markerBulletWrap }\n : { dot: styles.markerBulletSubDot, wrap: styles.markerBulletSubWrap };\n\n// eslint-disable-next-line no-use-before-define, prefer-const\nlet renderBulletItem: (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles,\n level: number\n) => ListRow;\n// eslint-disable-next-line no-use-before-define, prefer-const\nlet renderMultiLevelItem: (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles,\n level: number\n) => ListRow;\n\nconst renderNumberedItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => ({\n item,\n label: `${index + 1}`,\n rowStyle: buildRowStyles(index, total, gap, styles, \"center\"),\n variant: \"numbered\",\n});\n\nconst renderChecklistItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => {\n const isChecked = item.checked ?? true;\n return {\n boxStyle: [styles.checkBox, isChecked ? styles.checkBoxChecked : {}],\n item,\n rowStyle: buildRowStyles(index, total, gap, styles, \"center\"),\n variant: \"checklist\",\n };\n};\n\nconst renderIconItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => ({\n item,\n rowStyle: buildRowStyles(index, total, gap, styles, \"center\"),\n variant: \"icon\",\n});\n\nconst renderDescriptiveItem = (\n item: ListItem,\n index: number,\n total: number,\n gap: GapProp,\n styles: Styles\n): ListRow => ({\n item,\n rowStyle: buildRowStyles(index, total, gap, styles),\n variant: \"descriptive\",\n});\n\nconst renderItem = (\n item: ListItem,\n index: number,\n total: number,\n variant: ListVariant,\n gap: GapProp,\n styles: Styles,\n level: number\n): ListRow | null => {\n switch (variant) {\n case \"bullet\": {\n return renderBulletItem(item, index, total, gap, styles, level);\n }\n case \"numbered\": {\n return renderNumberedItem(item, index, total, gap, styles);\n }\n case \"checklist\": {\n return renderChecklistItem(item, index, total, gap, styles);\n }\n case \"icon\": {\n return renderIconItem(item, index, total, gap, styles);\n }\n case \"multi-level\": {\n return renderMultiLevelItem(item, index, total, gap, styles, level);\n }\n case \"descriptive\": {\n return renderDescriptiveItem(item, index, total, gap, styles);\n }\n default: {\n break;\n }\n }\n return null;\n};\n\nconst renderItemList = (\n items: ListItem[],\n variant: ListVariant,\n gap: GapProp,\n styles: Styles,\n level: number\n) => ({\n rows: items.map((item, index) =>\n renderItem(item, index, items.length, variant, gap, styles, level)\n ),\n style: level > 0 ? styles.childrenContainer : undefined,\n});\n\nrenderBulletItem = (item, index, total, gap, styles, level) => ({\n children:\n item.children && item.children.length > 0\n ? renderItemList(item.children, \"bullet\", gap, styles, level + 1)\n : null,\n item,\n marker: dotMarker(level, styles),\n rowStyle: buildRowStyles(index, total, gap, styles),\n textStyle: [styles.itemText],\n variant: \"bullet\",\n});\n\nrenderMultiLevelItem = (item, index, total, gap, styles, level) => ({\n children:\n item.children && item.children.length > 0\n ? renderItemList(item.children, \"multi-level\", gap, styles, level + 1)\n : null,\n item,\n marker: dotMarker(level, styles),\n rowStyle: buildRowStyles(index, total, gap, styles),\n textStyle: [\n level === 0 ? styles.itemText : styles.itemTextSub,\n level === 0 ? styles.itemTextBold : {},\n ],\n variant: \"multi-level\",\n});\n\nconst listLayout = (\n theme: PdfcnTheme,\n {\n items,\n variant = \"bullet\",\n gap = \"sm\",\n style,\n _level = 0,\n }: Omit\n) => {\n const styles = createListStyles(theme);\n\n const containerStyles: Style[] = [styles.container];\n if (_level > 0) {\n containerStyles.push(styles.childrenContainer);\n }\n const styleArray = style ? [...containerStyles, style] : containerStyles;\n\n return {\n container: styleArray,\n rows: items.map((item, index) =>\n renderItem(item, index, items.length, variant, gap, styles, _level)\n ),\n styles,\n };\n};\n\n/** List of items with multiple style variants including bullet, numbered, checklist, and descriptive. */\n@Component({\n imports: [TakumiText, TakumiView, NgTemplateOutlet],\n selector: \"pdf-list\",\n template: `\n @let s = layout().styles;\n \n \n \n \n @for (row of asRows(rows); track $index) {\n @if (row) {\n @switch (row.variant) {\n @case (\"numbered\") {\n \n \n {{\n row.label\n }}\n \n \n {{\n row.item.text\n }}\n \n \n }\n @case (\"checklist\") {\n \n \n \n {{\n row.item.text\n }}\n \n \n }\n @case (\"icon\") {\n \n \n ★\n \n \n {{\n row.item.text\n }}\n \n \n }\n @case (\"descriptive\") {\n \n \n \n {{\n row.item.text\n }}\n @if (row.item.description) {\n {{\n row.item.description\n }}\n }\n \n \n }\n @default {\n \n \n \n \n \n \n {{\n row.item.text\n }}\n \n \n @if (row.children) {\n \n \n \n }\n \n }\n }\n }\n }\n \n `,\n})\nexport class PdfList {\n readonly items = input.required();\n readonly variant = input(\"bullet\");\n readonly gap = input(\"sm\");\n readonly style = input();\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly _level = input(0);\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n listLayout(this.theme(), {\n _level: this._level(),\n gap: this.gap(),\n items: this.items(),\n style: this.style(),\n variant: this.variant(),\n })\n );\n\n protected readonly asRows = (rows: (ListRow | null)[]) => rows;\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/list/list.ts" }, { "path": "registry/bases/takumi/components/list/list.types.ts", - "content": "import type { Style } from \"@/lib/pdf-primitives\";\n\n/** List visual style variant. */\nexport type ListVariant =\n | \"bullet\"\n | \"numbered\"\n | \"checklist\"\n | \"icon\"\n | \"multi-level\"\n | \"descriptive\";\n\n/**\n * A single list item, optionally with nested children.\n * Props - `text` | `description` | `checked` | `children`\n * @see {@link ListItem}\n */\nexport interface ListItem {\n text: string;\n description?: string;\n checked?: boolean;\n children?: ListItem[];\n}\n\n/**\n * List of items with multiple style variants including bullet, numbered, checklist, and descriptive.\n * Props - `items` | `variant` | `gap` | `style` | `_level` | `noWrap`\n * @see {@link PdfListProps}\n */\nexport interface PdfListProps {\n items: ListItem[];\n /**\n * @default 'bullet'\n */\n variant?: ListVariant;\n /**\n * @default 'sm'\n */\n gap?: \"xs\" | \"sm\" | \"md\";\n style?: Style;\n _level?: number;\n /**\n * @default false\n */\n noWrap?: boolean;\n}\n", + "content": "import type { Style } from \"@/lib/pdf-primitives\";\n\n/** List visual style variant. */\nexport type ListVariant =\n | \"bullet\"\n | \"numbered\"\n | \"checklist\"\n | \"icon\"\n | \"multi-level\"\n | \"descriptive\";\n\n/**\n * A single list item, optionally with nested children.\n * Props - `text` | `description` | `checked` | `children`\n * @see {@link ListItem}\n */\nexport interface ListItem {\n text: string;\n description?: string;\n checked?: boolean;\n children?: ListItem[];\n}\n\n/**\n * List of items with multiple style variants including bullet, numbered, checklist, and descriptive.\n * Props - `items` | `variant` | `gap` | `style` | `_level` | `noWrap`\n * @see {@link PdfListProps}\n */\nexport interface PdfListProps {\n items: ListItem[];\n /**\n * @default 'bullet'\n */\n variant?: ListVariant;\n /**\n * @default 'sm'\n */\n gap?: \"xs\" | \"sm\" | \"md\";\n style?: Style;\n _level?: number;\n /**\n * @default false\n */\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/list/list.types.ts" } diff --git a/apps/web/public/r/takumi/medical-intake-form.json b/apps/web/public/r/takumi/medical-intake-form.json index da5cd2f..1945dc7 100644 --- a/apps/web/public/r/takumi/medical-intake-form.json +++ b/apps/web/public/r/takumi/medical-intake-form.json @@ -22,13 +22,13 @@ "files": [ { "path": "registry/bases/takumi/blocks/medical-intake-form/medical-intake-form.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { PdfForm } from \"@/components/pdf/form/form\";\nimport type { PdfFormGroup } from \"@/components/pdf/form/form.types\";\nimport { PdfList } from \"@/components/pdf/list/list\";\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 { PdfSignatureBlock } from \"@/components/pdf/signature/signature\";\nimport type { SignatureSigner } from \"@/components/pdf/signature/signature\";\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { MedicalIntakeFormProps } from \"./medical-intake-form.types\";\n\nconst FORM_VERSION = \"Form v1.0 · Revised 09/2026\";\nconst FORM_STYLE = { marginBottom: 0 };\n\nconst MEDICAL_CONDITIONS = [\n \"Diabetes\",\n \"High Blood Pressure\",\n \"Heart Disease\",\n \"Asthma\",\n \"COPD\",\n \"Cancer\",\n \"Stroke\",\n \"Thyroid Disorder\",\n \"Kidney Disease\",\n \"Liver Disease\",\n \"Seizures / Epilepsy\",\n \"Other\",\n];\n\nconst CONSENT_ACKNOWLEDGMENTS = [\n { checked: false, text: \"I have read and understand the consent above.\" },\n { checked: false, text: \"I have received the Notice of Privacy Practices.\" },\n];\n\nconst MEDICATION_ROWS = [\n \"medication-1\",\n \"medication-2\",\n \"medication-3\",\n \"medication-4\",\n];\n\nconst ALLERGY_ROWS = [\"allergy-1\", \"allergy-2\", \"allergy-3\"];\n\nconst blankChecklist = (labels: string[]) =>\n labels.map((text) => ({ checked: false, text }));\n\nconst PERSONAL_INFO_GROUPS: PdfFormGroup[] = [\n {\n fields: [\n { height: 14, label: \"Full Name\" },\n { height: 14, hint: \"DD / MM / YYYY\", label: \"Date of Birth\" },\n { height: 14, label: \"Gender\" },\n { height: 14, hint: \"+1 (555) 000-0000\", label: \"Phone Number\" },\n { height: 14, label: \"Email Address\" },\n ],\n layout: \"two-column\",\n title: \"Patient Information\",\n },\n {\n fields: [\n { height: 14, label: \"Street Address\", width: \"100%\" },\n { height: 14, label: \"City\" },\n { height: 14, label: \"State / Province\" },\n { height: 14, label: \"Postal Code\" },\n ],\n layout: \"two-column\",\n title: \"Address\",\n },\n];\n\nconst EMERGENCY_CONTACT_GROUPS: PdfFormGroup[] = [\n {\n fields: [\n { height: 14, label: \"Emergency Contact Name\" },\n { height: 14, label: \"Relationship\" },\n { height: 14, label: \"Phone Number\" },\n ],\n layout: \"two-column\",\n title: \"Emergency Contact\",\n },\n];\n\nconst INSURANCE_GROUPS: PdfFormGroup[] = [\n {\n fields: [\n { height: 14, label: \"Insurance Provider\" },\n { height: 14, label: \"Policy Number\" },\n { height: 14, label: \"Group Number\" },\n { height: 14, label: \"Subscriber Name\" },\n ],\n layout: \"two-column\",\n title: \"Insurance\",\n },\n];\n\nconst MEDICAL_HISTORY_COLUMNS = [\n blankChecklist(MEDICAL_CONDITIONS.slice(0, 4)),\n blankChecklist(MEDICAL_CONDITIONS.slice(4, 8)),\n blankChecklist(MEDICAL_CONDITIONS.slice(8)),\n];\n\nconst CONSENT_SIGNERS: [SignatureSigner, SignatureSigner] = [\n { label: \"Patient / Guardian Signature\" },\n { label: \"Date\" },\n];\n\nconst createIntakeStyles = (t: PdfcnTheme) =>\n StyleSheet.create({\n column: { flex: 1 },\n consentText: {\n fontSize: t.primitives.typography.xs,\n lineHeight: 1.4,\n marginBottom: 6,\n },\n labelText: { fontSize: 9, fontWeight: \"bold\", letterSpacing: 0.6 },\n page: {\n backgroundColor: t.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n paddingBottom: t.spacing.page.marginBottom,\n paddingLeft: t.spacing.page.marginLeft,\n paddingRight: t.spacing.page.marginRight,\n paddingTop: t.spacing.page.marginTop,\n position: \"relative\",\n },\n pageBreak: { breakAfter: \"page\" },\n pageTwo: { paddingBottom: 44, paddingTop: 24 },\n pageTwoHeader: {\n alignItems: \"flex-end\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n },\n reasonBox: {\n borderColor: t.colors.border,\n borderRadius: t.primitives.borderRadius.sm,\n borderStyle: \"solid\",\n borderWidth: 1,\n minHeight: 40,\n },\n row: { flexDirection: \"row\", gap: 20 },\n section: { marginBottom: 4 },\n signature: { marginBottom: 0, marginTop: 8 },\n title: { fontSize: 13, fontWeight: \"bold\" },\n });\n\ntype IntakeSections = Required<\n Pick<\n MedicalIntakeFormProps,\n | \"allergies\"\n | \"consent\"\n | \"emergencyContact\"\n | \"insurance\"\n | \"medicalHistory\"\n | \"medications\"\n | \"personalInfo\"\n | \"reasonForVisit\"\n >\n>;\n\nconst resolveSections = (props: MedicalIntakeFormProps): IntakeSections => ({\n allergies: props.allergies ?? true,\n consent: props.consent ?? true,\n emergencyContact: props.emergencyContact ?? true,\n insurance: props.insurance ?? true,\n medicalHistory: props.medicalHistory ?? true,\n medications: props.medications ?? true,\n personalInfo: props.personalInfo ?? true,\n reasonForVisit: props.reasonForVisit ?? true,\n});\n\nconst hasSecondPage = (sections: IntakeSections) =>\n sections.allergies ||\n sections.consent ||\n sections.medications ||\n sections.reasonForVisit;\n\nconst intakeLayout = (theme: PdfcnTheme, props: MedicalIntakeFormProps) => {\n const styles = createIntakeStyles(theme);\n const sections = resolveSections(props);\n const accent = props.accentColor\n ? resolveColor(props.accentColor, theme.colors)\n : theme.colors.primary;\n const totalPages = hasSecondPage(sections) ? 2 : 1;\n\n return {\n firstPage: totalPages > 1 ? [styles.page, styles.pageBreak] : styles.page,\n footerPadding: theme.spacing.page.marginLeft,\n secondPage: [styles.page, styles.pageTwo],\n sectionRule: {\n borderBottomColor: accent,\n borderBottomStyle: \"solid\" as const,\n borderBottomWidth: 1,\n marginBottom: 4,\n paddingBottom: 2,\n },\n sections,\n styles,\n totalPages,\n };\n};\n\n@Component({\n imports: [\n TakumiDocument,\n TakumiPage,\n TakumiView,\n NgTemplateOutlet,\n PdfForm,\n PdfImage,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfSignatureBlock,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-medical-intake-form-content\",\n template: `\n @let props = this.props();\n @let l = layout();\n @let styles = l.styles;\n \n \n {{\n label\n }}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n @if (l.sections.personalInfo) {\n \n }\n @if (l.sections.emergencyContact) {\n \n }\n @if (l.sections.insurance) {\n \n }\n \n \n @if (l.totalPages > 1) {\n \n \n {{\n props.clinicName + \" — Patient Intake Form (continued)\"\n }}\n {{\n props.clinicPhone\n }}\n \n @if (l.sections.medicalHistory) {\n \n \n \n @for (items of MEDICAL_HISTORY_COLUMNS; track $index) {\n \n \n \n }\n \n \n }\n @if (l.sections.medications) {\n \n \n \n \n \n Medication\n Dosage\n Frequency\n Prescribing Doctor\n \n \n \n @for (row of MEDICATION_ROWS; track row) {\n \n \n \n \n \n \n }\n \n \n \n }\n @if (l.sections.allergies) {\n \n \n \n \n \n Allergen\n Reaction\n Severity\n \n \n \n @for (row of ALLERGY_ROWS; track row) {\n \n \n \n \n \n }\n \n \n \n }\n @if (l.sections.reasonForVisit) {\n \n \n \n \n }\n @if (l.sections.consent) {\n \n \n \n {{ consentText() }}\n \n \n \n \n }\n \n \n }\n \n `,\n})\nexport class MedicalIntakeFormContent {\n readonly props = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly ALLERGY_ROWS = ALLERGY_ROWS;\n protected readonly CONSENT_ACKNOWLEDGMENTS = CONSENT_ACKNOWLEDGMENTS;\n protected readonly CONSENT_SIGNERS = CONSENT_SIGNERS;\n protected readonly EMERGENCY_CONTACT_GROUPS = EMERGENCY_CONTACT_GROUPS;\n protected readonly FORM_STYLE = FORM_STYLE;\n protected readonly FORM_VERSION = FORM_VERSION;\n protected readonly INSURANCE_GROUPS = INSURANCE_GROUPS;\n protected readonly MEDICAL_HISTORY_COLUMNS = MEDICAL_HISTORY_COLUMNS;\n protected readonly MEDICATION_ROWS = MEDICATION_ROWS;\n protected readonly PERSONAL_INFO_GROUPS = PERSONAL_INFO_GROUPS;\n\n protected readonly layout = computed(() =>\n intakeLayout(this.theme(), this.props())\n );\n\n protected readonly consentText = computed(\n () =>\n `I authorize ${this.props().clinicName} to provide treatment and to release the information required to process insurance claims for this visit, and I acknowledge that I have received the Notice of Privacy Practices (HIPAA) explaining how my health information may be used.`\n );\n}\n\n/**\n * Print-ready medical intake form with patient, emergency contact, insurance,\n * medical history, medication, allergy, reason for visit, and consent\n * sections. Every section can be hidden through its boolean prop, and all\n * fields are left blank for the patient to complete by hand.\n */\n@Component({\n imports: [MedicalIntakeFormContent, PdfcnThemeProvider],\n selector: \"pdf-medical-intake-form\",\n template: `\n \n \n \n `,\n})\nexport class MedicalIntakeFormDocument {\n readonly clinicName = input.required();\n readonly clinicLogo = input();\n readonly clinicAddress = input();\n readonly clinicPhone = input();\n readonly personalInfo = input(true, { transform: booleanAttribute });\n readonly emergencyContact = input(true, { transform: booleanAttribute });\n readonly insurance = input(true, { transform: booleanAttribute });\n readonly medicalHistory = input(true, { transform: booleanAttribute });\n readonly medications = input(true, { transform: booleanAttribute });\n readonly allergies = input(true, { transform: booleanAttribute });\n readonly reasonForVisit = input(true, { transform: booleanAttribute });\n readonly consent = input(true, { transform: booleanAttribute });\n readonly accentColor = input();\n readonly theme = input();\n\n protected readonly props = computed(\n (): MedicalIntakeFormProps => ({\n accentColor: this.accentColor(),\n allergies: this.allergies(),\n clinicAddress: this.clinicAddress(),\n clinicLogo: this.clinicLogo(),\n clinicName: this.clinicName(),\n clinicPhone: this.clinicPhone(),\n consent: this.consent(),\n emergencyContact: this.emergencyContact(),\n insurance: this.insurance(),\n medicalHistory: this.medicalHistory(),\n medications: this.medications(),\n personalInfo: this.personalInfo(),\n reasonForVisit: this.reasonForVisit(),\n })\n );\n}\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { PdfForm } from \"@/components/pdf/form/form\";\nimport type { PdfFormGroup } from \"@/components/pdf/form/form.types\";\nimport { PdfList } from \"@/components/pdf/list/list\";\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 { PdfSignatureBlock } from \"@/components/pdf/signature/signature\";\nimport type { SignatureSigner } from \"@/components/pdf/signature/signature\";\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { MedicalIntakeFormProps } from \"./medical-intake-form.types\";\n\nconst FORM_VERSION = \"Form v1.0 · Revised 09/2026\";\nconst FORM_STYLE = { marginBottom: 0 };\n\nconst MEDICAL_CONDITIONS = [\n \"Diabetes\",\n \"High Blood Pressure\",\n \"Heart Disease\",\n \"Asthma\",\n \"COPD\",\n \"Cancer\",\n \"Stroke\",\n \"Thyroid Disorder\",\n \"Kidney Disease\",\n \"Liver Disease\",\n \"Seizures / Epilepsy\",\n \"Other\",\n];\n\nconst CONSENT_ACKNOWLEDGMENTS = [\n { checked: false, text: \"I have read and understand the consent above.\" },\n { checked: false, text: \"I have received the Notice of Privacy Practices.\" },\n];\n\nconst MEDICATION_ROWS = [\n \"medication-1\",\n \"medication-2\",\n \"medication-3\",\n \"medication-4\",\n];\n\nconst ALLERGY_ROWS = [\"allergy-1\", \"allergy-2\", \"allergy-3\"];\n\nconst blankChecklist = (labels: string[]) =>\n labels.map((text) => ({ checked: false, text }));\n\nconst PERSONAL_INFO_GROUPS: PdfFormGroup[] = [\n {\n fields: [\n { height: 14, label: \"Full Name\" },\n { height: 14, hint: \"DD / MM / YYYY\", label: \"Date of Birth\" },\n { height: 14, label: \"Gender\" },\n { height: 14, hint: \"+1 (555) 000-0000\", label: \"Phone Number\" },\n { height: 14, label: \"Email Address\" },\n ],\n layout: \"two-column\",\n title: \"Patient Information\",\n },\n {\n fields: [\n { height: 14, label: \"Street Address\", width: \"100%\" },\n { height: 14, label: \"City\" },\n { height: 14, label: \"State / Province\" },\n { height: 14, label: \"Postal Code\" },\n ],\n layout: \"two-column\",\n title: \"Address\",\n },\n];\n\nconst EMERGENCY_CONTACT_GROUPS: PdfFormGroup[] = [\n {\n fields: [\n { height: 14, label: \"Emergency Contact Name\" },\n { height: 14, label: \"Relationship\" },\n { height: 14, label: \"Phone Number\" },\n ],\n layout: \"two-column\",\n title: \"Emergency Contact\",\n },\n];\n\nconst INSURANCE_GROUPS: PdfFormGroup[] = [\n {\n fields: [\n { height: 14, label: \"Insurance Provider\" },\n { height: 14, label: \"Policy Number\" },\n { height: 14, label: \"Group Number\" },\n { height: 14, label: \"Subscriber Name\" },\n ],\n layout: \"two-column\",\n title: \"Insurance\",\n },\n];\n\nconst MEDICAL_HISTORY_COLUMNS = [\n blankChecklist(MEDICAL_CONDITIONS.slice(0, 4)),\n blankChecklist(MEDICAL_CONDITIONS.slice(4, 8)),\n blankChecklist(MEDICAL_CONDITIONS.slice(8)),\n];\n\nconst CONSENT_SIGNERS: [SignatureSigner, SignatureSigner] = [\n { label: \"Patient / Guardian Signature\" },\n { label: \"Date\" },\n];\n\nconst createIntakeStyles = (t: PdfcnTheme) =>\n StyleSheet.create({\n column: { flex: 1 },\n consentText: {\n fontSize: t.primitives.typography.xs,\n lineHeight: 1.4,\n marginBottom: 6,\n },\n labelText: { fontSize: 9, fontWeight: \"bold\", letterSpacing: 0.6 },\n page: {\n backgroundColor: t.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n paddingBottom: t.spacing.page.marginBottom,\n paddingLeft: t.spacing.page.marginLeft,\n paddingRight: t.spacing.page.marginRight,\n paddingTop: t.spacing.page.marginTop,\n position: \"relative\",\n },\n pageBreak: { breakAfter: \"page\" },\n pageTwo: { paddingBottom: 44, paddingTop: 24 },\n pageTwoHeader: {\n alignItems: \"flex-end\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n },\n reasonBox: {\n borderColor: t.colors.border,\n borderRadius: t.primitives.borderRadius.sm,\n borderStyle: \"solid\",\n borderWidth: 1,\n minHeight: 40,\n },\n row: { flexDirection: \"row\", gap: 20 },\n section: { marginBottom: 4 },\n signature: { marginBottom: 0, marginTop: 8 },\n title: { fontSize: 13, fontWeight: \"bold\" },\n });\n\ntype IntakeSections = Required<\n Pick<\n MedicalIntakeFormProps,\n | \"allergies\"\n | \"consent\"\n | \"emergencyContact\"\n | \"insurance\"\n | \"medicalHistory\"\n | \"medications\"\n | \"personalInfo\"\n | \"reasonForVisit\"\n >\n>;\n\nconst resolveSections = (props: MedicalIntakeFormProps): IntakeSections => ({\n allergies: props.allergies ?? true,\n consent: props.consent ?? true,\n emergencyContact: props.emergencyContact ?? true,\n insurance: props.insurance ?? true,\n medicalHistory: props.medicalHistory ?? true,\n medications: props.medications ?? true,\n personalInfo: props.personalInfo ?? true,\n reasonForVisit: props.reasonForVisit ?? true,\n});\n\nconst hasSecondPage = (sections: IntakeSections) =>\n sections.allergies ||\n sections.consent ||\n sections.medications ||\n sections.reasonForVisit;\n\nconst intakeLayout = (theme: PdfcnTheme, props: MedicalIntakeFormProps) => {\n const styles = createIntakeStyles(theme);\n const sections = resolveSections(props);\n const accent = props.accentColor\n ? resolveColor(props.accentColor, theme.colors)\n : theme.colors.primary;\n const totalPages = hasSecondPage(sections) ? 2 : 1;\n\n return {\n firstPage: totalPages > 1 ? [styles.page, styles.pageBreak] : styles.page,\n footerPadding: theme.spacing.page.marginLeft,\n secondPage: [styles.page, styles.pageTwo],\n sectionRule: {\n borderBottomColor: accent,\n borderBottomStyle: \"solid\" as const,\n borderBottomWidth: 1,\n marginBottom: 4,\n paddingBottom: 2,\n },\n sections,\n styles,\n totalPages,\n };\n};\n\n@Component({\n imports: [\n TakumiDocument,\n TakumiPage,\n TakumiView,\n NgTemplateOutlet,\n PdfForm,\n PdfImage,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfSignatureBlock,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-medical-intake-form-content\",\n template: `\n @let props = this.props();\n @let l = layout();\n @let styles = l.styles;\n \n \n {{\n label\n }}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n @if (l.sections.personalInfo) {\n \n }\n @if (l.sections.emergencyContact) {\n \n }\n @if (l.sections.insurance) {\n \n }\n \n \n @if (l.totalPages > 1) {\n \n \n {{\n props.clinicName + \" — Patient Intake Form (continued)\"\n }}\n {{\n props.clinicPhone\n }}\n \n @if (l.sections.medicalHistory) {\n \n \n \n @for (items of MEDICAL_HISTORY_COLUMNS; track $index) {\n \n \n \n }\n \n \n }\n @if (l.sections.medications) {\n \n \n \n \n \n Medication\n Dosage\n Frequency\n Prescribing Doctor\n \n \n \n @for (row of MEDICATION_ROWS; track row) {\n \n \n \n \n \n \n }\n \n \n \n }\n @if (l.sections.allergies) {\n \n \n \n \n \n Allergen\n Reaction\n Severity\n \n \n \n @for (row of ALLERGY_ROWS; track row) {\n \n \n \n \n \n }\n \n \n \n }\n @if (l.sections.reasonForVisit) {\n \n \n \n \n }\n @if (l.sections.consent) {\n \n \n \n {{ consentText() }}\n \n \n \n \n }\n \n \n }\n \n `,\n})\nexport class MedicalIntakeFormContent {\n readonly props = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly ALLERGY_ROWS = ALLERGY_ROWS;\n protected readonly CONSENT_ACKNOWLEDGMENTS = CONSENT_ACKNOWLEDGMENTS;\n protected readonly CONSENT_SIGNERS = CONSENT_SIGNERS;\n protected readonly EMERGENCY_CONTACT_GROUPS = EMERGENCY_CONTACT_GROUPS;\n protected readonly FORM_STYLE = FORM_STYLE;\n protected readonly FORM_VERSION = FORM_VERSION;\n protected readonly INSURANCE_GROUPS = INSURANCE_GROUPS;\n protected readonly MEDICAL_HISTORY_COLUMNS = MEDICAL_HISTORY_COLUMNS;\n protected readonly MEDICATION_ROWS = MEDICATION_ROWS;\n protected readonly PERSONAL_INFO_GROUPS = PERSONAL_INFO_GROUPS;\n\n protected readonly layout = computed(() =>\n intakeLayout(this.theme(), this.props())\n );\n\n protected readonly consentText = computed(\n () =>\n `I authorize ${this.props().clinicName} to provide treatment and to release the information required to process insurance claims for this visit, and I acknowledge that I have received the Notice of Privacy Practices (HIPAA) explaining how my health information may be used.`\n );\n}\n\n/**\n * Print-ready medical intake form with patient, emergency contact, insurance,\n * medical history, medication, allergy, reason for visit, and consent\n * sections. Every section can be hidden through its boolean prop, and all\n * fields are left blank for the patient to complete by hand.\n */\n@Component({\n imports: [MedicalIntakeFormContent, PdfcnThemeProvider],\n selector: \"pdf-medical-intake-form\",\n template: `\n \n \n \n `,\n})\nexport class MedicalIntakeFormDocument {\n readonly clinicName = input.required();\n readonly clinicLogo = input();\n readonly clinicAddress = input();\n readonly clinicPhone = input();\n readonly personalInfo = input(true, { transform: booleanAttribute });\n readonly emergencyContact = input(true, { transform: booleanAttribute });\n readonly insurance = input(true, { transform: booleanAttribute });\n readonly medicalHistory = input(true, { transform: booleanAttribute });\n readonly medications = input(true, { transform: booleanAttribute });\n readonly allergies = input(true, { transform: booleanAttribute });\n readonly reasonForVisit = input(true, { transform: booleanAttribute });\n readonly consent = input(true, { transform: booleanAttribute });\n readonly accentColor = input();\n readonly theme = input();\n\n protected readonly props = computed(\n (): MedicalIntakeFormProps => ({\n accentColor: this.accentColor(),\n allergies: this.allergies(),\n clinicAddress: this.clinicAddress(),\n clinicLogo: this.clinicLogo(),\n clinicName: this.clinicName(),\n clinicPhone: this.clinicPhone(),\n consent: this.consent(),\n emergencyContact: this.emergencyContact(),\n insurance: this.insurance(),\n medicalHistory: this.medicalHistory(),\n medications: this.medications(),\n personalInfo: this.personalInfo(),\n reasonForVisit: this.reasonForVisit(),\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:block", "target": "components/pdf/blocks/medical-intake-form/medical-intake-form.ts" }, { "path": "registry/bases/takumi/blocks/medical-intake-form/medical-intake-form.types.ts", - "content": "import type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Medical intake form properties.\n * Props - `clinicName` | `clinicLogo` | `clinicAddress` | `clinicPhone` |\n * `personalInfo` | `emergencyContact` | `insurance` | `medicalHistory` |\n * `medications` | `allergies` | `reasonForVisit` | `consent` | `accentColor` | `theme`\n * @see {@link MedicalIntakeFormDocument}\n */\nexport interface MedicalIntakeFormProps {\n clinicName: string;\n clinicLogo?: string;\n clinicAddress?: string;\n clinicPhone?: string;\n /**\n * @default true\n */\n personalInfo?: boolean;\n /**\n * @default true\n */\n emergencyContact?: boolean;\n /**\n * @default true\n */\n insurance?: boolean;\n /**\n * @default true\n */\n medicalHistory?: boolean;\n /**\n * @default true\n */\n medications?: boolean;\n /**\n * @default true\n */\n allergies?: boolean;\n /**\n * @default true\n */\n reasonForVisit?: boolean;\n /**\n * @default true\n */\n consent?: boolean;\n /**\n * Theme color token (e.g. `\"primary\"`) or raw CSS color (e.g. `\"#0d9488\"`)\n * applied to section rules, table accents, and the consent callout.\n */\n accentColor?: string;\n theme?: PdfcnTheme;\n}\n", + "content": "import type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Medical intake form properties.\n * Props - `clinicName` | `clinicLogo` | `clinicAddress` | `clinicPhone` |\n * `personalInfo` | `emergencyContact` | `insurance` | `medicalHistory` |\n * `medications` | `allergies` | `reasonForVisit` | `consent` | `accentColor` | `theme`\n * @see {@link MedicalIntakeFormDocument}\n */\nexport interface MedicalIntakeFormProps {\n clinicName: string;\n clinicLogo?: string;\n clinicAddress?: string;\n clinicPhone?: string;\n /**\n * @default true\n */\n personalInfo?: boolean;\n /**\n * @default true\n */\n emergencyContact?: boolean;\n /**\n * @default true\n */\n insurance?: boolean;\n /**\n * @default true\n */\n medicalHistory?: boolean;\n /**\n * @default true\n */\n medications?: boolean;\n /**\n * @default true\n */\n allergies?: boolean;\n /**\n * @default true\n */\n reasonForVisit?: boolean;\n /**\n * @default true\n */\n consent?: boolean;\n /**\n * Theme color token (e.g. `\"primary\"`) or raw CSS color (e.g. `\"#0d9488\"`)\n * applied to section rules, table accents, and the consent callout.\n */\n accentColor?: string;\n theme?: PdfcnTheme;\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/medical-intake-form/medical-intake-form.types.ts" } diff --git a/apps/web/public/r/takumi/meeting-minutes.json b/apps/web/public/r/takumi/meeting-minutes.json index 2af079b..67c4f2e 100644 --- a/apps/web/public/r/takumi/meeting-minutes.json +++ b/apps/web/public/r/takumi/meeting-minutes.json @@ -20,13 +20,13 @@ "files": [ { "path": "registry/bases/takumi/blocks/meeting-minutes/meeting-minutes.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfList } from \"@/components/pdf/list/list\";\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type {\n MeetingMinutesActionStatus,\n MeetingMinutesProps,\n} from \"./meeting-minutes.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: MeetingMinutesProps = {\n absent: [{ name: \"Casey Wu\", role: \"QA Lead\" }],\n accentColor: \"#0891b2\",\n actionItems: [\n {\n dueDate: \"Sep 19, 2026\",\n owner: \"Jordan Lee\",\n status: \"In Progress\",\n task: \"Create pdfme integration RFC\",\n },\n {\n dueDate: \"Sep 22, 2026\",\n owner: \"Sam Patel\",\n status: \"Not Started\",\n task: \"Design community page wireframes\",\n },\n {\n dueDate: \"Sep 26, 2026\",\n owner: \"Alex Kim\",\n status: \"Complete\",\n task: \"Share Q2 outcomes deck with stakeholders\",\n },\n ],\n agenda: [\n \"Review Q2 outcomes\",\n \"Q3 feature priorities\",\n \"Resource allocation\",\n \"Timeline and milestones\",\n ],\n attendees: [\n { name: \"Alex Kim\", role: \"Product Lead\" },\n { name: \"Jordan Lee\", role: \"Engineering Lead\" },\n { name: \"Sam Patel\", role: \"Design Lead\" },\n ],\n date: \"September 12, 2026\",\n decisions: [\n {\n decision: \"Proceed with pdfme as second rendering base\",\n number: 1,\n rationale: \"Better JSX support\",\n },\n {\n decision: \"Allocate 2 engineers to PDF module full-time\",\n number: 2,\n },\n ],\n discussions: [\n {\n notes: [\n \"Shipped 4 of 5 planned features\",\n \"Customer satisfaction up 12%\",\n ],\n speaker: \"Alex Kim\",\n topic: \"Q2 Outcomes\",\n },\n {\n notes: [\n \"PDF generation module is top priority\",\n \"Community page scheduled for late Q3\",\n ],\n speaker: \"Jordan Lee\",\n topic: \"Q3 Feature Priorities\",\n },\n ],\n distributionList: [\"product-team@acme.com\", \"eng-leads@acme.com\"],\n guests: [\"Riya Shah (Advisor)\"],\n location: \"Conference Room B / Zoom\",\n meetingTitle: \"Q3 Product Roadmap Review\",\n nextMeeting: {\n agenda: [\"Review action items\", \"pdfme RFC walkthrough\"],\n date: \"September 19, 2026\",\n time: \"2:00 PM\",\n },\n organizer: \"Alex Kim\",\n preparedBy: \"Alex Kim\",\n time: \"2:00 PM - 3:30 PM\",\n};\n\nconst STATUS_VARIANT: Record<\n MeetingMinutesActionStatus,\n \"success\" | \"info\" | \"default\"\n> = {\n Complete: \"success\",\n \"In Progress\": \"info\",\n \"Not Started\": \"default\",\n};\n\nconst formatAttendee = (a: { name: string; role?: string }) =>\n `${a.name}${a.role ? ` — ${a.role}` : \"\"}`;\n\nconst meetingMinutesLayout = (theme: PdfcnTheme, data: MeetingMinutesProps) => {\n const styles = StyleSheet.create({\n columnHeading: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\n },\n discussionTopic: {\n marginBottom: theme.primitives.spacing[2],\n },\n listItem: {\n marginBottom: theme.primitives.spacing[1],\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\n },\n });\n\n const attendeeColumns = [\n { heading: \"Attendees\", names: data.attendees.map(formatAttendee) },\n ...(data.absent?.length\n ? [{ heading: \"Absent\", names: data.absent.map(formatAttendee) }]\n : []),\n ...(data.guests?.length ? [{ heading: \"Guests\", names: data.guests }] : []),\n ];\n\n const footerRightText = data.distributionList?.length\n ? `Distribution: ${data.distributionList.join(\", \")}`\n : undefined;\n\n const discussions = data.discussions.map((discussion) => ({\n ...discussion,\n items: discussion.notes.map((text) => ({ text })),\n }));\n\n const nextMeetingAgenda = data.nextMeeting?.agenda?.map((text) => ({\n text,\n }));\n\n return {\n attendeeColumns,\n discussions,\n footerRightText,\n nextMeetingAgenda,\n styles,\n };\n};\n\n@Component({\n imports: [\n TakumiDocument,\n TakumiPage,\n TakumiView,\n NgTemplateOutlet,\n PdfBadge,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-meeting-minutes-content\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n {{ text }}\n \n \n \n \n \n \n \n \n @for (column of l.attendeeColumns; track column.heading) {\n \n \n @for (name of column.names; track name) {\n {{ name }}\n }\n \n }\n \n \n \n @for (item of data.agenda; track item; let index = $index) {\n {{\n index + 1 + \". \" + item\n }}\n }\n \n \n \n @for (discussion of l.discussions; track discussion.topic) {\n \n {{\n discussion.topic\n }}\n @if (discussion.speaker) {\n {{\n \"— \" + discussion.speaker\n }}\n }\n \n \n }\n \n \n \n \n \n \n @for (d of data.decisions; track d.number) {\n \n {{\n d.number + \". \" + d.decision\n }}\n @if (d.rationale) {\n {{\n d.rationale\n }}\n }\n \n }\n \n \n \n \n \n \n Task\n Owner\n Due Date\n Status\n \n \n \n @for (item of data.actionItems; track item.task) {\n \n {{ item.task }}\n {{\n item.owner\n }}\n {{\n item.dueDate\n }}\n \n \n \n \n }\n \n \n \n @if (data.nextMeeting) {\n \n \n {{\n data.nextMeeting.date + \" · \" + data.nextMeeting.time\n }}\n @if (l.nextMeetingAgenda) {\n \n }\n \n }\n \n \n \n `,\n})\nexport class MeetingMinutesContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly STATUS_VARIANT = STATUS_VARIANT;\n\n protected readonly layout = computed(() =>\n meetingMinutesLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [MeetingMinutesContent, PdfcnThemeProvider],\n selector: \"pdf-meeting-minutes\",\n template: `\n \n \n \n `,\n})\nexport class MeetingMinutesDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly mergedData = computed(\n (): MeetingMinutesProps => ({ ...sampleData, ...this.data() })\n );\n}\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfList } from \"@/components/pdf/list/list\";\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type {\n MeetingMinutesActionStatus,\n MeetingMinutesProps,\n} from \"./meeting-minutes.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: MeetingMinutesProps = {\n absent: [{ name: \"Casey Wu\", role: \"QA Lead\" }],\n accentColor: \"#0891b2\",\n actionItems: [\n {\n dueDate: \"Sep 19, 2026\",\n owner: \"Jordan Lee\",\n status: \"In Progress\",\n task: \"Create pdfme integration RFC\",\n },\n {\n dueDate: \"Sep 22, 2026\",\n owner: \"Sam Patel\",\n status: \"Not Started\",\n task: \"Design community page wireframes\",\n },\n {\n dueDate: \"Sep 26, 2026\",\n owner: \"Alex Kim\",\n status: \"Complete\",\n task: \"Share Q2 outcomes deck with stakeholders\",\n },\n ],\n agenda: [\n \"Review Q2 outcomes\",\n \"Q3 feature priorities\",\n \"Resource allocation\",\n \"Timeline and milestones\",\n ],\n attendees: [\n { name: \"Alex Kim\", role: \"Product Lead\" },\n { name: \"Jordan Lee\", role: \"Engineering Lead\" },\n { name: \"Sam Patel\", role: \"Design Lead\" },\n ],\n date: \"September 12, 2026\",\n decisions: [\n {\n decision: \"Proceed with pdfme as second rendering base\",\n number: 1,\n rationale: \"Better JSX support\",\n },\n {\n decision: \"Allocate 2 engineers to PDF module full-time\",\n number: 2,\n },\n ],\n discussions: [\n {\n notes: [\n \"Shipped 4 of 5 planned features\",\n \"Customer satisfaction up 12%\",\n ],\n speaker: \"Alex Kim\",\n topic: \"Q2 Outcomes\",\n },\n {\n notes: [\n \"PDF generation module is top priority\",\n \"Community page scheduled for late Q3\",\n ],\n speaker: \"Jordan Lee\",\n topic: \"Q3 Feature Priorities\",\n },\n ],\n distributionList: [\"product-team@acme.com\", \"eng-leads@acme.com\"],\n guests: [\"Riya Shah (Advisor)\"],\n location: \"Conference Room B / Zoom\",\n meetingTitle: \"Q3 Product Roadmap Review\",\n nextMeeting: {\n agenda: [\"Review action items\", \"pdfme RFC walkthrough\"],\n date: \"September 19, 2026\",\n time: \"2:00 PM\",\n },\n organizer: \"Alex Kim\",\n preparedBy: \"Alex Kim\",\n time: \"2:00 PM - 3:30 PM\",\n};\n\nconst STATUS_VARIANT: Record<\n MeetingMinutesActionStatus,\n \"success\" | \"info\" | \"default\"\n> = {\n Complete: \"success\",\n \"In Progress\": \"info\",\n \"Not Started\": \"default\",\n};\n\nconst formatAttendee = (a: { name: string; role?: string }) =>\n `${a.name}${a.role ? ` — ${a.role}` : \"\"}`;\n\nconst meetingMinutesLayout = (theme: PdfcnTheme, data: MeetingMinutesProps) => {\n const styles = StyleSheet.create({\n columnHeading: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\n },\n discussionTopic: {\n marginBottom: theme.primitives.spacing[2],\n },\n listItem: {\n marginBottom: theme.primitives.spacing[1],\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\n },\n });\n\n const attendeeColumns = [\n { heading: \"Attendees\", names: data.attendees.map(formatAttendee) },\n ...(data.absent?.length\n ? [{ heading: \"Absent\", names: data.absent.map(formatAttendee) }]\n : []),\n ...(data.guests?.length ? [{ heading: \"Guests\", names: data.guests }] : []),\n ];\n\n const footerRightText = data.distributionList?.length\n ? `Distribution: ${data.distributionList.join(\", \")}`\n : undefined;\n\n const discussions = data.discussions.map((discussion) => ({\n ...discussion,\n items: discussion.notes.map((text) => ({ text })),\n }));\n\n const nextMeetingAgenda = data.nextMeeting?.agenda?.map((text) => ({\n text,\n }));\n\n return {\n attendeeColumns,\n discussions,\n footerRightText,\n nextMeetingAgenda,\n styles,\n };\n};\n\n@Component({\n imports: [\n TakumiDocument,\n TakumiPage,\n TakumiView,\n NgTemplateOutlet,\n PdfBadge,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-meeting-minutes-content\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n {{ text }}\n \n \n \n \n \n \n \n \n @for (column of l.attendeeColumns; track column.heading) {\n \n \n @for (name of column.names; track name) {\n {{ name }}\n }\n \n }\n \n \n \n @for (item of data.agenda; track item; let index = $index) {\n {{\n index + 1 + \". \" + item\n }}\n }\n \n \n \n @for (discussion of l.discussions; track discussion.topic) {\n \n {{\n discussion.topic\n }}\n @if (discussion.speaker) {\n {{\n \"— \" + discussion.speaker\n }}\n }\n \n \n }\n \n \n \n \n \n \n @for (d of data.decisions; track d.number) {\n \n {{\n d.number + \". \" + d.decision\n }}\n @if (d.rationale) {\n {{\n d.rationale\n }}\n }\n \n }\n \n \n \n \n \n \n Task\n Owner\n Due Date\n Status\n \n \n \n @for (item of data.actionItems; track item.task) {\n \n {{ item.task }}\n {{\n item.owner\n }}\n {{\n item.dueDate\n }}\n \n \n \n \n }\n \n \n \n @if (data.nextMeeting) {\n \n \n {{\n data.nextMeeting.date + \" · \" + data.nextMeeting.time\n }}\n @if (l.nextMeetingAgenda) {\n \n }\n \n }\n \n \n \n `,\n})\nexport class MeetingMinutesContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly STATUS_VARIANT = STATUS_VARIANT;\n\n protected readonly layout = computed(() =>\n meetingMinutesLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [MeetingMinutesContent, PdfcnThemeProvider],\n selector: \"pdf-meeting-minutes\",\n template: `\n \n \n \n `,\n})\nexport class MeetingMinutesDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly mergedData = computed(\n (): MeetingMinutesProps => ({ ...sampleData, ...this.data() })\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:block", "target": "components/pdf/blocks/meeting-minutes/meeting-minutes.ts" }, { "path": "registry/bases/takumi/blocks/meeting-minutes/meeting-minutes.types.ts", - "content": "export interface MeetingMinutesAttendee {\n name: string;\n role?: string;\n}\n\nexport interface MeetingMinutesDiscussion {\n topic: string;\n notes: string[];\n speaker?: string;\n}\n\nexport interface MeetingMinutesDecision {\n number: number;\n decision: string;\n rationale?: string;\n}\n\nexport type MeetingMinutesActionStatus =\n | \"Not Started\"\n | \"In Progress\"\n | \"Complete\";\n\nexport interface MeetingMinutesActionItem {\n task: string;\n owner: string;\n dueDate: string;\n status: MeetingMinutesActionStatus;\n}\n\nexport interface MeetingMinutesNextMeeting {\n date: string;\n time: string;\n agenda?: string[];\n}\n\nexport interface MeetingMinutesProps {\n meetingTitle: string;\n date: string;\n time: string;\n location: string;\n organizer: string;\n attendees: MeetingMinutesAttendee[];\n absent?: MeetingMinutesAttendee[];\n guests?: string[];\n agenda: string[];\n discussions: MeetingMinutesDiscussion[];\n decisions: MeetingMinutesDecision[];\n actionItems: MeetingMinutesActionItem[];\n nextMeeting?: MeetingMinutesNextMeeting;\n preparedBy: string;\n distributionList?: string[];\n accentColor?: string;\n renderingBase?: \"takumi\" | \"forme\";\n}\n", + "content": "export interface MeetingMinutesAttendee {\n name: string;\n role?: string;\n}\n\nexport interface MeetingMinutesDiscussion {\n topic: string;\n notes: string[];\n speaker?: string;\n}\n\nexport interface MeetingMinutesDecision {\n number: number;\n decision: string;\n rationale?: string;\n}\n\nexport type MeetingMinutesActionStatus =\n | \"Not Started\"\n | \"In Progress\"\n | \"Complete\";\n\nexport interface MeetingMinutesActionItem {\n task: string;\n owner: string;\n dueDate: string;\n status: MeetingMinutesActionStatus;\n}\n\nexport interface MeetingMinutesNextMeeting {\n date: string;\n time: string;\n agenda?: string[];\n}\n\nexport interface MeetingMinutesProps {\n meetingTitle: string;\n date: string;\n time: string;\n location: string;\n organizer: string;\n attendees: MeetingMinutesAttendee[];\n absent?: MeetingMinutesAttendee[];\n guests?: string[];\n agenda: string[];\n discussions: MeetingMinutesDiscussion[];\n decisions: MeetingMinutesDecision[];\n actionItems: MeetingMinutesActionItem[];\n nextMeeting?: MeetingMinutesNextMeeting;\n preparedBy: string;\n distributionList?: 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/meeting-minutes/meeting-minutes.types.ts" } diff --git a/apps/web/public/r/takumi/packing-slip.json b/apps/web/public/r/takumi/packing-slip.json index 8df68cd..d0564ea 100644 --- a/apps/web/public/r/takumi/packing-slip.json +++ b/apps/web/public/r/takumi/packing-slip.json @@ -20,13 +20,13 @@ "files": [ { "path": "registry/bases/takumi/blocks/packing-slip/packing-slip.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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { PackingSlipProps, PackingSlipSender } from \"./packing-slip.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: PackingSlipProps = {\n accentColor: \"#059669\",\n companyName: \"Acme Store\",\n customerService: \"support@acme-store.com\",\n items: [\n {\n name: \"Widget Pro\",\n qtyOrdered: 2,\n qtyPacked: 2,\n sku: \"WP-001\",\n unitPrice: 49.99,\n },\n {\n name: \"Gadget Lite\",\n qtyOrdered: 1,\n qtyPacked: 1,\n sku: \"GL-010\",\n unitPrice: 29.99,\n },\n {\n name: \"Cable Kit\",\n qtyOrdered: 3,\n qtyPacked: 2,\n sku: \"CK-204\",\n unitPrice: 9.5,\n },\n ],\n orderDate: \"Sep 10, 2026\",\n orderNumber: \"ORD-2026-0891\",\n poNumber: \"PO-4471\",\n returnsPolicy: \"Returns accepted within 30 days with original packaging.\",\n shipFrom: {\n address: \"100 Industrial Blvd\",\n city: \"Seattle\",\n name: \"Acme Warehouse\",\n state: \"WA\",\n zip: \"98101\",\n },\n shipTo: {\n address: \"456 Oak Ave\",\n city: \"Portland\",\n name: \"Jane Doe\",\n phone: \"(503) 555-0142\",\n state: \"OR\",\n zip: \"97201\",\n },\n shipping: {\n carrier: \"UPS\",\n estimatedDelivery: \"Sep 15, 2026\",\n method: \"Ground\",\n trackingNumber: \"1Z999AA10123456784\",\n },\n thankYouMessage: \"Thank you for your order!\",\n totalPackages: 1,\n totalWeight: \"3.2 kg\",\n};\n\nconst formatAddress = (a: PackingSlipSender & { country?: string }) =>\n `${a.address}, ${a.city}, ${a.state} ${a.zip}${a.country ? `, ${a.country}` : \"\"}`;\n\n@Component({\n imports: [\n TakumiDocument,\n TakumiPage,\n TakumiView,\n PdfImage,\n PdfKeyValue,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-packing-slip-content\",\n template: `\n @let data = this.data();\n @let styles = this.styles();\n \n \n \n \n \n \n \n \n Ship To\n {{ data.shipTo.name }}\n {{\n formatAddress(data.shipTo)\n }}\n @if (data.shipTo.phone) {\n {{ data.shipTo.phone }}\n }\n \n \n From\n {{ data.shipFrom.name }}\n {{\n formatAddress(data.shipFrom)\n }}\n \n \n Order\n {{ data.orderNumber }}\n @if (data.poNumber) {\n {{\n \"PO: \" + data.poNumber\n }}\n }\n \n \n \n \n \n Item\n SKU\n Packed\n Ordered\n Unit Price\n Total\n \n \n \n @for (item of data.items; track item.sku) {\n \n {{ item.name }}\n {{ item.sku }}\n {{\n item.qtyPacked\n }}\n {{\n item.qtyOrdered\n }}\n {{\n \"$\" + item.unitPrice.toFixed(2)\n }}\n {{\n \"$\" + (item.qtyPacked * item.unitPrice).toFixed(2)\n }}\n \n }\n \n \n \n \n Shipping\n {{\n data.shipping.carrier + \" — \" + data.shipping.method\n }}\n {{\n \"Tracking: \" + data.shipping.trackingNumber\n }}\n @if (data.shipping.estimatedDelivery) {\n {{\n \"Est. Delivery: \" + data.shipping.estimatedDelivery\n }}\n }\n \n \n \n \n \n @if (data.thankYouMessage || data.returnsPolicy) {\n \n @if (data.thankYouMessage) {\n {{\n data.thankYouMessage\n }}\n }\n @if (data.returnsPolicy) {\n {{\n data.returnsPolicy\n }}\n }\n \n }\n \n \n \n `,\n})\nexport class PackingSlipContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly formatAddress = formatAddress;\n\n protected readonly styles = computed(() => {\n const theme = this.theme();\n const styles = StyleSheet.create({\n columnHeading: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\n },\n });\n return styles;\n });\n\n protected readonly summaryItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n const totalPacked = data.items.reduce(\n (sum, item) => sum + item.qtyPacked,\n 0\n );\n const totalOrdered = data.items.reduce(\n (sum, item) => sum + item.qtyOrdered,\n 0\n );\n\n const summaryItems = [\n { key: \"Items Packed\", value: `${totalPacked} of ${totalOrdered}` },\n ...(data.totalPackages === undefined\n ? []\n : [{ key: \"Packages\", value: `${data.totalPackages}` }]),\n ...(data.totalWeight\n ? [{ key: \"Total Weight\", value: data.totalWeight }]\n : []),\n ];\n return summaryItems;\n });\n}\n\n@Component({\n imports: [PackingSlipContent, PdfcnThemeProvider],\n selector: \"pdf-packing-slip\",\n template: `\n \n \n \n `,\n})\nexport class PackingSlipDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly merged = computed(\n (): PackingSlipProps => ({ ...sampleData, ...this.data() })\n );\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { PackingSlipProps, PackingSlipSender } from \"./packing-slip.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: PackingSlipProps = {\n accentColor: \"#059669\",\n companyName: \"Acme Store\",\n customerService: \"support@acme-store.com\",\n items: [\n {\n name: \"Widget Pro\",\n qtyOrdered: 2,\n qtyPacked: 2,\n sku: \"WP-001\",\n unitPrice: 49.99,\n },\n {\n name: \"Gadget Lite\",\n qtyOrdered: 1,\n qtyPacked: 1,\n sku: \"GL-010\",\n unitPrice: 29.99,\n },\n {\n name: \"Cable Kit\",\n qtyOrdered: 3,\n qtyPacked: 2,\n sku: \"CK-204\",\n unitPrice: 9.5,\n },\n ],\n orderDate: \"Sep 10, 2026\",\n orderNumber: \"ORD-2026-0891\",\n poNumber: \"PO-4471\",\n returnsPolicy: \"Returns accepted within 30 days with original packaging.\",\n shipFrom: {\n address: \"100 Industrial Blvd\",\n city: \"Seattle\",\n name: \"Acme Warehouse\",\n state: \"WA\",\n zip: \"98101\",\n },\n shipTo: {\n address: \"456 Oak Ave\",\n city: \"Portland\",\n name: \"Jane Doe\",\n phone: \"(503) 555-0142\",\n state: \"OR\",\n zip: \"97201\",\n },\n shipping: {\n carrier: \"UPS\",\n estimatedDelivery: \"Sep 15, 2026\",\n method: \"Ground\",\n trackingNumber: \"1Z999AA10123456784\",\n },\n thankYouMessage: \"Thank you for your order!\",\n totalPackages: 1,\n totalWeight: \"3.2 kg\",\n};\n\nconst formatAddress = (a: PackingSlipSender & { country?: string }) =>\n `${a.address}, ${a.city}, ${a.state} ${a.zip}${a.country ? `, ${a.country}` : \"\"}`;\n\n@Component({\n imports: [\n TakumiDocument,\n TakumiPage,\n TakumiView,\n PdfImage,\n PdfKeyValue,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n TABLE,\n ],\n selector: \"pdf-packing-slip-content\",\n template: `\n @let data = this.data();\n @let styles = this.styles();\n \n \n \n \n \n \n \n \n Ship To\n {{ data.shipTo.name }}\n {{\n formatAddress(data.shipTo)\n }}\n @if (data.shipTo.phone) {\n {{ data.shipTo.phone }}\n }\n \n \n From\n {{ data.shipFrom.name }}\n {{\n formatAddress(data.shipFrom)\n }}\n \n \n Order\n {{ data.orderNumber }}\n @if (data.poNumber) {\n {{\n \"PO: \" + data.poNumber\n }}\n }\n \n \n \n \n \n Item\n SKU\n Packed\n Ordered\n Unit Price\n Total\n \n \n \n @for (item of data.items; track item.sku) {\n \n {{ item.name }}\n {{ item.sku }}\n {{\n item.qtyPacked\n }}\n {{\n item.qtyOrdered\n }}\n {{\n \"$\" + item.unitPrice.toFixed(2)\n }}\n {{\n \"$\" + (item.qtyPacked * item.unitPrice).toFixed(2)\n }}\n \n }\n \n \n \n \n Shipping\n {{\n data.shipping.carrier + \" — \" + data.shipping.method\n }}\n {{\n \"Tracking: \" + data.shipping.trackingNumber\n }}\n @if (data.shipping.estimatedDelivery) {\n {{\n \"Est. Delivery: \" + data.shipping.estimatedDelivery\n }}\n }\n \n \n \n \n \n @if (data.thankYouMessage || data.returnsPolicy) {\n \n @if (data.thankYouMessage) {\n {{\n data.thankYouMessage\n }}\n }\n @if (data.returnsPolicy) {\n {{\n data.returnsPolicy\n }}\n }\n \n }\n \n \n \n `,\n})\nexport class PackingSlipContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly formatAddress = formatAddress;\n\n protected readonly styles = computed(() => {\n const theme = this.theme();\n const styles = StyleSheet.create({\n columnHeading: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\n },\n });\n return styles;\n });\n\n protected readonly summaryItems = computed((): KeyValueEntry[] => {\n const data = this.data();\n const totalPacked = data.items.reduce(\n (sum, item) => sum + item.qtyPacked,\n 0\n );\n const totalOrdered = data.items.reduce(\n (sum, item) => sum + item.qtyOrdered,\n 0\n );\n\n const summaryItems = [\n { key: \"Items Packed\", value: `${totalPacked} of ${totalOrdered}` },\n ...(data.totalPackages === undefined\n ? []\n : [{ key: \"Packages\", value: `${data.totalPackages}` }]),\n ...(data.totalWeight\n ? [{ key: \"Total Weight\", value: data.totalWeight }]\n : []),\n ];\n return summaryItems;\n });\n}\n\n@Component({\n imports: [PackingSlipContent, PdfcnThemeProvider],\n selector: \"pdf-packing-slip\",\n template: `\n \n \n \n `,\n})\nexport class PackingSlipDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly merged = computed(\n (): PackingSlipProps => ({ ...sampleData, ...this.data() })\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:block", "target": "components/pdf/blocks/packing-slip/packing-slip.ts" }, { "path": "registry/bases/takumi/blocks/packing-slip/packing-slip.types.ts", - "content": "export interface PackingSlipRecipient {\n name: string;\n address: string;\n city: string;\n state: string;\n zip: string;\n country?: string;\n phone?: string;\n}\n\nexport interface PackingSlipSender {\n name: string;\n address: string;\n city: string;\n state: string;\n zip: string;\n}\n\nexport interface PackingSlipItem {\n name: string;\n sku: string;\n qtyPacked: number;\n qtyOrdered: number;\n unitPrice: number;\n}\n\nexport interface PackingSlipShipping {\n carrier: string;\n trackingNumber: string;\n method: string;\n estimatedDelivery?: string;\n}\n\nexport interface PackingSlipProps {\n companyName: string;\n companyLogo?: string;\n orderNumber: string;\n orderDate: string;\n poNumber?: string;\n shipTo: PackingSlipRecipient;\n shipFrom: PackingSlipSender;\n items: PackingSlipItem[];\n shipping: PackingSlipShipping;\n totalPackages?: number;\n totalWeight?: string;\n returnsPolicy?: string;\n customerService?: string;\n thankYouMessage?: string;\n accentColor?: string;\n renderingBase?: \"takumi\" | \"forme\";\n}\n", + "content": "export interface PackingSlipRecipient {\n name: string;\n address: string;\n city: string;\n state: string;\n zip: string;\n country?: string;\n phone?: string;\n}\n\nexport interface PackingSlipSender {\n name: string;\n address: string;\n city: string;\n state: string;\n zip: string;\n}\n\nexport interface PackingSlipItem {\n name: string;\n sku: string;\n qtyPacked: number;\n qtyOrdered: number;\n unitPrice: number;\n}\n\nexport interface PackingSlipShipping {\n carrier: string;\n trackingNumber: string;\n method: string;\n estimatedDelivery?: string;\n}\n\nexport interface PackingSlipProps {\n companyName: string;\n companyLogo?: string;\n orderNumber: string;\n orderDate: string;\n poNumber?: string;\n shipTo: PackingSlipRecipient;\n shipFrom: PackingSlipSender;\n items: PackingSlipItem[];\n shipping: PackingSlipShipping;\n totalPackages?: number;\n totalWeight?: string;\n returnsPolicy?: string;\n customerService?: string;\n thankYouMessage?: 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/packing-slip/packing-slip.types.ts" } diff --git a/apps/web/public/r/takumi/page-break.json b/apps/web/public/r/takumi/page-break.json index fba5bcd..3b7bd5b 100644 --- a/apps/web/public/r/takumi/page-break.json +++ b/apps/web/public/r/takumi/page-break.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/page-break/page-break.ts", - "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { TakumiView } from \"@/lib/pdf-primitives\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\n\nexport interface PageBreakProps extends Omit {\n children?: never;\n}\n\n@Component({\n imports: [TakumiView],\n selector: \"pdf-page-break\",\n template: ``,\n})\nexport class PdfPageBreak {\n readonly style = input();\n\n protected readonly pageBreakStyle = computed(\n () => [{ breakBefore: \"page\" }, this.style()].filter(Boolean) as never\n );\n}\n", + "content": "import { Component, computed, input } from \"@angular/core\";\n\nimport { TakumiView } from \"@/lib/pdf-primitives\";\nimport type { PDFComponentProps } from \"@/types/pdf-components\";\n\nexport interface PageBreakProps extends Omit {\n children?: never;\n}\n\n@Component({\n imports: [TakumiView],\n selector: \"pdf-page-break\",\n template: ``,\n})\nexport class PdfPageBreak {\n readonly style = input();\n\n protected readonly pageBreakStyle = computed(\n () => [{ breakBefore: \"page\" }, this.style()].filter(Boolean) as never\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/page-break/page-break.ts" } diff --git a/apps/web/public/r/takumi/page-footer.json b/apps/web/public/r/takumi/page-footer.json index f7f22d6..3879e1d 100644 --- a/apps/web/public/r/takumi/page-footer.json +++ b/apps/web/public/r/takumi/page-footer.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/page-footer/page-footer.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport {\n booleanAttribute,\n Component,\n computed,\n input,\n TemplateRef,\n inject,\n Injector,\n} from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiText,\n TakumiView,\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 PageFooterVariant =\n | \"simple\"\n | \"centered\"\n | \"branded\"\n | \"minimal\"\n | \"three-column\"\n | \"detailed\";\n\n/**\n * Footer row with layout variants, optional sticky or fixed positioning, and contact info support.\n * Props - `leftText` | `rightText` | `centerText` | `variant` | `background` | `textColor` | `marginTop` | `address` | `phone` | `email` | `website` | `fixed` | `sticky` | `pagePadding` | `noWrap` | `style`\n * @see {@link PageFooterProps}\n */\n/** Plain text, or a template for richer content such as a page number. */\nexport type FooterSlot = string | TemplateRef;\n\nexport interface PageFooterProps extends PDFComponentProps {\n leftText?: FooterSlot;\n rightText?: FooterSlot;\n centerText?: FooterSlot;\n /**\n * @default 'simple'\n */\n variant?: PageFooterVariant;\n background?: string;\n textColor?: string;\n marginTop?: number;\n address?: string;\n phone?: string;\n email?: string;\n website?: string;\n /**\n * @default false\n */\n fixed?: boolean;\n /**\n * @default false\n */\n sticky?: boolean;\n /**\n * @default 0\n */\n pagePadding?: number;\n /**\n * @default true\n */\n noWrap?: boolean;\n}\n\nconst createPageFooterStyles = (t: PdfcnTheme) => {\n const { spacing, fontWeights } = t.primitives;\n const c = t.colors;\n const { body } = t.typography;\n\n const textBase = {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: t.primitives.typography.xs,\n lineHeight: body.lineHeight,\n };\n\n return StyleSheet.create({\n brandedContainer: {\n alignItems: \"center\",\n backgroundColor: c.primary,\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingHorizontal: spacing[4],\n paddingVertical: spacing[3],\n },\n\n centeredContainer: {\n alignItems: \"center\",\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"column\",\n paddingTop: spacing[3],\n },\n\n companyBold: {\n ...textBase,\n color: c.foreground,\n fontWeight: fontWeights.bold,\n },\n\n companyName: {\n ...textBase,\n color: c.foreground,\n fontWeight: fontWeights.medium,\n },\n\n contactInfoCenter: {\n ...textBase,\n fontSize: t.primitives.typography.xs - 1,\n marginTop: spacing[0.5],\n textAlign: \"center\",\n },\n detailedContainer: {\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[1],\n display: \"flex\",\n flexDirection: \"column\",\n paddingTop: spacing[3],\n },\n detailedLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n detailedPageNumber: {\n ...textBase,\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n paddingTop: spacing[2],\n textAlign: \"center\",\n },\n detailedRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flexDirection: \"column\",\n },\n detailedTopRow: {\n alignItems: \"flex-start\",\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: spacing[2],\n },\n\n minimalContainer: {\n alignItems: \"center\",\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[1],\n paddingTop: spacing[1],\n },\n simpleContainer: {\n alignItems: \"center\",\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingTop: spacing[3],\n },\n textBranded: {\n ...textBase,\n color: c.primaryForeground,\n fontWeight: fontWeights.medium,\n },\n textBrandedRight: {\n ...textBase,\n color: c.primaryForeground,\n textAlign: \"right\",\n },\n textCenter: {\n ...textBase,\n flex: 1,\n textAlign: \"center\",\n },\n textCenteredVariant: {\n ...textBase,\n marginBottom: spacing[1],\n textAlign: \"center\",\n },\n\n textLeft: {\n ...textBase,\n flex: 1,\n },\n textRight: {\n ...textBase,\n textAlign: \"right\",\n },\n threeColumnCenter: {\n alignItems: \"center\",\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n threeColumnContainer: {\n alignItems: \"flex-start\",\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingTop: spacing[3],\n },\n threeColumnLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n threeColumnRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n });\n};\n\nconst applyTextColor = (\n styles: Style[],\n color: string | undefined\n): Style[] => {\n if (!color) {\n return styles;\n }\n return [...styles, { color }];\n};\n\n/** Container and slot styles of each variant. */\nconst pageFooterStyles = (\n theme: PdfcnTheme,\n {\n variant = \"simple\",\n background,\n textColor,\n marginTop,\n sticky = false,\n pagePadding = 0,\n style,\n }: PageFooterProps\n) => {\n const styles = createPageFooterStyles(theme);\n const mt = sticky ? 0 : (marginTop ?? theme.spacing.sectionGap);\n const resolvedTextColor = textColor\n ? resolveColor(textColor, theme.colors)\n : undefined;\n // A footer passed as a render option lays out at full page width, so the\n // page padding has to come from the footer itself to line up with the content.\n const placement: Style = sticky\n ? {\n bottom: pagePadding,\n left: pagePadding,\n position: \"absolute\",\n right: pagePadding,\n }\n : { paddingLeft: pagePadding, paddingRight: pagePadding };\n\n const applyOverrides = (base: Style[]): Style[] => {\n if (background) {\n base.push({ backgroundColor: resolveColor(background, theme.colors) });\n }\n if (style) {\n base.push(style);\n }\n base.push(placement);\n return base;\n };\n\n const variantRenderers: Record Style[][]> = {\n branded: () => [\n applyOverrides([styles.brandedContainer, { marginTop: mt }]),\n applyTextColor([styles.textBranded], resolvedTextColor),\n applyTextColor([styles.textBrandedRight], resolvedTextColor),\n ],\n centered: () => [\n applyOverrides([styles.centeredContainer, { marginTop: mt }]),\n applyTextColor([styles.textCenteredVariant], resolvedTextColor),\n ],\n detailed: () => [\n applyOverrides([styles.detailedContainer, { marginTop: mt }]),\n applyTextColor([styles.companyBold], resolvedTextColor),\n applyTextColor([styles.textLeft], resolvedTextColor),\n applyTextColor([styles.textRight], resolvedTextColor),\n applyTextColor([styles.detailedPageNumber], resolvedTextColor),\n ],\n minimal: () => [\n applyOverrides([styles.minimalContainer, { marginTop: mt }]),\n applyTextColor([styles.textLeft], resolvedTextColor),\n applyTextColor([styles.textRight], resolvedTextColor),\n ],\n simple: () => [\n applyOverrides([styles.simpleContainer, { marginTop: mt }]),\n applyTextColor([styles.textLeft], resolvedTextColor),\n applyTextColor([styles.textCenter], resolvedTextColor),\n applyTextColor([styles.textRight], resolvedTextColor),\n ],\n \"three-column\": () => [\n applyOverrides([styles.threeColumnContainer, { marginTop: mt }]),\n applyTextColor([styles.companyName], resolvedTextColor),\n applyTextColor([styles.contactInfoCenter], resolvedTextColor),\n applyTextColor([styles.textRight], resolvedTextColor),\n ],\n };\n\n const [container, ...slots] = variantRenderers[variant]();\n return { container, slots, styles };\n};\n\n@Component({\n imports: [TakumiText, TakumiView, NgTemplateOutlet],\n selector: \"pdf-page-footer\",\n template: `\n @let l = layout();\n @let s = l.styles;\n \n \n @switch (variant()) {\n @case (\"three-column\") {\n \n \n @if (address()) {\n {{ address() }}\n }\n \n \n @if (phone()) {\n {{ phone() }}\n }\n @if (email()) {\n {{ email() }}\n }\n @if (website()) {\n {{ website() }}\n }\n \n \n \n \n }\n @case (\"detailed\") {\n \n \n \n @if (address()) {\n {{ address() }}\n }\n \n \n @if (phone()) {\n {{\n \"Phone: \" + phone()\n }}\n }\n @if (email()) {\n {{\n \"Email: \" + email()\n }}\n }\n @if (website()) {\n {{\n \"Web: \" + website()\n }}\n }\n \n \n \n }\n @case (\"simple\") {\n \n \n \n }\n @case (\"centered\") {\n \n \n }\n @default {\n \n \n }\n }\n \n \n @if (value) {\n \n @if (isTemplate(value)) {\n \n } @else {\n {{ value }}\n }\n \n }\n \n `,\n})\nexport class PdfPageFooter {\n /** Templates passed in resolve the theme from where they render, not where they are declared. */\n protected readonly injector = inject(Injector);\n readonly leftText = input();\n readonly rightText = input();\n readonly centerText = input();\n readonly variant = input(\"simple\");\n readonly background = input();\n readonly textColor = input();\n readonly marginTop = input();\n readonly address = input();\n readonly phone = input();\n readonly email = input();\n readonly website = input();\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly sticky = input(false, { transform: booleanAttribute });\n readonly pagePadding = input(0);\n readonly noWrap = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n protected readonly isTemplate = (value: unknown) =>\n value instanceof TemplateRef;\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n pageFooterStyles(this.theme(), {\n background: this.background(),\n marginTop: this.marginTop(),\n pagePadding: this.pagePadding(),\n sticky: this.sticky(),\n style: this.style(),\n textColor: this.textColor(),\n variant: this.variant(),\n })\n );\n}\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport {\n booleanAttribute,\n Component,\n computed,\n input,\n TemplateRef,\n inject,\n Injector,\n} from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiText,\n TakumiView,\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 PageFooterVariant =\n | \"simple\"\n | \"centered\"\n | \"branded\"\n | \"minimal\"\n | \"three-column\"\n | \"detailed\";\n\n/**\n * Footer row with layout variants, optional sticky or fixed positioning, and contact info support.\n * Props - `leftText` | `rightText` | `centerText` | `variant` | `background` | `textColor` | `marginTop` | `address` | `phone` | `email` | `website` | `fixed` | `sticky` | `pagePadding` | `noWrap` | `style`\n * @see {@link PageFooterProps}\n */\n/** Plain text, or a template for richer content such as a page number. */\nexport type FooterSlot = string | TemplateRef;\n\nexport interface PageFooterProps extends PDFComponentProps {\n leftText?: FooterSlot;\n rightText?: FooterSlot;\n centerText?: FooterSlot;\n /**\n * @default 'simple'\n */\n variant?: PageFooterVariant;\n background?: string;\n textColor?: string;\n marginTop?: number;\n address?: string;\n phone?: string;\n email?: string;\n website?: string;\n /**\n * @default false\n */\n fixed?: boolean;\n /**\n * @default false\n */\n sticky?: boolean;\n /**\n * @default 0\n */\n pagePadding?: number;\n /**\n * @default true\n */\n noWrap?: boolean;\n}\n\nconst createPageFooterStyles = (t: PdfcnTheme) => {\n const { spacing, fontWeights } = t.primitives;\n const c = t.colors;\n const { body } = t.typography;\n\n const textBase = {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: t.primitives.typography.xs,\n lineHeight: body.lineHeight,\n };\n\n return StyleSheet.create({\n brandedContainer: {\n alignItems: \"center\",\n backgroundColor: c.primary,\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingHorizontal: spacing[4],\n paddingVertical: spacing[3],\n },\n\n centeredContainer: {\n alignItems: \"center\",\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"column\",\n paddingTop: spacing[3],\n },\n\n companyBold: {\n ...textBase,\n color: c.foreground,\n fontWeight: fontWeights.bold,\n },\n\n companyName: {\n ...textBase,\n color: c.foreground,\n fontWeight: fontWeights.medium,\n },\n\n contactInfoCenter: {\n ...textBase,\n fontSize: t.primitives.typography.xs - 1,\n marginTop: spacing[0.5],\n textAlign: \"center\",\n },\n detailedContainer: {\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[1],\n display: \"flex\",\n flexDirection: \"column\",\n paddingTop: spacing[3],\n },\n detailedLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n detailedPageNumber: {\n ...textBase,\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n paddingTop: spacing[2],\n textAlign: \"center\",\n },\n detailedRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flexDirection: \"column\",\n },\n detailedTopRow: {\n alignItems: \"flex-start\",\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: spacing[2],\n },\n\n minimalContainer: {\n alignItems: \"center\",\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[1],\n paddingTop: spacing[1],\n },\n simpleContainer: {\n alignItems: \"center\",\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingTop: spacing[3],\n },\n textBranded: {\n ...textBase,\n color: c.primaryForeground,\n fontWeight: fontWeights.medium,\n },\n textBrandedRight: {\n ...textBase,\n color: c.primaryForeground,\n textAlign: \"right\",\n },\n textCenter: {\n ...textBase,\n flex: 1,\n textAlign: \"center\",\n },\n textCenteredVariant: {\n ...textBase,\n marginBottom: spacing[1],\n textAlign: \"center\",\n },\n\n textLeft: {\n ...textBase,\n flex: 1,\n },\n textRight: {\n ...textBase,\n textAlign: \"right\",\n },\n threeColumnCenter: {\n alignItems: \"center\",\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n threeColumnContainer: {\n alignItems: \"flex-start\",\n borderTopColor: c.border,\n borderTopStyle: \"solid\",\n borderTopWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingTop: spacing[3],\n },\n threeColumnLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n threeColumnRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n });\n};\n\nconst applyTextColor = (\n styles: Style[],\n color: string | undefined\n): Style[] => {\n if (!color) {\n return styles;\n }\n return [...styles, { color }];\n};\n\n/** Container and slot styles of each variant. */\nconst pageFooterStyles = (\n theme: PdfcnTheme,\n {\n variant = \"simple\",\n background,\n textColor,\n marginTop,\n sticky = false,\n pagePadding = 0,\n style,\n }: PageFooterProps\n) => {\n const styles = createPageFooterStyles(theme);\n const mt = sticky ? 0 : (marginTop ?? theme.spacing.sectionGap);\n const resolvedTextColor = textColor\n ? resolveColor(textColor, theme.colors)\n : undefined;\n // A footer passed as a render option lays out at full page width, so the\n // page padding has to come from the footer itself to line up with the content.\n const placement: Style = sticky\n ? {\n bottom: pagePadding,\n left: pagePadding,\n position: \"absolute\",\n right: pagePadding,\n }\n : { paddingLeft: pagePadding, paddingRight: pagePadding };\n\n const applyOverrides = (base: Style[]): Style[] => {\n if (background) {\n base.push({ backgroundColor: resolveColor(background, theme.colors) });\n }\n if (style) {\n base.push(style);\n }\n base.push(placement);\n return base;\n };\n\n const variantRenderers: Record Style[][]> = {\n branded: () => [\n applyOverrides([styles.brandedContainer, { marginTop: mt }]),\n applyTextColor([styles.textBranded], resolvedTextColor),\n applyTextColor([styles.textBrandedRight], resolvedTextColor),\n ],\n centered: () => [\n applyOverrides([styles.centeredContainer, { marginTop: mt }]),\n applyTextColor([styles.textCenteredVariant], resolvedTextColor),\n ],\n detailed: () => [\n applyOverrides([styles.detailedContainer, { marginTop: mt }]),\n applyTextColor([styles.companyBold], resolvedTextColor),\n applyTextColor([styles.textLeft], resolvedTextColor),\n applyTextColor([styles.textRight], resolvedTextColor),\n applyTextColor([styles.detailedPageNumber], resolvedTextColor),\n ],\n minimal: () => [\n applyOverrides([styles.minimalContainer, { marginTop: mt }]),\n applyTextColor([styles.textLeft], resolvedTextColor),\n applyTextColor([styles.textRight], resolvedTextColor),\n ],\n simple: () => [\n applyOverrides([styles.simpleContainer, { marginTop: mt }]),\n applyTextColor([styles.textLeft], resolvedTextColor),\n applyTextColor([styles.textCenter], resolvedTextColor),\n applyTextColor([styles.textRight], resolvedTextColor),\n ],\n \"three-column\": () => [\n applyOverrides([styles.threeColumnContainer, { marginTop: mt }]),\n applyTextColor([styles.companyName], resolvedTextColor),\n applyTextColor([styles.contactInfoCenter], resolvedTextColor),\n applyTextColor([styles.textRight], resolvedTextColor),\n ],\n };\n\n const [container, ...slots] = variantRenderers[variant]();\n return { container, slots, styles };\n};\n\n@Component({\n imports: [TakumiText, TakumiView, NgTemplateOutlet],\n selector: \"pdf-page-footer\",\n template: `\n @let l = layout();\n @let s = l.styles;\n \n \n @switch (variant()) {\n @case (\"three-column\") {\n \n \n @if (address()) {\n {{ address() }}\n }\n \n \n @if (phone()) {\n {{ phone() }}\n }\n @if (email()) {\n {{ email() }}\n }\n @if (website()) {\n {{ website() }}\n }\n \n \n \n \n }\n @case (\"detailed\") {\n \n \n \n @if (address()) {\n {{ address() }}\n }\n \n \n @if (phone()) {\n {{\n \"Phone: \" + phone()\n }}\n }\n @if (email()) {\n {{\n \"Email: \" + email()\n }}\n }\n @if (website()) {\n {{\n \"Web: \" + website()\n }}\n }\n \n \n \n }\n @case (\"simple\") {\n \n \n \n }\n @case (\"centered\") {\n \n \n }\n @default {\n \n \n }\n }\n \n \n @if (value) {\n \n @if (isTemplate(value)) {\n \n } @else {\n {{ value }}\n }\n \n }\n \n `,\n})\nexport class PdfPageFooter {\n /** Templates passed in resolve the theme from where they render, not where they are declared. */\n protected readonly injector = inject(Injector);\n readonly leftText = input();\n readonly rightText = input();\n readonly centerText = input();\n readonly variant = input(\"simple\");\n readonly background = input();\n readonly textColor = input();\n readonly marginTop = input();\n readonly address = input();\n readonly phone = input();\n readonly email = input();\n readonly website = input();\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly sticky = input(false, { transform: booleanAttribute });\n readonly pagePadding = input(0);\n readonly noWrap = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n protected readonly isTemplate = (value: unknown) =>\n value instanceof TemplateRef;\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n pageFooterStyles(this.theme(), {\n background: this.background(),\n marginTop: this.marginTop(),\n pagePadding: this.pagePadding(),\n sticky: this.sticky(),\n style: this.style(),\n textColor: this.textColor(),\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/page-footer/page-footer.ts" } diff --git a/apps/web/public/r/takumi/page-header.json b/apps/web/public/r/takumi/page-header.json index a787c90..c0dbfea 100644 --- a/apps/web/public/r/takumi/page-header.json +++ b/apps/web/public/r/takumi/page-header.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/page-header/page-header.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport {\n booleanAttribute,\n Component,\n computed,\n input,\n inject,\n Injector,\n} from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiText,\n TakumiView,\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 PageHeaderVariant =\n | \"simple\"\n | \"centered\"\n | \"minimal\"\n | \"branded\"\n | \"logo-left\"\n | \"logo-right\"\n | \"two-column\";\n\n/**\n * Header row with layout variants, logo support, and optional fixed positioning.\n * Props - `title` | `subtitle` | `rightText` | `rightSubText` | `variant` | `background` | `titleColor` | `marginBottom` | `address` | `phone` | `email` | `logo` | `fixed` | `noWrap` | `style`\n * @see {@link PageHeaderProps}\n */\nexport interface PageHeaderProps extends PDFComponentProps {\n title: string;\n subtitle?: string;\n rightText?: string;\n rightSubText?: string;\n /**\n * @default 'simple'\n */\n variant?: PageHeaderVariant;\n background?: string;\n titleColor?: string;\n marginBottom?: number;\n address?: string;\n phone?: string;\n email?: string;\n logo?: TemplateRef;\n /**\n * @default false\n */\n fixed?: boolean;\n /**\n * @default true\n */\n noWrap?: boolean;\n}\n\nconst createPageHeaderStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius, fontWeights } = t.primitives;\n const c = t.colors;\n const { heading, body } = t.typography;\n\n return StyleSheet.create({\n brandedContainer: {\n alignItems: \"center\",\n backgroundColor: c.primary,\n borderRadius: borderRadius.sm,\n display: \"flex\",\n flexDirection: \"column\",\n padding: spacing[6],\n },\n centeredContainer: {\n alignItems: \"center\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"column\",\n paddingBottom: spacing[4],\n },\n contactInfo: {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[0.5],\n textAlign: \"right\",\n },\n\n logoContainer: {\n height: 48,\n marginRight: spacing[4],\n width: 48,\n },\n\n logoContent: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n logoLeftContainer: {\n alignItems: \"center\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n paddingBottom: spacing[4],\n },\n logoRightContainer: {\n alignItems: \"center\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[4],\n },\n\n logoRightContent: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n\n logoRightLogoContainer: {\n height: 48,\n marginLeft: spacing[4],\n width: 48,\n },\n minimalContainer: {\n alignItems: \"center\",\n borderBottomColor: c.primary,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[1],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[3],\n },\n minimalLeft: {\n flex: 1,\n },\n minimalRight: {\n alignItems: \"flex-end\",\n },\n\n rightSubText: {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[1],\n textAlign: \"right\",\n },\n rightText: {\n color: c.foreground,\n fontFamily: body.fontFamily,\n fontSize: body.fontSize,\n fontWeight: fontWeights.medium,\n textAlign: \"right\",\n },\n simpleContainer: {\n alignItems: \"flex-start\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[4],\n },\n\n simpleLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n simpleRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flexDirection: \"column\",\n },\n\n subtitle: {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: body.fontSize,\n lineHeight: body.lineHeight,\n marginTop: spacing[1],\n },\n subtitleBranded: {\n color: c.primaryForeground,\n marginTop: spacing[1],\n },\n subtitleCentered: {\n textAlign: \"center\",\n },\n\n title: {\n color: c.foreground,\n fontFamily: heading.fontFamily,\n fontSize: heading.fontSize.h3,\n fontWeight: fontWeights.bold,\n lineHeight: heading.lineHeight,\n marginBottom: 0,\n },\n titleBranded: {\n color: c.primaryForeground,\n },\n titleCentered: {\n textAlign: \"center\",\n },\n\n titleMinimal: {\n fontSize: heading.fontSize.h3,\n fontWeight: fontWeights.bold,\n },\n twoColumnContainer: {\n alignItems: \"flex-start\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[4],\n },\n twoColumnLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n twoColumnRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flexDirection: \"column\",\n },\n });\n};\n\nconst buildContainerStyles = (\n base: Style,\n mb: number,\n background: string | undefined,\n theme: PdfcnTheme,\n style: Style | undefined,\n ...extras: Style[]\n): Style[] => {\n const result: Style[] = [base, { marginBottom: mb }, ...extras];\n if (background) {\n result.push({ backgroundColor: resolveColor(background, theme.colors) });\n }\n if (style) {\n result.push(style);\n }\n return result;\n};\n\nconst buildTitleStyles = (\n base: Style[],\n titleColor: string | undefined,\n theme: PdfcnTheme\n): Style[] => {\n if (!titleColor) {\n return base;\n }\n return [...base, { color: resolveColor(titleColor, theme.colors) }];\n};\n\n/** Container and title styles of each variant. */\nconst pageHeaderStyles = (\n theme: PdfcnTheme,\n {\n variant = \"simple\",\n background,\n titleColor,\n marginBottom,\n style,\n }: Omit\n) => {\n const styles = createPageHeaderStyles(theme);\n const mb = marginBottom ?? theme.spacing.sectionGap;\n\n const variantRenderers: Record<\n PageHeaderVariant,\n () => { container: Style[]; title: Style[] }\n > = {\n branded: () => ({\n container: buildContainerStyles(\n styles.brandedContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles(\n [styles.title, styles.titleBranded, styles.titleCentered],\n titleColor,\n theme\n ),\n }),\n centered: () => ({\n container: buildContainerStyles(\n styles.centeredContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles(\n [styles.title, styles.titleCentered],\n titleColor,\n theme\n ),\n }),\n \"logo-left\": () => ({\n container: buildContainerStyles(\n styles.logoLeftContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n \"logo-right\": () => ({\n container: buildContainerStyles(\n styles.logoRightContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n minimal: () => ({\n container: buildContainerStyles(\n styles.minimalContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles(\n [styles.title, styles.titleMinimal],\n titleColor,\n theme\n ),\n }),\n simple: () => ({\n container: buildContainerStyles(\n styles.simpleContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n \"two-column\": () => ({\n container: buildContainerStyles(\n styles.twoColumnContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n };\n\n return { ...variantRenderers[variant](), styles };\n};\n\n@Component({\n imports: [TakumiText, TakumiView, NgTemplateOutlet],\n selector: \"pdf-page-header\",\n template: `\n \n \n @let s = layout().styles;\n \n @switch (variant()) {\n @case (\"branded\") {\n {{ title() }}\n @if (subtitle()) {\n {{\n subtitle()\n }}\n }\n }\n @case (\"centered\") {\n {{ title() }}\n @if (subtitle()) {\n {{\n subtitle()\n }}\n }\n }\n @case (\"logo-right\") {\n \n \n \n @if (logo(); as logo) {\n \n }\n }\n @case (\"logo-left\") {\n @if (logo(); as logo) {\n \n }\n \n \n \n \n }\n @case (\"two-column\") {\n \n \n \n @if (address() || phone() || email()) {\n \n @if (address()) {\n {{\n address()\n }}\n }\n @if (phone()) {\n {{\n phone()\n }}\n }\n @if (email()) {\n {{\n email()\n }}\n }\n \n }\n }\n @case (\"minimal\") {\n \n \n \n \n }\n @default {\n \n \n \n \n }\n }\n \n \n {{ title() }}\n @if (subtitle()) {\n {{ subtitle() }}\n }\n \n \n @if (rightText() || rightSubText()) {\n \n @if (rightText()) {\n {{ rightText() }}\n }\n @if (rightSubText()) {\n {{\n rightSubText()\n }}\n }\n \n }\n \n \n `,\n})\nexport class PdfPageHeader {\n /** Templates passed in resolve the theme from where they render, not where they are declared. */\n protected readonly injector = inject(Injector);\n readonly title = input.required();\n readonly subtitle = input();\n readonly rightText = input();\n readonly rightSubText = input();\n readonly variant = input(\"simple\");\n readonly background = input();\n readonly titleColor = input();\n readonly marginBottom = input();\n readonly address = input();\n readonly phone = input();\n readonly email = input();\n readonly logo = input>();\n /** Part of the props API but unused, as in the original. */\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly noWrap = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n pageHeaderStyles(this.theme(), {\n background: this.background(),\n marginBottom: this.marginBottom(),\n style: this.style(),\n titleColor: this.titleColor(),\n variant: this.variant(),\n })\n );\n}\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport {\n booleanAttribute,\n Component,\n computed,\n input,\n inject,\n Injector,\n} from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiText,\n TakumiView,\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 PageHeaderVariant =\n | \"simple\"\n | \"centered\"\n | \"minimal\"\n | \"branded\"\n | \"logo-left\"\n | \"logo-right\"\n | \"two-column\";\n\n/**\n * Header row with layout variants, logo support, and optional fixed positioning.\n * Props - `title` | `subtitle` | `rightText` | `rightSubText` | `variant` | `background` | `titleColor` | `marginBottom` | `address` | `phone` | `email` | `logo` | `fixed` | `noWrap` | `style`\n * @see {@link PageHeaderProps}\n */\nexport interface PageHeaderProps extends PDFComponentProps {\n title: string;\n subtitle?: string;\n rightText?: string;\n rightSubText?: string;\n /**\n * @default 'simple'\n */\n variant?: PageHeaderVariant;\n background?: string;\n titleColor?: string;\n marginBottom?: number;\n address?: string;\n phone?: string;\n email?: string;\n logo?: TemplateRef;\n /**\n * @default false\n */\n fixed?: boolean;\n /**\n * @default true\n */\n noWrap?: boolean;\n}\n\nconst createPageHeaderStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius, fontWeights } = t.primitives;\n const c = t.colors;\n const { heading, body } = t.typography;\n\n return StyleSheet.create({\n brandedContainer: {\n alignItems: \"center\",\n backgroundColor: c.primary,\n borderRadius: borderRadius.sm,\n display: \"flex\",\n flexDirection: \"column\",\n padding: spacing[6],\n },\n centeredContainer: {\n alignItems: \"center\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"column\",\n paddingBottom: spacing[4],\n },\n contactInfo: {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[0.5],\n textAlign: \"right\",\n },\n\n logoContainer: {\n height: 48,\n marginRight: spacing[4],\n width: 48,\n },\n\n logoContent: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n logoLeftContainer: {\n alignItems: \"center\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n paddingBottom: spacing[4],\n },\n logoRightContainer: {\n alignItems: \"center\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[4],\n },\n\n logoRightContent: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n\n logoRightLogoContainer: {\n height: 48,\n marginLeft: spacing[4],\n width: 48,\n },\n minimalContainer: {\n alignItems: \"center\",\n borderBottomColor: c.primary,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[1],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[3],\n },\n minimalLeft: {\n flex: 1,\n },\n minimalRight: {\n alignItems: \"flex-end\",\n },\n\n rightSubText: {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[1],\n textAlign: \"right\",\n },\n rightText: {\n color: c.foreground,\n fontFamily: body.fontFamily,\n fontSize: body.fontSize,\n fontWeight: fontWeights.medium,\n textAlign: \"right\",\n },\n simpleContainer: {\n alignItems: \"flex-start\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[4],\n },\n\n simpleLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n simpleRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flexDirection: \"column\",\n },\n\n subtitle: {\n color: c.mutedForeground,\n fontFamily: body.fontFamily,\n fontSize: body.fontSize,\n lineHeight: body.lineHeight,\n marginTop: spacing[1],\n },\n subtitleBranded: {\n color: c.primaryForeground,\n marginTop: spacing[1],\n },\n subtitleCentered: {\n textAlign: \"center\",\n },\n\n title: {\n color: c.foreground,\n fontFamily: heading.fontFamily,\n fontSize: heading.fontSize.h3,\n fontWeight: fontWeights.bold,\n lineHeight: heading.lineHeight,\n marginBottom: 0,\n },\n titleBranded: {\n color: c.primaryForeground,\n },\n titleCentered: {\n textAlign: \"center\",\n },\n\n titleMinimal: {\n fontSize: heading.fontSize.h3,\n fontWeight: fontWeights.bold,\n },\n twoColumnContainer: {\n alignItems: \"flex-start\",\n borderBottomColor: c.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: spacing[0.5],\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingBottom: spacing[4],\n },\n twoColumnLeft: {\n display: \"flex\",\n flex: 1,\n flexDirection: \"column\",\n },\n twoColumnRight: {\n alignItems: \"flex-end\",\n display: \"flex\",\n flexDirection: \"column\",\n },\n });\n};\n\nconst buildContainerStyles = (\n base: Style,\n mb: number,\n background: string | undefined,\n theme: PdfcnTheme,\n style: Style | undefined,\n ...extras: Style[]\n): Style[] => {\n const result: Style[] = [base, { marginBottom: mb }, ...extras];\n if (background) {\n result.push({ backgroundColor: resolveColor(background, theme.colors) });\n }\n if (style) {\n result.push(style);\n }\n return result;\n};\n\nconst buildTitleStyles = (\n base: Style[],\n titleColor: string | undefined,\n theme: PdfcnTheme\n): Style[] => {\n if (!titleColor) {\n return base;\n }\n return [...base, { color: resolveColor(titleColor, theme.colors) }];\n};\n\n/** Container and title styles of each variant. */\nconst pageHeaderStyles = (\n theme: PdfcnTheme,\n {\n variant = \"simple\",\n background,\n titleColor,\n marginBottom,\n style,\n }: Omit\n) => {\n const styles = createPageHeaderStyles(theme);\n const mb = marginBottom ?? theme.spacing.sectionGap;\n\n const variantRenderers: Record<\n PageHeaderVariant,\n () => { container: Style[]; title: Style[] }\n > = {\n branded: () => ({\n container: buildContainerStyles(\n styles.brandedContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles(\n [styles.title, styles.titleBranded, styles.titleCentered],\n titleColor,\n theme\n ),\n }),\n centered: () => ({\n container: buildContainerStyles(\n styles.centeredContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles(\n [styles.title, styles.titleCentered],\n titleColor,\n theme\n ),\n }),\n \"logo-left\": () => ({\n container: buildContainerStyles(\n styles.logoLeftContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n \"logo-right\": () => ({\n container: buildContainerStyles(\n styles.logoRightContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n minimal: () => ({\n container: buildContainerStyles(\n styles.minimalContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles(\n [styles.title, styles.titleMinimal],\n titleColor,\n theme\n ),\n }),\n simple: () => ({\n container: buildContainerStyles(\n styles.simpleContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n \"two-column\": () => ({\n container: buildContainerStyles(\n styles.twoColumnContainer,\n mb,\n background,\n theme,\n style\n ),\n title: buildTitleStyles([styles.title], titleColor, theme),\n }),\n };\n\n return { ...variantRenderers[variant](), styles };\n};\n\n@Component({\n imports: [TakumiText, TakumiView, NgTemplateOutlet],\n selector: \"pdf-page-header\",\n template: `\n \n \n @let s = layout().styles;\n \n @switch (variant()) {\n @case (\"branded\") {\n {{ title() }}\n @if (subtitle()) {\n {{\n subtitle()\n }}\n }\n }\n @case (\"centered\") {\n {{ title() }}\n @if (subtitle()) {\n {{\n subtitle()\n }}\n }\n }\n @case (\"logo-right\") {\n \n \n \n @if (logo(); as logo) {\n \n }\n }\n @case (\"logo-left\") {\n @if (logo(); as logo) {\n \n }\n \n \n \n \n }\n @case (\"two-column\") {\n \n \n \n @if (address() || phone() || email()) {\n \n @if (address()) {\n {{\n address()\n }}\n }\n @if (phone()) {\n {{\n phone()\n }}\n }\n @if (email()) {\n {{\n email()\n }}\n }\n \n }\n }\n @case (\"minimal\") {\n \n \n \n \n }\n @default {\n \n \n \n \n }\n }\n \n \n {{ title() }}\n @if (subtitle()) {\n {{ subtitle() }}\n }\n \n \n @if (rightText() || rightSubText()) {\n \n @if (rightText()) {\n {{ rightText() }}\n }\n @if (rightSubText()) {\n {{\n rightSubText()\n }}\n }\n \n }\n \n \n `,\n})\nexport class PdfPageHeader {\n /** Templates passed in resolve the theme from where they render, not where they are declared. */\n protected readonly injector = inject(Injector);\n readonly title = input.required();\n readonly subtitle = input();\n readonly rightText = input();\n readonly rightSubText = input();\n readonly variant = input(\"simple\");\n readonly background = input();\n readonly titleColor = input();\n readonly marginBottom = input();\n readonly address = input();\n readonly phone = input();\n readonly email = input();\n readonly logo = input>();\n /** Part of the props API but unused, as in the original. */\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly noWrap = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n pageHeaderStyles(this.theme(), {\n background: this.background(),\n marginBottom: this.marginBottom(),\n style: this.style(),\n titleColor: this.titleColor(),\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/page-header/page-header.ts" } diff --git a/apps/web/public/r/takumi/page-number.json b/apps/web/public/r/takumi/page-number.json index a231fcb..6a64273 100644 --- a/apps/web/public/r/takumi/page-number.json +++ b/apps/web/public/r/takumi/page-number.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/page-number/page-number.ts", - "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiCounter,\n TakumiText,\n TakumiView,\n flatten,\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 PageNumberAlign = \"left\" | \"center\" | \"right\";\nexport type PageNumberSize = \"xs\" | \"sm\" | \"md\";\n\n/**\n * Auto page number rendered with a configurable format string at a or inline position.\n * Props - `format` | `align` | `size` | `fixed` | `muted` | `style`\n * @see {@link PageNumberProps}\n */\nexport interface PageNumberProps extends Omit {\n /**\n * Format string — use `{page}` for current page and `{total}` for total page count.\n * @default 'Page {page} of {total}'\n */\n format?: string;\n /**\n * @default 'center'\n */\n align?: PageNumberAlign;\n /**\n * @default 'sm'\n */\n size?: PageNumberSize;\n /**\n * @default false\n */\n fixed?: boolean;\n /**\n * @default true\n */\n muted?: boolean;\n children?: never;\n}\n\nconst createPageNumberStyles = (t: PdfcnTheme) => {\n const { typography, colors, primitives } = t;\n return StyleSheet.create({\n alignCenter: { textAlign: \"center\" },\n alignLeft: { textAlign: \"left\" },\n alignRight: { textAlign: \"right\" },\n colorForeground: { color: colors.foreground },\n colorMuted: { color: colors.mutedForeground },\n container: {\n display: \"flex\",\n flexDirection: \"row\",\n width: \"100%\",\n },\n justifyCenter: { justifyContent: \"center\" },\n justifyLeft: { justifyContent: \"flex-start\" },\n justifyRight: { justifyContent: \"flex-end\" },\n sizeMd: { fontSize: primitives.typography.base },\n sizeSm: { fontSize: primitives.typography.sm },\n sizeXs: { fontSize: primitives.typography.xs },\n text: { fontFamily: typography.body.fontFamily },\n });\n};\n\nconst pageNumberLayout = (\n theme: PdfcnTheme,\n {\n format = \"Page {page} of {total}\",\n align = \"center\",\n size = \"sm\",\n muted = true,\n style,\n }: PageNumberProps\n) => {\n const styles = createPageNumberStyles(theme);\n const alignMap = {\n center: styles.alignCenter,\n left: styles.alignLeft,\n right: styles.alignRight,\n } as Record;\n const sizeMap = {\n md: styles.sizeMd,\n sm: styles.sizeSm,\n xs: styles.sizeXs,\n } as Record;\n const justifyMap = {\n center: styles.justifyCenter,\n left: styles.justifyLeft,\n right: styles.justifyRight,\n } as Record;\n const textStyles: Style[] = [\n styles.text,\n alignMap[align],\n sizeMap[size],\n muted ? styles.colorMuted : styles.colorForeground,\n ];\n if (style) {\n textStyles.push(...[style].flat());\n }\n return {\n container: [styles.container, justifyMap[align]],\n parts: format.split(/({page}|{total})/).map((part) => {\n if (part === \"{page}\") {\n return { counter: \"pageNumber\" as const, style: flatten(textStyles) };\n }\n if (part === \"{total}\") {\n return { counter: \"totalPages\" as const, style: flatten(textStyles) };\n }\n return { style: textStyles, text: part };\n }),\n };\n};\n\n@Component({\n imports: [TakumiCounter, TakumiText, TakumiView],\n selector: \"pdf-page-number\",\n template: `\n @let l = layout();\n \n @for (part of l.parts; track $index) {\n @if (part.counter) {\n \n } @else {\n {{ part.text }}\n }\n }\n \n `,\n})\nexport class PdfPageNumber {\n readonly format = input(\"Page {page} of {total}\");\n readonly align = input(\"center\");\n readonly size = input(\"sm\");\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly muted = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n pageNumberLayout(this.theme(), {\n align: this.align(),\n format: this.format(),\n muted: this.muted(),\n size: this.size(),\n style: this.style(),\n })\n );\n}\n", + "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiCounter,\n TakumiText,\n TakumiView,\n flatten,\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 PageNumberAlign = \"left\" | \"center\" | \"right\";\nexport type PageNumberSize = \"xs\" | \"sm\" | \"md\";\n\n/**\n * Auto page number rendered with a configurable format string at a or inline position.\n * Props - `format` | `align` | `size` | `fixed` | `muted` | `style`\n * @see {@link PageNumberProps}\n */\nexport interface PageNumberProps extends Omit {\n /**\n * Format string — use `{page}` for current page and `{total}` for total page count.\n * @default 'Page {page} of {total}'\n */\n format?: string;\n /**\n * @default 'center'\n */\n align?: PageNumberAlign;\n /**\n * @default 'sm'\n */\n size?: PageNumberSize;\n /**\n * @default false\n */\n fixed?: boolean;\n /**\n * @default true\n */\n muted?: boolean;\n children?: never;\n}\n\nconst createPageNumberStyles = (t: PdfcnTheme) => {\n const { typography, colors, primitives } = t;\n return StyleSheet.create({\n alignCenter: { textAlign: \"center\" },\n alignLeft: { textAlign: \"left\" },\n alignRight: { textAlign: \"right\" },\n colorForeground: { color: colors.foreground },\n colorMuted: { color: colors.mutedForeground },\n container: {\n display: \"flex\",\n flexDirection: \"row\",\n width: \"100%\",\n },\n justifyCenter: { justifyContent: \"center\" },\n justifyLeft: { justifyContent: \"flex-start\" },\n justifyRight: { justifyContent: \"flex-end\" },\n sizeMd: { fontSize: primitives.typography.base },\n sizeSm: { fontSize: primitives.typography.sm },\n sizeXs: { fontSize: primitives.typography.xs },\n text: { fontFamily: typography.body.fontFamily },\n });\n};\n\nconst pageNumberLayout = (\n theme: PdfcnTheme,\n {\n format = \"Page {page} of {total}\",\n align = \"center\",\n size = \"sm\",\n muted = true,\n style,\n }: PageNumberProps\n) => {\n const styles = createPageNumberStyles(theme);\n const alignMap = {\n center: styles.alignCenter,\n left: styles.alignLeft,\n right: styles.alignRight,\n } as Record;\n const sizeMap = {\n md: styles.sizeMd,\n sm: styles.sizeSm,\n xs: styles.sizeXs,\n } as Record;\n const justifyMap = {\n center: styles.justifyCenter,\n left: styles.justifyLeft,\n right: styles.justifyRight,\n } as Record;\n const textStyles: Style[] = [\n styles.text,\n alignMap[align],\n sizeMap[size],\n muted ? styles.colorMuted : styles.colorForeground,\n ];\n if (style) {\n textStyles.push(...[style].flat());\n }\n return {\n container: [styles.container, justifyMap[align]],\n parts: format.split(/({page}|{total})/).map((part) => {\n if (part === \"{page}\") {\n return { counter: \"pageNumber\" as const, style: flatten(textStyles) };\n }\n if (part === \"{total}\") {\n return { counter: \"totalPages\" as const, style: flatten(textStyles) };\n }\n return { style: textStyles, text: part };\n }),\n };\n};\n\n@Component({\n imports: [TakumiCounter, TakumiText, TakumiView],\n selector: \"pdf-page-number\",\n template: `\n @let l = layout();\n \n @for (part of l.parts; track $index) {\n @if (part.counter) {\n \n } @else {\n {{ part.text }}\n }\n }\n \n `,\n})\nexport class PdfPageNumber {\n readonly format = input(\"Page {page} of {total}\");\n readonly align = input(\"center\");\n readonly size = input(\"sm\");\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly muted = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n pageNumberLayout(this.theme(), {\n align: this.align(),\n format: this.format(),\n muted: this.muted(),\n size: this.size(),\n style: this.style(),\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/page-number/page-number.ts" } diff --git a/apps/web/public/r/takumi/pdf-image.json b/apps/web/public/r/takumi/pdf-image.json index 957c7df..45763fb 100644 --- a/apps/web/public/r/takumi/pdf-image.json +++ b/apps/web/public/r/takumi/pdf-image.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/pdf-image/pdf-image.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 StyleSheet,\n TakumiImage,\n TakumiText,\n TakumiView,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/** HTTP method used when fetching the image from a URL. */\nexport type PdfImageHTTPMethod =\n | \"GET\"\n | \"HEAD\"\n | \"POST\"\n | \"PUT\"\n | \"DELETE\"\n | \"PATCH\";\n\nexport type PdfImageSrc =\n | string\n | {\n uri: string;\n method?: PdfImageHTTPMethod;\n headers?: Record;\n body?: string;\n };\n\nexport type PdfImageFit = \"cover\" | \"contain\" | \"fill\" | \"none\";\n\nexport type PdfImageVariant =\n | \"default\"\n | \"full-width\"\n | \"thumbnail\"\n | \"avatar\"\n | \"cover\"\n | \"bordered\"\n | \"rounded\";\n\n/**\n * Image element with layout presets, caption, and aspect ratio support.\n * Props - `src` | `variant` | `width` | `height` | `fit` | `position` | `caption` | `aspectRatio` | `borderRadius` | `noWrap` | `style`\n * @see {@link PdfImageProps}\n */\nexport interface PdfImageProps {\n src: PdfImageSrc;\n /**\n * @default 'default'\n */\n variant?: PdfImageVariant;\n width?: number | string;\n height?: number | string;\n fit?: PdfImageFit;\n /**\n * @default '50% 50%'\n */\n position?: string;\n caption?: string;\n aspectRatio?: number;\n borderRadius?: number;\n /**\n * @default true\n */\n noWrap?: boolean;\n style?: Style;\n}\n\ninterface VariantDefaults {\n width?: number | string;\n height?: number | string;\n fit: PdfImageFit;\n borderRadius?: number;\n}\n\nconst VARIANT_DEFAULTS: Record = {\n avatar: { borderRadius: 999, fit: \"cover\", height: 48, width: 48 },\n bordered: { fit: \"contain\", width: \"100%\" },\n cover: { fit: \"cover\", height: 160, width: \"100%\" },\n default: { fit: \"contain\" },\n \"full-width\": { fit: \"cover\", width: \"100%\" },\n rounded: { borderRadius: 8, fit: \"contain\", width: 200 },\n thumbnail: { fit: \"cover\", height: 80, width: 80 },\n};\n\nconst UNSUPPORTED_FORMATS = new Set([\"webp\", \"avif\", \"heic\", \"heif\", \"ico\"]);\n\nconst detectFormat = (src: PdfImageSrc): string | null => {\n if (typeof src !== \"string\") {\n return null;\n }\n const dataMatch = src.match(/^data:image\\/([a-zA-Z0-9+.-]+)/);\n if (dataMatch) {\n return dataMatch[1].toLowerCase();\n }\n return src.split(\"?\")[0].split(\".\").pop()?.toLowerCase() ?? null;\n};\n\nconst warnIfUnsupported = (src: PdfImageSrc): void => {\n const fmt = detectFormat(src);\n if (fmt && UNSUPPORTED_FORMATS.has(fmt)) {\n console.warn(\n `[PdfImage] Unsupported format \"${fmt}\" detected. Takumi supports: JPEG, PNG, GIF (first frame), BMP, SVG. Convert to PNG or JPEG before use.`\n );\n }\n};\n\nconst createImageStyles = (t: PdfcnTheme) => {\n const { spacing } = t.primitives;\n return StyleSheet.create({\n caption: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[1],\n textAlign: \"center\",\n },\n container: { flexDirection: \"column\" },\n image: {},\n imageBordered: {\n borderColor: t.colors.border,\n borderStyle: \"solid\",\n borderWidth: 1,\n },\n });\n};\n\nconst pdfImageStyles = (\n theme: PdfcnTheme,\n {\n variant = \"default\",\n width,\n height,\n fit,\n position = \"50% 50%\",\n aspectRatio,\n borderRadius,\n style,\n }: Omit\n) => {\n const styles = createImageStyles(theme);\n const defaults = VARIANT_DEFAULTS[variant];\n\n const resolvedWidth = width ?? defaults.width;\n const resolvedHeight: number | string | undefined = (() => {\n if (height !== undefined) {\n return height;\n }\n if (defaults.height !== undefined) {\n return defaults.height;\n }\n return aspectRatio !== undefined && typeof resolvedWidth === \"number\"\n ? resolvedWidth / aspectRatio\n : undefined;\n })();\n\n const resolvedFit = fit ?? defaults.fit;\n const resolvedRadius = borderRadius ?? defaults.borderRadius;\n\n const imageStyles: Style[] = [styles.image];\n if (resolvedWidth !== undefined) {\n imageStyles.push({ width: resolvedWidth } as Style);\n }\n if (resolvedHeight !== undefined) {\n imageStyles.push({ height: resolvedHeight } as Style);\n }\n imageStyles.push({\n objectFit: resolvedFit,\n objectPosition: position,\n } as Style);\n if (resolvedRadius !== undefined) {\n imageStyles.push({ borderRadius: resolvedRadius } as Style);\n }\n if (variant === \"bordered\") {\n imageStyles.push(styles.imageBordered);\n }\n if (style) {\n imageStyles.push(style);\n }\n\n return {\n caption: styles.caption,\n container: styles.container,\n image: imageStyles,\n };\n};\n\n@Component({\n imports: [TakumiImage, TakumiText, TakumiView, NgTemplateOutlet],\n selector: \"pdf-image\",\n template: `\n @if (noWrap()) {\n \n \n \n } @else {\n \n }\n \n \n \n @if (caption()) {\n {{ caption() }}\n }\n \n \n `,\n})\nexport class PdfImage {\n readonly src = input.required();\n readonly variant = input(\"default\");\n readonly width = input();\n readonly height = input();\n readonly fit = input();\n readonly position = input(\"50% 50%\");\n readonly caption = input();\n readonly aspectRatio = input();\n readonly borderRadius = input();\n readonly noWrap = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly styles = computed(() => {\n warnIfUnsupported(this.src());\n return pdfImageStyles(this.theme(), {\n aspectRatio: this.aspectRatio(),\n borderRadius: this.borderRadius(),\n fit: this.fit(),\n height: this.height(),\n position: this.position(),\n style: this.style(),\n variant: this.variant(),\n width: this.width(),\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 StyleSheet,\n TakumiImage,\n TakumiText,\n TakumiView,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/** HTTP method used when fetching the image from a URL. */\nexport type PdfImageHTTPMethod =\n | \"GET\"\n | \"HEAD\"\n | \"POST\"\n | \"PUT\"\n | \"DELETE\"\n | \"PATCH\";\n\nexport type PdfImageSrc =\n | string\n | {\n uri: string;\n method?: PdfImageHTTPMethod;\n headers?: Record;\n body?: string;\n };\n\nexport type PdfImageFit = \"cover\" | \"contain\" | \"fill\" | \"none\";\n\nexport type PdfImageVariant =\n | \"default\"\n | \"full-width\"\n | \"thumbnail\"\n | \"avatar\"\n | \"cover\"\n | \"bordered\"\n | \"rounded\";\n\n/**\n * Image element with layout presets, caption, and aspect ratio support.\n * Props - `src` | `variant` | `width` | `height` | `fit` | `position` | `caption` | `aspectRatio` | `borderRadius` | `noWrap` | `style`\n * @see {@link PdfImageProps}\n */\nexport interface PdfImageProps {\n src: PdfImageSrc;\n /**\n * @default 'default'\n */\n variant?: PdfImageVariant;\n width?: number | string;\n height?: number | string;\n fit?: PdfImageFit;\n /**\n * @default '50% 50%'\n */\n position?: string;\n caption?: string;\n aspectRatio?: number;\n borderRadius?: number;\n /**\n * @default true\n */\n noWrap?: boolean;\n style?: Style;\n}\n\ninterface VariantDefaults {\n width?: number | string;\n height?: number | string;\n fit: PdfImageFit;\n borderRadius?: number;\n}\n\nconst VARIANT_DEFAULTS: Record = {\n avatar: { borderRadius: 999, fit: \"cover\", height: 48, width: 48 },\n bordered: { fit: \"contain\", width: \"100%\" },\n cover: { fit: \"cover\", height: 160, width: \"100%\" },\n default: { fit: \"contain\" },\n \"full-width\": { fit: \"cover\", width: \"100%\" },\n rounded: { borderRadius: 8, fit: \"contain\", width: 200 },\n thumbnail: { fit: \"cover\", height: 80, width: 80 },\n};\n\nconst UNSUPPORTED_FORMATS = new Set([\"webp\", \"avif\", \"heic\", \"heif\", \"ico\"]);\n\nconst detectFormat = (src: PdfImageSrc): string | null => {\n if (typeof src !== \"string\") {\n return null;\n }\n const dataMatch = src.match(/^data:image\\/([a-zA-Z0-9+.-]+)/);\n if (dataMatch) {\n return dataMatch[1].toLowerCase();\n }\n return src.split(\"?\")[0].split(\".\").pop()?.toLowerCase() ?? null;\n};\n\nconst warnIfUnsupported = (src: PdfImageSrc): void => {\n const fmt = detectFormat(src);\n if (fmt && UNSUPPORTED_FORMATS.has(fmt)) {\n console.warn(\n `[PdfImage] Unsupported format \"${fmt}\" detected. Takumi supports: JPEG, PNG, GIF (first frame), BMP, SVG. Convert to PNG or JPEG before use.`\n );\n }\n};\n\nconst createImageStyles = (t: PdfcnTheme) => {\n const { spacing } = t.primitives;\n return StyleSheet.create({\n caption: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[1],\n textAlign: \"center\",\n },\n container: { flexDirection: \"column\" },\n image: {},\n imageBordered: {\n borderColor: t.colors.border,\n borderStyle: \"solid\",\n borderWidth: 1,\n },\n });\n};\n\nconst pdfImageStyles = (\n theme: PdfcnTheme,\n {\n variant = \"default\",\n width,\n height,\n fit,\n position = \"50% 50%\",\n aspectRatio,\n borderRadius,\n style,\n }: Omit\n) => {\n const styles = createImageStyles(theme);\n const defaults = VARIANT_DEFAULTS[variant];\n\n const resolvedWidth = width ?? defaults.width;\n const resolvedHeight: number | string | undefined = (() => {\n if (height !== undefined) {\n return height;\n }\n if (defaults.height !== undefined) {\n return defaults.height;\n }\n return aspectRatio !== undefined && typeof resolvedWidth === \"number\"\n ? resolvedWidth / aspectRatio\n : undefined;\n })();\n\n const resolvedFit = fit ?? defaults.fit;\n const resolvedRadius = borderRadius ?? defaults.borderRadius;\n\n const imageStyles: Style[] = [styles.image];\n if (resolvedWidth !== undefined) {\n imageStyles.push({ width: resolvedWidth } as Style);\n }\n if (resolvedHeight !== undefined) {\n imageStyles.push({ height: resolvedHeight } as Style);\n }\n imageStyles.push({\n objectFit: resolvedFit,\n objectPosition: position,\n } as Style);\n if (resolvedRadius !== undefined) {\n imageStyles.push({ borderRadius: resolvedRadius } as Style);\n }\n if (variant === \"bordered\") {\n imageStyles.push(styles.imageBordered);\n }\n if (style) {\n imageStyles.push(style);\n }\n\n return {\n caption: styles.caption,\n container: styles.container,\n image: imageStyles,\n };\n};\n\n@Component({\n imports: [TakumiImage, TakumiText, TakumiView, NgTemplateOutlet],\n selector: \"pdf-image\",\n template: `\n @if (noWrap()) {\n \n \n \n } @else {\n \n }\n \n \n \n @if (caption()) {\n {{ caption() }}\n }\n \n \n `,\n})\nexport class PdfImage {\n readonly src = input.required();\n readonly variant = input(\"default\");\n readonly width = input();\n readonly height = input();\n readonly fit = input();\n readonly position = input(\"50% 50%\");\n readonly caption = input();\n readonly aspectRatio = input();\n readonly borderRadius = input();\n readonly noWrap = input(true, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly styles = computed(() => {\n warnIfUnsupported(this.src());\n return pdfImageStyles(this.theme(), {\n aspectRatio: this.aspectRatio(),\n borderRadius: this.borderRadius(),\n fit: this.fit(),\n height: this.height(),\n position: this.position(),\n style: this.style(),\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/pdf-image/pdf-image.ts" } diff --git a/apps/web/public/r/takumi/press-release.json b/apps/web/public/r/takumi/press-release.json index 3b9d55c..8ee1850 100644 --- a/apps/web/public/r/takumi/press-release.json +++ b/apps/web/public/r/takumi/press-release.json @@ -18,13 +18,13 @@ "files": [ { "path": "registry/bases/takumi/blocks/press-release/press-release.ts", - "content": "import { Component, computed, input } from \"@angular/core\";\n\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 { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n TakumiDocument,\n TakumiPage,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { PressReleaseProps } from \"./press-release.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: PressReleaseProps = {\n accentColor: \"#1e40af\",\n address: \"123 Market St, San Francisco, CA 94103\",\n body: [\n \"Acme Corp today announced the launch of pdfcn, an open-source React component library for generating professional PDF documents.\",\n \"pdfcn is designed to work seamlessly with shadcn/ui and follows the same registry-based distribution model, letting developers add print-ready document blocks with a single CLI command.\",\n ],\n boilerplate:\n \"Acme Corp is a leading provider of developer tools and open-source software.\",\n companyName: \"Acme Corp\",\n date: \"September 10, 2026\",\n dateline: { city: \"San Francisco\", state: \"CA\" },\n headline: \"Acme Corp Launches Revolutionary PDF Toolkit for Developers\",\n mediaContact: {\n email: \"press@acme.com\",\n name: \"Press Team\",\n phone: \"(555) 123-4567\",\n },\n quotes: [\n {\n author: \"Jane Doe\",\n text: \"We built pdfcn because generating PDFs in React was unnecessarily painful. Now it feels like writing any other component.\",\n title: \"CTO, Acme Corp\",\n },\n ],\n socialLinks: [\n { platform: \"GitHub\", url: \"https://github.com/acme\" },\n { platform: \"X\", url: \"https://x.com/acme\" },\n ],\n subheadline:\n \"New open-source library makes generating professional PDFs in React effortless\",\n};\n\nconst pressReleaseStyles = (theme: PdfcnTheme) =>\n StyleSheet.create({\n columnHeading: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\n },\n });\n\n@Component({\n imports: [\n TakumiDocument,\n TakumiPage,\n PdfImage,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n ],\n selector: \"pdf-press-release-content\",\n template: `\n @let data = this.data();\n \n \n \n \n \n \n \n For Immediate Release\n {{\n data.headline\n }}\n @if (data.subheadline) {\n {{\n data.subheadline\n }}\n }\n \n \n {{\n data.dateline.city +\n \", \" +\n data.dateline.state +\n \" — \" +\n data.date\n }}\n @for (paragraph of data.body; track $index) {\n {{ paragraph }}\n }\n \n @for (quote of data.quotes ?? []; track quote.author) {\n \n {{\n \"“\" + quote.text + \"”\"\n }}\n {{\n \"— \" + quote.author + \", \" + quote.title\n }}\n \n }\n \n {{ \"About \" + data.companyName }}\n {{ data.boilerplate }}\n \n \n Media Contact\n {{\n data.mediaContact.name\n }}\n {{\n data.mediaContact.email\n }}\n {{\n data.mediaContact.phone\n }}\n @if (data.mediaContact.website) {\n {{\n data.mediaContact.website\n }}\n }\n \n ###\n \n \n \n `,\n})\nexport class PressReleaseContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() => pressReleaseStyles(this.theme()));\n\n protected readonly footerRightText = computed(() => {\n const data = this.data();\n return data.socialLinks?.length\n ? data.socialLinks.map((link) => link.platform).join(\" · \")\n : undefined;\n });\n}\n\n@Component({\n imports: [PdfcnThemeProvider, PressReleaseContent],\n selector: \"pdf-press-release\",\n template: `\n \n \n \n `,\n})\nexport class PressReleaseDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly mergedData = computed(\n (): PressReleaseProps => ({ ...sampleData, ...this.data() })\n );\n}\n", + "content": "import { Component, computed, input } from \"@angular/core\";\n\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 { PdfText } from \"@/components/pdf/text/text\";\nimport {\n PdfcnThemeProvider,\n injectPdfcnTheme,\n} from \"@/components/pdf/theme-provider\";\nimport {\n TakumiDocument,\n TakumiPage,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { PressReleaseProps } from \"./press-release.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: PressReleaseProps = {\n accentColor: \"#1e40af\",\n address: \"123 Market St, San Francisco, CA 94103\",\n body: [\n \"Acme Corp today announced the launch of pdfcn, an open-source React component library for generating professional PDF documents.\",\n \"pdfcn is designed to work seamlessly with shadcn/ui and follows the same registry-based distribution model, letting developers add print-ready document blocks with a single CLI command.\",\n ],\n boilerplate:\n \"Acme Corp is a leading provider of developer tools and open-source software.\",\n companyName: \"Acme Corp\",\n date: \"September 10, 2026\",\n dateline: { city: \"San Francisco\", state: \"CA\" },\n headline: \"Acme Corp Launches Revolutionary PDF Toolkit for Developers\",\n mediaContact: {\n email: \"press@acme.com\",\n name: \"Press Team\",\n phone: \"(555) 123-4567\",\n },\n quotes: [\n {\n author: \"Jane Doe\",\n text: \"We built pdfcn because generating PDFs in React was unnecessarily painful. Now it feels like writing any other component.\",\n title: \"CTO, Acme Corp\",\n },\n ],\n socialLinks: [\n { platform: \"GitHub\", url: \"https://github.com/acme\" },\n { platform: \"X\", url: \"https://x.com/acme\" },\n ],\n subheadline:\n \"New open-source library makes generating professional PDFs in React effortless\",\n};\n\nconst pressReleaseStyles = (theme: PdfcnTheme) =>\n StyleSheet.create({\n columnHeading: {\n fontSize: 9,\n fontWeight: \"bold\",\n marginBottom: 2,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n padding: theme.spacing.page.marginTop,\n paddingBottom: theme.spacing.page.marginBottom,\n position: \"relative\",\n },\n });\n\n@Component({\n imports: [\n TakumiDocument,\n TakumiPage,\n PdfImage,\n PdfPageFooter,\n PdfPageHeader,\n PdfSection,\n PdfText,\n ],\n selector: \"pdf-press-release-content\",\n template: `\n @let data = this.data();\n \n \n \n \n \n \n \n For Immediate Release\n {{\n data.headline\n }}\n @if (data.subheadline) {\n {{\n data.subheadline\n }}\n }\n \n \n {{\n data.dateline.city +\n \", \" +\n data.dateline.state +\n \" — \" +\n data.date\n }}\n @for (paragraph of data.body; track $index) {\n {{ paragraph }}\n }\n \n @for (quote of data.quotes ?? []; track quote.author) {\n \n {{\n \"“\" + quote.text + \"”\"\n }}\n {{\n \"— \" + quote.author + \", \" + quote.title\n }}\n \n }\n \n {{ \"About \" + data.companyName }}\n {{ data.boilerplate }}\n \n \n Media Contact\n {{\n data.mediaContact.name\n }}\n {{\n data.mediaContact.email\n }}\n {{\n data.mediaContact.phone\n }}\n @if (data.mediaContact.website) {\n {{\n data.mediaContact.website\n }}\n }\n \n ###\n \n \n \n `,\n})\nexport class PressReleaseContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly styles = computed(() => pressReleaseStyles(this.theme()));\n\n protected readonly footerRightText = computed(() => {\n const data = this.data();\n return data.socialLinks?.length\n ? data.socialLinks.map((link) => link.platform).join(\" · \")\n : undefined;\n });\n}\n\n@Component({\n imports: [PdfcnThemeProvider, PressReleaseContent],\n selector: \"pdf-press-release\",\n template: `\n \n \n \n `,\n})\nexport class PressReleaseDocument {\n readonly theme = input();\n readonly data = input>();\n\n protected readonly mergedData = computed(\n (): PressReleaseProps => ({ ...sampleData, ...this.data() })\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:block", "target": "components/pdf/blocks/press-release/press-release.ts" }, { "path": "registry/bases/takumi/blocks/press-release/press-release.types.ts", - "content": "export interface PressReleaseDateline {\n city: string;\n state: string;\n}\n\nexport interface PressReleaseQuote {\n text: string;\n author: string;\n title: string;\n}\n\nexport interface PressReleaseMediaContact {\n name: string;\n email: string;\n phone: string;\n website?: string;\n}\n\nexport interface PressReleaseSocialLink {\n platform: string;\n url: string;\n}\n\nexport interface PressReleaseProps {\n companyName: string;\n companyLogo?: string;\n date: string;\n headline: string;\n subheadline?: string;\n dateline: PressReleaseDateline;\n body: string[];\n quotes?: PressReleaseQuote[];\n boilerplate: string;\n mediaContact: PressReleaseMediaContact;\n address?: string;\n socialLinks?: PressReleaseSocialLink[];\n accentColor?: string;\n renderingBase?: \"takumi\" | \"forme\";\n}\n", + "content": "export interface PressReleaseDateline {\n city: string;\n state: string;\n}\n\nexport interface PressReleaseQuote {\n text: string;\n author: string;\n title: string;\n}\n\nexport interface PressReleaseMediaContact {\n name: string;\n email: string;\n phone: string;\n website?: string;\n}\n\nexport interface PressReleaseSocialLink {\n platform: string;\n url: string;\n}\n\nexport interface PressReleaseProps {\n companyName: string;\n companyLogo?: string;\n date: string;\n headline: string;\n subheadline?: string;\n dateline: PressReleaseDateline;\n body: string[];\n quotes?: PressReleaseQuote[];\n boilerplate: string;\n mediaContact: PressReleaseMediaContact;\n address?: string;\n socialLinks?: PressReleaseSocialLink[];\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/press-release/press-release.types.ts" } diff --git a/apps/web/public/r/takumi/qrcode.json b/apps/web/public/r/takumi/qrcode.json index 0b1d941..9af4f24 100644 --- a/apps/web/public/r/takumi/qrcode.json +++ b/apps/web/public/r/takumi/qrcode.json @@ -17,7 +17,7 @@ "files": [ { "path": "registry/bases/takumi/components/qrcode/qrcode.ts", - "content": "import { Component, computed, input } from \"@angular/core\";\nimport QRCode from \"qrcode\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiSvg,\n TakumiText,\n TakumiView,\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 QRCodeErrorLevel = \"L\" | \"M\" | \"Q\" | \"H\";\n\n/**\n * QR code rendered as an SVG grid for use in PDF documents.\n * Props - `value` | `size` | `color` | `backgroundColor` | `errorLevel` | `margin` | `caption` | `style`\n * @see {@link PdfQRCodeProps}\n */\nexport interface PdfQRCodeProps extends Omit {\n value: string;\n size?: number;\n color?: string;\n backgroundColor?: string;\n errorLevel?: QRCodeErrorLevel;\n margin?: number;\n caption?: string;\n children?: never;\n}\n\nconst createQRCodeStyles = (t: PdfcnTheme) => {\n const { spacing } = t.primitives;\n return StyleSheet.create({\n caption: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[1],\n textAlign: \"center\",\n },\n container: { alignItems: \"center\" },\n });\n};\n\nconst generateQRMatrix = (\n value: string,\n errorLevel: QRCodeErrorLevel,\n margin: number\n): boolean[][] => {\n const qr = QRCode.create(value, { errorCorrectionLevel: errorLevel });\n const { size, data } = qr.modules;\n const totalSize = size + margin * 2;\n const matrix: boolean[][] = [];\n for (let row = 0; row < totalSize; row += 1) {\n const rowData: boolean[] = [];\n for (let col = 0; col < totalSize; col += 1) {\n const isInMargin =\n row < margin ||\n row >= size + margin ||\n col < margin ||\n col >= size + margin;\n if (isInMargin) {\n rowData.push(false);\n } else {\n rowData.push(data[(row - margin) * size + (col - margin)] === 1);\n }\n }\n matrix.push(rowData);\n }\n return matrix;\n};\n\nconst qrCodeLayout = (\n theme: PdfcnTheme,\n {\n value,\n size = 100,\n color = \"#000000\",\n backgroundColor = \"#ffffff\",\n errorLevel = \"M\",\n margin = 2,\n style,\n }: Omit\n) => {\n const styles = createQRCodeStyles(theme);\n const matrix = generateQRMatrix(value, errorLevel, margin);\n const moduleSize = size / matrix.length;\n const resolvedColor = resolveColor(color, theme.colors);\n const resolvedBgColor =\n backgroundColor === \"transparent\"\n ? undefined\n : resolveColor(backgroundColor, theme.colors);\n const containerStyles: Style[] = [styles.container];\n if (style) {\n containerStyles.push(...[style].flat());\n }\n\n return {\n caption: styles.caption,\n container: containerStyles,\n moduleSize,\n modules: matrix\n .flatMap((row, y) =>\n row\n .map((isDark, x) => (isDark ? { x, y } : null))\n .filter((pos): pos is { x: number; y: number } => pos !== null)\n )\n .map((pos) => ({ x: pos.x * moduleSize, y: pos.y * moduleSize })),\n resolvedBgColor,\n resolvedColor,\n viewBox: `0 0 ${size} ${size}`,\n };\n};\n\n@Component({\n imports: [TakumiSvg, TakumiText, TakumiView],\n selector: \"pdf-qrcode\",\n template: `\n @let l = layout();\n \n \n @if (l.resolvedBgColor !== undefined) {\n \n }\n @for (pos of l.modules; track $index) {\n \n }\n \n @if (caption()) {\n {{ caption() }}\n }\n \n `,\n})\nexport class PdfQRCode {\n readonly value = input.required();\n readonly size = input(100);\n readonly color = input(\"#000000\");\n readonly backgroundColor = input(\"#ffffff\");\n readonly errorLevel = input(\"M\");\n readonly margin = input(2);\n readonly caption = input();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n qrCodeLayout(this.theme(), {\n backgroundColor: this.backgroundColor(),\n color: this.color(),\n errorLevel: this.errorLevel(),\n margin: this.margin(),\n size: this.size(),\n style: this.style(),\n value: this.value(),\n })\n );\n}\n", + "content": "import { Component, computed, input } from \"@angular/core\";\nimport QRCode from \"qrcode\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiSvg,\n TakumiText,\n TakumiView,\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 QRCodeErrorLevel = \"L\" | \"M\" | \"Q\" | \"H\";\n\n/**\n * QR code rendered as an SVG grid for use in PDF documents.\n * Props - `value` | `size` | `color` | `backgroundColor` | `errorLevel` | `margin` | `caption` | `style`\n * @see {@link PdfQRCodeProps}\n */\nexport interface PdfQRCodeProps extends Omit {\n value: string;\n size?: number;\n color?: string;\n backgroundColor?: string;\n errorLevel?: QRCodeErrorLevel;\n margin?: number;\n caption?: string;\n children?: never;\n}\n\nconst createQRCodeStyles = (t: PdfcnTheme) => {\n const { spacing } = t.primitives;\n return StyleSheet.create({\n caption: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.primitives.typography.xs,\n marginTop: spacing[1],\n textAlign: \"center\",\n },\n container: { alignItems: \"center\" },\n });\n};\n\nconst generateQRMatrix = (\n value: string,\n errorLevel: QRCodeErrorLevel,\n margin: number\n): boolean[][] => {\n const qr = QRCode.create(value, { errorCorrectionLevel: errorLevel });\n const { size, data } = qr.modules;\n const totalSize = size + margin * 2;\n const matrix: boolean[][] = [];\n for (let row = 0; row < totalSize; row += 1) {\n const rowData: boolean[] = [];\n for (let col = 0; col < totalSize; col += 1) {\n const isInMargin =\n row < margin ||\n row >= size + margin ||\n col < margin ||\n col >= size + margin;\n if (isInMargin) {\n rowData.push(false);\n } else {\n rowData.push(data[(row - margin) * size + (col - margin)] === 1);\n }\n }\n matrix.push(rowData);\n }\n return matrix;\n};\n\nconst qrCodeLayout = (\n theme: PdfcnTheme,\n {\n value,\n size = 100,\n color = \"#000000\",\n backgroundColor = \"#ffffff\",\n errorLevel = \"M\",\n margin = 2,\n style,\n }: Omit\n) => {\n const styles = createQRCodeStyles(theme);\n const matrix = generateQRMatrix(value, errorLevel, margin);\n const moduleSize = size / matrix.length;\n const resolvedColor = resolveColor(color, theme.colors);\n const resolvedBgColor =\n backgroundColor === \"transparent\"\n ? undefined\n : resolveColor(backgroundColor, theme.colors);\n const containerStyles: Style[] = [styles.container];\n if (style) {\n containerStyles.push(...[style].flat());\n }\n\n return {\n caption: styles.caption,\n container: containerStyles,\n moduleSize,\n modules: matrix\n .flatMap((row, y) =>\n row\n .map((isDark, x) => (isDark ? { x, y } : null))\n .filter((pos): pos is { x: number; y: number } => pos !== null)\n )\n .map((pos) => ({ x: pos.x * moduleSize, y: pos.y * moduleSize })),\n resolvedBgColor,\n resolvedColor,\n viewBox: `0 0 ${size} ${size}`,\n };\n};\n\n@Component({\n imports: [TakumiSvg, TakumiText, TakumiView],\n selector: \"pdf-qrcode\",\n template: `\n @let l = layout();\n \n \n @if (l.resolvedBgColor !== undefined) {\n \n }\n @for (pos of l.modules; track $index) {\n \n }\n \n @if (caption()) {\n {{ caption() }}\n }\n \n `,\n})\nexport class PdfQRCode {\n readonly value = input.required();\n readonly size = input(100);\n readonly color = input(\"#000000\");\n readonly backgroundColor = input(\"#ffffff\");\n readonly errorLevel = input(\"M\");\n readonly margin = input(2);\n readonly caption = input();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n qrCodeLayout(this.theme(), {\n backgroundColor: this.backgroundColor(),\n color: this.color(),\n errorLevel: this.errorLevel(),\n margin: this.margin(),\n size: this.size(),\n style: this.style(),\n value: this.value(),\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/qrcode/qrcode.ts" } diff --git a/apps/web/public/r/takumi/report-financial.json b/apps/web/public/r/takumi/report-financial.json index b9c0a3f..43c41c9 100644 --- a/apps/web/public/r/takumi/report-financial.json +++ b/apps/web/public/r/takumi/report-financial.json @@ -23,19 +23,19 @@ "files": [ { "path": "registry/bases/takumi/blocks/report-financial/report-financial.ts", - "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleFinancialData: BaseReportData = {\n author: \"Finance Ops\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"Revenue accelerated after enterprise expansion campaign launch.\",\n \"Gross margin improved due to infrastructure cost renegotiation.\",\n \"Collections requires executive follow-up on two overdue accounts.\",\n ],\n period: \"Q1 2026\",\n rows: [\n {\n label: \"Enterprise Sales\",\n owner: \"A. Patel\",\n progress: 88,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"SMB Sales\",\n owner: \"L. Khan\",\n progress: 79,\n risk: \"Medium\",\n status: \"On Track\",\n },\n {\n label: \"Collections\",\n owner: \"J. Reyes\",\n progress: 63,\n risk: \"High\",\n status: \"At Risk\",\n },\n {\n label: \"Cost Optimization\",\n owner: \"K. Singh\",\n progress: 82,\n risk: \"Low\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 72 },\n { label: \"W2\", value: 74 },\n { label: \"W3\", value: 76 },\n { label: \"W4\", value: 77 },\n { label: \"W5\", value: 79 },\n { label: \"W6\", value: 80 },\n { label: \"W7\", value: 81 },\n { label: \"W8\", value: 83 },\n { label: \"W9\", value: 82 },\n { label: \"W10\", value: 84 },\n { label: \"W11\", value: 86 },\n { label: \"W12\", value: 88 },\n ],\n subtitle: \"Revenue, margin, and expense control overview\",\n summary: [\n { label: \"Revenue\", tone: \"success\", trend: \"+14.2% QoQ\", value: \"$2.48M\" },\n {\n label: \"Gross Margin\",\n tone: \"success\",\n trend: \"+2.1 pts\",\n value: \"61.8%\",\n },\n { label: \"Opex\", tone: \"success\", trend: \"-3.4% QoQ\", value: \"$0.93M\" },\n { label: \"Runway\", tone: \"info\", trend: \"Stable\", value: \"22 months\" },\n ],\n title: \"Quarterly Financial Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-financial\",\n template: `\n \n `,\n})\nexport class FinancialReportDocument {\n readonly theme = input();\n readonly data = input(sampleFinancialData);\n}\n", + "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleFinancialData: BaseReportData = {\n author: \"Finance Ops\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"Revenue accelerated after enterprise expansion campaign launch.\",\n \"Gross margin improved due to infrastructure cost renegotiation.\",\n \"Collections requires executive follow-up on two overdue accounts.\",\n ],\n period: \"Q1 2026\",\n rows: [\n {\n label: \"Enterprise Sales\",\n owner: \"A. Patel\",\n progress: 88,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"SMB Sales\",\n owner: \"L. Khan\",\n progress: 79,\n risk: \"Medium\",\n status: \"On Track\",\n },\n {\n label: \"Collections\",\n owner: \"J. Reyes\",\n progress: 63,\n risk: \"High\",\n status: \"At Risk\",\n },\n {\n label: \"Cost Optimization\",\n owner: \"K. Singh\",\n progress: 82,\n risk: \"Low\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 72 },\n { label: \"W2\", value: 74 },\n { label: \"W3\", value: 76 },\n { label: \"W4\", value: 77 },\n { label: \"W5\", value: 79 },\n { label: \"W6\", value: 80 },\n { label: \"W7\", value: 81 },\n { label: \"W8\", value: 83 },\n { label: \"W9\", value: 82 },\n { label: \"W10\", value: 84 },\n { label: \"W11\", value: 86 },\n { label: \"W12\", value: 88 },\n ],\n subtitle: \"Revenue, margin, and expense control overview\",\n summary: [\n { label: \"Revenue\", tone: \"success\", trend: \"+14.2% QoQ\", value: \"$2.48M\" },\n {\n label: \"Gross Margin\",\n tone: \"success\",\n trend: \"+2.1 pts\",\n value: \"61.8%\",\n },\n { label: \"Opex\", tone: \"success\", trend: \"-3.4% QoQ\", value: \"$0.93M\" },\n { label: \"Runway\", tone: \"info\", trend: \"Stable\", value: \"22 months\" },\n ],\n title: \"Quarterly Financial Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-financial\",\n template: `\n \n `,\n})\nexport class FinancialReportDocument {\n readonly theme = input();\n readonly data = input(sampleFinancialData);\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/report-financial/report-financial.ts" }, { "path": "registry/bases/takumi/blocks/report-financial/report-layout.ts", - "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const deliveryOffset: Record = {\n area: 0,\n bar: 31,\n donut: 65,\n \"horizontal-bar\": -2,\n line: -31,\n pie: 0,\n };\n const graphHeight: Record = {\n area: 191,\n bar: 184,\n donut: 193,\n \"horizontal-bar\": 163,\n line: 195,\n pie: 191,\n };\n const graphOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const styles = StyleSheet.create({\n col: {\n flex: 1,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 8,\n width: \"48.6%\",\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n paddingBottom: theme.spacing.page.marginBottom,\n paddingLeft: theme.spacing.page.marginLeft,\n paddingRight: theme.spacing.page.marginRight,\n paddingTop: theme.spacing.page.marginTop,\n position: \"relative\",\n },\n pageBreak: {\n breakAfter: \"page\",\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: [\n styles.graphShell,\n {\n marginTop: graphVariant === \"horizontal-bar\" ? 34 : 0,\n position: \"relative\" as const,\n top: graphOffset[graphVariant],\n },\n ],\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metrics: data.summary.map((metric) => ({\n cardStyle: [\n styles.metricCard,\n {\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n ],\n metric,\n })),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle:\n graphVariant === \"horizontal-bar\" ? { marginTop: -6 } : undefined,\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n TakumiDocument,\n TakumiPage,\n TakumiView,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (card of l.metrics; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n \n\n \n \n\n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n\n \n \n\n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n\n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n}\n", + "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const deliveryOffset: Record = {\n area: 0,\n bar: 31,\n donut: 65,\n \"horizontal-bar\": -2,\n line: -31,\n pie: 0,\n };\n const graphHeight: Record = {\n area: 191,\n bar: 184,\n donut: 193,\n \"horizontal-bar\": 163,\n line: 195,\n pie: 191,\n };\n const graphOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const styles = StyleSheet.create({\n col: {\n flex: 1,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 8,\n width: \"48.6%\",\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n paddingBottom: theme.spacing.page.marginBottom,\n paddingLeft: theme.spacing.page.marginLeft,\n paddingRight: theme.spacing.page.marginRight,\n paddingTop: theme.spacing.page.marginTop,\n position: \"relative\",\n },\n pageBreak: {\n breakAfter: \"page\",\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: [\n styles.graphShell,\n {\n marginTop: graphVariant === \"horizontal-bar\" ? 34 : 0,\n position: \"relative\" as const,\n top: graphOffset[graphVariant],\n },\n ],\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metrics: data.summary.map((metric) => ({\n cardStyle: [\n styles.metricCard,\n {\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n ],\n metric,\n })),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle:\n graphVariant === \"horizontal-bar\" ? { marginTop: -6 } : undefined,\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n TakumiDocument,\n TakumiPage,\n TakumiView,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (card of l.metrics; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n \n\n \n \n\n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n\n \n \n\n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n\n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\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/report-financial/report-layout.ts" }, { "path": "registry/bases/takumi/blocks/report-financial/report.types.ts", - "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: string[];\n}\n", + "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: 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/report-financial/report.types.ts" } diff --git a/apps/web/public/r/takumi/report-marketing.json b/apps/web/public/r/takumi/report-marketing.json index 3c1ce42..aa43186 100644 --- a/apps/web/public/r/takumi/report-marketing.json +++ b/apps/web/public/r/takumi/report-marketing.json @@ -23,19 +23,19 @@ "files": [ { "path": "registry/bases/takumi/blocks/report-marketing/report-layout.ts", - "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const deliveryOffset: Record = {\n area: 0,\n bar: 31,\n donut: 65,\n \"horizontal-bar\": -2,\n line: -31,\n pie: 0,\n };\n const graphHeight: Record = {\n area: 191,\n bar: 184,\n donut: 193,\n \"horizontal-bar\": 163,\n line: 195,\n pie: 191,\n };\n const graphOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const styles = StyleSheet.create({\n col: {\n flex: 1,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 8,\n width: \"48.6%\",\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n paddingBottom: theme.spacing.page.marginBottom,\n paddingLeft: theme.spacing.page.marginLeft,\n paddingRight: theme.spacing.page.marginRight,\n paddingTop: theme.spacing.page.marginTop,\n position: \"relative\",\n },\n pageBreak: {\n breakAfter: \"page\",\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: [\n styles.graphShell,\n {\n marginTop: graphVariant === \"horizontal-bar\" ? 34 : 0,\n position: \"relative\" as const,\n top: graphOffset[graphVariant],\n },\n ],\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metrics: data.summary.map((metric) => ({\n cardStyle: [\n styles.metricCard,\n {\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n ],\n metric,\n })),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle:\n graphVariant === \"horizontal-bar\" ? { marginTop: -6 } : undefined,\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n TakumiDocument,\n TakumiPage,\n TakumiView,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (card of l.metrics; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n \n\n \n \n\n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n\n \n \n\n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n\n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n}\n", + "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const deliveryOffset: Record = {\n area: 0,\n bar: 31,\n donut: 65,\n \"horizontal-bar\": -2,\n line: -31,\n pie: 0,\n };\n const graphHeight: Record = {\n area: 191,\n bar: 184,\n donut: 193,\n \"horizontal-bar\": 163,\n line: 195,\n pie: 191,\n };\n const graphOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const styles = StyleSheet.create({\n col: {\n flex: 1,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 8,\n width: \"48.6%\",\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n paddingBottom: theme.spacing.page.marginBottom,\n paddingLeft: theme.spacing.page.marginLeft,\n paddingRight: theme.spacing.page.marginRight,\n paddingTop: theme.spacing.page.marginTop,\n position: \"relative\",\n },\n pageBreak: {\n breakAfter: \"page\",\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: [\n styles.graphShell,\n {\n marginTop: graphVariant === \"horizontal-bar\" ? 34 : 0,\n position: \"relative\" as const,\n top: graphOffset[graphVariant],\n },\n ],\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metrics: data.summary.map((metric) => ({\n cardStyle: [\n styles.metricCard,\n {\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n ],\n metric,\n })),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle:\n graphVariant === \"horizontal-bar\" ? { marginTop: -6 } : undefined,\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n TakumiDocument,\n TakumiPage,\n TakumiView,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (card of l.metrics; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n \n\n \n \n\n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n\n \n \n\n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n\n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\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/report-marketing/report-layout.ts" }, { "path": "registry/bases/takumi/blocks/report-marketing/report-marketing.ts", - "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleMarketingData: BaseReportData = {\n author: \"Growth Team\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"Channel mix improved CAC while maintaining lead quality.\",\n \"Lifecycle email workflow has deliverability issues under investigation.\",\n \"Referral program is producing higher-intent pipeline with lower cost.\",\n ],\n period: \"Campaign Cycle 2026-02\",\n rows: [\n {\n label: \"SEO\",\n owner: \"H. Evans\",\n progress: 84,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Paid Search\",\n owner: \"K. Martin\",\n progress: 80,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Lifecycle Email\",\n owner: \"V. Lee\",\n progress: 64,\n risk: \"Medium\",\n status: \"At Risk\",\n },\n {\n label: \"Partner Referrals\",\n owner: \"J. Gomez\",\n progress: 75,\n risk: \"Medium\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 55 },\n { label: \"W2\", value: 57 },\n { label: \"W3\", value: 59 },\n { label: \"W4\", value: 60 },\n { label: \"W5\", value: 62 },\n { label: \"W6\", value: 63 },\n { label: \"W7\", value: 65 },\n { label: \"W8\", value: 67 },\n { label: \"W9\", value: 66 },\n { label: \"W10\", value: 68 },\n { label: \"W11\", value: 70 },\n { label: \"W12\", value: 72 },\n ],\n subtitle: \"Pipeline, conversion efficiency, and channel performance\",\n summary: [\n { label: \"MQLs\", tone: \"success\", trend: \"+22.1% cycle\", value: \"3,940\" },\n { label: \"CAC\", tone: \"success\", trend: \"-7.4%\", value: \"$118\" },\n { label: \"Win Rate\", tone: \"info\", trend: \"+1.1 pts\", value: \"28.6%\" },\n { label: \"Churn Risk\", tone: \"warning\", trend: \"+0.8 pts\", value: \"6.2%\" },\n ],\n title: \"Growth & Marketing Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-marketing\",\n template: `\n \n `,\n})\nexport class MarketingReportDocument {\n readonly theme = input();\n readonly data = input(sampleMarketingData);\n}\n", + "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleMarketingData: BaseReportData = {\n author: \"Growth Team\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"Channel mix improved CAC while maintaining lead quality.\",\n \"Lifecycle email workflow has deliverability issues under investigation.\",\n \"Referral program is producing higher-intent pipeline with lower cost.\",\n ],\n period: \"Campaign Cycle 2026-02\",\n rows: [\n {\n label: \"SEO\",\n owner: \"H. Evans\",\n progress: 84,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Paid Search\",\n owner: \"K. Martin\",\n progress: 80,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Lifecycle Email\",\n owner: \"V. Lee\",\n progress: 64,\n risk: \"Medium\",\n status: \"At Risk\",\n },\n {\n label: \"Partner Referrals\",\n owner: \"J. Gomez\",\n progress: 75,\n risk: \"Medium\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 55 },\n { label: \"W2\", value: 57 },\n { label: \"W3\", value: 59 },\n { label: \"W4\", value: 60 },\n { label: \"W5\", value: 62 },\n { label: \"W6\", value: 63 },\n { label: \"W7\", value: 65 },\n { label: \"W8\", value: 67 },\n { label: \"W9\", value: 66 },\n { label: \"W10\", value: 68 },\n { label: \"W11\", value: 70 },\n { label: \"W12\", value: 72 },\n ],\n subtitle: \"Pipeline, conversion efficiency, and channel performance\",\n summary: [\n { label: \"MQLs\", tone: \"success\", trend: \"+22.1% cycle\", value: \"3,940\" },\n { label: \"CAC\", tone: \"success\", trend: \"-7.4%\", value: \"$118\" },\n { label: \"Win Rate\", tone: \"info\", trend: \"+1.1 pts\", value: \"28.6%\" },\n { label: \"Churn Risk\", tone: \"warning\", trend: \"+0.8 pts\", value: \"6.2%\" },\n ],\n title: \"Growth & Marketing Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-marketing\",\n template: `\n \n `,\n})\nexport class MarketingReportDocument {\n readonly theme = input();\n readonly data = input(sampleMarketingData);\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/report-marketing/report-marketing.ts" }, { "path": "registry/bases/takumi/blocks/report-marketing/report.types.ts", - "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: string[];\n}\n", + "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: 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/report-marketing/report.types.ts" } diff --git a/apps/web/public/r/takumi/report-operations.json b/apps/web/public/r/takumi/report-operations.json index 6adf087..a8184fc 100644 --- a/apps/web/public/r/takumi/report-operations.json +++ b/apps/web/public/r/takumi/report-operations.json @@ -23,19 +23,19 @@ "files": [ { "path": "registry/bases/takumi/blocks/report-operations/report-layout.ts", - "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const deliveryOffset: Record = {\n area: 0,\n bar: 31,\n donut: 65,\n \"horizontal-bar\": -2,\n line: -31,\n pie: 0,\n };\n const graphHeight: Record = {\n area: 191,\n bar: 184,\n donut: 193,\n \"horizontal-bar\": 163,\n line: 195,\n pie: 191,\n };\n const graphOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const styles = StyleSheet.create({\n col: {\n flex: 1,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 8,\n width: \"48.6%\",\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n paddingBottom: theme.spacing.page.marginBottom,\n paddingLeft: theme.spacing.page.marginLeft,\n paddingRight: theme.spacing.page.marginRight,\n paddingTop: theme.spacing.page.marginTop,\n position: \"relative\",\n },\n pageBreak: {\n breakAfter: \"page\",\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: [\n styles.graphShell,\n {\n marginTop: graphVariant === \"horizontal-bar\" ? 34 : 0,\n position: \"relative\" as const,\n top: graphOffset[graphVariant],\n },\n ],\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metrics: data.summary.map((metric) => ({\n cardStyle: [\n styles.metricCard,\n {\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n ],\n metric,\n })),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle:\n graphVariant === \"horizontal-bar\" ? { marginTop: -6 } : undefined,\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n TakumiDocument,\n TakumiPage,\n TakumiView,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (card of l.metrics; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n \n\n \n \n\n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n\n \n \n\n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n\n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n}\n", + "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const deliveryOffset: Record = {\n area: 0,\n bar: 31,\n donut: 65,\n \"horizontal-bar\": -2,\n line: -31,\n pie: 0,\n };\n const graphHeight: Record = {\n area: 191,\n bar: 184,\n donut: 193,\n \"horizontal-bar\": 163,\n line: 195,\n pie: 191,\n };\n const graphOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const styles = StyleSheet.create({\n col: {\n flex: 1,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 8,\n width: \"48.6%\",\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n paddingBottom: theme.spacing.page.marginBottom,\n paddingLeft: theme.spacing.page.marginLeft,\n paddingRight: theme.spacing.page.marginRight,\n paddingTop: theme.spacing.page.marginTop,\n position: \"relative\",\n },\n pageBreak: {\n breakAfter: \"page\",\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: [\n styles.graphShell,\n {\n marginTop: graphVariant === \"horizontal-bar\" ? 34 : 0,\n position: \"relative\" as const,\n top: graphOffset[graphVariant],\n },\n ],\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metrics: data.summary.map((metric) => ({\n cardStyle: [\n styles.metricCard,\n {\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n ],\n metric,\n })),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle:\n graphVariant === \"horizontal-bar\" ? { marginTop: -6 } : undefined,\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n TakumiDocument,\n TakumiPage,\n TakumiView,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (card of l.metrics; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n \n\n \n \n\n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n\n \n \n\n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n\n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\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/report-operations/report-layout.ts" }, { "path": "registry/bases/takumi/blocks/report-operations/report-operations.ts", - "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleOperationsData: BaseReportData = {\n author: \"Delivery Office\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"SLA improved after shift rebalancing and incident triage changes.\",\n \"Backlog grew in week 4 due to release-related ticket surge.\",\n \"Incident queue remediation plan has executive sponsorship and budget.\",\n ],\n period: \"February 2026\",\n rows: [\n {\n label: \"L1 Support\",\n owner: \"N. Mehta\",\n progress: 91,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"L2 Support\",\n owner: \"D. Chen\",\n progress: 85,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Incident Queue\",\n owner: \"R. Walker\",\n progress: 66,\n risk: \"High\",\n status: \"At Risk\",\n },\n {\n label: \"Automation Rollout\",\n owner: \"M. Roy\",\n progress: 77,\n risk: \"Medium\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 69 },\n { label: \"W2\", value: 71 },\n { label: \"W3\", value: 73 },\n { label: \"W4\", value: 74 },\n { label: \"W5\", value: 75 },\n { label: \"W6\", value: 76 },\n { label: \"W7\", value: 78 },\n { label: \"W8\", value: 79 },\n { label: \"W9\", value: 78 },\n { label: \"W10\", value: 80 },\n { label: \"W11\", value: 81 },\n { label: \"W12\", value: 83 },\n ],\n subtitle: \"Delivery throughput, SLA adherence, and backlog visibility\",\n summary: [\n {\n label: \"Tickets Closed\",\n tone: \"success\",\n trend: \"+9.8% MoM\",\n value: \"1,284\",\n },\n {\n label: \"SLA Hit Rate\",\n tone: \"success\",\n trend: \"+1.4 pts\",\n value: \"96.1%\",\n },\n { label: \"Backlog\", tone: \"warning\", trend: \"+6.0%\", value: \"214\" },\n { label: \"Escalations\", tone: \"success\", trend: \"-18.5%\", value: \"17\" },\n ],\n title: \"Monthly Operations Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-operations\",\n template: `\n \n `,\n})\nexport class OperationsReportDocument {\n readonly theme = input();\n readonly data = input(sampleOperationsData);\n\n protected readonly graphColors = [\"#2563EB\"];\n protected readonly graphData = [\n { label: \"Incident\", value: 66 },\n { label: \"Automation\", value: 77 },\n { label: \"L2 Support\", value: 85 },\n { label: \"L1 Support\", value: 91 },\n ];\n}\n", + "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleOperationsData: BaseReportData = {\n author: \"Delivery Office\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"SLA improved after shift rebalancing and incident triage changes.\",\n \"Backlog grew in week 4 due to release-related ticket surge.\",\n \"Incident queue remediation plan has executive sponsorship and budget.\",\n ],\n period: \"February 2026\",\n rows: [\n {\n label: \"L1 Support\",\n owner: \"N. Mehta\",\n progress: 91,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"L2 Support\",\n owner: \"D. Chen\",\n progress: 85,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Incident Queue\",\n owner: \"R. Walker\",\n progress: 66,\n risk: \"High\",\n status: \"At Risk\",\n },\n {\n label: \"Automation Rollout\",\n owner: \"M. Roy\",\n progress: 77,\n risk: \"Medium\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 69 },\n { label: \"W2\", value: 71 },\n { label: \"W3\", value: 73 },\n { label: \"W4\", value: 74 },\n { label: \"W5\", value: 75 },\n { label: \"W6\", value: 76 },\n { label: \"W7\", value: 78 },\n { label: \"W8\", value: 79 },\n { label: \"W9\", value: 78 },\n { label: \"W10\", value: 80 },\n { label: \"W11\", value: 81 },\n { label: \"W12\", value: 83 },\n ],\n subtitle: \"Delivery throughput, SLA adherence, and backlog visibility\",\n summary: [\n {\n label: \"Tickets Closed\",\n tone: \"success\",\n trend: \"+9.8% MoM\",\n value: \"1,284\",\n },\n {\n label: \"SLA Hit Rate\",\n tone: \"success\",\n trend: \"+1.4 pts\",\n value: \"96.1%\",\n },\n { label: \"Backlog\", tone: \"warning\", trend: \"+6.0%\", value: \"214\" },\n { label: \"Escalations\", tone: \"success\", trend: \"-18.5%\", value: \"17\" },\n ],\n title: \"Monthly Operations Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-operations\",\n template: `\n \n `,\n})\nexport class OperationsReportDocument {\n readonly theme = input();\n readonly data = input(sampleOperationsData);\n\n protected readonly graphColors = [\"#2563EB\"];\n protected readonly graphData = [\n { label: \"Incident\", value: 66 },\n { label: \"Automation\", value: 77 },\n { label: \"L2 Support\", value: 85 },\n { label: \"L1 Support\", value: 91 },\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:block", "target": "components/pdf/blocks/report-operations/report-operations.ts" }, { "path": "registry/bases/takumi/blocks/report-operations/report.types.ts", - "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: string[];\n}\n", + "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: 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/report-operations/report.types.ts" } diff --git a/apps/web/public/r/takumi/report-security.json b/apps/web/public/r/takumi/report-security.json index 5c4e962..2257709 100644 --- a/apps/web/public/r/takumi/report-security.json +++ b/apps/web/public/r/takumi/report-security.json @@ -23,19 +23,19 @@ "files": [ { "path": "registry/bases/takumi/blocks/report-security/report-layout.ts", - "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const deliveryOffset: Record = {\n area: 0,\n bar: 31,\n donut: 65,\n \"horizontal-bar\": -2,\n line: -31,\n pie: 0,\n };\n const graphHeight: Record = {\n area: 191,\n bar: 184,\n donut: 193,\n \"horizontal-bar\": 163,\n line: 195,\n pie: 191,\n };\n const graphOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const styles = StyleSheet.create({\n col: {\n flex: 1,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 8,\n width: \"48.6%\",\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n paddingBottom: theme.spacing.page.marginBottom,\n paddingLeft: theme.spacing.page.marginLeft,\n paddingRight: theme.spacing.page.marginRight,\n paddingTop: theme.spacing.page.marginTop,\n position: \"relative\",\n },\n pageBreak: {\n breakAfter: \"page\",\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: [\n styles.graphShell,\n {\n marginTop: graphVariant === \"horizontal-bar\" ? 34 : 0,\n position: \"relative\" as const,\n top: graphOffset[graphVariant],\n },\n ],\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metrics: data.summary.map((metric) => ({\n cardStyle: [\n styles.metricCard,\n {\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n ],\n metric,\n })),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle:\n graphVariant === \"horizontal-bar\" ? { marginTop: -6 } : undefined,\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n TakumiDocument,\n TakumiPage,\n TakumiView,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (card of l.metrics; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n \n\n \n \n\n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n\n \n \n\n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n\n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n}\n", + "content": "import { Component, booleanAttribute, computed, input } from \"@angular/core\";\nimport type { TemplateRef } from \"@angular/core\";\n\nimport { PdfBadge } from \"@/components/pdf/badge/badge\";\nimport { PdfDataTable } from \"@/components/pdf/data-table/data-table\";\nimport type {\n DataTableCellContext,\n DataTableColumn,\n} from \"@/components/pdf/data-table/data-table.types\";\nimport { PdfGraph } from \"@/components/pdf/graph/graph\";\nimport { PdfKeyValue } from \"@/components/pdf/key-value/key-value\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PdfPageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PdfPageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfPageNumber } from \"@/components/pdf/page-number/page-number\";\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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { BaseReportData, ReportRow } from \"./report.types\";\n\nexport interface ReportTemplateProps {\n theme?: PdfcnTheme;\n data?: BaseReportData;\n}\n\ntype ReportGraphVariant =\n | \"bar\"\n | \"horizontal-bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\";\n\ninterface ReportLayoutProps {\n data: BaseReportData;\n titlePrefix: string;\n statusLabel: string;\n statusTone: \"success\" | \"warning\" | \"destructive\" | \"info\";\n graphVariant: ReportGraphVariant;\n graphTitle: string;\n graphSubtitle: string;\n graphLegend?: \"bottom\" | \"right\" | \"none\";\n graphShowValues?: boolean;\n graphColors?: string[];\n graphData?: { label: string; value: number }[];\n}\n\nconst toneColor = (\n theme: PdfcnTheme,\n tone: \"success\" | \"warning\" | \"destructive\" | \"info\"\n) => {\n if (tone === \"success\") {\n return theme.colors.success;\n }\n if (tone === \"warning\") {\n return theme.colors.warning;\n }\n if (tone === \"destructive\") {\n return theme.colors.destructive;\n }\n return theme.colors.info;\n};\n\nconst reportLayout = (\n theme: PdfcnTheme,\n {\n data,\n graphVariant,\n graphLegend = \"none\",\n graphShowValues = false,\n graphData,\n statusTone,\n }: ReportLayoutProps\n) => {\n const accent = toneColor(theme, statusTone);\n const deliveryOffset: Record = {\n area: 0,\n bar: 31,\n donut: 65,\n \"horizontal-bar\": -2,\n line: -31,\n pie: 0,\n };\n const graphHeight: Record = {\n area: 191,\n bar: 184,\n donut: 193,\n \"horizontal-bar\": 163,\n line: 195,\n pie: 191,\n };\n const graphOffset: Record = {\n area: 0,\n bar: 0,\n donut: 0,\n \"horizontal-bar\": 0,\n line: 0,\n pie: 0,\n };\n const styles = StyleSheet.create({\n col: {\n flex: 1,\n },\n graphShell: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 12,\n },\n metricCard: {\n backgroundColor: theme.colors.background,\n borderColor: theme.colors.border,\n borderRadius: theme.primitives.borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: 1,\n padding: 8,\n width: \"48.6%\",\n },\n metricLabel: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n letterSpacing: 0.5,\n marginBottom: 2,\n textTransform: \"uppercase\",\n },\n metricTrend: {\n color: theme.colors.mutedForeground,\n fontSize: 9,\n },\n metricValue: {\n color: theme.colors.foreground,\n fontSize: 14,\n fontWeight: theme.primitives.fontWeights.bold,\n marginBottom: 2,\n },\n metricsGrid: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 8,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n minHeight: 841,\n paddingBottom: theme.spacing.page.marginBottom,\n paddingLeft: theme.spacing.page.marginLeft,\n paddingRight: theme.spacing.page.marginRight,\n paddingTop: theme.spacing.page.marginTop,\n position: \"relative\",\n },\n pageBreak: {\n breakAfter: \"page\",\n },\n toolbar: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 8,\n },\n twoColumn: {\n alignItems: \"flex-start\",\n flexDirection: \"row\",\n gap: 10,\n },\n });\n\n const avgProgress = Math.round(\n data.rows.reduce((sum, row) => sum + row.progress, 0) /\n Math.max(data.rows.length, 1)\n );\n\n return {\n deliveryStyle: {\n position: \"relative\" as const,\n top: deliveryOffset[graphVariant],\n },\n graphData: graphData ?? data.series,\n graphHeight: graphHeight[graphVariant],\n graphLegend,\n graphShellStyle: [\n styles.graphShell,\n {\n marginTop: graphVariant === \"horizontal-bar\" ? 34 : 0,\n position: \"relative\" as const,\n top: graphOffset[graphVariant],\n },\n ],\n graphShowValues,\n highlights: data.highlights.map((item) => ({\n checked: true,\n text: item,\n })),\n metrics: data.summary.map((metric) => ({\n cardStyle: [\n styles.metricCard,\n {\n borderLeftColor: metric.tone ? toneColor(theme, metric.tone) : accent,\n borderLeftWidth: 3,\n },\n ],\n metric,\n })),\n riskItems: [\n {\n key: \"Open Risks\",\n value: `${data.rows.filter((r) => r.risk !== \"Low\").length}`,\n },\n {\n key: \"On-Track Streams\",\n value: `${data.rows.filter((r) => r.status === \"On Track\").length}/${data.rows.length}`,\n },\n {\n key: \"Avg Progress\",\n value: `${avgProgress}%`,\n },\n ],\n rowsFooter: {\n label: \"Totals\",\n owner: \"-\",\n progress: avgProgress,\n risk: \"-\",\n status: \"-\",\n },\n sectionStyle:\n graphVariant === \"horizontal-bar\" ? { marginTop: -6 } : undefined,\n showGrid: graphVariant !== \"pie\" && graphVariant !== \"donut\",\n smooth: graphVariant === \"line\" || graphVariant === \"area\",\n styles,\n };\n};\n\nconst deliveryColumns = (\n progress: TemplateRef>\n): DataTableColumn[] => [\n { header: \"Stream\", key: \"label\" },\n { header: \"Owner\", key: \"owner\" },\n { align: \"center\", header: \"Status\", key: \"status\" },\n {\n align: \"right\",\n header: \"Progress\",\n key: \"progress\",\n render: progress,\n },\n { align: \"right\", header: \"Risk\", key: \"risk\" },\n];\n\n@Component({\n imports: [\n PdfBadge,\n PdfDataTable,\n PdfGraph,\n PdfKeyValue,\n PdfList,\n PdfPageFooter,\n PdfPageHeader,\n PdfPageNumber,\n PdfSection,\n PdfText,\n TakumiDocument,\n TakumiPage,\n TakumiView,\n ],\n selector: \"pdf-report-layout\",\n template: `\n @let data = this.data();\n @let l = layout();\n @let styles = l.styles;\n \n \n \n {{ value }}%\n \n \n \n\n \n \n Author: {{ data.author }}\n \n\n \n Executive Summary\n \n @for (card of l.metrics; track card.metric.label) {\n \n {{\n card.metric.label\n }}\n {{\n card.metric.value\n }}\n @if (card.metric.trend) {\n \n }\n \n }\n \n \n\n \n \n\n \n \n Performance Trend\n \n \n \n \n\n \n Delivery Table\n \n \n\n \n \n\n \n \n Highlights & Risks\n \n \n \n \n \n \n \n \n \n\n \n \n \n `,\n})\nexport class ReportLayout {\n readonly data = input.required();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\" | undefined>(\"none\");\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\n\n protected readonly theme = injectPdfcnTheme();\n\n protected readonly deliveryColumns = deliveryColumns;\n\n protected readonly layout = computed(() =>\n reportLayout(this.theme(), {\n data: this.data(),\n graphColors: this.graphColors(),\n graphData: this.graphData(),\n graphLegend: this.graphLegend(),\n graphShowValues: this.graphShowValues(),\n graphSubtitle: this.graphSubtitle(),\n graphTitle: this.graphTitle(),\n graphVariant: this.graphVariant(),\n statusLabel: this.statusLabel(),\n statusTone: this.statusTone(),\n titlePrefix: this.titlePrefix(),\n })\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ReportLayout],\n selector: \"pdf-report-template-frame\",\n template: `\n @if (data(); as data) {\n \n \n \n }\n `,\n})\nexport class ReportTemplateFrame {\n readonly theme = input();\n readonly data = input();\n readonly titlePrefix = input.required();\n readonly statusLabel = input.required();\n readonly statusTone = input.required<\n \"success\" | \"warning\" | \"destructive\" | \"info\"\n >();\n readonly graphVariant = input.required();\n readonly graphTitle = input.required();\n readonly graphSubtitle = input.required();\n readonly graphLegend = input<\"bottom\" | \"right\" | \"none\">();\n readonly graphShowValues = input(false, { transform: booleanAttribute });\n readonly graphColors = input();\n readonly graphData = input<{ label: string; value: number }[]>();\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/report-security/report-layout.ts" }, { "path": "registry/bases/takumi/blocks/report-security/report-security.ts", - "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleSecurityData: BaseReportData = {\n author: \"Security Engineering\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"Critical vulnerabilities reduced through mandatory patch windows.\",\n \"Secrets rotation remains the highest-risk stream and needs additional staffing.\",\n \"External penetration test scheduled for next sprint to validate fixes.\",\n ],\n period: \"Sprint 05, 2026\",\n rows: [\n {\n label: \"Identity Hardening\",\n owner: \"E. Brown\",\n progress: 87,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Secrets Rotation\",\n owner: \"P. Nair\",\n progress: 58,\n risk: \"High\",\n status: \"At Risk\",\n },\n {\n label: \"Dependency Scanning\",\n owner: \"I. Shah\",\n progress: 81,\n risk: \"Medium\",\n status: \"On Track\",\n },\n {\n label: \"WAF Policy\",\n owner: \"S. Reed\",\n progress: 76,\n risk: \"Low\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 61 },\n { label: \"W2\", value: 63 },\n { label: \"W3\", value: 64 },\n { label: \"W4\", value: 66 },\n { label: \"W5\", value: 67 },\n { label: \"W6\", value: 68 },\n { label: \"W7\", value: 69 },\n { label: \"W8\", value: 71 },\n { label: \"W9\", value: 72 },\n { label: \"W10\", value: 74 },\n { label: \"W11\", value: 76 },\n { label: \"W12\", value: 78 },\n ],\n subtitle: \"Vulnerability trends, control maturity, and remediation health\",\n summary: [\n {\n label: \"Critical Vulns\",\n tone: \"success\",\n trend: \"-3 from last sprint\",\n value: \"2\",\n },\n { label: \"Patch SLA\", tone: \"success\", trend: \"+5.3 pts\", value: \"92.0%\" },\n { label: \"Open Findings\", tone: \"warning\", trend: \"+4\", value: \"41\" },\n { label: \"Control Score\", tone: \"info\", trend: \"+2 pts\", value: \"84/100\" },\n ],\n title: \"Security Posture Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-security\",\n template: `\n \n `,\n})\nexport class SecurityReportDocument {\n readonly theme = input();\n readonly data = input(sampleSecurityData);\n\n protected readonly graphColors = [\"#DC2626\", \"#F59E0B\", \"#16A34A\", \"#0EA5E9\"];\n protected readonly graphData = [\n { label: \"High Risk\", value: 14 },\n { label: \"Medium Risk\", value: 17 },\n { label: \"Low Risk\", value: 8 },\n { label: \"Info\", value: 4 },\n ];\n}\n", + "content": "import { Component, input } from \"@angular/core\";\n\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { ReportTemplateFrame } from \"./report-layout\";\nimport type { BaseReportData } from \"./report.types\";\n\nconst sampleSecurityData: BaseReportData = {\n author: \"Security Engineering\",\n generatedAt: \"February 23, 2026\",\n highlights: [\n \"Critical vulnerabilities reduced through mandatory patch windows.\",\n \"Secrets rotation remains the highest-risk stream and needs additional staffing.\",\n \"External penetration test scheduled for next sprint to validate fixes.\",\n ],\n period: \"Sprint 05, 2026\",\n rows: [\n {\n label: \"Identity Hardening\",\n owner: \"E. Brown\",\n progress: 87,\n risk: \"Low\",\n status: \"On Track\",\n },\n {\n label: \"Secrets Rotation\",\n owner: \"P. Nair\",\n progress: 58,\n risk: \"High\",\n status: \"At Risk\",\n },\n {\n label: \"Dependency Scanning\",\n owner: \"I. Shah\",\n progress: 81,\n risk: \"Medium\",\n status: \"On Track\",\n },\n {\n label: \"WAF Policy\",\n owner: \"S. Reed\",\n progress: 76,\n risk: \"Low\",\n status: \"On Track\",\n },\n ],\n series: [\n { label: \"W1\", value: 61 },\n { label: \"W2\", value: 63 },\n { label: \"W3\", value: 64 },\n { label: \"W4\", value: 66 },\n { label: \"W5\", value: 67 },\n { label: \"W6\", value: 68 },\n { label: \"W7\", value: 69 },\n { label: \"W8\", value: 71 },\n { label: \"W9\", value: 72 },\n { label: \"W10\", value: 74 },\n { label: \"W11\", value: 76 },\n { label: \"W12\", value: 78 },\n ],\n subtitle: \"Vulnerability trends, control maturity, and remediation health\",\n summary: [\n {\n label: \"Critical Vulns\",\n tone: \"success\",\n trend: \"-3 from last sprint\",\n value: \"2\",\n },\n { label: \"Patch SLA\", tone: \"success\", trend: \"+5.3 pts\", value: \"92.0%\" },\n { label: \"Open Findings\", tone: \"warning\", trend: \"+4\", value: \"41\" },\n { label: \"Control Score\", tone: \"info\", trend: \"+2 pts\", value: \"84/100\" },\n ],\n title: \"Security Posture Report\",\n};\n\n@Component({\n imports: [ReportTemplateFrame],\n selector: \"pdf-report-security\",\n template: `\n \n `,\n})\nexport class SecurityReportDocument {\n readonly theme = input();\n readonly data = input(sampleSecurityData);\n\n protected readonly graphColors = [\"#DC2626\", \"#F59E0B\", \"#16A34A\", \"#0EA5E9\"];\n protected readonly graphData = [\n { label: \"High Risk\", value: 14 },\n { label: \"Medium Risk\", value: 17 },\n { label: \"Low Risk\", value: 8 },\n { label: \"Info\", value: 4 },\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:block", "target": "components/pdf/blocks/report-security/report-security.ts" }, { "path": "registry/bases/takumi/blocks/report-security/report.types.ts", - "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: string[];\n}\n", + "content": "export interface SummaryMetric {\n label: string;\n value: string;\n trend?: string;\n tone?: \"success\" | \"warning\" | \"destructive\" | \"info\";\n}\n\nexport type ReportRow = Record & {\n label: string;\n owner: string;\n status: string;\n progress: number;\n risk?: string;\n};\n\nexport interface ReportSeriesPoint {\n label: string;\n value: number;\n}\n\nexport interface BaseReportData {\n title: string;\n subtitle: string;\n generatedAt: string;\n period: string;\n author: string;\n summary: SummaryMetric[];\n rows: ReportRow[];\n series: ReportSeriesPoint[];\n highlights: 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/report-security/report.types.ts" } diff --git a/apps/web/public/r/takumi/section.json b/apps/web/public/r/takumi/section.json index b1774e1..79dd03a 100644 --- a/apps/web/public/r/takumi/section.json +++ b/apps/web/public/r/takumi/section.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/section/section.ts", - "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiView,\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 SectionSpacing = \"none\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type SectionPadding = \"none\" | \"sm\" | \"md\" | \"lg\";\nexport type SectionVariant = \"default\" | \"callout\" | \"highlight\" | \"card\";\n\n/**\n * Layout container with spacing, padding, and visual style variants.\n * Props - `spacing` | `padding` | `background` | `border` | `variant` | `accentColor` | `noWrap` | `children` | `style`\n * @see {@link SectionProps}\n */\nexport interface SectionProps extends PDFComponentProps {\n /**\n * @default 'md'\n */\n spacing?: SectionSpacing;\n padding?: SectionPadding;\n background?: string;\n /**\n * @default false\n */\n border?: boolean;\n /**\n * @default 'default'\n */\n variant?: SectionVariant;\n accentColor?: string;\n /**\n * @default false\n */\n noWrap?: boolean;\n}\n\nconst createSectionStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius } = t.primitives;\n return StyleSheet.create({\n base: { flexDirection: \"column\" },\n border: {\n borderColor: t.colors.border,\n borderRadius: borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: spacing[0.5],\n },\n callout: {\n borderLeftColor: t.colors.primary,\n borderLeftStyle: \"solid\",\n borderLeftWidth: spacing[1],\n paddingLeft: spacing[4],\n paddingVertical: spacing[2],\n },\n card: {\n borderColor: t.colors.border,\n borderRadius: borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: spacing[0.5],\n padding: spacing[4],\n },\n highlight: {\n backgroundColor: t.colors.muted,\n borderLeftColor: t.colors.primary,\n borderLeftStyle: \"solid\",\n borderLeftWidth: spacing[1],\n padding: spacing[4],\n },\n paddingLg: { padding: spacing[6] },\n paddingMd: { padding: spacing[4] },\n paddingNone: { padding: spacing[0] },\n paddingSm: { padding: spacing[3] },\n spacingLg: { marginVertical: spacing[8] },\n spacingMd: { marginVertical: t.spacing.sectionGap },\n spacingNone: { marginVertical: spacing[0] },\n spacingSm: { marginVertical: spacing[4] },\n spacingXl: { marginVertical: spacing[12] },\n });\n};\n\nconst sectionStyle = (\n theme: PdfcnTheme,\n {\n spacing = \"md\",\n padding,\n background,\n border,\n variant = \"default\",\n accentColor,\n style,\n }: SectionProps\n) => {\n const styles = createSectionStyles(theme);\n const spacingMap = {\n lg: styles.spacingLg,\n md: styles.spacingMd,\n none: styles.spacingNone,\n sm: styles.spacingSm,\n xl: styles.spacingXl,\n };\n const paddingMap = {\n lg: styles.paddingLg,\n md: styles.paddingMd,\n none: styles.paddingNone,\n sm: styles.paddingSm,\n };\n const variantMap: Record = {\n callout: styles.callout,\n card: styles.card,\n default: null,\n highlight: styles.highlight,\n };\n const styleArray: Style[] = [styles.base, spacingMap[spacing]];\n const variantStyle = variantMap[variant];\n if (variantStyle) {\n styleArray.push(variantStyle);\n }\n if (accentColor && (variant === \"callout\" || variant === \"highlight\")) {\n styleArray.push({\n borderLeftColor: resolveColor(accentColor, theme.colors),\n });\n }\n if (padding && padding in paddingMap) {\n styleArray.push(paddingMap[padding]);\n }\n if (border && variant === \"default\") {\n styleArray.push(styles.border);\n }\n if (background) {\n styleArray.push({\n backgroundColor: resolveColor(background, theme.colors),\n });\n }\n if (style) {\n styleArray.push(...[style].flat());\n }\n return styleArray;\n};\n\n@Component({\n imports: [TakumiView],\n selector: \"pdf-section\",\n template: ``,\n})\nexport class PdfSection {\n readonly spacing = input(\"md\");\n readonly padding = input();\n readonly background = input();\n readonly border = input(false, { transform: booleanAttribute });\n readonly variant = input(\"default\");\n readonly accentColor = input();\n /** Part of the props API but unused, as in the original. */\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly sectionStyle = computed(() =>\n sectionStyle(this.theme(), {\n accentColor: this.accentColor(),\n background: this.background(),\n border: this.border(),\n padding: this.padding(),\n spacing: this.spacing(),\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 StyleSheet,\n TakumiView,\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 SectionSpacing = \"none\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type SectionPadding = \"none\" | \"sm\" | \"md\" | \"lg\";\nexport type SectionVariant = \"default\" | \"callout\" | \"highlight\" | \"card\";\n\n/**\n * Layout container with spacing, padding, and visual style variants.\n * Props - `spacing` | `padding` | `background` | `border` | `variant` | `accentColor` | `noWrap` | `children` | `style`\n * @see {@link SectionProps}\n */\nexport interface SectionProps extends PDFComponentProps {\n /**\n * @default 'md'\n */\n spacing?: SectionSpacing;\n padding?: SectionPadding;\n background?: string;\n /**\n * @default false\n */\n border?: boolean;\n /**\n * @default 'default'\n */\n variant?: SectionVariant;\n accentColor?: string;\n /**\n * @default false\n */\n noWrap?: boolean;\n}\n\nconst createSectionStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius } = t.primitives;\n return StyleSheet.create({\n base: { flexDirection: \"column\" },\n border: {\n borderColor: t.colors.border,\n borderRadius: borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: spacing[0.5],\n },\n callout: {\n borderLeftColor: t.colors.primary,\n borderLeftStyle: \"solid\",\n borderLeftWidth: spacing[1],\n paddingLeft: spacing[4],\n paddingVertical: spacing[2],\n },\n card: {\n borderColor: t.colors.border,\n borderRadius: borderRadius.md,\n borderStyle: \"solid\",\n borderWidth: spacing[0.5],\n padding: spacing[4],\n },\n highlight: {\n backgroundColor: t.colors.muted,\n borderLeftColor: t.colors.primary,\n borderLeftStyle: \"solid\",\n borderLeftWidth: spacing[1],\n padding: spacing[4],\n },\n paddingLg: { padding: spacing[6] },\n paddingMd: { padding: spacing[4] },\n paddingNone: { padding: spacing[0] },\n paddingSm: { padding: spacing[3] },\n spacingLg: { marginVertical: spacing[8] },\n spacingMd: { marginVertical: t.spacing.sectionGap },\n spacingNone: { marginVertical: spacing[0] },\n spacingSm: { marginVertical: spacing[4] },\n spacingXl: { marginVertical: spacing[12] },\n });\n};\n\nconst sectionStyle = (\n theme: PdfcnTheme,\n {\n spacing = \"md\",\n padding,\n background,\n border,\n variant = \"default\",\n accentColor,\n style,\n }: SectionProps\n) => {\n const styles = createSectionStyles(theme);\n const spacingMap = {\n lg: styles.spacingLg,\n md: styles.spacingMd,\n none: styles.spacingNone,\n sm: styles.spacingSm,\n xl: styles.spacingXl,\n };\n const paddingMap = {\n lg: styles.paddingLg,\n md: styles.paddingMd,\n none: styles.paddingNone,\n sm: styles.paddingSm,\n };\n const variantMap: Record = {\n callout: styles.callout,\n card: styles.card,\n default: null,\n highlight: styles.highlight,\n };\n const styleArray: Style[] = [styles.base, spacingMap[spacing]];\n const variantStyle = variantMap[variant];\n if (variantStyle) {\n styleArray.push(variantStyle);\n }\n if (accentColor && (variant === \"callout\" || variant === \"highlight\")) {\n styleArray.push({\n borderLeftColor: resolveColor(accentColor, theme.colors),\n });\n }\n if (padding && padding in paddingMap) {\n styleArray.push(paddingMap[padding]);\n }\n if (border && variant === \"default\") {\n styleArray.push(styles.border);\n }\n if (background) {\n styleArray.push({\n backgroundColor: resolveColor(background, theme.colors),\n });\n }\n if (style) {\n styleArray.push(...[style].flat());\n }\n return styleArray;\n};\n\n@Component({\n imports: [TakumiView],\n selector: \"pdf-section\",\n template: ``,\n})\nexport class PdfSection {\n readonly spacing = input(\"md\");\n readonly padding = input();\n readonly background = input();\n readonly border = input(false, { transform: booleanAttribute });\n readonly variant = input(\"default\");\n readonly accentColor = input();\n /** Part of the props API but unused, as in the original. */\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly sectionStyle = computed(() =>\n sectionStyle(this.theme(), {\n accentColor: this.accentColor(),\n background: this.background(),\n border: this.border(),\n padding: this.padding(),\n spacing: this.spacing(),\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/section/section.ts" } diff --git a/apps/web/public/r/takumi/shipping-label.json b/apps/web/public/r/takumi/shipping-label.json index 4dfede9..5482800 100644 --- a/apps/web/public/r/takumi/shipping-label.json +++ b/apps/web/public/r/takumi/shipping-label.json @@ -20,13 +20,13 @@ "files": [ { "path": "registry/bases/takumi/blocks/shipping-label/shipping-label.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { 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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type {\n ShippingLabelAddress,\n ShippingLabelData,\n} from \"./shipping-label.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: ShippingLabelData = {\n carrier: \"UPS\",\n dimensions: '12\" x 8\" x 6\"',\n from: {\n address: \"456 Industrial Blvd\",\n city: \"Los Angeles\",\n country: \"USA\",\n name: \"ACME Corporation\",\n state: \"CA\",\n zip: \"90001\",\n },\n handlingLabels: [\"FRAGILE\", \"THIS SIDE UP\"],\n packageCount: 1,\n postage: \"$18.40\",\n serviceLevel: \"Ground\",\n to: {\n address: \"123 Main Street, Apt 4B\",\n city: \"New York\",\n country: \"USA\",\n name: \"John Doe\",\n phone: \"(503) 555-0142\",\n state: \"NY\",\n zip: \"10001\",\n },\n trackingNumber: \"TRACK123456789US\",\n weight: \"2.5 kg\",\n};\n\n// Standard 4\" x 6\" shipping label, expressed in PDF points (72 dpi)\nconst LABEL_SIZE = { height: 432, width: 288 };\n\nconst formatCityLine = (party: ShippingLabelAddress) => {\n const cityStateZip = `${party.city}, ${party.state} ${party.zip}`;\n return party.country ? `${cityStateZip}, ${party.country}` : cityStateZip;\n};\n\nconst formatStreetLine = (party: ShippingLabelAddress) => party.address;\n\nconst shippingLabelLayout = (theme: PdfcnTheme, data: ShippingLabelData) => {\n const accent = resolveColor(\n data.accentColor ?? theme.colors.primary,\n theme.colors\n );\n\n const detailRows = [\n ...(data.weight ? [{ key: \"Weight\", value: data.weight }] : []),\n ...(data.dimensions ? [{ key: \"Dimensions\", value: data.dimensions }] : []),\n ...(typeof data.packageCount === \"number\"\n ? [{ key: \"Packages\", value: `${data.packageCount}` }]\n : []),\n { key: \"Postage\", value: data.postage ?? \"PAID\" },\n ];\n\n const styles = StyleSheet.create({\n addresses: { flex: 1, flexDirection: \"row\" },\n badgesRow: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 6,\n marginTop: 8,\n },\n barcodeArea: { alignItems: \"center\", marginTop: 10 },\n carrierName: { fontSize: 16, fontWeight: \"bold\" },\n fromColumn: { flex: 1, paddingLeft: 12 },\n handlingTag: {\n alignItems: \"center\",\n backgroundColor: theme.colors.foreground,\n justifyContent: \"center\",\n paddingHorizontal: 8,\n paddingVertical: 4,\n },\n handlingTagText: {\n color: theme.colors.background,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1,\n textTransform: \"uppercase\",\n },\n headerRow: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n },\n label: {\n borderColor: theme.colors.foreground,\n borderStyle: \"solid\",\n borderWidth: 2,\n flex: 1,\n padding: 10,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n flexDirection: \"column\",\n height: LABEL_SIZE.height,\n overflow: \"hidden\",\n padding: 8,\n width: LABEL_SIZE.width,\n },\n rule: {\n backgroundColor: theme.colors.foreground,\n height: 2,\n marginVertical: 6,\n },\n sectionLabel: {\n color: accent,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1,\n marginBottom: 4,\n textTransform: \"uppercase\",\n },\n serviceRight: { alignItems: \"flex-end\" },\n shipToColumn: {\n borderRightColor: theme.colors.foreground,\n borderRightStyle: \"solid\",\n borderRightWidth: 2,\n flex: 1.4,\n paddingRight: 12,\n },\n table: {\n borderColor: theme.colors.foreground,\n borderStyle: \"solid\",\n borderWidth: 2,\n },\n tableKey: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 0.5,\n textTransform: \"uppercase\",\n width: 84,\n },\n tableRow: {\n alignItems: \"center\",\n borderBottomColor: theme.colors.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n flexDirection: \"row\",\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n tableRowLast: {\n alignItems: \"center\",\n flexDirection: \"row\",\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n tableValue: { flex: 1 },\n trackingText: {\n fontWeight: \"bold\",\n letterSpacing: 2,\n marginTop: 6,\n textTransform: \"uppercase\",\n },\n });\n\n return { detailRows, styles };\n};\n\n@Component({\n imports: [\n NgTemplateOutlet,\n PdfImage,\n PdfQRCode,\n PdfText,\n TakumiDocument,\n TakumiPage,\n TakumiView,\n ],\n selector: \"pdf-shipping-label-content\",\n template: `\n @let data = this.data();\n @let styles = this.layout().styles;\n @let detailRows = this.layout().detailRows;\n \n \n {{ party.name }}\n {{ formatStreetLine(party) }}\n {{ formatCityLine(party) }}\n @if (party.phone) {\n {{\n party.phone\n }}\n }\n \n \n \n \n \n {{\n data.carrier\n }}\n \n {{\n data.serviceLevel\n }}\n \n \n\n \n\n \n \n Ship To\n \n \n \n From\n \n \n \n\n \n\n \n @for (row of detailRows; track row.key; let index = $index) {\n \n {{\n row.key\n }}\n {{\n row.value\n }}\n \n }\n \n\n @if (data.handlingLabels && data.handlingLabels.length > 0) {\n \n @for (label of data.handlingLabels; track $index) {\n \n {{\n label\n }}\n \n }\n \n }\n\n \n @if (data.barcodeUrl) {\n \n } @else {\n \n }\n {{ data.trackingNumber }}\n \n \n \n \n `,\n})\nexport class ShippingLabelContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly LABEL_SIZE = LABEL_SIZE;\n protected readonly formatStreetLine = formatStreetLine;\n protected readonly formatCityLine = formatCityLine;\n\n protected readonly layout = computed(() =>\n shippingLabelLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ShippingLabelContent],\n selector: \"pdf-shipping-label\",\n template: `\n \n \n \n `,\n})\nexport class ShippingLabelDocument {\n readonly theme = input();\n readonly data = input(sampleData);\n}\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { 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 TakumiDocument,\n TakumiPage,\n TakumiView,\n StyleSheet,\n} from \"@/lib/pdf-primitives\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type {\n ShippingLabelAddress,\n ShippingLabelData,\n} from \"./shipping-label.types\";\n\n// Sample data — replace with your own props or data source\nconst sampleData: ShippingLabelData = {\n carrier: \"UPS\",\n dimensions: '12\" x 8\" x 6\"',\n from: {\n address: \"456 Industrial Blvd\",\n city: \"Los Angeles\",\n country: \"USA\",\n name: \"ACME Corporation\",\n state: \"CA\",\n zip: \"90001\",\n },\n handlingLabels: [\"FRAGILE\", \"THIS SIDE UP\"],\n packageCount: 1,\n postage: \"$18.40\",\n serviceLevel: \"Ground\",\n to: {\n address: \"123 Main Street, Apt 4B\",\n city: \"New York\",\n country: \"USA\",\n name: \"John Doe\",\n phone: \"(503) 555-0142\",\n state: \"NY\",\n zip: \"10001\",\n },\n trackingNumber: \"TRACK123456789US\",\n weight: \"2.5 kg\",\n};\n\n// Standard 4\" x 6\" shipping label, expressed in PDF points (72 dpi)\nconst LABEL_SIZE = { height: 432, width: 288 };\n\nconst formatCityLine = (party: ShippingLabelAddress) => {\n const cityStateZip = `${party.city}, ${party.state} ${party.zip}`;\n return party.country ? `${cityStateZip}, ${party.country}` : cityStateZip;\n};\n\nconst formatStreetLine = (party: ShippingLabelAddress) => party.address;\n\nconst shippingLabelLayout = (theme: PdfcnTheme, data: ShippingLabelData) => {\n const accent = resolveColor(\n data.accentColor ?? theme.colors.primary,\n theme.colors\n );\n\n const detailRows = [\n ...(data.weight ? [{ key: \"Weight\", value: data.weight }] : []),\n ...(data.dimensions ? [{ key: \"Dimensions\", value: data.dimensions }] : []),\n ...(typeof data.packageCount === \"number\"\n ? [{ key: \"Packages\", value: `${data.packageCount}` }]\n : []),\n { key: \"Postage\", value: data.postage ?? \"PAID\" },\n ];\n\n const styles = StyleSheet.create({\n addresses: { flex: 1, flexDirection: \"row\" },\n badgesRow: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: 6,\n marginTop: 8,\n },\n barcodeArea: { alignItems: \"center\", marginTop: 10 },\n carrierName: { fontSize: 16, fontWeight: \"bold\" },\n fromColumn: { flex: 1, paddingLeft: 12 },\n handlingTag: {\n alignItems: \"center\",\n backgroundColor: theme.colors.foreground,\n justifyContent: \"center\",\n paddingHorizontal: 8,\n paddingVertical: 4,\n },\n handlingTagText: {\n color: theme.colors.background,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1,\n textTransform: \"uppercase\",\n },\n headerRow: {\n alignItems: \"center\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n },\n label: {\n borderColor: theme.colors.foreground,\n borderStyle: \"solid\",\n borderWidth: 2,\n flex: 1,\n padding: 10,\n },\n page: {\n backgroundColor: theme.colors.background,\n boxSizing: \"border-box\",\n flexDirection: \"column\",\n height: LABEL_SIZE.height,\n overflow: \"hidden\",\n padding: 8,\n width: LABEL_SIZE.width,\n },\n rule: {\n backgroundColor: theme.colors.foreground,\n height: 2,\n marginVertical: 6,\n },\n sectionLabel: {\n color: accent,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 1,\n marginBottom: 4,\n textTransform: \"uppercase\",\n },\n serviceRight: { alignItems: \"flex-end\" },\n shipToColumn: {\n borderRightColor: theme.colors.foreground,\n borderRightStyle: \"solid\",\n borderRightWidth: 2,\n flex: 1.4,\n paddingRight: 12,\n },\n table: {\n borderColor: theme.colors.foreground,\n borderStyle: \"solid\",\n borderWidth: 2,\n },\n tableKey: {\n color: theme.colors.mutedForeground,\n fontSize: 8,\n fontWeight: \"bold\",\n letterSpacing: 0.5,\n textTransform: \"uppercase\",\n width: 84,\n },\n tableRow: {\n alignItems: \"center\",\n borderBottomColor: theme.colors.border,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n flexDirection: \"row\",\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n tableRowLast: {\n alignItems: \"center\",\n flexDirection: \"row\",\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n tableValue: { flex: 1 },\n trackingText: {\n fontWeight: \"bold\",\n letterSpacing: 2,\n marginTop: 6,\n textTransform: \"uppercase\",\n },\n });\n\n return { detailRows, styles };\n};\n\n@Component({\n imports: [\n NgTemplateOutlet,\n PdfImage,\n PdfQRCode,\n PdfText,\n TakumiDocument,\n TakumiPage,\n TakumiView,\n ],\n selector: \"pdf-shipping-label-content\",\n template: `\n @let data = this.data();\n @let styles = this.layout().styles;\n @let detailRows = this.layout().detailRows;\n \n \n {{ party.name }}\n {{ formatStreetLine(party) }}\n {{ formatCityLine(party) }}\n @if (party.phone) {\n {{\n party.phone\n }}\n }\n \n \n \n \n \n {{\n data.carrier\n }}\n \n {{\n data.serviceLevel\n }}\n \n \n\n \n\n \n \n Ship To\n \n \n \n From\n \n \n \n\n \n\n \n @for (row of detailRows; track row.key; let index = $index) {\n \n {{\n row.key\n }}\n {{\n row.value\n }}\n \n }\n \n\n @if (data.handlingLabels && data.handlingLabels.length > 0) {\n \n @for (label of data.handlingLabels; track $index) {\n \n {{\n label\n }}\n \n }\n \n }\n\n \n @if (data.barcodeUrl) {\n \n } @else {\n \n }\n {{ data.trackingNumber }}\n \n \n \n \n `,\n})\nexport class ShippingLabelContent {\n readonly data = input.required();\n\n private readonly theme = injectPdfcnTheme();\n\n protected readonly LABEL_SIZE = LABEL_SIZE;\n protected readonly formatStreetLine = formatStreetLine;\n protected readonly formatCityLine = formatCityLine;\n\n protected readonly layout = computed(() =>\n shippingLabelLayout(this.theme(), this.data())\n );\n}\n\n@Component({\n imports: [PdfcnThemeProvider, ShippingLabelContent],\n selector: \"pdf-shipping-label\",\n template: `\n \n \n \n `,\n})\nexport class ShippingLabelDocument {\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/shipping-label/shipping-label.ts" }, { "path": "registry/bases/takumi/blocks/shipping-label/shipping-label.types.ts", - "content": "export interface ShippingLabelAddress {\n name: string;\n address: string;\n city: string;\n state: string;\n zip: string;\n country?: string;\n}\n\nexport interface ShippingLabelDestination extends ShippingLabelAddress {\n phone?: string;\n}\n\nexport interface ShippingLabelData {\n from: ShippingLabelAddress;\n to: ShippingLabelDestination;\n carrier: string;\n serviceLevel: string;\n trackingNumber: string;\n barcodeUrl?: string;\n weight?: string;\n dimensions?: string;\n packageCount?: number;\n handlingLabels?: string[];\n postage?: string;\n accentColor?: string;\n}\n", + "content": "export interface ShippingLabelAddress {\n name: string;\n address: string;\n city: string;\n state: string;\n zip: string;\n country?: string;\n}\n\nexport interface ShippingLabelDestination extends ShippingLabelAddress {\n phone?: string;\n}\n\nexport interface ShippingLabelData {\n from: ShippingLabelAddress;\n to: ShippingLabelDestination;\n carrier: string;\n serviceLevel: string;\n trackingNumber: string;\n barcodeUrl?: string;\n weight?: string;\n dimensions?: string;\n packageCount?: number;\n handlingLabels?: string[];\n postage?: string;\n accentColor?: 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/shipping-label/shipping-label.types.ts" } diff --git a/apps/web/public/r/takumi/signature.json b/apps/web/public/r/takumi/signature.json index 65fa3b3..c7595cc 100644 --- a/apps/web/public/r/takumi/signature.json +++ b/apps/web/public/r/takumi/signature.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/signature/signature.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport { Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiText,\n TakumiView,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type SignatureVariant = \"single\" | \"double\" | \"inline\";\n\n/**\n * Signature signer properties.\n * Props - `label` | `name` | `title` | `date`\n * @see {@link SignatureSigner}\n */\nexport interface SignatureSigner {\n label?: string;\n name?: string;\n title?: string;\n date?: string;\n}\n\n/**\n * Signature block properties.\n * Props - `variant` | `label` | `name` | `title` | `date` | `signers` | `style`\n * @see {@link PdfSignatureBlockProps}\n */\nexport interface PdfSignatureBlockProps {\n /**\n * Layout variant: [single, double, inline]\n * @default 'single'\n */\n variant?: SignatureVariant;\n label?: string;\n name?: string;\n title?: string;\n date?: string;\n signers?: [SignatureSigner, SignatureSigner];\n style?: Style;\n}\n\nconst createSignatureStyles = (t: PdfcnTheme) => {\n const { spacing, fontWeights, typography } = t.primitives;\n return StyleSheet.create({\n block: { flex: 1, minWidth: 140 },\n container: {\n marginBottom: t.spacing.componentGap,\n marginTop: t.spacing.sectionGap,\n },\n dateText: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n marginTop: 1,\n },\n doubleRow: {\n flexDirection: \"row\",\n gap: spacing[8],\n justifyContent: \"space-between\",\n },\n inlineLabel: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n },\n inlineLine: {\n borderBottomColor: t.colors.foreground,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n height: spacing[5],\n minWidth: 120,\n paddingHorizontal: spacing[2],\n },\n inlineName: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n },\n inlineRow: {\n alignItems: \"center\",\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: spacing[3],\n },\n label: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n marginBottom: spacing[1],\n },\n line: {\n borderBottomColor: t.colors.foreground,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n marginBottom: spacing[1],\n minHeight: spacing[6],\n },\n name: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n },\n titleText: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n },\n });\n};\n\nconst signatureLayout = (\n theme: PdfcnTheme,\n {\n variant = \"single\",\n label = \"Signature\",\n name,\n title,\n date,\n signers,\n style,\n }: PdfSignatureBlockProps\n) => {\n const styles = createSignatureStyles(theme);\n const containerStyles: Style[] = [styles.container];\n if (style) {\n containerStyles.push(style);\n }\n const container = [{ breakInside: \"avoid\" as const }, containerStyles]\n .flat()\n .filter(Boolean);\n\n if (variant === \"inline\") {\n return { container, inlineLabel: `${label}:`, signers: [], styles };\n }\n\n if (variant === \"double\") {\n const [first, second] = signers ?? [\n { date: \"\", label: \"Authorized by\", name: \"\", title: \"\" },\n { date: \"\", label: \"Approved by\", name: \"\", title: \"\" },\n ];\n return { container, signers: [first, second], styles };\n }\n\n return { container, signers: [{ date, label, name, title }], styles };\n};\n\n@Component({\n imports: [TakumiText, TakumiView, NgTemplateOutlet],\n selector: \"pdf-signature-block\",\n template: `\n @let l = layout();\n @let s = l.styles;\n \n @switch (variant()) {\n @case (\"inline\") {\n \n {{\n l.inlineLabel\n }}\n \n @if (name()) {\n {{ name() }}\n }\n \n }\n @case (\"double\") {\n \n @for (signer of l.signers; track $index) {\n \n }\n \n }\n @default {\n \n }\n }\n \n \n \n @if (signer.label) {\n {{ signer.label }}\n }\n \n @if (signer.name) {\n {{ signer.name }}\n }\n @if (signer.title) {\n {{ signer.title }}\n }\n @if (signer.date) {\n {{ signer.date }}\n }\n \n \n `,\n})\nexport class PdfSignatureBlock {\n readonly variant = input(\"single\");\n readonly label = input(\"Signature\");\n readonly name = input();\n readonly title = input();\n readonly date = input();\n readonly signers = input<[SignatureSigner, SignatureSigner]>();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n signatureLayout(this.theme(), {\n date: this.date(),\n label: this.label(),\n name: this.name(),\n signers: this.signers(),\n style: this.style(),\n title: this.title(),\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 StyleSheet,\n TakumiText,\n TakumiView,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type SignatureVariant = \"single\" | \"double\" | \"inline\";\n\n/**\n * Signature signer properties.\n * Props - `label` | `name` | `title` | `date`\n * @see {@link SignatureSigner}\n */\nexport interface SignatureSigner {\n label?: string;\n name?: string;\n title?: string;\n date?: string;\n}\n\n/**\n * Signature block properties.\n * Props - `variant` | `label` | `name` | `title` | `date` | `signers` | `style`\n * @see {@link PdfSignatureBlockProps}\n */\nexport interface PdfSignatureBlockProps {\n /**\n * Layout variant: [single, double, inline]\n * @default 'single'\n */\n variant?: SignatureVariant;\n label?: string;\n name?: string;\n title?: string;\n date?: string;\n signers?: [SignatureSigner, SignatureSigner];\n style?: Style;\n}\n\nconst createSignatureStyles = (t: PdfcnTheme) => {\n const { spacing, fontWeights, typography } = t.primitives;\n return StyleSheet.create({\n block: { flex: 1, minWidth: 140 },\n container: {\n marginBottom: t.spacing.componentGap,\n marginTop: t.spacing.sectionGap,\n },\n dateText: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n marginTop: 1,\n },\n doubleRow: {\n flexDirection: \"row\",\n gap: spacing[8],\n justifyContent: \"space-between\",\n },\n inlineLabel: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n },\n inlineLine: {\n borderBottomColor: t.colors.foreground,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n height: spacing[5],\n minWidth: 120,\n paddingHorizontal: spacing[2],\n },\n inlineName: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n },\n inlineRow: {\n alignItems: \"center\",\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n gap: spacing[3],\n },\n label: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n marginBottom: spacing[1],\n },\n line: {\n borderBottomColor: t.colors.foreground,\n borderBottomStyle: \"solid\",\n borderBottomWidth: 1,\n marginBottom: spacing[1],\n minHeight: spacing[6],\n },\n name: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n },\n titleText: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.sm,\n },\n });\n};\n\nconst signatureLayout = (\n theme: PdfcnTheme,\n {\n variant = \"single\",\n label = \"Signature\",\n name,\n title,\n date,\n signers,\n style,\n }: PdfSignatureBlockProps\n) => {\n const styles = createSignatureStyles(theme);\n const containerStyles: Style[] = [styles.container];\n if (style) {\n containerStyles.push(style);\n }\n const container = [{ breakInside: \"avoid\" as const }, containerStyles]\n .flat()\n .filter(Boolean);\n\n if (variant === \"inline\") {\n return { container, inlineLabel: `${label}:`, signers: [], styles };\n }\n\n if (variant === \"double\") {\n const [first, second] = signers ?? [\n { date: \"\", label: \"Authorized by\", name: \"\", title: \"\" },\n { date: \"\", label: \"Approved by\", name: \"\", title: \"\" },\n ];\n return { container, signers: [first, second], styles };\n }\n\n return { container, signers: [{ date, label, name, title }], styles };\n};\n\n@Component({\n imports: [TakumiText, TakumiView, NgTemplateOutlet],\n selector: \"pdf-signature-block\",\n template: `\n @let l = layout();\n @let s = l.styles;\n \n @switch (variant()) {\n @case (\"inline\") {\n \n {{\n l.inlineLabel\n }}\n \n @if (name()) {\n {{ name() }}\n }\n \n }\n @case (\"double\") {\n \n @for (signer of l.signers; track $index) {\n \n }\n \n }\n @default {\n \n }\n }\n \n \n \n @if (signer.label) {\n {{ signer.label }}\n }\n \n @if (signer.name) {\n {{ signer.name }}\n }\n @if (signer.title) {\n {{ signer.title }}\n }\n @if (signer.date) {\n {{ signer.date }}\n }\n \n \n `,\n})\nexport class PdfSignatureBlock {\n readonly variant = input(\"single\");\n readonly label = input(\"Signature\");\n readonly name = input();\n readonly title = input();\n readonly date = input();\n readonly signers = input<[SignatureSigner, SignatureSigner]>();\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly layout = computed(() =>\n signatureLayout(this.theme(), {\n date: this.date(),\n label: this.label(),\n name: this.name(),\n signers: this.signers(),\n style: this.style(),\n title: this.title(),\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/signature/signature.ts" } diff --git a/apps/web/public/r/takumi/stack.json b/apps/web/public/r/takumi/stack.json index 929f1ed..20362c3 100644 --- a/apps/web/public/r/takumi/stack.json +++ b/apps/web/public/r/takumi/stack.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/stack/stack.ts", - "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiView,\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 StackGap = \"none\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type StackDirection = \"vertical\" | \"horizontal\";\nexport type StackAlign = \"start\" | \"center\" | \"end\" | \"stretch\";\nexport type StackJustify = \"start\" | \"center\" | \"end\" | \"between\" | \"around\";\n\n/**\n * Flex layout container with gap and direction control.\n * Props - `gap` | `direction` | `align` | `justify` | `wrap` | `noWrap` | `children` | `style`\n * @see {@link StackProps}\n */\nexport interface StackProps extends PDFComponentProps {\n /**\n * @default 'md'\n */\n gap?: StackGap;\n /**\n * @default 'vertical'\n */\n direction?: StackDirection;\n /**\n * @default 'start'\n */\n align?: StackAlign;\n /**\n * @default 'start'\n */\n justify?: StackJustify;\n /**\n * @default false\n */\n wrap?: boolean;\n /**\n * @default false\n */\n noWrap?: boolean;\n}\n\nconst createStackStyles = (t: PdfcnTheme) => {\n const { spacing } = t.primitives;\n return StyleSheet.create({\n alignCenter: { alignItems: \"center\" },\n alignEnd: { alignItems: \"flex-end\" },\n alignStart: { alignItems: \"flex-start\" },\n alignStretch: { alignItems: \"stretch\" },\n gapLg: { gap: spacing[6] },\n gapMd: { gap: spacing[4] },\n gapNone: { gap: spacing[0] },\n gapSm: { gap: spacing[2] },\n gapXl: { gap: spacing[8] },\n horizontal: { flexDirection: \"row\" },\n justifyAround: { justifyContent: \"space-around\" },\n justifyBetween: { justifyContent: \"space-between\" },\n justifyCenter: { justifyContent: \"center\" },\n justifyEnd: { justifyContent: \"flex-end\" },\n justifyStart: { justifyContent: \"flex-start\" },\n vertical: { flexDirection: \"column\" },\n wrap: { flexWrap: \"wrap\" },\n });\n};\n\nconst stackStyle = (\n theme: PdfcnTheme,\n {\n gap = \"md\",\n direction = \"vertical\",\n align,\n justify,\n wrap,\n style,\n }: Omit\n) => {\n const styles = createStackStyles(theme);\n const gapMap = {\n lg: styles.gapLg,\n md: styles.gapMd,\n none: styles.gapNone,\n sm: styles.gapSm,\n xl: styles.gapXl,\n };\n const alignMap = {\n center: styles.alignCenter,\n end: styles.alignEnd,\n start: styles.alignStart,\n stretch: styles.alignStretch,\n };\n const justifyMap = {\n around: styles.justifyAround,\n between: styles.justifyBetween,\n center: styles.justifyCenter,\n end: styles.justifyEnd,\n start: styles.justifyStart,\n };\n const styleArray: Style[] = [\n direction === \"horizontal\" ? styles.horizontal : styles.vertical,\n gapMap[gap],\n ];\n if (align && align in alignMap) {\n styleArray.push(alignMap[align]);\n }\n if (justify && justify in justifyMap) {\n styleArray.push(justifyMap[justify]);\n }\n if (wrap) {\n styleArray.push(styles.wrap);\n }\n if (style) {\n styleArray.push(...[style].flat());\n }\n return styleArray;\n};\n\n@Component({\n imports: [TakumiView],\n selector: \"pdf-stack\",\n template: ``,\n})\nexport class PdfStack {\n readonly gap = input(\"md\");\n readonly direction = input(\"vertical\");\n readonly align = input();\n readonly justify = input();\n readonly wrap = input(false, { transform: booleanAttribute });\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly stackStyle = computed(() =>\n stackStyle(this.theme(), {\n align: this.align(),\n direction: this.direction(),\n gap: this.gap(),\n justify: this.justify(),\n style: this.style(),\n wrap: this.wrap(),\n })\n );\n}\n", + "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiView,\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 StackGap = \"none\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type StackDirection = \"vertical\" | \"horizontal\";\nexport type StackAlign = \"start\" | \"center\" | \"end\" | \"stretch\";\nexport type StackJustify = \"start\" | \"center\" | \"end\" | \"between\" | \"around\";\n\n/**\n * Flex layout container with gap and direction control.\n * Props - `gap` | `direction` | `align` | `justify` | `wrap` | `noWrap` | `children` | `style`\n * @see {@link StackProps}\n */\nexport interface StackProps extends PDFComponentProps {\n /**\n * @default 'md'\n */\n gap?: StackGap;\n /**\n * @default 'vertical'\n */\n direction?: StackDirection;\n /**\n * @default 'start'\n */\n align?: StackAlign;\n /**\n * @default 'start'\n */\n justify?: StackJustify;\n /**\n * @default false\n */\n wrap?: boolean;\n /**\n * @default false\n */\n noWrap?: boolean;\n}\n\nconst createStackStyles = (t: PdfcnTheme) => {\n const { spacing } = t.primitives;\n return StyleSheet.create({\n alignCenter: { alignItems: \"center\" },\n alignEnd: { alignItems: \"flex-end\" },\n alignStart: { alignItems: \"flex-start\" },\n alignStretch: { alignItems: \"stretch\" },\n gapLg: { gap: spacing[6] },\n gapMd: { gap: spacing[4] },\n gapNone: { gap: spacing[0] },\n gapSm: { gap: spacing[2] },\n gapXl: { gap: spacing[8] },\n horizontal: { flexDirection: \"row\" },\n justifyAround: { justifyContent: \"space-around\" },\n justifyBetween: { justifyContent: \"space-between\" },\n justifyCenter: { justifyContent: \"center\" },\n justifyEnd: { justifyContent: \"flex-end\" },\n justifyStart: { justifyContent: \"flex-start\" },\n vertical: { flexDirection: \"column\" },\n wrap: { flexWrap: \"wrap\" },\n });\n};\n\nconst stackStyle = (\n theme: PdfcnTheme,\n {\n gap = \"md\",\n direction = \"vertical\",\n align,\n justify,\n wrap,\n style,\n }: Omit\n) => {\n const styles = createStackStyles(theme);\n const gapMap = {\n lg: styles.gapLg,\n md: styles.gapMd,\n none: styles.gapNone,\n sm: styles.gapSm,\n xl: styles.gapXl,\n };\n const alignMap = {\n center: styles.alignCenter,\n end: styles.alignEnd,\n start: styles.alignStart,\n stretch: styles.alignStretch,\n };\n const justifyMap = {\n around: styles.justifyAround,\n between: styles.justifyBetween,\n center: styles.justifyCenter,\n end: styles.justifyEnd,\n start: styles.justifyStart,\n };\n const styleArray: Style[] = [\n direction === \"horizontal\" ? styles.horizontal : styles.vertical,\n gapMap[gap],\n ];\n if (align && align in alignMap) {\n styleArray.push(alignMap[align]);\n }\n if (justify && justify in justifyMap) {\n styleArray.push(justifyMap[justify]);\n }\n if (wrap) {\n styleArray.push(styles.wrap);\n }\n if (style) {\n styleArray.push(...[style].flat());\n }\n return styleArray;\n};\n\n@Component({\n imports: [TakumiView],\n selector: \"pdf-stack\",\n template: ``,\n})\nexport class PdfStack {\n readonly gap = input(\"md\");\n readonly direction = input(\"vertical\");\n readonly align = input();\n readonly justify = input();\n readonly wrap = input(false, { transform: booleanAttribute });\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly stackStyle = computed(() =>\n stackStyle(this.theme(), {\n align: this.align(),\n direction: this.direction(),\n gap: this.gap(),\n justify: this.justify(),\n style: this.style(),\n wrap: this.wrap(),\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/stack/stack.ts" } diff --git a/apps/web/public/r/takumi/table.json b/apps/web/public/r/takumi/table.json index 1145670..1d9b043 100644 --- a/apps/web/public/r/takumi/table.json +++ b/apps/web/public/r/takumi/table.json @@ -13,19 +13,19 @@ "files": [ { "path": "registry/bases/takumi/components/table/table.styles.ts", - "content": "import { StyleSheet } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Creates all table styles derived from the active theme.\n * @param t - The resolved PdfcnTheme instance.\n */\nexport const createTableStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius, fontWeights, typography } = t.primitives;\n const borderColor = t.colors.border;\n\n const hairline = 0.5;\n const rule = 1;\n const thick = 1.5;\n\n const cellPadV = spacing[2] - 2;\n const cellPadH = spacing[2] + 2;\n // eslint-disable-next-line prefer-destructuring\n const cellPadVCompact = spacing[0.5];\n // eslint-disable-next-line prefer-destructuring\n const cellPadHCompact = spacing[2];\n\n const rowDivider = {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\" as const,\n borderBottomWidth: hairline,\n };\n\n return StyleSheet.create({\n cell: {\n flex: 1,\n justifyContent: \"center\",\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellBordered: {\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellBorderedBorder: {\n borderRightColor: borderColor,\n borderRightStyle: \"solid\",\n borderRightWidth: hairline,\n },\n\n cellCompact: {\n paddingHorizontal: cellPadHCompact,\n paddingVertical: cellPadVCompact,\n },\n\n cellFixed: {\n flexGrow: 0,\n flexShrink: 0,\n justifyContent: \"center\",\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellGridBorder: {\n borderRightColor: borderColor,\n borderRightStyle: \"solid\",\n borderRightWidth: hairline,\n },\n\n cellMinimal: {\n paddingHorizontal: spacing[2] - 2,\n paddingVertical: spacing[1] + 1,\n },\n\n cellPrimaryHeader: {\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellStriped: {\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellText: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n lineHeight: 1.2,\n },\n cellTextCompact: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n lineHeight: 1.2,\n },\n cellTextFooter: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n cellTextHeaderBordered: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.bold,\n lineHeight: 1.2,\n },\n cellTextHeaderCompact: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.semibold,\n letterSpacing: 0.6,\n lineHeight: 1.2,\n textTransform: \"uppercase\",\n },\n cellTextHeaderGrid: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n cellTextHeaderLine: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n\n cellTextHeaderMinimal: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.medium,\n lineHeight: 1.2,\n },\n cellTextHeaderPrimaryHeader: {\n color: t.colors.primaryForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.semibold,\n letterSpacing: 0.6,\n lineHeight: 1.2,\n textTransform: \"uppercase\",\n },\n cellTextHeaderStriped: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n row: {\n display: \"flex\",\n flexDirection: \"row\",\n },\n rowBordered: rowDivider,\n rowCompact: rowDivider,\n rowFooter: {\n borderTopColor: borderColor,\n borderTopStyle: \"solid\",\n borderTopWidth: rule,\n },\n\n rowFooterStriped: {\n backgroundColor: t.colors.muted,\n borderTopColor: borderColor,\n borderTopStyle: \"solid\",\n borderTopWidth: rule,\n },\n rowGrid: rowDivider,\n\n rowHeaderBordered: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n\n rowHeaderCompact: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowHeaderGrid: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n\n rowHeaderLine: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowHeaderMinimal: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowHeaderPrimaryHeader: {\n backgroundColor: t.colors.primary,\n },\n rowHeaderStriped: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowLine: rowDivider,\n\n rowMinimal: rowDivider,\n rowPrimaryHeader: rowDivider,\n\n rowStripe: {\n backgroundColor: t.colors.muted,\n },\n\n rowStriped: {},\n table: {\n display: \"flex\",\n flexDirection: \"column\",\n marginBottom: t.spacing.componentGap,\n width: \"100%\",\n },\n tableBordered: {\n borderBottomLeftRadius: borderRadius.sm,\n borderBottomRightRadius: borderRadius.sm,\n borderColor,\n borderStyle: \"solid\",\n borderTopLeftRadius: borderRadius.sm,\n borderTopRightRadius: borderRadius.sm,\n borderWidth: rule,\n overflow: \"hidden\" as const,\n },\n tableCompact: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n tableGrid: {\n borderBottomLeftRadius: borderRadius.md,\n borderBottomRightRadius: borderRadius.md,\n borderColor,\n borderStyle: \"solid\",\n borderTopLeftRadius: borderRadius.md,\n borderTopRightRadius: borderRadius.md,\n borderWidth: thick,\n overflow: \"hidden\" as const,\n },\n tableLine: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n tableMinimal: {\n paddingVertical: spacing[2],\n },\n\n tablePrimaryHeader: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n\n tableStriped: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n borderTopColor: borderColor,\n borderTopStyle: \"solid\",\n borderTopWidth: hairline,\n },\n });\n};\n", + "content": "import { StyleSheet } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Creates all table styles derived from the active theme.\n * @param t - The resolved PdfcnTheme instance.\n */\nexport const createTableStyles = (t: PdfcnTheme) => {\n const { spacing, borderRadius, fontWeights, typography } = t.primitives;\n const borderColor = t.colors.border;\n\n const hairline = 0.5;\n const rule = 1;\n const thick = 1.5;\n\n const cellPadV = spacing[2] - 2;\n const cellPadH = spacing[2] + 2;\n // eslint-disable-next-line prefer-destructuring\n const cellPadVCompact = spacing[0.5];\n // eslint-disable-next-line prefer-destructuring\n const cellPadHCompact = spacing[2];\n\n const rowDivider = {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\" as const,\n borderBottomWidth: hairline,\n };\n\n return StyleSheet.create({\n cell: {\n flex: 1,\n justifyContent: \"center\",\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellBordered: {\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellBorderedBorder: {\n borderRightColor: borderColor,\n borderRightStyle: \"solid\",\n borderRightWidth: hairline,\n },\n\n cellCompact: {\n paddingHorizontal: cellPadHCompact,\n paddingVertical: cellPadVCompact,\n },\n\n cellFixed: {\n flexGrow: 0,\n flexShrink: 0,\n justifyContent: \"center\",\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellGridBorder: {\n borderRightColor: borderColor,\n borderRightStyle: \"solid\",\n borderRightWidth: hairline,\n },\n\n cellMinimal: {\n paddingHorizontal: spacing[2] - 2,\n paddingVertical: spacing[1] + 1,\n },\n\n cellPrimaryHeader: {\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellStriped: {\n paddingHorizontal: cellPadH,\n paddingVertical: cellPadV,\n },\n\n cellText: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n lineHeight: 1.2,\n },\n cellTextCompact: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n lineHeight: 1.2,\n },\n cellTextFooter: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n cellTextHeaderBordered: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.bold,\n lineHeight: 1.2,\n },\n cellTextHeaderCompact: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.semibold,\n letterSpacing: 0.6,\n lineHeight: 1.2,\n textTransform: \"uppercase\",\n },\n cellTextHeaderGrid: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n cellTextHeaderLine: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n\n cellTextHeaderMinimal: {\n color: t.colors.mutedForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.medium,\n lineHeight: 1.2,\n },\n cellTextHeaderPrimaryHeader: {\n color: t.colors.primaryForeground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: typography.xs,\n fontWeight: fontWeights.semibold,\n letterSpacing: 0.6,\n lineHeight: 1.2,\n textTransform: \"uppercase\",\n },\n cellTextHeaderStriped: {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n fontSize: t.typography.body.fontSize,\n fontWeight: fontWeights.semibold,\n lineHeight: 1.2,\n },\n row: {\n display: \"flex\",\n flexDirection: \"row\",\n },\n rowBordered: rowDivider,\n rowCompact: rowDivider,\n rowFooter: {\n borderTopColor: borderColor,\n borderTopStyle: \"solid\",\n borderTopWidth: rule,\n },\n\n rowFooterStriped: {\n backgroundColor: t.colors.muted,\n borderTopColor: borderColor,\n borderTopStyle: \"solid\",\n borderTopWidth: rule,\n },\n rowGrid: rowDivider,\n\n rowHeaderBordered: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n\n rowHeaderCompact: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowHeaderGrid: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n\n rowHeaderLine: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowHeaderMinimal: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowHeaderPrimaryHeader: {\n backgroundColor: t.colors.primary,\n },\n rowHeaderStriped: {\n backgroundColor: t.colors.muted,\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: rule,\n },\n rowLine: rowDivider,\n\n rowMinimal: rowDivider,\n rowPrimaryHeader: rowDivider,\n\n rowStripe: {\n backgroundColor: t.colors.muted,\n },\n\n rowStriped: {},\n table: {\n display: \"flex\",\n flexDirection: \"column\",\n marginBottom: t.spacing.componentGap,\n width: \"100%\",\n },\n tableBordered: {\n borderBottomLeftRadius: borderRadius.sm,\n borderBottomRightRadius: borderRadius.sm,\n borderColor,\n borderStyle: \"solid\",\n borderTopLeftRadius: borderRadius.sm,\n borderTopRightRadius: borderRadius.sm,\n borderWidth: rule,\n overflow: \"hidden\" as const,\n },\n tableCompact: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n tableGrid: {\n borderBottomLeftRadius: borderRadius.md,\n borderBottomRightRadius: borderRadius.md,\n borderColor,\n borderStyle: \"solid\",\n borderTopLeftRadius: borderRadius.md,\n borderTopRightRadius: borderRadius.md,\n borderWidth: thick,\n overflow: \"hidden\" as const,\n },\n tableLine: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n tableMinimal: {\n paddingVertical: spacing[2],\n },\n\n tablePrimaryHeader: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n },\n\n tableStriped: {\n borderBottomColor: borderColor,\n borderBottomStyle: \"solid\",\n borderBottomWidth: hairline,\n borderTopColor: borderColor,\n borderTopStyle: \"solid\",\n borderTopWidth: hairline,\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/table/table.styles.ts" }, { "path": "registry/bases/takumi/components/table/table.ts", - "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport {\n Component,\n DestroyRef,\n booleanAttribute,\n computed,\n inject,\n input,\n signal,\n} from \"@angular/core\";\nimport type { WritableSignal } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n TakumiText,\n TakumiView,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { createTableStyles } from \"./table.styles\";\nimport type {\n TableCellProps,\n TableProps,\n TableRowProps,\n TableSectionProps,\n TableVariant,\n} from \"./table.types\";\n\nconst tableCellStyles = (\n theme: PdfcnTheme,\n {\n header,\n footer,\n align,\n width,\n style,\n variant = \"line\",\n _last,\n }: TableCellProps\n) => {\n const styles = createTableStyles(theme);\n const cellStyles: Style[] =\n width === undefined\n ? [styles.cell]\n : [styles.cellFixed, { width } as Style];\n\n const cellVariantStyle = (\n {\n bordered: styles.cellBordered,\n compact: styles.cellCompact,\n minimal: styles.cellMinimal,\n \"primary-header\": styles.cellPrimaryHeader,\n striped: styles.cellStriped,\n } as Partial>\n )[variant];\n if (cellVariantStyle) {\n cellStyles.push(cellVariantStyle);\n }\n\n if (variant === \"grid\" && !_last) {\n cellStyles.push(styles.cellGridBorder);\n } else if (variant === \"bordered\" && !_last) {\n cellStyles.push(styles.cellBorderedBorder);\n }\n\n if (align) {\n cellStyles.push({ textAlign: align } as Style);\n }\n\n const styleArray = style ? [...cellStyles, style] : cellStyles;\n\n let textStyle: Style = styles.cellText;\n if (header) {\n textStyle = {\n bordered: styles.cellTextHeaderBordered,\n compact: styles.cellTextHeaderCompact,\n grid: styles.cellTextHeaderGrid,\n line: styles.cellTextHeaderLine,\n minimal: styles.cellTextHeaderMinimal,\n \"primary-header\": styles.cellTextHeaderPrimaryHeader,\n striped: styles.cellTextHeaderStriped,\n }[variant];\n } else if (footer) {\n textStyle = styles.cellTextFooter;\n } else if (variant === \"compact\") {\n textStyle = styles.cellTextCompact;\n }\n\n return {\n cell: styleArray,\n text: [\n textStyle,\n align ? { textAlign: align } : {},\n { margin: 0, padding: 0 },\n ],\n };\n};\n\nconst rowStyle = (\n theme: PdfcnTheme,\n { header, footer, stripe, style, variant = \"line\" }: TableRowProps\n) => {\n const styles = createTableStyles(theme);\n const rowStyles: Style[] = [\n styles.row,\n {\n bordered: styles.rowBordered,\n compact: styles.rowCompact,\n grid: styles.rowGrid,\n line: styles.rowLine,\n minimal: styles.rowMinimal,\n \"primary-header\": styles.rowPrimaryHeader,\n striped: styles.rowStriped,\n }[variant],\n ];\n\n if (header) {\n rowStyles.push(\n {\n bordered: styles.rowHeaderBordered,\n compact: styles.rowHeaderCompact,\n grid: styles.rowHeaderGrid,\n line: styles.rowHeaderLine,\n minimal: styles.rowHeaderMinimal,\n \"primary-header\": styles.rowHeaderPrimaryHeader,\n striped: styles.rowHeaderStriped,\n }[variant]\n );\n }\n\n if (footer) {\n if (variant === \"striped\") {\n rowStyles.push(styles.rowFooterStriped);\n } else {\n rowStyles.push(styles.rowFooter);\n }\n }\n\n if (stripe && !header && !footer) {\n rowStyles.push(styles.rowStripe);\n }\n\n const styleArray = style ? [...rowStyles, style] : rowStyles;\n return [{ breakInside: \"avoid\" as const }, styleArray].flat().filter(Boolean);\n};\n\nconst tableStyle = (\n theme: PdfcnTheme,\n { style, variant = \"line\" }: TableProps\n) => {\n const styles = createTableStyles(theme);\n const tableStyles: Style[] = [\n styles.table,\n {\n bordered: styles.tableBordered,\n compact: styles.tableCompact,\n grid: styles.tableGrid,\n line: styles.tableLine,\n minimal: styles.tableMinimal,\n \"primary-header\": styles.tablePrimaryHeader,\n striped: styles.tableStriped,\n }[variant],\n ];\n\n const styleArray = style ? [...tableStyles, style] : tableStyles;\n return styleArray;\n};\n\n/** Adds `item` to `list` in creation order and removes it on destroy. */\nconst register = (list: WritableSignal, item: T) => {\n list.update((items) => [...items, item]);\n inject(DestroyRef).onDestroy(() =>\n list.update((items) => items.filter((entry) => entry !== item))\n );\n};\n\n@Component({\n imports: [TakumiView, NgTemplateOutlet],\n selector: \"pdf-table\",\n template: `\n \n @if (noWrap()) {\n \n \n \n } @else {\n \n }\n `,\n})\nexport class PdfTable {\n readonly variant = input(\"line\");\n readonly zebraStripe = input(false, { transform: booleanAttribute });\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n /** Rows inside ``, in document order. */\n readonly bodyRows = signal([]);\n readonly zebra = computed(\n () => this.variant() === \"striped\" || this.zebraStripe()\n );\n\n private readonly theme = injectPdfcnTheme();\n protected readonly tableStyle = computed(() =>\n tableStyle(this.theme(), { style: this.style(), variant: this.variant() })\n );\n}\n\n@Component({\n imports: [TakumiView],\n selector: \"pdf-table-header\",\n template: ``,\n})\nexport class PdfTableHeader {\n readonly style = input();\n}\n\n@Component({\n imports: [TakumiView],\n selector: \"pdf-table-body\",\n template: ``,\n})\nexport class PdfTableBody {\n readonly style = input();\n}\n\n@Component({\n imports: [TakumiView],\n selector: \"pdf-table-footer\",\n template: ``,\n})\nexport class PdfTableFooter {\n readonly style = input();\n}\n\n/** Inside a ``, the table's variant and zebra striping apply. */\n@Component({\n imports: [TakumiView],\n selector: \"pdf-table-row\",\n template: ``,\n})\nexport class PdfTableRow {\n readonly header = input(false, { transform: booleanAttribute });\n readonly footer = input(false, { transform: booleanAttribute });\n readonly stripe = input(false, { transform: booleanAttribute });\n readonly variant = input(\"line\");\n readonly style = input();\n\n private readonly table = inject(PdfTable, { optional: true });\n readonly cells = signal([]);\n readonly resolvedVariant = computed(\n () => this.table?.variant() ?? this.variant()\n );\n\n constructor() {\n if (this.table && inject(PdfTableBody, { optional: true })) {\n register(this.table.bodyRows, this);\n }\n }\n\n private readonly theme = injectPdfcnTheme();\n protected readonly rowStyle = computed(() =>\n rowStyle(this.theme(), {\n footer: this.footer(),\n header: this.header(),\n stripe:\n this.stripe() ||\n (this.table !== null &&\n this.table.zebra() &&\n this.table.bodyRows().indexOf(this) % 2 === 1),\n style: this.style(),\n variant: this.resolvedVariant(),\n })\n );\n}\n\n/** Inside a ``, the row's `header`, `footer`, and variant apply. */\n@Component({\n imports: [TakumiText, TakumiView],\n selector: \"pdf-table-cell\",\n template: `\n \n \n \n `,\n})\nexport class PdfTableCell {\n readonly header = input(false, { transform: booleanAttribute });\n readonly footer = input(false, { transform: booleanAttribute });\n readonly align = input();\n readonly width = input();\n readonly variant = input(\"line\");\n readonly style = input();\n\n private readonly row = inject(PdfTableRow, { optional: true });\n\n constructor() {\n if (this.row) {\n register(this.row.cells, this);\n }\n }\n\n private readonly theme = injectPdfcnTheme();\n protected readonly styles = computed(() =>\n tableCellStyles(this.theme(), {\n _last: this.row?.cells().at(-1) === this,\n align: this.align(),\n footer: this.row ? this.row.footer() : this.footer(),\n header: this.row ? this.row.header() : this.header(),\n style: this.style(),\n variant: this.row ? this.row.resolvedVariant() : this.variant(),\n width: this.width(),\n })\n );\n}\n\nexport const TABLE = [\n PdfTable,\n PdfTableHeader,\n PdfTableBody,\n PdfTableFooter,\n PdfTableRow,\n PdfTableCell,\n] as const;\n", + "content": "import { NgTemplateOutlet } from \"@angular/common\";\nimport {\n Component,\n DestroyRef,\n booleanAttribute,\n computed,\n inject,\n input,\n signal,\n} from \"@angular/core\";\nimport type { WritableSignal } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n TakumiText,\n TakumiView,\n} from \"@/lib/pdf-primitives\";\nimport type { Style } from \"@/lib/pdf-primitives\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport { createTableStyles } from \"./table.styles\";\nimport type {\n TableCellProps,\n TableProps,\n TableRowProps,\n TableSectionProps,\n TableVariant,\n} from \"./table.types\";\n\nconst tableCellStyles = (\n theme: PdfcnTheme,\n {\n header,\n footer,\n align,\n width,\n style,\n variant = \"line\",\n _last,\n }: TableCellProps\n) => {\n const styles = createTableStyles(theme);\n const cellStyles: Style[] =\n width === undefined\n ? [styles.cell]\n : [styles.cellFixed, { width } as Style];\n\n const cellVariantStyle = (\n {\n bordered: styles.cellBordered,\n compact: styles.cellCompact,\n minimal: styles.cellMinimal,\n \"primary-header\": styles.cellPrimaryHeader,\n striped: styles.cellStriped,\n } as Partial>\n )[variant];\n if (cellVariantStyle) {\n cellStyles.push(cellVariantStyle);\n }\n\n if (variant === \"grid\" && !_last) {\n cellStyles.push(styles.cellGridBorder);\n } else if (variant === \"bordered\" && !_last) {\n cellStyles.push(styles.cellBorderedBorder);\n }\n\n if (align) {\n cellStyles.push({ textAlign: align } as Style);\n }\n\n const styleArray = style ? [...cellStyles, style] : cellStyles;\n\n let textStyle: Style = styles.cellText;\n if (header) {\n textStyle = {\n bordered: styles.cellTextHeaderBordered,\n compact: styles.cellTextHeaderCompact,\n grid: styles.cellTextHeaderGrid,\n line: styles.cellTextHeaderLine,\n minimal: styles.cellTextHeaderMinimal,\n \"primary-header\": styles.cellTextHeaderPrimaryHeader,\n striped: styles.cellTextHeaderStriped,\n }[variant];\n } else if (footer) {\n textStyle = styles.cellTextFooter;\n } else if (variant === \"compact\") {\n textStyle = styles.cellTextCompact;\n }\n\n return {\n cell: styleArray,\n text: [\n textStyle,\n align ? { textAlign: align } : {},\n { margin: 0, padding: 0 },\n ],\n };\n};\n\nconst rowStyle = (\n theme: PdfcnTheme,\n { header, footer, stripe, style, variant = \"line\" }: TableRowProps\n) => {\n const styles = createTableStyles(theme);\n const rowStyles: Style[] = [\n styles.row,\n {\n bordered: styles.rowBordered,\n compact: styles.rowCompact,\n grid: styles.rowGrid,\n line: styles.rowLine,\n minimal: styles.rowMinimal,\n \"primary-header\": styles.rowPrimaryHeader,\n striped: styles.rowStriped,\n }[variant],\n ];\n\n if (header) {\n rowStyles.push(\n {\n bordered: styles.rowHeaderBordered,\n compact: styles.rowHeaderCompact,\n grid: styles.rowHeaderGrid,\n line: styles.rowHeaderLine,\n minimal: styles.rowHeaderMinimal,\n \"primary-header\": styles.rowHeaderPrimaryHeader,\n striped: styles.rowHeaderStriped,\n }[variant]\n );\n }\n\n if (footer) {\n if (variant === \"striped\") {\n rowStyles.push(styles.rowFooterStriped);\n } else {\n rowStyles.push(styles.rowFooter);\n }\n }\n\n if (stripe && !header && !footer) {\n rowStyles.push(styles.rowStripe);\n }\n\n const styleArray = style ? [...rowStyles, style] : rowStyles;\n return [{ breakInside: \"avoid\" as const }, styleArray].flat().filter(Boolean);\n};\n\nconst tableStyle = (\n theme: PdfcnTheme,\n { style, variant = \"line\" }: TableProps\n) => {\n const styles = createTableStyles(theme);\n const tableStyles: Style[] = [\n styles.table,\n {\n bordered: styles.tableBordered,\n compact: styles.tableCompact,\n grid: styles.tableGrid,\n line: styles.tableLine,\n minimal: styles.tableMinimal,\n \"primary-header\": styles.tablePrimaryHeader,\n striped: styles.tableStriped,\n }[variant],\n ];\n\n const styleArray = style ? [...tableStyles, style] : tableStyles;\n return styleArray;\n};\n\n/** Adds `item` to `list` in creation order and removes it on destroy. */\nconst register = (list: WritableSignal, item: T) => {\n list.update((items) => [...items, item]);\n inject(DestroyRef).onDestroy(() =>\n list.update((items) => items.filter((entry) => entry !== item))\n );\n};\n\n@Component({\n imports: [TakumiView, NgTemplateOutlet],\n selector: \"pdf-table\",\n template: `\n \n @if (noWrap()) {\n \n \n \n } @else {\n \n }\n `,\n})\nexport class PdfTable {\n readonly variant = input(\"line\");\n readonly zebraStripe = input(false, { transform: booleanAttribute });\n readonly noWrap = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n /** Rows inside ``, in document order. */\n readonly bodyRows = signal([]);\n readonly zebra = computed(\n () => this.variant() === \"striped\" || this.zebraStripe()\n );\n\n private readonly theme = injectPdfcnTheme();\n protected readonly tableStyle = computed(() =>\n tableStyle(this.theme(), { style: this.style(), variant: this.variant() })\n );\n}\n\n@Component({\n imports: [TakumiView],\n selector: \"pdf-table-header\",\n template: ``,\n})\nexport class PdfTableHeader {\n readonly style = input();\n}\n\n@Component({\n imports: [TakumiView],\n selector: \"pdf-table-body\",\n template: ``,\n})\nexport class PdfTableBody {\n readonly style = input();\n}\n\n@Component({\n imports: [TakumiView],\n selector: \"pdf-table-footer\",\n template: ``,\n})\nexport class PdfTableFooter {\n readonly style = input();\n}\n\n/** Inside a ``, the table's variant and zebra striping apply. */\n@Component({\n imports: [TakumiView],\n selector: \"pdf-table-row\",\n template: ``,\n})\nexport class PdfTableRow {\n readonly header = input(false, { transform: booleanAttribute });\n readonly footer = input(false, { transform: booleanAttribute });\n readonly stripe = input(false, { transform: booleanAttribute });\n readonly variant = input(\"line\");\n readonly style = input();\n\n private readonly table = inject(PdfTable, { optional: true });\n readonly cells = signal([]);\n readonly resolvedVariant = computed(\n () => this.table?.variant() ?? this.variant()\n );\n\n constructor() {\n if (this.table && inject(PdfTableBody, { optional: true })) {\n register(this.table.bodyRows, this);\n }\n }\n\n private readonly theme = injectPdfcnTheme();\n protected readonly rowStyle = computed(() =>\n rowStyle(this.theme(), {\n footer: this.footer(),\n header: this.header(),\n stripe:\n this.stripe() ||\n (this.table !== null &&\n this.table.zebra() &&\n this.table.bodyRows().indexOf(this) % 2 === 1),\n style: this.style(),\n variant: this.resolvedVariant(),\n })\n );\n}\n\n/** Inside a ``, the row's `header`, `footer`, and variant apply. */\n@Component({\n imports: [TakumiText, TakumiView],\n selector: \"pdf-table-cell\",\n template: `\n \n \n \n `,\n})\nexport class PdfTableCell {\n readonly header = input(false, { transform: booleanAttribute });\n readonly footer = input(false, { transform: booleanAttribute });\n readonly align = input();\n readonly width = input();\n readonly variant = input(\"line\");\n readonly style = input();\n\n private readonly row = inject(PdfTableRow, { optional: true });\n\n constructor() {\n if (this.row) {\n register(this.row.cells, this);\n }\n }\n\n private readonly theme = injectPdfcnTheme();\n protected readonly styles = computed(() =>\n tableCellStyles(this.theme(), {\n _last: this.row?.cells().at(-1) === this,\n align: this.align(),\n footer: this.row ? this.row.footer() : this.footer(),\n header: this.row ? this.row.header() : this.header(),\n style: this.style(),\n variant: this.row ? this.row.resolvedVariant() : this.variant(),\n width: this.width(),\n })\n );\n}\n\nexport const TABLE = [\n PdfTable,\n PdfTableHeader,\n PdfTableBody,\n PdfTableFooter,\n PdfTableRow,\n PdfTableCell,\n] as const;\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/table/table.ts" }, { "path": "registry/bases/takumi/components/table/table.types.ts", - "content": "import type { PDFComponentProps } from \"@/types/pdf-components\";\n\n/** Table visual style variant. */\nexport type TableVariant =\n | \"line\"\n | \"grid\"\n | \"minimal\"\n | \"striped\"\n | \"compact\"\n | \"bordered\"\n | \"primary-header\";\n\n/**\n * Table container with visual style variants and optional zebra striping.\n * Props - `variant` | `zebraStripe` | `noWrap` | `children` | `style`\n * @see {@link TableProps}\n */\nexport interface TableProps extends PDFComponentProps {\n /**\n * @default 'line'\n */\n variant?: TableVariant;\n /**\n * @default false\n */\n zebraStripe?: boolean;\n /**\n * @default false\n */\n noWrap?: boolean;\n}\n\nexport type TableSectionProps = PDFComponentProps;\n\n/**\n * Table row with optional header, footer, and stripe states.\n * Props - `header` | `footer` | `stripe` | `variant` | `children` | `style`\n * @see {@link TableRowProps}\n */\nexport interface TableRowProps extends PDFComponentProps {\n header?: boolean;\n footer?: boolean;\n stripe?: boolean;\n variant?: TableVariant;\n}\n\n/**\n * Table cell with alignment, width, and header or footer text styling.\n * Props - `header` | `footer` | `align` | `width` | `variant` | `_last` | `children` | `style`\n * @see {@link TableCellProps}\n */\nexport interface TableCellProps extends PDFComponentProps {\n header?: boolean;\n footer?: boolean;\n align?: \"left\" | \"center\" | \"right\";\n width?: string | number;\n variant?: TableVariant;\n _last?: boolean;\n}\n", + "content": "import type { PDFComponentProps } from \"@/types/pdf-components\";\n\n/** Table visual style variant. */\nexport type TableVariant =\n | \"line\"\n | \"grid\"\n | \"minimal\"\n | \"striped\"\n | \"compact\"\n | \"bordered\"\n | \"primary-header\";\n\n/**\n * Table container with visual style variants and optional zebra striping.\n * Props - `variant` | `zebraStripe` | `noWrap` | `children` | `style`\n * @see {@link TableProps}\n */\nexport interface TableProps extends PDFComponentProps {\n /**\n * @default 'line'\n */\n variant?: TableVariant;\n /**\n * @default false\n */\n zebraStripe?: boolean;\n /**\n * @default false\n */\n noWrap?: boolean;\n}\n\nexport type TableSectionProps = PDFComponentProps;\n\n/**\n * Table row with optional header, footer, and stripe states.\n * Props - `header` | `footer` | `stripe` | `variant` | `children` | `style`\n * @see {@link TableRowProps}\n */\nexport interface TableRowProps extends PDFComponentProps {\n header?: boolean;\n footer?: boolean;\n stripe?: boolean;\n variant?: TableVariant;\n}\n\n/**\n * Table cell with alignment, width, and header or footer text styling.\n * Props - `header` | `footer` | `align` | `width` | `variant` | `_last` | `children` | `style`\n * @see {@link TableCellProps}\n */\nexport interface TableCellProps extends PDFComponentProps {\n header?: boolean;\n footer?: boolean;\n align?: \"left\" | \"center\" | \"right\";\n width?: string | number;\n variant?: TableVariant;\n _last?: 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/table/table.types.ts" } diff --git a/apps/web/public/r/takumi/text.json b/apps/web/public/r/takumi/text.json index 8795f02..e06a0d8 100644 --- a/apps/web/public/r/takumi/text.json +++ b/apps/web/public/r/takumi/text.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/text/text.ts", - "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiText,\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 TextVariant = \"xs\" | \"sm\" | \"base\" | \"lg\" | \"xl\" | \"2xl\" | \"3xl\";\nexport type TextWeight = \"normal\" | \"medium\" | \"semibold\" | \"bold\";\nexport type TextDecoration = \"underline\" | \"line-through\" | \"none\";\n\n/**\n * Body text with typography scale, alignment, and decoration options.\n * Props - `variant` | `align` | `color` | `weight` | `italic` | `decoration` | `transform` | `noMargin` | `children` | `style`\n * @see {@link TextProps}\n */\nexport interface TextProps extends PDFComponentProps {\n /**\n * @default 'base'\n */\n variant?: TextVariant;\n /**\n * @default 'left'\n */\n align?: \"left\" | \"center\" | \"right\" | \"justify\";\n color?: string;\n /**\n * @default 'normal'\n */\n weight?: TextWeight;\n /**\n * @default false\n */\n italic?: boolean;\n /**\n * @default 'none'\n */\n decoration?: TextDecoration;\n transform?: \"uppercase\" | \"lowercase\" | \"capitalize\";\n /**\n * @default false\n */\n noMargin?: boolean;\n}\n\nconst createTextStyles = (t: PdfcnTheme) => {\n const { fontWeights, letterSpacing } = t.primitives;\n const base = {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n lineHeight: t.typography.body.lineHeight,\n marginBottom: t.spacing.paragraphGap,\n marginTop: 0,\n };\n return StyleSheet.create({\n \"2xl\": { ...base, fontSize: t.primitives.typography[\"2xl\"] },\n \"3xl\": { ...base, fontSize: t.primitives.typography[\"3xl\"] },\n base: { ...base, fontSize: t.primitives.typography.base },\n capitalize: { textTransform: \"capitalize\" },\n decorationNone: { textDecoration: \"none\" },\n italic: { fontStyle: \"italic\" },\n lg: { ...base, fontSize: t.primitives.typography.lg },\n lineThrough: { textDecoration: \"line-through\" },\n lowercase: { textTransform: \"lowercase\" },\n noMargin: { marginBottom: 0, marginTop: 0 },\n sm: { ...base, fontSize: t.primitives.typography.sm },\n text: { ...base, fontSize: t.typography.body.fontSize },\n underline: { textDecoration: \"underline\" },\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 xl: { ...base, fontSize: t.primitives.typography.xl },\n xs: { ...base, fontSize: t.primitives.typography.xs },\n });\n};\n\nconst textStyle = (\n theme: PdfcnTheme,\n {\n variant,\n align,\n color,\n weight,\n italic,\n decoration,\n transform,\n noMargin,\n style,\n }: TextProps\n) => {\n const styles = createTextStyles(theme);\n const weightMap = {\n bold: styles.weightBold,\n medium: styles.weightMedium,\n normal: styles.weightNormal,\n semibold: styles.weightSemibold,\n };\n const decorationMap = {\n \"line-through\": styles.lineThrough,\n none: styles.decorationNone,\n underline: styles.underline,\n };\n const transformMap = {\n capitalize: styles.capitalize,\n lowercase: styles.lowercase,\n uppercase: styles.uppercase,\n };\n const styleArray: Style[] = [variant ? styles[variant] : styles.text];\n if (weight && weight in weightMap) {\n styleArray.push(weightMap[weight]);\n }\n if (italic) {\n styleArray.push(styles.italic);\n }\n if (decoration && decoration in decorationMap) {\n styleArray.push(decorationMap[decoration]);\n }\n if (transform && transform in transformMap) {\n styleArray.push(transformMap[transform]);\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 styleArray;\n};\n\n@Component({\n imports: [TakumiText],\n selector: \"pdf-text\",\n template: ``,\n})\nexport class PdfText {\n readonly variant = input();\n readonly align = input();\n readonly color = input();\n readonly weight = input();\n readonly italic = input(false, { transform: booleanAttribute });\n readonly decoration = input();\n readonly transform = input();\n readonly noMargin = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly textStyle = computed(() =>\n textStyle(this.theme(), {\n align: this.align(),\n color: this.color(),\n decoration: this.decoration(),\n italic: this.italic(),\n noMargin: this.noMargin(),\n style: this.style(),\n transform: this.transform(),\n variant: this.variant(),\n weight: this.weight(),\n })\n );\n}\n", + "content": "import { booleanAttribute, Component, computed, input } from \"@angular/core\";\n\nimport { injectPdfcnTheme } from \"@/components/pdf/theme-provider\";\nimport {\n StyleSheet,\n TakumiText,\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 TextVariant = \"xs\" | \"sm\" | \"base\" | \"lg\" | \"xl\" | \"2xl\" | \"3xl\";\nexport type TextWeight = \"normal\" | \"medium\" | \"semibold\" | \"bold\";\nexport type TextDecoration = \"underline\" | \"line-through\" | \"none\";\n\n/**\n * Body text with typography scale, alignment, and decoration options.\n * Props - `variant` | `align` | `color` | `weight` | `italic` | `decoration` | `transform` | `noMargin` | `children` | `style`\n * @see {@link TextProps}\n */\nexport interface TextProps extends PDFComponentProps {\n /**\n * @default 'base'\n */\n variant?: TextVariant;\n /**\n * @default 'left'\n */\n align?: \"left\" | \"center\" | \"right\" | \"justify\";\n color?: string;\n /**\n * @default 'normal'\n */\n weight?: TextWeight;\n /**\n * @default false\n */\n italic?: boolean;\n /**\n * @default 'none'\n */\n decoration?: TextDecoration;\n transform?: \"uppercase\" | \"lowercase\" | \"capitalize\";\n /**\n * @default false\n */\n noMargin?: boolean;\n}\n\nconst createTextStyles = (t: PdfcnTheme) => {\n const { fontWeights, letterSpacing } = t.primitives;\n const base = {\n color: t.colors.foreground,\n fontFamily: t.typography.body.fontFamily,\n lineHeight: t.typography.body.lineHeight,\n marginBottom: t.spacing.paragraphGap,\n marginTop: 0,\n };\n return StyleSheet.create({\n \"2xl\": { ...base, fontSize: t.primitives.typography[\"2xl\"] },\n \"3xl\": { ...base, fontSize: t.primitives.typography[\"3xl\"] },\n base: { ...base, fontSize: t.primitives.typography.base },\n capitalize: { textTransform: \"capitalize\" },\n decorationNone: { textDecoration: \"none\" },\n italic: { fontStyle: \"italic\" },\n lg: { ...base, fontSize: t.primitives.typography.lg },\n lineThrough: { textDecoration: \"line-through\" },\n lowercase: { textTransform: \"lowercase\" },\n noMargin: { marginBottom: 0, marginTop: 0 },\n sm: { ...base, fontSize: t.primitives.typography.sm },\n text: { ...base, fontSize: t.typography.body.fontSize },\n underline: { textDecoration: \"underline\" },\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 xl: { ...base, fontSize: t.primitives.typography.xl },\n xs: { ...base, fontSize: t.primitives.typography.xs },\n });\n};\n\nconst textStyle = (\n theme: PdfcnTheme,\n {\n variant,\n align,\n color,\n weight,\n italic,\n decoration,\n transform,\n noMargin,\n style,\n }: TextProps\n) => {\n const styles = createTextStyles(theme);\n const weightMap = {\n bold: styles.weightBold,\n medium: styles.weightMedium,\n normal: styles.weightNormal,\n semibold: styles.weightSemibold,\n };\n const decorationMap = {\n \"line-through\": styles.lineThrough,\n none: styles.decorationNone,\n underline: styles.underline,\n };\n const transformMap = {\n capitalize: styles.capitalize,\n lowercase: styles.lowercase,\n uppercase: styles.uppercase,\n };\n const styleArray: Style[] = [variant ? styles[variant] : styles.text];\n if (weight && weight in weightMap) {\n styleArray.push(weightMap[weight]);\n }\n if (italic) {\n styleArray.push(styles.italic);\n }\n if (decoration && decoration in decorationMap) {\n styleArray.push(decorationMap[decoration]);\n }\n if (transform && transform in transformMap) {\n styleArray.push(transformMap[transform]);\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 styleArray;\n};\n\n@Component({\n imports: [TakumiText],\n selector: \"pdf-text\",\n template: ``,\n})\nexport class PdfText {\n readonly variant = input();\n readonly align = input();\n readonly color = input();\n readonly weight = input();\n readonly italic = input(false, { transform: booleanAttribute });\n readonly decoration = input();\n readonly transform = input();\n readonly noMargin = input(false, { transform: booleanAttribute });\n readonly style = input();\n\n private readonly theme = injectPdfcnTheme();\n protected readonly textStyle = computed(() =>\n textStyle(this.theme(), {\n align: this.align(),\n color: this.color(),\n decoration: this.decoration(),\n italic: this.italic(),\n noMargin: this.noMargin(),\n style: this.style(),\n transform: this.transform(),\n variant: this.variant(),\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/text/text.ts" } diff --git a/apps/web/public/r/takumi/theme-provider.json b/apps/web/public/r/takumi/theme-provider.json index e882205..c35b4b6 100644 --- a/apps/web/public/r/takumi/theme-provider.json +++ b/apps/web/public/r/takumi/theme-provider.json @@ -13,7 +13,7 @@ "files": [ { "path": "registry/bases/takumi/components/theme-provider.ts", - "content": "import {\n Component,\n InjectionToken,\n inject,\n input,\n signal,\n} from \"@angular/core\";\nimport type { Signal } from \"@angular/core\";\n\nimport { professionalTheme } from \"@/lib/pdf-themes/professional\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type { PdfcnTheme };\n\nexport const PDFCN_THEME = new InjectionToken>(\n \"PDFCN_THEME\"\n);\n\nconst defaultTheme = signal(professionalTheme).asReadonly();\n\n/** The theme of the nearest ``, or the professional theme. */\nexport const injectPdfcnTheme = (): Signal =>\n inject(PDFCN_THEME, { optional: true }) ?? defaultTheme;\n\n/** Provides a theme to the components it wraps. */\n@Component({\n providers: [\n {\n provide: PDFCN_THEME,\n useFactory: () => inject(PdfcnThemeProvider).theme,\n },\n ],\n selector: \"pdf-theme-provider\",\n template: \"\",\n})\nexport class PdfcnThemeProvider {\n readonly theme = input(professionalTheme, {\n transform: (theme: PdfcnTheme | undefined) => theme ?? professionalTheme,\n });\n}\n", + "content": "import {\n Component,\n InjectionToken,\n inject,\n input,\n signal,\n} from \"@angular/core\";\nimport type { Signal } from \"@angular/core\";\n\nimport { professionalTheme } from \"@/lib/pdf-themes/professional\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type { PdfcnTheme };\n\nexport const PDFCN_THEME = new InjectionToken>(\n \"PDFCN_THEME\"\n);\n\nconst defaultTheme = signal(professionalTheme).asReadonly();\n\n/** The theme of the nearest ``, or the professional theme. */\nexport const injectPdfcnTheme = (): Signal =>\n inject(PDFCN_THEME, { optional: true }) ?? defaultTheme;\n\n/** Provides a theme to the components it wraps. */\n@Component({\n providers: [\n {\n provide: PDFCN_THEME,\n useFactory: () => inject(PdfcnThemeProvider).theme,\n },\n ],\n selector: \"pdf-theme-provider\",\n template: \"\",\n})\nexport class PdfcnThemeProvider {\n readonly theme = input(professionalTheme, {\n transform: (theme: PdfcnTheme | undefined) => theme ?? professionalTheme,\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:lib", "target": "components/pdf/theme-provider.ts" } diff --git a/apps/web/public/r/takumi/utils.json b/apps/web/public/r/takumi/utils.json index aaf888b..b6e970e 100644 --- a/apps/web/public/r/takumi/utils.json +++ b/apps/web/public/r/takumi/utils.json @@ -13,31 +13,31 @@ "files": [ { "path": "registry/bases/takumi/lib/resolve-color.ts", - "content": "import type { ColorTokens } from \"@/types/pdf-themes\";\n\n/** Theme color token keys that can be used for the color prop */\nexport const THEME_COLOR_KEYS = [\n \"foreground\",\n \"background\",\n \"muted\",\n \"mutedForeground\",\n \"primary\",\n \"primaryForeground\",\n \"border\",\n \"accent\",\n \"destructive\",\n \"success\",\n \"warning\",\n \"info\",\n] as const satisfies (keyof ColorTokens)[];\n\n/** Resolves a color value: theme token key → hex, or raw CSS color as-is. */\nexport const resolveColor = (value: string, colors: ColorTokens): string => {\n const key = value as (typeof THEME_COLOR_KEYS)[number];\n return THEME_COLOR_KEYS.includes(key) ? colors[key] : value;\n};\n", + "content": "import type { ColorTokens } from \"@/types/pdf-themes\";\n\n/** Theme color token keys that can be used for the color prop */\nexport const THEME_COLOR_KEYS = [\n \"foreground\",\n \"background\",\n \"muted\",\n \"mutedForeground\",\n \"primary\",\n \"primaryForeground\",\n \"border\",\n \"accent\",\n \"destructive\",\n \"success\",\n \"warning\",\n \"info\",\n] as const satisfies (keyof ColorTokens)[];\n\n/** Resolves a color value: theme token key → hex, or raw CSS color as-is. */\nexport const resolveColor = (value: string, colors: ColorTokens): string => {\n const key = value as (typeof THEME_COLOR_KEYS)[number];\n return THEME_COLOR_KEYS.includes(key) ? colors[key] : 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:lib", "target": "lib/resolve-color.ts" }, { "path": "registry/bases/takumi/components/theme-provider.ts", - "content": "import {\n Component,\n InjectionToken,\n inject,\n input,\n signal,\n} from \"@angular/core\";\nimport type { Signal } from \"@angular/core\";\n\nimport { professionalTheme } from \"@/lib/pdf-themes/professional\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type { PdfcnTheme };\n\nexport const PDFCN_THEME = new InjectionToken>(\n \"PDFCN_THEME\"\n);\n\nconst defaultTheme = signal(professionalTheme).asReadonly();\n\n/** The theme of the nearest ``, or the professional theme. */\nexport const injectPdfcnTheme = (): Signal =>\n inject(PDFCN_THEME, { optional: true }) ?? defaultTheme;\n\n/** Provides a theme to the components it wraps. */\n@Component({\n providers: [\n {\n provide: PDFCN_THEME,\n useFactory: () => inject(PdfcnThemeProvider).theme,\n },\n ],\n selector: \"pdf-theme-provider\",\n template: \"\",\n})\nexport class PdfcnThemeProvider {\n readonly theme = input(professionalTheme, {\n transform: (theme: PdfcnTheme | undefined) => theme ?? professionalTheme,\n });\n}\n", + "content": "import {\n Component,\n InjectionToken,\n inject,\n input,\n signal,\n} from \"@angular/core\";\nimport type { Signal } from \"@angular/core\";\n\nimport { professionalTheme } from \"@/lib/pdf-themes/professional\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nexport type { PdfcnTheme };\n\nexport const PDFCN_THEME = new InjectionToken>(\n \"PDFCN_THEME\"\n);\n\nconst defaultTheme = signal(professionalTheme).asReadonly();\n\n/** The theme of the nearest ``, or the professional theme. */\nexport const injectPdfcnTheme = (): Signal =>\n inject(PDFCN_THEME, { optional: true }) ?? defaultTheme;\n\n/** Provides a theme to the components it wraps. */\n@Component({\n providers: [\n {\n provide: PDFCN_THEME,\n useFactory: () => inject(PdfcnThemeProvider).theme,\n },\n ],\n selector: \"pdf-theme-provider\",\n template: \"\",\n})\nexport class PdfcnThemeProvider {\n readonly theme = input(professionalTheme, {\n transform: (theme: PdfcnTheme | undefined) => theme ?? professionalTheme,\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:lib", "target": "components/pdf/theme-provider.ts" }, { "path": "registry/lib/pdf-renderer.ts", - "content": "import {\n DOCUMENT,\n ElementRef,\n RendererFactory2,\n createComponent,\n createEnvironmentInjector,\n getPlatform,\n inject,\n platformCore,\n} from \"@angular/core\";\nimport type {\n EnvironmentInjector,\n Provider,\n Renderer2,\n Type,\n} from \"@angular/core\";\n\n/** An element in the tree an Angular component renders into. */\nexport class PdfElement {\n readonly name: string;\n readonly namespace: string | null;\n parent: PdfElement | null = null;\n readonly children: PdfNode[] = [];\n readonly attributes: Record = {};\n /** The primitive directive on this element. Elements without one are transparent. */\n primitive: PdfPrimitive | null = null;\n\n constructor(name: string, namespace: string | null) {\n this.name = name;\n this.namespace = namespace;\n }\n\n /** Angular reads hydration markers through this in apps with client hydration. */\n getAttribute(name: string): string | null {\n return this.attributes[name] ?? null;\n }\n}\n\nexport class PdfTextNode {\n parent: PdfElement | null = null;\n\n value: string;\n\n constructor(value: string) {\n this.value = value;\n }\n}\n\n/** Angular's anchor for control flow and projection. Serializers skip it. */\nexport class PdfComment {\n parent: PdfElement | null = null;\n}\n\nexport type PdfNode = PdfElement | PdfTextNode | PdfComment;\n\n/** Base class for the directives that map to engine nodes. */\nexport abstract class PdfPrimitive {\n readonly element: PdfElement =\n inject>(ElementRef).nativeElement;\n\n constructor() {\n this.element.primitive = this;\n }\n}\n\nconst detach = (node: PdfNode) => {\n if (node.parent) {\n node.parent.children.splice(node.parent.children.indexOf(node), 1);\n node.parent = null;\n }\n};\n\n// oxlint-disable-next-line no-empty-function -- Renderer2 hooks the PDF tree ignores\nconst noop = () => {};\n\nconst renderer: Renderer2 = {\n addClass: noop,\n appendChild(parent: PdfElement, child: PdfNode) {\n detach(child);\n child.parent = parent;\n parent.children.push(child);\n },\n createComment: () => new PdfComment(),\n createElement: (name: string, namespace?: string | null) =>\n new PdfElement(name, namespace ?? null),\n createText: (value: string) => new PdfTextNode(value),\n data: {},\n destroy: noop,\n destroyNode: null,\n insertBefore(parent: PdfElement, child: PdfNode, ref: PdfNode | null) {\n detach(child);\n child.parent = parent;\n const index = ref ? parent.children.indexOf(ref) : -1;\n parent.children.splice(\n index === -1 ? parent.children.length : index,\n 0,\n child\n );\n },\n listen: () => noop,\n nextSibling(node: PdfNode) {\n const siblings = node.parent?.children;\n return siblings?.[siblings.indexOf(node) + 1] ?? null;\n },\n parentNode: (node: PdfNode) => node.parent,\n removeAttribute(element: PdfElement, name: string) {\n Reflect.deleteProperty(element.attributes, name);\n },\n removeChild(_parent: PdfElement | null, child: PdfNode) {\n detach(child);\n },\n removeClass: noop,\n removeStyle: noop,\n selectRootElement: (node: PdfElement) => node,\n setAttribute(element: PdfElement, name: string, value: string) {\n element.attributes[name] = value;\n },\n setProperty: noop,\n setStyle: noop,\n setValue(node: PdfTextNode, value: string) {\n node.value = value;\n },\n};\n\nconst rendererFactory: RendererFactory2 = {\n createRenderer: () => renderer,\n};\n\nexport interface RenderOptions {\n /** Values for the component's inputs. */\n inputs?: Partial>;\n providers?: Provider[];\n}\n\n/** Renders a component once and reads its element tree before tearing it down. */\nexport const renderTree = (\n component: Type,\n { inputs = {}, providers = [] }: RenderOptions,\n read: (root: PdfElement) => R\n): R => {\n const environmentInjector = createEnvironmentInjector(\n [\n { provide: RendererFactory2, useValue: rendererFactory },\n // Angular looks up a style host on creation. PDF components have no styles.\n { provide: DOCUMENT, useValue: { head: null } },\n ...providers,\n ],\n // bootstrapApplication's platform lacks the marker platformCore() asserts in dev mode.\n (getPlatform() ?? platformCore()).injector as EnvironmentInjector\n );\n const ref = createComponent(component, { environmentInjector });\n try {\n for (const [name, value] of Object.entries(inputs)) {\n ref.setInput(name, value);\n }\n ref.changeDetectorRef.detectChanges();\n return read(ref.location.nativeElement as PdfElement);\n } finally {\n ref.destroy();\n environmentInjector.destroy();\n }\n};\n\n/** Elements without a primitive pass their children through, like component hosts. */\nexport const contentOf = (element: PdfElement): (PdfElement | PdfTextNode)[] =>\n element.children.flatMap((child) => {\n if (child instanceof PdfComment) {\n return [];\n }\n if (child instanceof PdfElement && !child.primitive && !child.namespace) {\n return contentOf(child);\n }\n return [child];\n });\n\n/** All text under a node, in document order. */\nexport const textOf = (node: PdfNode): string => {\n if (node instanceof PdfTextNode) {\n return node.value;\n }\n if (node instanceof PdfElement) {\n return node.children.map(textOf).join(\"\");\n }\n return \"\";\n};\n", + "content": "import {\n DOCUMENT,\n ElementRef,\n RendererFactory2,\n createComponent,\n createEnvironmentInjector,\n getPlatform,\n inject,\n platformCore,\n} from \"@angular/core\";\nimport type {\n EnvironmentInjector,\n Provider,\n Renderer2,\n Type,\n} from \"@angular/core\";\n\n/** An element in the tree an Angular component renders into. */\nexport class PdfElement {\n readonly name: string;\n readonly namespace: string | null;\n parent: PdfElement | null = null;\n readonly children: PdfNode[] = [];\n readonly attributes: Record = {};\n /** The primitive directive on this element. Elements without one are transparent. */\n primitive: PdfPrimitive | null = null;\n\n constructor(name: string, namespace: string | null) {\n this.name = name;\n this.namespace = namespace;\n }\n\n /** Angular reads hydration markers through this in apps with client hydration. */\n getAttribute(name: string): string | null {\n return this.attributes[name] ?? null;\n }\n}\n\nexport class PdfTextNode {\n parent: PdfElement | null = null;\n\n value: string;\n\n constructor(value: string) {\n this.value = value;\n }\n}\n\n/** Angular's anchor for control flow and projection. Serializers skip it. */\nexport class PdfComment {\n parent: PdfElement | null = null;\n}\n\nexport type PdfNode = PdfElement | PdfTextNode | PdfComment;\n\n/** Base class for the directives that map to engine nodes. */\nexport abstract class PdfPrimitive {\n readonly element: PdfElement =\n inject>(ElementRef).nativeElement;\n\n constructor() {\n this.element.primitive = this;\n }\n}\n\nconst detach = (node: PdfNode) => {\n if (node.parent) {\n node.parent.children.splice(node.parent.children.indexOf(node), 1);\n node.parent = null;\n }\n};\n\n// oxlint-disable-next-line no-empty-function -- Renderer2 hooks the PDF tree ignores\nconst noop = () => {};\n\nconst renderer: Renderer2 = {\n addClass: noop,\n appendChild(parent: PdfElement, child: PdfNode) {\n detach(child);\n child.parent = parent;\n parent.children.push(child);\n },\n createComment: () => new PdfComment(),\n createElement: (name: string, namespace?: string | null) =>\n new PdfElement(name, namespace ?? null),\n createText: (value: string) => new PdfTextNode(value),\n data: {},\n destroy: noop,\n destroyNode: null,\n insertBefore(parent: PdfElement, child: PdfNode, ref: PdfNode | null) {\n detach(child);\n child.parent = parent;\n const index = ref ? parent.children.indexOf(ref) : -1;\n parent.children.splice(\n index === -1 ? parent.children.length : index,\n 0,\n child\n );\n },\n listen: () => noop,\n nextSibling(node: PdfNode) {\n const siblings = node.parent?.children;\n return siblings?.[siblings.indexOf(node) + 1] ?? null;\n },\n parentNode: (node: PdfNode) => node.parent,\n removeAttribute(element: PdfElement, name: string) {\n Reflect.deleteProperty(element.attributes, name);\n },\n removeChild(_parent: PdfElement | null, child: PdfNode) {\n detach(child);\n },\n removeClass: noop,\n removeStyle: noop,\n selectRootElement: (node: PdfElement) => node,\n setAttribute(element: PdfElement, name: string, value: string) {\n element.attributes[name] = value;\n },\n setProperty: noop,\n setStyle: noop,\n setValue(node: PdfTextNode, value: string) {\n node.value = value;\n },\n};\n\nconst rendererFactory: RendererFactory2 = {\n createRenderer: () => renderer,\n};\n\nexport interface RenderOptions {\n /** Values for the component's inputs. */\n inputs?: Partial>;\n providers?: Provider[];\n}\n\n/** Renders a component once and reads its element tree before tearing it down. */\nexport const renderTree = (\n component: Type,\n { inputs = {}, providers = [] }: RenderOptions,\n read: (root: PdfElement) => R\n): R => {\n const environmentInjector = createEnvironmentInjector(\n [\n { provide: RendererFactory2, useValue: rendererFactory },\n // Angular looks up a style host on creation. PDF components have no styles.\n { provide: DOCUMENT, useValue: { head: null } },\n ...providers,\n ],\n // bootstrapApplication's platform lacks the marker platformCore() asserts in dev mode.\n (getPlatform() ?? platformCore()).injector as EnvironmentInjector\n );\n const ref = createComponent(component, { environmentInjector });\n try {\n for (const [name, value] of Object.entries(inputs)) {\n ref.setInput(name, value);\n }\n ref.changeDetectorRef.detectChanges();\n return read(ref.location.nativeElement as PdfElement);\n } finally {\n ref.destroy();\n environmentInjector.destroy();\n }\n};\n\n/** Elements without a primitive pass their children through, like component hosts. */\nexport const contentOf = (element: PdfElement): (PdfElement | PdfTextNode)[] =>\n element.children.flatMap((child) => {\n if (child instanceof PdfComment) {\n return [];\n }\n if (child instanceof PdfElement && !child.primitive && !child.namespace) {\n return contentOf(child);\n }\n return [child];\n });\n\n/** All text under a node, in document order. */\nexport const textOf = (node: PdfNode): string => {\n if (node instanceof PdfTextNode) {\n return node.value;\n }\n if (node instanceof PdfElement) {\n return node.children.map(textOf).join(\"\");\n }\n return \"\";\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:lib", "target": "lib/pdf-renderer.ts" }, { "path": "registry/bases/takumi/lib/pdf-primitives.ts", - "content": "import { Directive, booleanAttribute, input } from \"@angular/core\";\n\nimport { PdfPrimitive } from \"@/lib/pdf-renderer\";\n\n/** CSS-like style object. Known CSS properties allow dot access. */\nexport type Style = Partial> &\n Record;\n\nexport const StyleSheet = {\n create>(styles: T): T {\n return styles;\n },\n};\n\nexport type StyleInput = Style | Style[] | false | null | undefined;\n\n/**\n * pdfcn's shared component tokens follow the PDF convention of using points.\n * Takumi follows browser CSS instead, where numeric lengths are pixels at\n * 96 DPI. Converting at the primitive boundary keeps the public component API\n * and the generated document's physical measurements aligned with Forme.\n */\nexport const PDF_POINT_TO_CSS_PIXEL = 96 / 72;\n\nexport const pointToCssPixel = (value: number): number =>\n value * PDF_POINT_TO_CSS_PIXEL;\n\nconst POINT_LENGTH_PROPERTIES = new Set([\n \"blockSize\",\n \"borderBlockEndWidth\",\n \"borderBlockStartWidth\",\n \"borderBlockWidth\",\n \"borderBottomLeftRadius\",\n \"borderBottomRightRadius\",\n \"borderBottomWidth\",\n \"borderEndEndRadius\",\n \"borderEndStartRadius\",\n \"borderInlineEndWidth\",\n \"borderInlineStartWidth\",\n \"borderInlineWidth\",\n \"borderLeftWidth\",\n \"borderRadius\",\n \"borderRightWidth\",\n \"borderStartEndRadius\",\n \"borderStartStartRadius\",\n \"borderTopLeftRadius\",\n \"borderTopRightRadius\",\n \"borderTopWidth\",\n \"borderWidth\",\n \"bottom\",\n \"columnGap\",\n \"flexBasis\",\n \"fontSize\",\n \"gap\",\n \"height\",\n \"inlineSize\",\n \"inset\",\n \"insetBlock\",\n \"insetBlockEnd\",\n \"insetBlockStart\",\n \"insetInline\",\n \"insetInlineEnd\",\n \"insetInlineStart\",\n \"left\",\n \"letterSpacing\",\n \"margin\",\n \"marginBlock\",\n \"marginBlockEnd\",\n \"marginBlockStart\",\n \"marginBottom\",\n \"marginInline\",\n \"marginInlineEnd\",\n \"marginInlineStart\",\n \"marginLeft\",\n \"marginRight\",\n \"marginTop\",\n \"maxBlockSize\",\n \"maxHeight\",\n \"maxInlineSize\",\n \"maxWidth\",\n \"minBlockSize\",\n \"minHeight\",\n \"minInlineSize\",\n \"minWidth\",\n \"outlineOffset\",\n \"outlineWidth\",\n \"padding\",\n \"paddingBlock\",\n \"paddingBlockEnd\",\n \"paddingBlockStart\",\n \"paddingBottom\",\n \"paddingInline\",\n \"paddingInlineEnd\",\n \"paddingInlineStart\",\n \"paddingLeft\",\n \"paddingRight\",\n \"paddingTop\",\n \"right\",\n \"rowGap\",\n \"textDecorationThickness\",\n \"textIndent\",\n \"top\",\n \"width\",\n]);\n\nexport const normalizeTakumiStyle = (style: Style): Style => {\n const {\n marginHorizontal,\n marginVertical,\n paddingHorizontal,\n paddingVertical,\n ...normalized\n } = style;\n\n if (marginHorizontal !== undefined) {\n normalized.marginLeft ??= marginHorizontal;\n normalized.marginRight ??= marginHorizontal;\n }\n if (marginVertical !== undefined) {\n normalized.marginBottom ??= marginVertical;\n normalized.marginTop ??= marginVertical;\n }\n if (paddingHorizontal !== undefined) {\n normalized.paddingLeft ??= paddingHorizontal;\n normalized.paddingRight ??= paddingHorizontal;\n }\n if (paddingVertical !== undefined) {\n normalized.paddingBottom ??= paddingVertical;\n normalized.paddingTop ??= paddingVertical;\n }\n\n const borderSides = [\"Top\", \"Right\", \"Bottom\", \"Left\"] as const;\n if (normalized.borderWidth !== undefined) {\n normalized.borderStyle ??= \"solid\";\n }\n for (const side of borderSides) {\n if (normalized[`border${side}Width`] !== undefined) {\n normalized[`border${side}Style`] ??= \"solid\";\n }\n }\n\n return Object.fromEntries(\n Object.entries(normalized).map(([property, value]) => [\n property,\n typeof value === \"number\" && POINT_LENGTH_PROPERTIES.has(property)\n ? pointToCssPixel(value)\n : value,\n ])\n );\n};\n\nexport const flatten = (\n style?: StyleInput\n): Record | undefined => {\n if (!style) {\n return undefined;\n }\n if (Array.isArray(style)) {\n return normalizeTakumiStyle(Object.assign({}, ...style.filter(Boolean)));\n }\n return normalizeTakumiStyle(style);\n};\n\n/** The tag and props a primitive stands for, as Takumi's element reader expects them. */\nexport interface TakumiHost {\n tag: string;\n props: {\n className?: string;\n height?: unknown;\n src?: unknown;\n style?: unknown;\n width?: unknown;\n } & Record;\n}\n\nexport abstract class TakumiPrimitive extends PdfPrimitive {\n abstract host(): TakumiHost;\n}\n\n@Directive({ selector: \"takumi-view\" })\nexport class TakumiView extends TakumiPrimitive {\n readonly style = input();\n readonly className = input();\n readonly wrap = input(undefined, {\n transform: (value: unknown) =>\n value === undefined ? undefined : booleanAttribute(value),\n });\n readonly fixed = input(false, { transform: booleanAttribute });\n readonly break = input(false, { transform: booleanAttribute });\n\n host(): TakumiHost {\n const merged = {\n display: \"flex\",\n flexDirection: \"column\",\n ...flatten(this.style()),\n };\n if (this.break()) {\n Object.assign(merged, { breakBefore: \"page\" });\n }\n if (this.wrap() === false) {\n Object.assign(merged, { breakInside: \"avoid\" });\n }\n if (this.fixed()) {\n Object.assign(merged, { position: \"fixed\" });\n }\n return {\n props: { className: this.className(), style: merged },\n tag: \"div\",\n };\n }\n}\n\n/**\n * Text node. With `ifString`, it only wraps plain text content and\n * passes element content through unchanged.\n */\n@Directive({ selector: \"takumi-text\" })\nexport class TakumiText extends TakumiPrimitive {\n readonly ifString = input(false, { transform: booleanAttribute });\n readonly style = input();\n readonly className = input();\n readonly href = input();\n readonly src = input();\n\n host(): TakumiHost {\n const merged = flatten(this.style());\n const link = this.href() ?? this.src();\n if (link) {\n return {\n props: { className: this.className(), href: link, style: merged },\n tag: \"a\",\n };\n }\n return {\n props: { className: this.className(), style: merged },\n tag: \"span\",\n };\n }\n}\n\n@Directive({ selector: \"takumi-image\" })\nexport class TakumiImage extends TakumiPrimitive {\n readonly src = input.required();\n readonly style = input();\n\n host(): TakumiHost {\n const src = this.src();\n const resolved = typeof src === \"string\" ? src : src.uri;\n return {\n props: { alt: \"\", src: resolved, style: flatten(this.style()) },\n tag: \"img\",\n };\n }\n}\n\n@Directive({ selector: \"takumi-link\" })\nexport class TakumiLink extends TakumiPrimitive {\n readonly src = input.required();\n readonly style = input();\n\n host(): TakumiHost {\n return {\n props: { href: this.src(), style: flatten(this.style()) },\n tag: \"a\",\n };\n }\n}\n\n@Directive({ selector: \"takumi-document\" })\nexport class TakumiDocument extends TakumiPrimitive {\n readonly title = input();\n readonly style = input();\n\n host(): TakumiHost {\n return {\n props: {\n \"data-pdf-document\": this.title(),\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n ...flatten(this.style()),\n },\n },\n tag: \"div\",\n };\n }\n}\n\n@Directive({ selector: \"takumi-page\" })\nexport class TakumiPage extends TakumiPrimitive {\n readonly size = input();\n readonly style = input();\n\n host(): TakumiHost {\n return {\n props: {\n \"data-pdf-page\": true,\n style: {\n display: \"flex\",\n flexDirection: \"column\",\n ...flatten(this.style()),\n },\n },\n tag: \"div\",\n };\n }\n}\n\n/** Takumi's page counters, which the engine fills in per page. */\n@Directive({ selector: \"takumi-counter\" })\nexport class TakumiCounter extends TakumiPrimitive {\n readonly counter = input.required<\"pageNumber\" | \"totalPages\">();\n readonly format = input();\n readonly className = input();\n readonly style = input