@aibrains/pdf-renderer 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/components/KeyValueTable.d.ts +23 -0
  2. package/dist/components/KeyValueTable.d.ts.map +1 -0
  3. package/dist/components/KeyValueTable.js +37 -0
  4. package/dist/components/KeyValueTable.js.map +1 -0
  5. package/dist/components/LineItemTable.d.ts +53 -0
  6. package/dist/components/LineItemTable.d.ts.map +1 -0
  7. package/dist/components/LineItemTable.js +99 -0
  8. package/dist/components/LineItemTable.js.map +1 -0
  9. package/dist/components/SignatureLine.d.ts +24 -0
  10. package/dist/components/SignatureLine.d.ts.map +1 -0
  11. package/dist/components/SignatureLine.js +34 -0
  12. package/dist/components/SignatureLine.js.map +1 -0
  13. package/dist/components/TotalsBlock.d.ts +41 -0
  14. package/dist/components/TotalsBlock.d.ts.map +1 -0
  15. package/dist/components/TotalsBlock.js +59 -0
  16. package/dist/components/TotalsBlock.js.map +1 -0
  17. package/dist/components/index.d.ts +20 -0
  18. package/dist/components/index.d.ts.map +1 -0
  19. package/dist/components/index.js +23 -0
  20. package/dist/components/index.js.map +1 -0
  21. package/dist/core/fonts.d.ts +87 -0
  22. package/dist/core/fonts.d.ts.map +1 -0
  23. package/dist/core/fonts.js +159 -0
  24. package/dist/core/fonts.js.map +1 -0
  25. package/dist/core/index.d.ts +2 -0
  26. package/dist/core/index.d.ts.map +1 -1
  27. package/dist/core/index.js +6 -1
  28. package/dist/core/index.js.map +1 -1
  29. package/dist/index.d.ts +3 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +4 -2
  32. package/dist/index.js.map +1 -1
  33. package/dist/primitives/BrandedFooter.d.ts +18 -0
  34. package/dist/primitives/BrandedFooter.d.ts.map +1 -0
  35. package/dist/primitives/BrandedFooter.js +35 -0
  36. package/dist/primitives/BrandedFooter.js.map +1 -0
  37. package/dist/primitives/BrandedHeader.d.ts +41 -0
  38. package/dist/primitives/BrandedHeader.d.ts.map +1 -0
  39. package/dist/primitives/BrandedHeader.js +52 -0
  40. package/dist/primitives/BrandedHeader.js.map +1 -0
  41. package/dist/primitives/Document.d.ts +21 -0
  42. package/dist/primitives/Document.d.ts.map +1 -0
  43. package/dist/primitives/Document.js +19 -0
  44. package/dist/primitives/Document.js.map +1 -0
  45. package/dist/primitives/Page.d.ts +27 -0
  46. package/dist/primitives/Page.d.ts.map +1 -0
  47. package/dist/primitives/Page.js +32 -0
  48. package/dist/primitives/Page.js.map +1 -0
  49. package/dist/primitives/Watermark.d.ts +25 -0
  50. package/dist/primitives/Watermark.d.ts.map +1 -0
  51. package/dist/primitives/Watermark.js +35 -0
  52. package/dist/primitives/Watermark.js.map +1 -0
  53. package/dist/primitives/index.d.ts +21 -0
  54. package/dist/primitives/index.d.ts.map +1 -0
  55. package/dist/primitives/index.js +24 -0
  56. package/dist/primitives/index.js.map +1 -0
  57. package/fonts/NotoSans-Bold.woff +0 -0
  58. package/fonts/NotoSans-Regular.woff +0 -0
  59. package/fonts/NotoSansDevanagari-Bold.woff +0 -0
  60. package/fonts/NotoSansDevanagari-Regular.woff +0 -0
  61. package/package.json +26 -5
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ /**
3
+ * Font registration for @aibrains/pdf-renderer.
4
+ *
5
+ * Two font families ship with the package:
6
+ * - `Noto Sans` — Latin script (Regular + Bold)
7
+ * - `Noto Sans Devanagari` — Devanagari script for Nepali (Regular + Bold)
8
+ *
9
+ * Both are sourced from @fontsource/* at build time and copied to ./fonts/ at the
10
+ * package root (see scripts/copy-fonts.js). At runtime, paths resolve identically
11
+ * from `src/core/fonts.ts` and `dist/core/fonts.js` because both live two
12
+ * directories below the package root (../../fonts/).
13
+ *
14
+ * Devanagari rendering uses Yoga + Fontkit + Harfbuzz inside @react-pdf/renderer v4
15
+ * to handle complex script shaping (conjuncts, vowel marks). This is the canary for
16
+ * Risk R45 (Devanagari shaping defects in production); snapshot tests in the
17
+ * primitives + components directories exercise the pipeline.
18
+ *
19
+ * Call `registerFonts()` exactly once per process before the first render. The
20
+ * `Document` primitive (in `primitives/Document.tsx`) does this automatically.
21
+ *
22
+ * For browser consumers (Shell live-preview via `<PDFViewer>`), the same fonts
23
+ * are bundled in the published tarball; consumers' bundlers (Rsbuild, Webpack)
24
+ * pick them up via the relative path. URL-based registration for CDN deployments
25
+ * is a Sprint C.2 concern.
26
+ */
27
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ var desc = Object.getOwnPropertyDescriptor(m, k);
30
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
31
+ desc = { enumerable: true, get: function() { return m[k]; } };
32
+ }
33
+ Object.defineProperty(o, k2, desc);
34
+ }) : (function(o, m, k, k2) {
35
+ if (k2 === undefined) k2 = k;
36
+ o[k2] = m[k];
37
+ }));
38
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
39
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
40
+ }) : function(o, v) {
41
+ o["default"] = v;
42
+ });
43
+ var __importStar = (this && this.__importStar) || (function () {
44
+ var ownKeys = function(o) {
45
+ ownKeys = Object.getOwnPropertyNames || function (o) {
46
+ var ar = [];
47
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
48
+ return ar;
49
+ };
50
+ return ownKeys(o);
51
+ };
52
+ return function (mod) {
53
+ if (mod && mod.__esModule) return mod;
54
+ var result = {};
55
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
56
+ __setModuleDefault(result, mod);
57
+ return result;
58
+ };
59
+ })();
60
+ Object.defineProperty(exports, "__esModule", { value: true });
61
+ exports.FONT_FAMILY_DEVANAGARI = exports.FONT_FAMILY_LATIN = void 0;
62
+ exports.pickFontFamily = pickFontFamily;
63
+ exports.registerFonts = registerFonts;
64
+ exports._resetFontsForTest = _resetFontsForTest;
65
+ const path = __importStar(require("node:path"));
66
+ const renderer_1 = require("@react-pdf/renderer");
67
+ const PACKAGE_ROOT = path.resolve(__dirname, '..', '..');
68
+ const FONT_DIR = path.join(PACKAGE_ROOT, 'fonts');
69
+ /** Latin font family registered by `registerFonts()`. */
70
+ exports.FONT_FAMILY_LATIN = 'Noto Sans';
71
+ /** Devanagari (Nepali) font family registered by `registerFonts()`. */
72
+ exports.FONT_FAMILY_DEVANAGARI = 'Noto Sans Devanagari';
73
+ // Unicode range U+0900..U+097F covers the full Devanagari block. Any codepoint
74
+ // in that range means the run contains Devanagari script and needs the
75
+ // Devanagari font. Latin (Basic Latin + Latin-1 Supplement) lives outside
76
+ // this range — we route it to the default Latin family. Mixed runs are split
77
+ // into multiple <Text> elements by the component layer.
78
+ const DEVANAGARI_RANGE = /[ऀ-ॿ]/;
79
+ /**
80
+ * Pick the correct font family for a text run.
81
+ *
82
+ * `@react-pdf/renderer` does NOT support CSS-style font-fallback chains —
83
+ * each text run uses exactly one font family. For mixed-script content
84
+ * (e.g., dual-language labels "Invoice / बिल"), components must split into
85
+ * separate `<Text>` elements and call this helper per segment.
86
+ *
87
+ * Detection rule: **any-Devanagari-wins**. The implementation tests
88
+ * `DEVANAGARI_RANGE.test(str)`, which returns true if ANY codepoint in the
89
+ * string falls in the Devanagari block — regardless of position. So
90
+ * `pickFontFamily('Invoice / बिल')` returns `FONT_FAMILY_DEVANAGARI` even
91
+ * though Latin appears first. This is intentional for V1: when a Devanagari
92
+ * character is present, we always need its font to render correctly; the
93
+ * Latin characters in `Noto Sans Devanagari` render acceptably (the font
94
+ * includes Basic Latin glyphs). If first-script-wins semantics are ever
95
+ * needed, change `DEVANAGARI_RANGE.test(str)` to scan only the first script
96
+ * cluster.
97
+ *
98
+ * @example
99
+ * pickFontFamily('Subtotal') // 'Noto Sans'
100
+ * pickFontFamily('उप-योग') // 'Noto Sans Devanagari'
101
+ * pickFontFamily('Invoice / बिल') // 'Noto Sans Devanagari' (any-Devanagari-wins)
102
+ * pickFontFamily('बिल / Invoice') // 'Noto Sans Devanagari'
103
+ * pickFontFamily('') // 'Noto Sans' (default for empty / null / undefined)
104
+ */
105
+ function pickFontFamily(text) {
106
+ if (text === null || text === undefined || text === '')
107
+ return exports.FONT_FAMILY_LATIN;
108
+ const str = String(text);
109
+ return DEVANAGARI_RANGE.test(str) ? exports.FONT_FAMILY_DEVANAGARI : exports.FONT_FAMILY_LATIN;
110
+ }
111
+ let registered = false;
112
+ /**
113
+ * Register the bundled fonts with `@react-pdf/renderer`. Idempotent — safe to
114
+ * call multiple times; subsequent calls short-circuit.
115
+ *
116
+ * Throws if the font files are not on disk (which means `npm run build` was
117
+ * never run after installation). Surfaces a clear error rather than silently
118
+ * rendering with the default font.
119
+ */
120
+ function registerFonts() {
121
+ if (registered)
122
+ return;
123
+ // @react-pdf/renderer uses NUMERIC fontWeight internally (400 for normal,
124
+ // 700 for bold). Passing the string 'normal'/'bold' to Font.register stores
125
+ // them as strings but the resolver looks up numerics, so the registration
126
+ // doesn't match at render time. Use numeric weights at registration to match.
127
+ renderer_1.Font.register({
128
+ family: exports.FONT_FAMILY_LATIN,
129
+ fonts: [
130
+ {
131
+ src: path.join(FONT_DIR, 'NotoSans-Regular.woff'),
132
+ fontWeight: 400,
133
+ },
134
+ {
135
+ src: path.join(FONT_DIR, 'NotoSans-Bold.woff'),
136
+ fontWeight: 700,
137
+ },
138
+ ],
139
+ });
140
+ renderer_1.Font.register({
141
+ family: exports.FONT_FAMILY_DEVANAGARI,
142
+ fonts: [
143
+ {
144
+ src: path.join(FONT_DIR, 'NotoSansDevanagari-Regular.woff'),
145
+ fontWeight: 400,
146
+ },
147
+ {
148
+ src: path.join(FONT_DIR, 'NotoSansDevanagari-Bold.woff'),
149
+ fontWeight: 700,
150
+ },
151
+ ],
152
+ });
153
+ registered = true;
154
+ }
155
+ /** Test-only escape hatch — resets the registration guard so a test can re-register. */
156
+ function _resetFontsForTest() {
157
+ registered = false;
158
+ }
159
+ //# sourceMappingURL=fonts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fonts.js","sourceRoot":"","sources":["../../src/core/fonts.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CH,wCAMC;AAgCD,sCAoCC;AAGD,gDAEC;AA3HD,gDAAkC;AAClC,kDAA2C;AAE3C,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AAElD,yDAAyD;AAC5C,QAAA,iBAAiB,GAAG,WAAoB,CAAC;AACtD,uEAAuE;AAC1D,QAAA,sBAAsB,GAAG,sBAA+B,CAAC;AAEtE,+EAA+E;AAC/E,uEAAuE;AACvE,0EAA0E;AAC1E,6EAA6E;AAC7E,wDAAwD;AACxD,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,cAAc,CAC5B,IAAwC;IAExC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,yBAAiB,CAAC;IACjF,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACzB,OAAO,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,8BAAsB,CAAC,CAAC,CAAC,yBAAiB,CAAC;AACjF,CAAC;AAsBD,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB;;;;;;;GAOG;AACH,SAAgB,aAAa;IAC3B,IAAI,UAAU;QAAE,OAAO;IAEvB,0EAA0E;IAC1E,4EAA4E;IAC5E,0EAA0E;IAC1E,8EAA8E;IAC9E,eAAI,CAAC,QAAQ,CAAC;QACZ,MAAM,EAAE,yBAAiB;QACzB,KAAK,EAAE;YACL;gBACE,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,uBAAuB,CAAC;gBACjD,UAAU,EAAE,GAAG;aAChB;YACD;gBACE,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC;gBAC9C,UAAU,EAAE,GAAG;aAChB;SACF;KACF,CAAC,CAAC;IAEH,eAAI,CAAC,QAAQ,CAAC;QACZ,MAAM,EAAE,8BAAsB;QAC9B,KAAK,EAAE;YACL;gBACE,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,iCAAiC,CAAC;gBAC3D,UAAU,EAAE,GAAG;aAChB;YACD;gBACE,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,8BAA8B,CAAC;gBACxD,UAAU,EAAE,GAAG;aAChB;SACF;KACF,CAAC,CAAC;IAEH,UAAU,GAAG,IAAI,CAAC;AACpB,CAAC;AAED,wFAAwF;AACxF,SAAgB,kBAAkB;IAChC,UAAU,GAAG,KAAK,CAAC;AACrB,CAAC"}
@@ -11,4 +11,6 @@ export { t, tDual } from './i18n';
11
11
  export type { Lang, Namespace } from './i18n';
