tt-pdf-generator 1.4.1 → 1.5.1

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.
@@ -0,0 +1,49 @@
1
+ import { ReactElement } from 'react';
2
+ import { DocumentProps } from '@react-pdf/renderer';
3
+ import type { FontStyle } from '@react-pdf/font';
4
+ export interface FontConfig {
5
+ family: string;
6
+ fonts: {
7
+ src: string;
8
+ fontWeight?: number;
9
+ fontStyle?: FontStyle;
10
+ }[];
11
+ }
12
+ export interface ComponentData {
13
+ type: string;
14
+ visible?: string;
15
+ props?: Record<string, any>;
16
+ children?: ComponentData[] | ComponentData | string | number;
17
+ }
18
+ export interface Template {
19
+ fonts?: FontConfig[];
20
+ components: ComponentData[];
21
+ images?: Record<string, any>;
22
+ [key: string]: any;
23
+ }
24
+ export type TemplateData = Record<string, any>;
25
+ export interface PdfGeneratorProps {
26
+ data: string;
27
+ template: string;
28
+ }
29
+ export interface ComponentMap {
30
+ [key: string]: React.ComponentType<any>;
31
+ }
32
+ export interface RenderPdfComponentArgs {
33
+ componentData: ComponentData | ComponentData[] | string | number;
34
+ components: ComponentMap;
35
+ data: TemplateData;
36
+ allProps: Record<string, any>;
37
+ images: Record<string, any>;
38
+ }
39
+ export type PdfResult = Blob;
40
+ export interface PdfGenerationError extends Error {
41
+ originalError?: Error;
42
+ template?: string;
43
+ data?: string;
44
+ }
45
+ export type GeneratePdfFunction = (template: string, data: string) => Promise<PdfResult>;
46
+ export type ParseJsonFunction = (jsonString: string) => Template | TemplateData | null;
47
+ export type RenderPdfComponentFunction = (args: RenderPdfComponentArgs) => ReactElement | ReactElement[] | null;
48
+ export type PdfDocumentElement = ReactElement<DocumentProps>;
49
+ export type PdfComponentElement = ReactElement<any>;
@@ -0,0 +1,17 @@
1
+ export declare const IMAGES: {
2
+ zeyaraaLogo: string;
3
+ phone: string;
4
+ letter: string;
5
+ dot: string;
6
+ masjid: string;
7
+ logo: string;
8
+ masajid: string;
9
+ logoBlack: string;
10
+ };
11
+ export declare const FONTS: {
12
+ zainExtraLight: string;
13
+ zainLight: string;
14
+ zainRegular: string;
15
+ zainBold: string;
16
+ zainExtraBold: string;
17
+ };
@@ -0,0 +1,14 @@
1
+ import { RenderPdfComponentArgs, TemplateData } from '../types';
2
+ export declare const generateQrCode: (text: string) => Promise<string>;
3
+ export declare function renderPdfComponent(args: RenderPdfComponentArgs): any;
4
+ export declare function renderHtmlComponent(args: RenderPdfComponentArgs): any;
5
+ export declare const mapDataProps: (props: Record<string, any>, data: any, images: any) => {
6
+ [k: string]: any;
7
+ };
8
+ export declare const parseJson: (jsonString: string) => TemplateData | null;
9
+ export declare function getNestedProperty({ obj, path, }: {
10
+ obj?: any;
11
+ path: string;
12
+ }): any;
13
+ export declare function safeBooleanEval(code: string): boolean;
14
+ export declare function convertFileToBase64(file: File): Promise<string>;
@@ -0,0 +1,21 @@
1
+ import { Table, TD, TH, TR } from '@ag-media/react-pdf-table';
2
+ import { Image, Page, Text, View } from '@react-pdf/renderer';
3
+ export declare const PDF_COMPONENTS: {
4
+ Page: typeof Page;
5
+ View: typeof View;
6
+ Text: typeof Text;
7
+ Image: typeof Image;
8
+ Table: typeof Table;
9
+ TH: typeof TH;
10
+ TR: typeof TR;
11
+ TD: typeof TD;
12
+ QrCode: import("react").FC<import("@react-pdf/renderer").ImageProps & {
13
+ qrCodeText: string;
14
+ }>;
15
+ Map: import("react").FC<import("../components/react-pdf/Map").MapProps>;
16
+ Markdown: import("react").FC<import("../components/react-pdf/Markdown").MarkdownProps>;
17
+ Bullet: import("react").FC<{
18
+ direction?: "rtl" | "ltr";
19
+ } & import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement>>;
20
+ Html: import("react").FC<any>;
21
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tt-pdf-generator",
3
- "version": "1.4.1",
3
+ "version": "1.5.1",
4
4
  "description": "TT pdf generator - A powerful React-based PDF generation library for creating documents",
5
5
  "main": "dist/pdf-generator.browser.js",
6
6
  "module": "dist/pdf-generator.esm.js",
@@ -21,7 +21,8 @@
21
21
  "build": "node esbuild.config.js",
22
22
  "build:browser": "node esbuild.browser.config.js",
23
23
  "build:esm": "node esbuild.esm.config.js",
24
- "build:all": "npm run build:browser && npm run build:esm",
24
+ "build:types": "tsc -p tsconfig.declaration.json && npx tsc-alias -p tsconfig.declaration.json && mv dist/index.d.ts dist/pdf-generator.d.ts",
25
+ "build:all": "npm run build:browser && npm run build:esm && npm run build:types",
25
26
  "build:cli": "node esbuild.cli.config.js",
26
27
  "build:images": "node scripts/build-images.js",
27
28
  "build:dev": "node esbuild.dev.config.js",
@@ -81,6 +82,7 @@
81
82
  "eslint-plugin-react": "^7.37.5",
82
83
  "prettier": "^3.5.3",
83
84
  "react": "^19.1.0",
85
+ "tsc-alias": "^1.8.16",
84
86
  "typescript": "^5.8.3"
85
87
  },
86
88
  "dependencies": {
@@ -95,7 +97,7 @@
95
97
  "@radix-ui/react-slot": "^1.2.3",
96
98
  "@radix-ui/react-switch": "^1.2.6",
97
99
  "@radix-ui/react-tabs": "^1.1.12",
98
- "@react-pdf/renderer": "^4.3.0",
100
+ "@react-pdf/renderer": ">=4.0.0",
99
101
  "@supabase/auth-ui-react": "^0.4.7",
100
102
  "@supabase/auth-ui-shared": "^0.1.8",
101
103
  "@supabase/supabase-js": "^2.54.0",
@@ -106,8 +108,9 @@
106
108
  "crypto": "^1.0.1",
107
109
  "lucide-react": "^0.525.0",
108
110
  "qrcode": "^1.5.4",
109
- "react-dom": "^19.1.0",
111
+ "react-dom": ">=18.0.0",
110
112
  "react-markdown": "^10.1.0",
113
+ "react-pdf-html": "^2.1.4",
111
114
  "remark": "^15.0.1",
112
115
  "remark-parse": "^11.0.0",
113
116
  "tailwind-merge": "^3.3.1",