12
12
  export { formatDate, formatNumber, formatCurrency } from './format';
13
13
  export type { DateFormat, NumberGrouping } from './format';
14
+ export { registerFonts, pickFontFamily, FONT_FAMILY_LATIN, FONT_FAMILY_DEVANAGARI, } from './fonts';
15
+ export type { ImageSource } from './fonts';
14
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAClC,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACpE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAClC,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACpE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE3D,OAAO,EACL,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
@@ -7,7 +7,7 @@
7
7
  * and reusable components on top of these.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.formatCurrency = exports.formatNumber = exports.formatDate = exports.tDual = exports.t = exports.DEFAULT_MARGINS_MM = exports.DEFAULT_FONT_SIZE = exports.DEFAULT_SPACING = exports.DEFAULT_COLORS = void 0;
10
+ exports.FONT_FAMILY_DEVANAGARI = exports.FONT_FAMILY_LATIN = exports.pickFontFamily = exports.registerFonts = exports.formatCurrency = exports.formatNumber = exports.formatDate = exports.tDual = exports.t = exports.DEFAULT_MARGINS_MM = exports.DEFAULT_FONT_SIZE = exports.DEFAULT_SPACING = exports.DEFAULT_COLORS = void 0;
11
11
  var theme_1 = require("./theme");
12
12
  Object.defineProperty(exports, "DEFAULT_COLORS", { enumerable: true, get: function () { return theme_1.DEFAULT_COLORS; } });
13
13
  Object.defineProperty(exports, "DEFAULT_SPACING", { enumerable: true, get: function () { return theme_1.DEFAULT_SPACING; } });
@@ -20,4 +20,9 @@ var format_1 = require("./format");
20
20
  Object.defineProperty(exports, "formatDate", { enumerable: true, get: function () { return format_1.formatDate; } });
21
21
  Object.defineProperty(exports, "formatNumber", { enumerable: true, get: function () { return format_1.formatNumber; } });
22
22
  Object.defineProperty(exports, "formatCurrency", { enumerable: true, get: function () { return format_1.formatCurrency; } });
23
+ var fonts_1 = require("./fonts");
24
+ Object.defineProperty(exports, "registerFonts", { enumerable: true, get: function () { return fonts_1.registerFonts; } });
25
+ Object.defineProperty(exports, "pickFontFamily", { enumerable: true, get: function () { return fonts_1.pickFontFamily; } });
26
+ Object.defineProperty(exports, "FONT_FAMILY_LATIN", { enumerable: true, get: function () { return fonts_1.FONT_FAMILY_LATIN; } });
27
+ Object.defineProperty(exports, "FONT_FAMILY_DEVANAGARI", { enumerable: true, get: function () { return fonts_1.FONT_FAMILY_DEVANAGARI; } });
23
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,iCAKiB;AAJf,uGAAA,cAAc,OAAA;AACd,wGAAA,eAAe,OAAA;AACf,0GAAA,iBAAiB,OAAA;AACjB,2GAAA,kBAAkB,OAAA;AAIpB,+BAAkC;AAAzB,yFAAA,CAAC,OAAA;AAAE,6FAAA,KAAK,OAAA;AAGjB,mCAAoE;AAA3D,oGAAA,UAAU,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,wGAAA,cAAc,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,iCAKiB;AAJf,uGAAA,cAAc,OAAA;AACd,wGAAA,eAAe,OAAA;AACf,0GAAA,iBAAiB,OAAA;AACjB,2GAAA,kBAAkB,OAAA;AAIpB,+BAAkC;AAAzB,yFAAA,CAAC,OAAA;AAAE,6FAAA,KAAK,OAAA;AAGjB,mCAAoE;AAA3D,oGAAA,UAAU,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,wGAAA,cAAc,OAAA;AAGjD,iCAKiB;AAJf,sGAAA,aAAa,OAAA;AACb,uGAAA,cAAc,OAAA;AACd,0GAAA,iBAAiB,OAAA;AACjB,+GAAA,sBAAsB,OAAA"}
package/dist/index.d.ts CHANGED
@@ -14,6 +14,8 @@
14
14
  *
15
15
  * Design source of truth: docs/pilot-greenlight/c-epic-pdf-generation-design.md
16
16
  */
17
- export declare const PDF_RENDERER_PACKAGE_VERSION = "0.2.0";
17
+ export declare const PDF_RENDERER_PACKAGE_VERSION = "0.3.0";
18
18
  export * from './core';
19
+ export * from './primitives';
20
+ export * from './components';
19
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,4BAA4B,UAAU,CAAC;AAGpD,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,4BAA4B,UAAU,CAAC;AAGpD,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -31,7 +31,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
33
  exports.PDF_RENDERER_PACKAGE_VERSION = void 0;
34
- exports.PDF_RENDERER_PACKAGE_VERSION = '0.2.0';
35
- // Re-export the C.0.2 core API surface.
34
+ exports.PDF_RENDERER_PACKAGE_VERSION = '0.3.0';
35
+ // Re-export the C.0.2 core API surface + C.0.3 primitives + components.
36
36
  __exportStar(require("./core"), exports);
37
+ __exportStar(require("./primitives"), exports);
38
+ __exportStar(require("./components"), exports);
37
39
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;AAEU,QAAA,4BAA4B,GAAG,OAAO,CAAC;AAEpD,wCAAwC;AACxC,yCAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;AAEU,QAAA,4BAA4B,GAAG,OAAO,CAAC;AAEpD,wEAAwE;AACxE,yCAAuB;AACvB,+CAA6B;AAC7B,+CAA6B"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * BrandedFooter — fixed-bottom page footer with optional text + page number.
3
+ *
4
+ * Sits on every page via `fixed` (a @react-pdf/renderer flag that pins the
5
+ * element across pagination). Pages without the footer can simply omit it.
6
+ */
7
+ import * as React from 'react';
8
+ import { type Lang } from '../core/i18n';
9
+ export interface BrandedFooterConfig {
10
+ /** Custom footer text (e.g., school slogan, terms reference, etc.) */
11
+ text?: string;
12
+ /** Show "Page X of Y" — defaults to true. */
13
+ showPageNumbers?: boolean;
14
+ /** Language for the page-number label (defaults to 'en'). */
15
+ lang?: Lang;
16
+ }
17
+ export declare const BrandedFooter: React.FC<BrandedFooterConfig>;
18
+ //# sourceMappingURL=BrandedFooter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrandedFooter.d.ts","sourceRoot":"","sources":["../../src/primitives/BrandedFooter.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAK,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAG5C,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,6DAA6D;IAC7D,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAsBD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAqBvD,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BrandedFooter = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const renderer_1 = require("@react-pdf/renderer");
6
+ const theme_1 = require("../core/theme");
7
+ const i18n_1 = require("../core/i18n");
8
+ const fonts_1 = require("../core/fonts");
9
+ const styles = renderer_1.StyleSheet.create({
10
+ container: {
11
+ position: 'absolute',
12
+ bottom: 8,
13
+ left: 0,
14
+ right: 0,
15
+ flexDirection: 'row',
16
+ justifyContent: 'space-between',
17
+ alignItems: 'center',
18
+ paddingTop: theme_1.DEFAULT_SPACING.xs,
19
+ borderTopWidth: 1,
20
+ borderTopColor: theme_1.DEFAULT_COLORS.border,
21
+ paddingHorizontal: 24,
22
+ },
23
+ text: {
24
+ fontSize: theme_1.DEFAULT_FONT_SIZE.xs,
25
+ color: theme_1.DEFAULT_COLORS.textMuted,
26
+ },
27
+ });
28
+ const BrandedFooter = ({ text, showPageNumbers = true, lang = 'en', }) => {
29
+ // Page-number label uses the localized "Page X of Y" — pick the matching font
30
+ // based on the language (ne → Devanagari, else → Latin).
31
+ const pageNumberFontFamily = lang === 'ne' ? fonts_1.FONT_FAMILY_DEVANAGARI : fonts_1.FONT_FAMILY_LATIN;
32
+ return ((0, jsx_runtime_1.jsxs)(renderer_1.View, { style: styles.container, fixed: true, children: [(0, jsx_runtime_1.jsx)(renderer_1.Text, { style: [styles.text, { fontFamily: (0, fonts_1.pickFontFamily)(text) }], children: text !== null && text !== void 0 ? text : '' }), showPageNumbers && ((0, jsx_runtime_1.jsx)(renderer_1.Text, { style: [styles.text, { fontFamily: pageNumberFontFamily }], render: ({ pageNumber, totalPages }) => (0, i18n_1.t)('common', 'pageOf', lang, { page: pageNumber, total: totalPages }) }))] }));
33
+ };
34
+ exports.BrandedFooter = BrandedFooter;
35
+ //# sourceMappingURL=BrandedFooter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrandedFooter.js","sourceRoot":"","sources":["../../src/primitives/BrandedFooter.tsx"],"names":[],"mappings":";;;;AAQA,kDAA6D;AAC7D,yCAAmF;AACnF,uCAA4C;AAC5C,yCAA0F;AAW1F,MAAM,MAAM,GAAG,qBAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,CAAC;QACR,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,eAAe;QAC/B,UAAU,EAAE,QAAQ;QACpB,UAAU,EAAE,uBAAe,CAAC,EAAE;QAC9B,cAAc,EAAE,CAAC;QACjB,cAAc,EAAE,sBAAc,CAAC,MAAM;QACrC,iBAAiB,EAAE,EAAE;KACtB;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE,yBAAiB,CAAC,EAAE;QAC9B,KAAK,EAAE,sBAAc,CAAC,SAAS;KAChC;CACF,CAAC,CAAC;AAEI,MAAM,aAAa,GAAkC,CAAC,EAC3D,IAAI,EACJ,eAAe,GAAG,IAAI,EACtB,IAAI,GAAG,IAAI,GACZ,EAAE,EAAE;IACH,8EAA8E;IAC9E,yDAAyD;IACzD,MAAM,oBAAoB,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,8BAAsB,CAAC,CAAC,CAAC,yBAAiB,CAAC;IACxF,OAAO,CACL,wBAAC,eAAI,IAAC,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,mBAClC,uBAAC,eAAI,IAAC,KAAK,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,IAAA,sBAAc,EAAC,IAAI,CAAC,EAAE,CAAC,YAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,GAAQ,EACpF,eAAe,IAAI,CAClB,uBAAC,eAAI,IACH,KAAK,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC,EAC1D,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,CACrC,IAAA,QAAC,EAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,GAEtE,CACH,IACI,CACR,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,aAAa,iBAqBxB"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * BrandedHeader — page header with logo, school name, and address.
3
+ *
4
+ * Used by Invoice, Receipt, Report Card, Admit Card. Per template config:
5
+ * - `header.showLogo` — toggle the logo (if branding.logoS3Key present)
6
+ * - `header.showSchoolName` — toggle the school name
7
+ * - `header.showSchoolAddress` — toggle the address lines
8
+ * - `header.tagline` — optional tagline below the school name
9
+ *
10
+ * Logo source: callers must pre-resolve the S3 key to a URL or Buffer and
11
+ * pass it as the `logoSrc` prop. The header doesn't fetch anything.
12
+ */
13
+ import * as React from 'react';
14
+ import { type ImageSource } from '../core/fonts';
15
+ export interface BrandedHeaderBranding {
16
+ /**
17
+ * Pre-resolved logo source. Accepts URL string, Buffer, or react-pdf
18
+ * SourceObject literal — see `ImageSource` in `core/fonts.ts`. Pass
19
+ * `undefined` to skip.
20
+ */
21
+ logoSrc?: ImageSource;
22
+ schoolName?: string;
23
+ addressLines?: string[];
24
+ phone?: string;
25
+ email?: string;
26
+ }
27
+ export interface BrandedHeaderConfig {
28
+ showLogo?: boolean;
29
+ showSchoolName?: boolean;
30
+ showSchoolAddress?: boolean;
31
+ showContact?: boolean;
32
+ tagline?: string;
33
+ /** Primary brand color — applied to the school name. Defaults to theme primary. */
34
+ primaryColor?: string;
35
+ }
36
+ export interface BrandedHeaderProps {
37
+ branding: BrandedHeaderBranding;
38
+ config?: BrandedHeaderConfig;
39
+ }
40
+ export declare const BrandedHeader: React.FC<BrandedHeaderProps>;
41
+ //# sourceMappingURL=BrandedHeader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrandedHeader.d.ts","sourceRoot":"","sources":["../../src/primitives/BrandedHeader.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjE,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,qBAAqB,CAAC;IAChC,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B;AAwCD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA2CtD,CAAC"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BrandedHeader = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const renderer_1 = require("@react-pdf/renderer");
6
+ const theme_1 = require("../core/theme");
7
+ const fonts_1 = require("../core/fonts");
8
+ const styles = renderer_1.StyleSheet.create({
9
+ container: {
10
+ flexDirection: 'row',
11
+ justifyContent: 'space-between',
12
+ alignItems: 'flex-start',
13
+ paddingBottom: theme_1.DEFAULT_SPACING.md,
14
+ borderBottomWidth: 1,
15
+ borderBottomColor: theme_1.DEFAULT_COLORS.border,
16
+ marginBottom: theme_1.DEFAULT_SPACING.lg,
17
+ },
18
+ logo: {
19
+ width: 64,
20
+ height: 64,
21
+ objectFit: 'contain',
22
+ },
23
+ textBlock: {
24
+ flexDirection: 'column',
25
+ alignItems: 'flex-end',
26
+ flex: 1,
27
+ },
28
+ schoolName: {
29
+ fontSize: theme_1.DEFAULT_FONT_SIZE.lg,
30
+ fontWeight: 'bold',
31
+ marginBottom: 2,
32
+ },
33
+ tagline: {
34
+ // No italic variant registered in V1 — keep style upright.
35
+ fontSize: theme_1.DEFAULT_FONT_SIZE.xs,
36
+ color: theme_1.DEFAULT_COLORS.textMuted,
37
+ marginBottom: 4,
38
+ },
39
+ address: {
40
+ fontSize: theme_1.DEFAULT_FONT_SIZE.xs,
41
+ color: theme_1.DEFAULT_COLORS.textMuted,
42
+ lineHeight: 1.3,
43
+ },
44
+ });
45
+ const BrandedHeader = ({ branding, config = {}, }) => {
46
+ const { showLogo = true, showSchoolName = true, showSchoolAddress = true, showContact = true, tagline, primaryColor, } = config;
47
+ const hasLogo = showLogo && branding.logoSrc;
48
+ const schoolColor = primaryColor !== null && primaryColor !== void 0 ? primaryColor : theme_1.DEFAULT_COLORS.primary;
49
+ return ((0, jsx_runtime_1.jsxs)(renderer_1.View, { style: styles.container, children: [hasLogo && (0, jsx_runtime_1.jsx)(renderer_1.Image, { style: styles.logo, src: branding.logoSrc }), (0, jsx_runtime_1.jsxs)(renderer_1.View, { style: styles.textBlock, children: [showSchoolName && branding.schoolName && ((0, jsx_runtime_1.jsx)(renderer_1.Text, { style: [styles.schoolName, { color: schoolColor, fontFamily: (0, fonts_1.pickFontFamily)(branding.schoolName) }], children: branding.schoolName })), tagline && ((0, jsx_runtime_1.jsx)(renderer_1.Text, { style: [styles.tagline, { fontFamily: (0, fonts_1.pickFontFamily)(tagline) }], children: tagline })), showSchoolAddress && branding.addressLines && branding.addressLines.length > 0 && ((0, jsx_runtime_1.jsx)(renderer_1.View, { children: branding.addressLines.map((line, idx) => ((0, jsx_runtime_1.jsx)(renderer_1.Text, { style: [styles.address, { fontFamily: (0, fonts_1.pickFontFamily)(line) }], children: line }, idx))) })), showContact && (branding.phone || branding.email) && ((0, jsx_runtime_1.jsx)(renderer_1.Text, { style: styles.address, children: [branding.phone, branding.email].filter(Boolean).join(' · ') }))] })] }));
50
+ };
51
+ exports.BrandedHeader = BrandedHeader;
52
+ //# sourceMappingURL=BrandedHeader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrandedHeader.js","sourceRoot":"","sources":["../../src/primitives/BrandedHeader.tsx"],"names":[],"mappings":"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"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Document — wraps `@react-pdf/renderer`'s Document and ensures the bundled
3
+ * fonts are registered before the first render.
4
+ *
5
+ * Every consumer document (InvoicePdf, ReceiptPdf, ReportCardPdf, ...) should
6
+ * wrap its `<Page>` children in this Document rather than the raw RPDF one.
7
+ * That makes font registration a render-side invariant rather than a per-caller
8
+ * concern, eliminating an easy gap.
9
+ */
10
+ import * as React from 'react';
11
+ export interface DocumentProps {
12
+ /** Document title surfaced in PDF metadata. */
13
+ title?: string;
14
+ /** Document author surfaced in PDF metadata. */
15
+ author?: string;
16
+ /** Document subject surfaced in PDF metadata. */
17
+ subject?: string;
18
+ children: React.ReactNode;
19
+ }
20
+ export declare const Document: React.FC<DocumentProps>;
21
+ //# sourceMappingURL=Document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Document.d.ts","sourceRoot":"","sources":["../../src/primitives/Document.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAUD,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAY5C,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Document = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const renderer_1 = require("@react-pdf/renderer");
6
+ const fonts_1 = require("../core/fonts");
7
+ /**
8
+ * Register fonts on module load (idempotent). Each consumer document still
9
+ * wraps children in `<Document>`, so the registration is also guaranteed by
10
+ * the render path — but pre-registering here means snapshot tests that
11
+ * accidentally render outside `<Document>` still get correct shaping.
12
+ */
13
+ (0, fonts_1.registerFonts)();
14
+ const Document = ({ title, author, subject, children, }) => {
15
+ // RPDF's Document props don't include children in its TS type — pass via prop.
16
+ return ((0, jsx_runtime_1.jsx)(renderer_1.Document, { title: title, author: author, subject: subject, children: children }));
17
+ };
18
+ exports.Document = Document;
19
+ //# sourceMappingURL=Document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Document.js","sourceRoot":"","sources":["../../src/primitives/Document.tsx"],"names":[],"mappings":";;;;AAWA,kDAA+D;AAC/D,yCAA8C;AAY9C;;;;;GAKG;AACH,IAAA,qBAAa,GAAE,CAAC;AAET,MAAM,QAAQ,GAA4B,CAAC,EAChD,KAAK,EACL,MAAM,EACN,OAAO,EACP,QAAQ,GACT,EAAE,EAAE;IACH,+EAA+E;IAC/E,OAAO,CACL,uBAAC,mBAAY,IAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,YACzD,QAA8B,GAClB,CAChB,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,QAAQ,YAYnB"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Page — wraps `@react-pdf/renderer`'s Page with EdForge defaults.
3
+ *
4
+ * Margins come from template config (`PdfTemplateConfig.margins`); pageSize
5
+ * from `template.pageSize`. The default values mirror the design doc § 4.2
6
+ * (A4 portrait, 15mm margins on all sides) which suit a printable invoice in
7
+ * Nepal pilot defaults.
8
+ */
9
+ import * as React from 'react';
10
+ export type PageSize = 'A4' | 'A5' | 'LETTER';
11
+ export type Orientation = 'portrait' | 'landscape';
12
+ export interface PageProps {
13
+ /** Defaults to A4. */
14
+ size?: PageSize;
15
+ /** Defaults to portrait. */
16
+ orientation?: Orientation;
17
+ /** Margins in millimetres; defaults to 15mm on all sides. */
18
+ margins?: {
19
+ top: number;
20
+ right: number;
21
+ bottom: number;
22
+ left: number;
23
+ };
24
+ children: React.ReactNode;
25
+ }
26
+ export declare const Page: React.FC<PageProps>;
27
+ //# sourceMappingURL=Page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../src/primitives/Page.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,QAAQ,CAAC;AAC9C,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,WAAW,CAAC;AAEnD,MAAM,WAAW,SAAS;IACxB,sBAAsB;IACtB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,4BAA4B;IAC5B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,6DAA6D;IAC7D,OAAO,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACvE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAgBD,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAuBpC,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Page = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const renderer_1 = require("@react-pdf/renderer");
6
+ const theme_1 = require("../core/theme");
7
+ const fonts_1 = require("../core/fonts");
8
+ const mm = (value) => `${value}mm`;
9
+ // react-pdf does NOT support CSS-style font-fallback chains. The page default
10
+ // is Latin; Devanagari text runs MUST explicitly set fontFamily to
11
+ // 'Noto Sans Devanagari' (use `pickFontFamily(text)` helper from core/fonts).
12
+ const baseStyles = renderer_1.StyleSheet.create({
13
+ page: {
14
+ fontFamily: fonts_1.FONT_FAMILY_LATIN,
15
+ fontSize: theme_1.DEFAULT_FONT_SIZE.md,
16
+ color: theme_1.DEFAULT_COLORS.text,
17
+ backgroundColor: theme_1.DEFAULT_COLORS.background,
18
+ },
19
+ });
20
+ const Page = ({ size = 'A4', orientation = 'portrait', margins = theme_1.DEFAULT_MARGINS_MM, children, }) => {
21
+ return ((0, jsx_runtime_1.jsx)(renderer_1.Page, { size: size, orientation: orientation, style: [
22
+ baseStyles.page,
23
+ {
24
+ paddingTop: mm(margins.top),
25
+ paddingRight: mm(margins.right),
26
+ paddingBottom: mm(margins.bottom),
27
+ paddingLeft: mm(margins.left),
28
+ },
29
+ ], children: children }));
30
+ };
31
+ exports.Page = Page;
32
+ //# sourceMappingURL=Page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Page.js","sourceRoot":"","sources":["../../src/primitives/Page.tsx"],"names":[],"mappings":";;;;AAUA,kDAAmE;AACnE,yCAAsF;AACtF,yCAAkD;AAelD,MAAM,EAAE,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC;AAE3C,8EAA8E;AAC9E,mEAAmE;AACnE,8EAA8E;AAC9E,MAAM,UAAU,GAAG,qBAAU,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE;QACJ,UAAU,EAAE,yBAAiB;QAC7B,QAAQ,EAAE,yBAAiB,CAAC,EAAE;QAC9B,KAAK,EAAE,sBAAc,CAAC,IAAI;QAC1B,eAAe,EAAE,sBAAc,CAAC,UAAU;KAC3C;CACF,CAAC,CAAC;AAEI,MAAM,IAAI,GAAwB,CAAC,EACxC,IAAI,GAAG,IAAI,EACX,WAAW,GAAG,UAAU,EACxB,OAAO,GAAG,0BAAkB,EAC5B,QAAQ,GACT,EAAE,EAAE;IACH,OAAO,CACL,uBAAC,eAAQ,IACP,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE;YACL,UAAU,CAAC,IAAI;YACf;gBACE,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;gBAC3B,YAAY,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;gBAC/B,aAAa,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;gBACjC,WAAW,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;aAC9B;SACF,YAEA,QAA8B,GACtB,CACZ,CAAC;AACJ,CAAC,CAAC;AAvBW,QAAA,IAAI,QAuBf"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Watermark — diagonal translucent text overlay.
3
+ *
4
+ * Common cases:
5
+ * - "DRAFT" on a not-yet-issued invoice preview
6
+ * - "PAID" on a settled invoice
7
+ * - "CANCELLED" on a voided invoice or refunded receipt
8
+ *
9
+ * Positioned absolutely, rotated 45deg. Use sparingly — it bleeds through to
10
+ * the body content visually.
11
+ */
12
+ import * as React from 'react';
13
+ export interface WatermarkProps {
14
+ text: string;
15
+ /** 0.0–1.0. Defaults to 0.10 (faint). */
16
+ opacity?: number;
17
+ /** Rotation in degrees. Defaults to -45 (bottom-left to top-right). */
18
+ rotation?: number;
19
+ /** Hex color. Defaults to theme danger. */
20
+ color?: string;
21
+ /** Font size in pt. Defaults to 96. */
22
+ fontSize?: number;
23
+ }
24
+ export declare const Watermark: React.FC<WatermarkProps>;
25
+ //# sourceMappingURL=Watermark.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Watermark.d.ts","sourceRoot":"","sources":["../../src/primitives/Watermark.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAiBD,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAyB9C,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Watermark = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const renderer_1 = require("@react-pdf/renderer");
6
+ const theme_1 = require("../core/theme");
7
+ const fonts_1 = require("../core/fonts");
8
+ const styles = renderer_1.StyleSheet.create({
9
+ container: {
10
+ position: 'absolute',
11
+ top: '40%',
12
+ left: 0,
13
+ right: 0,
14
+ alignItems: 'center',
15
+ justifyContent: 'center',
16
+ },
17
+ text: {
18
+ fontWeight: 'bold',
19
+ letterSpacing: 8,
20
+ },
21
+ });
22
+ const Watermark = ({ text, opacity = 0.1, rotation = -45, color = theme_1.DEFAULT_COLORS.danger, fontSize = 96, }) => {
23
+ return ((0, jsx_runtime_1.jsx)(renderer_1.View, { style: styles.container, fixed: true, children: (0, jsx_runtime_1.jsx)(renderer_1.Text, { style: [
24
+ styles.text,
25
+ {
26
+ color,
27
+ opacity,
28
+ fontSize,
29
+ fontFamily: (0, fonts_1.pickFontFamily)(text),
30
+ transform: `rotate(${rotation}deg)`,
31
+ },
32
+ ], children: text }) }));
33
+ };
34
+ exports.Watermark = Watermark;
35
+ //# sourceMappingURL=Watermark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Watermark.js","sourceRoot":"","sources":["../../src/primitives/Watermark.tsx"],"names":[],"mappings":";;;;AAaA,kDAA6D;AAC7D,yCAA+C;AAC/C,yCAA+C;AAc/C,MAAM,MAAM,GAAG,qBAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,QAAQ,EAAE,UAAU;QACpB,GAAG,EAAE,KAAK;QACV,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,CAAC;QACR,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;KACzB;IACD,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM;QAClB,aAAa,EAAE,CAAC;KACjB;CACF,CAAC,CAAC;AAEI,MAAM,SAAS,GAA6B,CAAC,EAClD,IAAI,EACJ,OAAO,GAAG,GAAG,EACb,QAAQ,GAAG,CAAC,EAAE,EACd,KAAK,GAAG,sBAAc,CAAC,MAAM,EAC7B,QAAQ,GAAG,EAAE,GACd,EAAE,EAAE;IACH,OAAO,CACL,uBAAC,eAAI,IAAC,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,kBAClC,uBAAC,eAAI,IACH,KAAK,EAAE;gBACL,MAAM,CAAC,IAAI;gBACX;oBACE,KAAK;oBACL,OAAO;oBACP,QAAQ;oBACR,UAAU,EAAE,IAAA,sBAAc,EAAC,IAAI,CAAC;oBAChC,SAAS,EAAE,UAAU,QAAQ,MAAM;iBACpC;aACF,YAEA,IAAI,GACA,GACF,CACR,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,SAAS,aAyBpB"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Layout primitives — building blocks that compose into document components.
3
+ *
4
+ * Sprint C.0.3:
5
+ * - Document — wraps RPDF Document, auto-registers fonts
6
+ * - Page — wraps RPDF Page with template margins + default font + theme
7
+ * - BrandedHeader — logo + school name + address (driven by branding)
8
+ * - BrandedFooter — footer text + page numbers
9
+ * - Watermark — DRAFT/PAID/CANCELLED diagonal overlay
10
+ */
11
+ export { Document } from './Document';
12
+ export type { DocumentProps } from './Document';
13
+ export { Page } from './Page';
14
+ export type { PageProps, PageSize, Orientation } from './Page';
15
+ export { BrandedHeader } from './BrandedHeader';
16
+ export type { BrandedHeaderProps, BrandedHeaderBranding, BrandedHeaderConfig, } from './BrandedHeader';
17
+ export { BrandedFooter } from './BrandedFooter';
18
+ export type { BrandedFooterConfig } from './BrandedFooter';
19
+ export { Watermark } from './Watermark';
20
+ export type { WatermarkProps } from './Watermark';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}