@addsign/moje-agenda-shared-lib 1.0.48 → 1.0.50
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.
package/dist/assets/tailwind.css
CHANGED
|
@@ -759,9 +759,6 @@ video {
|
|
|
759
759
|
.mt-\[4px\] {
|
|
760
760
|
margin-top: 4px;
|
|
761
761
|
}
|
|
762
|
-
.mt-\[5vh\] {
|
|
763
|
-
margin-top: 5vh;
|
|
764
|
-
}
|
|
765
762
|
.mt-auto {
|
|
766
763
|
margin-top: auto;
|
|
767
764
|
}
|
|
@@ -861,18 +858,12 @@ video {
|
|
|
861
858
|
.max-h-\[400px\] {
|
|
862
859
|
max-height: 400px;
|
|
863
860
|
}
|
|
864
|
-
.max-h-\[calc\(100vh_-_20px\)\] {
|
|
865
|
-
max-height: calc(100vh - 20px);
|
|
866
|
-
}
|
|
867
861
|
.max-h-full {
|
|
868
862
|
max-height: 100%;
|
|
869
863
|
}
|
|
870
864
|
.min-h-5 {
|
|
871
865
|
min-height: 1.25rem;
|
|
872
866
|
}
|
|
873
|
-
.min-h-64 {
|
|
874
|
-
min-height: 16rem;
|
|
875
|
-
}
|
|
876
867
|
.min-h-\[285px\] {
|
|
877
868
|
min-height: 285px;
|
|
878
869
|
}
|
|
@@ -958,9 +949,6 @@ video {
|
|
|
958
949
|
.min-w-20 {
|
|
959
950
|
min-width: 5rem;
|
|
960
951
|
}
|
|
961
|
-
.min-w-96 {
|
|
962
|
-
min-width: 24rem;
|
|
963
|
-
}
|
|
964
952
|
.min-w-\[100px\] {
|
|
965
953
|
min-width: 100px;
|
|
966
954
|
}
|
|
@@ -970,6 +958,9 @@ video {
|
|
|
970
958
|
.min-w-\[180px\] {
|
|
971
959
|
min-width: 180px;
|
|
972
960
|
}
|
|
961
|
+
.max-w-\[80vw\] {
|
|
962
|
+
max-width: 80vw;
|
|
963
|
+
}
|
|
973
964
|
.max-w-full {
|
|
974
965
|
max-width: 100%;
|
|
975
966
|
}
|
|
@@ -26,24 +26,25 @@ function ModalDialog({
|
|
|
26
26
|
return /* @__PURE__ */ jsx(
|
|
27
27
|
"div",
|
|
28
28
|
{
|
|
29
|
-
className: "fixed inset-0 bg-black bg-opacity-25 flex items-
|
|
29
|
+
className: "fixed inset-0 bg-black bg-opacity-25 flex items-center justify-center p-4",
|
|
30
30
|
style: { zIndex: 50 },
|
|
31
31
|
children: /* @__PURE__ */ jsxs(
|
|
32
32
|
"div",
|
|
33
33
|
{
|
|
34
34
|
ref,
|
|
35
|
-
className: `
|
|
36
|
-
relative
|
|
35
|
+
className: `w-full max-w-[80vw] bg-white rounded-lg shadow-lg flex flex-col justify-start items-center
|
|
36
|
+
relative gap-5 p-5 overflow-y-auto` + (classNameWrapper ? ` ${classNameWrapper}` : ""),
|
|
37
|
+
style: { maxHeight: "90vh" },
|
|
37
38
|
children: [
|
|
38
39
|
/* @__PURE__ */ jsx(
|
|
39
40
|
"div",
|
|
40
41
|
{
|
|
41
|
-
className: "w-11 h-11 p-2 right-0 top-[16px] absolute rounded-full justify-center items-center inline-flex mr-4 hover:bg-gray-100",
|
|
42
|
+
className: "w-11 h-11 p-2 right-0 top-[16px] absolute rounded-full justify-center items-center inline-flex mr-4 hover:bg-gray-100 cursor-pointer",
|
|
42
43
|
onClick: cancelAction,
|
|
43
44
|
children: /* @__PURE__ */ jsx(IoCloseOutline, { className: "w-6 h-6 relative text-gray-400" })
|
|
44
45
|
}
|
|
45
46
|
),
|
|
46
|
-
children && /* @__PURE__ */ jsx("div", { className: "
|
|
47
|
+
children && /* @__PURE__ */ jsx("div", { className: "text-left w-full", children })
|
|
47
48
|
]
|
|
48
49
|
}
|
|
49
50
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalDialog.js","sources":["../../lib/components/ModalDialog.tsx"],"sourcesContent":["import { createRef, useEffect } from \"react\";\nimport { IoCloseOutline } from \"react-icons/io5\";\nimport { useClickAway } from \"react-use\";\n\nexport interface IModalDialogProps {\n cancelAction: () => void;\n children?: React.ReactNode;\n classNameWrapper?: string;\n closeOnCLickAway?: boolean;\n}\n\nexport function ModalDialog({\n cancelAction,\n classNameWrapper,\n children,\n closeOnCLickAway = true,\n}: IModalDialogProps) {\n const ref = createRef<HTMLDivElement>();\n\n useClickAway(ref, () => {\n closeOnCLickAway ? cancelAction() : null;\n });\n\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n cancelAction();\n }\n };\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n window.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [cancelAction]);\n\n return (\n <div\n className=\"fixed inset-0 bg-black bg-opacity-25 flex items-
|
|
1
|
+
{"version":3,"file":"ModalDialog.js","sources":["../../lib/components/ModalDialog.tsx"],"sourcesContent":["import { createRef, useEffect } from \"react\";\nimport { IoCloseOutline } from \"react-icons/io5\";\nimport { useClickAway } from \"react-use\";\n\nexport interface IModalDialogProps {\n cancelAction: () => void;\n children?: React.ReactNode;\n classNameWrapper?: string;\n closeOnCLickAway?: boolean;\n}\n\nexport function ModalDialog({\n cancelAction,\n classNameWrapper,\n children,\n closeOnCLickAway = true,\n}: IModalDialogProps) {\n const ref = createRef<HTMLDivElement>();\n\n useClickAway(ref, () => {\n closeOnCLickAway ? cancelAction() : null;\n });\n\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n cancelAction();\n }\n };\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n window.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [cancelAction]);\n\n return (\n <div\n className=\"fixed inset-0 bg-black bg-opacity-25 flex items-center justify-center p-4\"\n style={{ zIndex: 50 }}\n >\n <div\n ref={ref}\n className={\n `w-full max-w-[80vw] bg-white rounded-lg shadow-lg flex flex-col justify-start items-center \n relative gap-5 p-5 overflow-y-auto` +\n (classNameWrapper ? ` ${classNameWrapper}` : \"\")\n }\n style={{ maxHeight: \"90vh\" }}\n >\n <div\n className=\"w-11 h-11 p-2 right-0 top-[16px] absolute rounded-full justify-center items-center inline-flex mr-4 hover:bg-gray-100 cursor-pointer\"\n onClick={cancelAction}\n >\n <IoCloseOutline className=\"w-6 h-6 relative text-gray-400\" />\n </div>\n\n {children && <div className=\"text-left w-full\">{children}</div>}\n </div>\n </div>\n );\n}\n\nexport default ModalDialog;\n"],"names":[],"mappings":";;;;AAWO,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAmB;AACrB,GAAsB;AACpB,QAAM,MAAM;AAEZ,eAAa,KAAK,MAAM;AACtB,uBAAmB,aAAiB,IAAA;AAAA,EAAA,CACrC;AAED,YAAU,MAAM;AACR,UAAA,gBAAgB,CAAC,UAAyB;AAC1C,UAAA,MAAM,QAAQ,UAAU;AACb;MACf;AAAA,IAAA;AAEK,WAAA,iBAAiB,WAAW,aAAa;AAChD,WAAO,MAAM;AACJ,aAAA,oBAAoB,WAAW,aAAa;AAAA,IAAA;AAAA,EACrD,GACC,CAAC,YAAY,CAAC;AAGf,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,QAAQ,GAAG;AAAA,MAEpB,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA,WACE;AAAA,kDAEC,mBAAmB,IAAI,gBAAgB,KAAK;AAAA,UAE/C,OAAO,EAAE,WAAW,OAAO;AAAA,UAE3B,UAAA;AAAA,YAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAU;AAAA,gBACV,SAAS;AAAA,gBAET,UAAA,oBAAC,gBAAe,EAAA,WAAU,iCAAiC,CAAA;AAAA,cAAA;AAAA,YAC7D;AAAA,YAEC,YAAY,oBAAC,OAAI,EAAA,WAAU,oBAAoB,UAAS;AAAA,UAAA;AAAA,QAAA;AAAA,MAC3D;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
package/dist/utils/PdfManager.js
CHANGED
|
@@ -58,7 +58,7 @@ class PDFManager {
|
|
|
58
58
|
marginBottom = 0
|
|
59
59
|
} = options;
|
|
60
60
|
const lineHeight = fontSize * 0.5;
|
|
61
|
-
const maxWidth = textOptions.width ||
|
|
61
|
+
const maxWidth = textOptions.width || 190 - marginLeft;
|
|
62
62
|
this.doc.setFontSize(fontSize);
|
|
63
63
|
this.doc.setFont("Arial", bold ? "bold" : "normal");
|
|
64
64
|
const textLines = this.doc.splitTextToSize(text, maxWidth);
|
|
@@ -138,7 +138,7 @@ class PDFManager {
|
|
|
138
138
|
this.appendSquare({
|
|
139
139
|
color: "#000",
|
|
140
140
|
height: 0.2,
|
|
141
|
-
width:
|
|
141
|
+
width: 190,
|
|
142
142
|
marginTop: -fontSize / 3,
|
|
143
143
|
// Add space between squares
|
|
144
144
|
marginBottom: fontSize / 2 + 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdfManager.js","sources":["../../lib/utils/PdfManager.ts"],"sourcesContent":["import jsPDF from \"jspdf\";\r\nimport \"jspdf-autotable\";\r\nimport fontArial from \"../fonts/arial\";\r\nimport fontArialBold from \"../fonts/arialBold\";\r\n\r\nclass PDFManager {\r\n private doc: jsPDF;\r\n private currentYPosition: number;\r\n private pageHeight: number;\r\n\r\n constructor() {\r\n this.doc = new jsPDF();\r\n this.pageHeight = this.doc.internal.pageSize.height; // Get page height\r\n this.currentYPosition = 10; // Start position at the top of the page\r\n this.loadFonts();\r\n }\r\n public getPageHeight(): number {\r\n return this.pageHeight;\r\n }\r\n public getCurrentY(): number {\r\n return this.currentYPosition;\r\n }\r\n\r\n /**\r\n * Adds a new page and resets the Y position.\r\n */\r\n public addNewPage() {\r\n this.doc.addPage();\r\n this.currentYPosition = 10; // Reset Y position for the new page\r\n }\r\n\r\n private loadFonts() {\r\n this.doc.addFileToVFS(\"arial.ttf\", fontArial);\r\n this.doc.addFont(\"arial.ttf\", \"Arial\", \"normal\");\r\n this.doc.addFileToVFS(\"arialBold.ttf\", fontArialBold);\r\n this.doc.addFont(\"arialBold.ttf\", \"Arial\", \"bold\");\r\n this.doc.setFont(\"Arial\", \"normal\");\r\n }\r\n\r\n /**\r\n * Checks if a page break is needed and adds a new page if required.\r\n */\r\n private checkPageBreak(lineHeight: number) {\r\n if (this.currentYPosition + lineHeight >= this.pageHeight) {\r\n this.doc.addPage();\r\n this.currentYPosition = 10; // Reset Y position for the new page\r\n }\r\n }\r\n\r\n /**\r\n * Appends text to the current PDF document.\r\n */\r\n appendText(\r\n text: string,\r\n options: {\r\n fontSize?: number;\r\n bold?: boolean;\r\n marginLeft?: number;\r\n marginTop?: number;\r\n marginBottom?: number;\r\n } = {},\r\n textOptions: any = {},\r\n ) {\r\n const {\r\n fontSize = 12,\r\n bold = false,\r\n marginTop = 0,\r\n marginLeft = 0,\r\n marginBottom = 0,\r\n } = options;\r\n const lineHeight = fontSize * 0.5; // Approximate line height based on font size\r\n const maxWidth = textOptions.width || 180 - marginLeft; // Adjust width based on offset\r\n\r\n this.doc.setFontSize(fontSize);\r\n\r\n this.doc.setFont(\"Arial\", bold ? \"bold\" : \"normal\");\r\n\r\n // Split the text into multiple lines if it exceeds the maxWidth\r\n const textLines = this.doc.splitTextToSize(text, maxWidth);\r\n this.currentYPosition += marginTop;\r\n // Loop through each line and append it to the document\r\n textLines.forEach((line: string) => {\r\n this.checkPageBreak(lineHeight); // Check if new page is needed\r\n this.doc.text(line, 10 + marginLeft, this.currentYPosition, {\r\n maxWidth, ...textOptions\r\n });\r\n\r\n this.currentYPosition += lineHeight; // Update Y position after each line\r\n });\r\n this.currentYPosition += marginBottom;\r\n }\r\n\r\n appendSquare(\r\n options: {\r\n color?: [number, number, number] | string; // RGB color or string (default is black)\r\n height?: number; // Square height (default is 10 units)\r\n width?: number; // Square width (default is 10 units)\r\n marginLeft?: number; // Left margin before the table\r\n marginTop?: number; // Top margin before the table\r\n marginBottom?: number; // Bottom margin after the table\r\n startX?: number; // X coordinate where the square starts (default is 10)\r\n fill?: boolean; // Whether the square should be filled or outlined (default is true)\r\n } = {},\r\n ) {\r\n const {\r\n color = [0, 0, 0], // Default black color\r\n height = 10, // Default square height\r\n width = 10, // Default square width\r\n marginTop = 0, // Default no offset\r\n marginBottom = 0, // Default no offset\r\n marginLeft = 0, // Default no offset\r\n startX = 10, // Default starting X position\r\n fill = true, // Default to filled square\r\n } = options;\r\n\r\n // Adjust currentYPosition for any offset\r\n this.currentYPosition += marginTop;\r\n\r\n // Check if a new page is needed\r\n this.checkPageBreak(height + marginTop + marginBottom);\r\n\r\n // Set the color for the square\r\n if (Array.isArray(color)) {\r\n this.doc.setFillColor(...color); // For RGB color\r\n this.doc.setDrawColor(...color); // For outline color in case it's not filled\r\n } else {\r\n this.doc.setFillColor(color); // For string color (e.g., 'red', '#FF0000')\r\n this.doc.setDrawColor(color); // For outline color in case it's not filled\r\n }\r\n\r\n // Draw the square (filled or outlined)\r\n if (fill) {\r\n this.doc.rect(startX + marginLeft, this.currentYPosition, width, height, \"F\"); // F for filled\r\n } else {\r\n this.doc.rect(startX + marginLeft, this.currentYPosition, width, height, \"S\"); // S for outlined (stroke)\r\n }\r\n\r\n // Update Y position after the square (including bottom margin)\r\n this.currentYPosition += height + marginBottom;\r\n }\r\n appendTable(\r\n headers: string[] | null, // The table headers\r\n data: any[][], // The table data as an array of arrays\r\n options: {\r\n bold?: boolean; // Bold font for headers\r\n marginLeft?: number; // Left margin before the table\r\n marginRight?: number; // Left margin before the table\r\n marginTop?: number; // Top margin before the table\r\n marginBottom?: number; // Bottom margin after the table\r\n } = {},\r\n tableOptions: any = {},\r\n ) {\r\n const {\r\n bold = true,\r\n marginLeft = 0,\r\n marginRight = 0,\r\n marginTop = 0,\r\n marginBottom = 0,\r\n } = options;\r\n\r\n // Adjust the current Y position with the top margin\r\n this.currentYPosition += marginTop;\r\n\r\n // Append the table using autoTable\r\n (this.doc as any).autoTable({\r\n head: headers ? [headers] : null,\r\n body: data,\r\n startY: this.currentYPosition,\r\n margin: { left: 10 + marginLeft, right: 10 + marginRight }, // Adjust the left margin\r\n styles: { ...tableOptions.styles },\r\n headStyles: { fontStyle: bold ? \"bold\" : \"normal\" },\r\n ...tableOptions,\r\n });\r\n\r\n // Update the Y position after the table\r\n this.currentYPosition =\r\n (this.doc as any).lastAutoTable.finalY + marginBottom;\r\n }\r\n\r\n //helper function for appening title with square\r\n appendPageTitle(title: string) {\r\n this.appendText(title, { fontSize: 14, bold: true });\r\n\r\n }\r\n appendPageTitleWithLine(title: string, fontSize: number = 14) {\r\n this.appendText(title, { fontSize: fontSize, bold: true });\r\n this.appendSquare({\r\n color: \"#000\",\r\n height: 0.2,\r\n width: 180,\r\n marginTop: -fontSize / 3, // Add space between squares\r\n marginBottom: (fontSize / 2) + 1, // Add space between squares\r\n startX: 10,\r\n fill: true, // Filled green square\r\n });\r\n }\r\n\r\n appendPageTitleWithSquare(title: string) {\r\n this.appendSquare({\r\n color: \"#000\", // Green square\r\n height: 10,\r\n width: 10,\r\n marginTop: 0, // Add space between squares\r\n marginBottom: 0, // Add space between squares\r\n startX: 10,\r\n fill: true, // Filled green square\r\n });\r\n this.appendText(title, { fontSize: 14, bold: true, marginLeft: 12, marginTop: -6, marginBottom: 5 });\r\n\r\n }\r\n\r\n\r\n\r\n\r\n /**\r\n * Saves the current PDF document.\r\n */\r\n savePDF(fileName: string = \"report.pdf\") {\r\n this.doc.save(fileName);\r\n this.doc.close()\r\n }\r\n}\r\n\r\nexport default PDFManager;\r\n"],"names":["jsPDF"],"mappings":";;;;;;;;;AAKA,MAAM,WAAW;AAAA,EAKf,cAAc;AAJN;AACA;AACA;AAGD,SAAA,MAAM,IAAIA;AACf,SAAK,aAAa,KAAK,IAAI,SAAS,SAAS;AAC7C,SAAK,mBAAmB;AACxB,SAAK,UAAU;AAAA,EACjB;AAAA,EACO,gBAAwB;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EACO,cAAsB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;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AAO,EAAE,UAAU,IAAI,MAAM,MAAM;AAAA,EAErD;AAAA,EACA,wBAAwB,OAAe,WAAmB,IAAI;AAC5D,SAAK,WAAW,OAAO,EAAE,UAAoB,MAAM,MAAM;AACzD,SAAK,aAAa;AAAA,MAChB,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,WAAW,CAAC,WAAW;AAAA;AAAA,MACvB,cAAe,WAAW,IAAK;AAAA;AAAA,MAC/B,QAAQ;AAAA,MACR,MAAM;AAAA;AAAA,IAAA,CACP;AAAA,EACH;AAAA,EAEA,0BAA0B,OAAe;AACvC,SAAK,aAAa;AAAA,MAChB,OAAO;AAAA;AAAA,MACP,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,WAAW;AAAA;AAAA,MACX,cAAc;AAAA;AAAA,MACd,QAAQ;AAAA,MACR,MAAM;AAAA;AAAA,IAAA,CACP;AACD,SAAK,WAAW,OAAO,EAAE,UAAU,IAAI,MAAM,MAAM,YAAY,IAAI,WAAW,IAAI,cAAc,GAAG;AAAA,EAErG;AAAA;AAAA;AAAA;AAAA,EAQA,QAAQ,WAAmB,cAAc;AAClC,SAAA,IAAI,KAAK,QAAQ;AACtB,SAAK,IAAI;EACX;AACF;"}
|
|
1
|
+
{"version":3,"file":"PdfManager.js","sources":["../../lib/utils/PdfManager.ts"],"sourcesContent":["import jsPDF from \"jspdf\";\r\nimport \"jspdf-autotable\";\r\nimport fontArial from \"../fonts/arial\";\r\nimport fontArialBold from \"../fonts/arialBold\";\r\n\r\nclass PDFManager {\r\n private doc: jsPDF;\r\n private currentYPosition: number;\r\n private pageHeight: number;\r\n\r\n constructor() {\r\n this.doc = new jsPDF();\r\n this.pageHeight = this.doc.internal.pageSize.height; // Get page height\r\n this.currentYPosition = 10; // Start position at the top of the page\r\n this.loadFonts();\r\n }\r\n public getPageHeight(): number {\r\n return this.pageHeight;\r\n }\r\n public getCurrentY(): number {\r\n return this.currentYPosition;\r\n }\r\n\r\n /**\r\n * Adds a new page and resets the Y position.\r\n */\r\n public addNewPage() {\r\n this.doc.addPage();\r\n this.currentYPosition = 10; // Reset Y position for the new page\r\n }\r\n\r\n private loadFonts() {\r\n this.doc.addFileToVFS(\"arial.ttf\", fontArial);\r\n this.doc.addFont(\"arial.ttf\", \"Arial\", \"normal\");\r\n this.doc.addFileToVFS(\"arialBold.ttf\", fontArialBold);\r\n this.doc.addFont(\"arialBold.ttf\", \"Arial\", \"bold\");\r\n this.doc.setFont(\"Arial\", \"normal\");\r\n }\r\n\r\n /**\r\n * Checks if a page break is needed and adds a new page if required.\r\n */\r\n private checkPageBreak(lineHeight: number) {\r\n if (this.currentYPosition + lineHeight >= this.pageHeight) {\r\n this.doc.addPage();\r\n this.currentYPosition = 10; // Reset Y position for the new page\r\n }\r\n }\r\n\r\n /**\r\n * Appends text to the current PDF document.\r\n */\r\n appendText(\r\n text: string,\r\n options: {\r\n fontSize?: number;\r\n bold?: boolean;\r\n marginLeft?: number;\r\n marginTop?: number;\r\n marginBottom?: number;\r\n } = {},\r\n textOptions: any = {},\r\n ) {\r\n const {\r\n fontSize = 12,\r\n bold = false,\r\n marginTop = 0,\r\n marginLeft = 0,\r\n marginBottom = 0,\r\n } = options;\r\n const lineHeight = fontSize * 0.5; // Approximate line height based on font size\r\n const maxWidth = textOptions.width || 190 - marginLeft; // Adjust width based on offset\r\n\r\n this.doc.setFontSize(fontSize);\r\n\r\n this.doc.setFont(\"Arial\", bold ? \"bold\" : \"normal\");\r\n\r\n // Split the text into multiple lines if it exceeds the maxWidth\r\n const textLines = this.doc.splitTextToSize(text, maxWidth);\r\n this.currentYPosition += marginTop;\r\n // Loop through each line and append it to the document\r\n textLines.forEach((line: string) => {\r\n this.checkPageBreak(lineHeight); // Check if new page is needed\r\n this.doc.text(line, 10 + marginLeft, this.currentYPosition, {\r\n maxWidth, ...textOptions\r\n });\r\n\r\n this.currentYPosition += lineHeight; // Update Y position after each line\r\n });\r\n this.currentYPosition += marginBottom;\r\n }\r\n\r\n appendSquare(\r\n options: {\r\n color?: [number, number, number] | string; // RGB color or string (default is black)\r\n height?: number; // Square height (default is 10 units)\r\n width?: number; // Square width (default is 10 units)\r\n marginLeft?: number; // Left margin before the table\r\n marginTop?: number; // Top margin before the table\r\n marginBottom?: number; // Bottom margin after the table\r\n startX?: number; // X coordinate where the square starts (default is 10)\r\n fill?: boolean; // Whether the square should be filled or outlined (default is true)\r\n } = {},\r\n ) {\r\n const {\r\n color = [0, 0, 0], // Default black color\r\n height = 10, // Default square height\r\n width = 10, // Default square width\r\n marginTop = 0, // Default no offset\r\n marginBottom = 0, // Default no offset\r\n marginLeft = 0, // Default no offset\r\n startX = 10, // Default starting X position\r\n fill = true, // Default to filled square\r\n } = options;\r\n\r\n // Adjust currentYPosition for any offset\r\n this.currentYPosition += marginTop;\r\n\r\n // Check if a new page is needed\r\n this.checkPageBreak(height + marginTop + marginBottom);\r\n\r\n // Set the color for the square\r\n if (Array.isArray(color)) {\r\n this.doc.setFillColor(...color); // For RGB color\r\n this.doc.setDrawColor(...color); // For outline color in case it's not filled\r\n } else {\r\n this.doc.setFillColor(color); // For string color (e.g., 'red', '#FF0000')\r\n this.doc.setDrawColor(color); // For outline color in case it's not filled\r\n }\r\n\r\n // Draw the square (filled or outlined)\r\n if (fill) {\r\n this.doc.rect(startX + marginLeft, this.currentYPosition, width, height, \"F\"); // F for filled\r\n } else {\r\n this.doc.rect(startX + marginLeft, this.currentYPosition, width, height, \"S\"); // S for outlined (stroke)\r\n }\r\n\r\n // Update Y position after the square (including bottom margin)\r\n this.currentYPosition += height + marginBottom;\r\n }\r\n appendTable(\r\n headers: string[] | null, // The table headers\r\n data: any[][], // The table data as an array of arrays\r\n options: {\r\n bold?: boolean; // Bold font for headers\r\n marginLeft?: number; // Left margin before the table\r\n marginRight?: number; // Left margin before the table\r\n marginTop?: number; // Top margin before the table\r\n marginBottom?: number; // Bottom margin after the table\r\n } = {},\r\n tableOptions: any = {},\r\n ) {\r\n const {\r\n bold = true,\r\n marginLeft = 0,\r\n marginRight = 0,\r\n marginTop = 0,\r\n marginBottom = 0,\r\n } = options;\r\n\r\n // Adjust the current Y position with the top margin\r\n this.currentYPosition += marginTop;\r\n\r\n // Append the table using autoTable\r\n (this.doc as any).autoTable({\r\n head: headers ? [headers] : null,\r\n body: data,\r\n startY: this.currentYPosition,\r\n margin: { left: 10 + marginLeft, right: 10 + marginRight }, // Adjust the left margin\r\n styles: { ...tableOptions.styles },\r\n headStyles: { fontStyle: bold ? \"bold\" : \"normal\" },\r\n ...tableOptions,\r\n });\r\n\r\n // Update the Y position after the table\r\n this.currentYPosition =\r\n (this.doc as any).lastAutoTable.finalY + marginBottom;\r\n }\r\n\r\n //helper function for appening title with square\r\n appendPageTitle(title: string) {\r\n this.appendText(title, { fontSize: 14, bold: true });\r\n\r\n }\r\n appendPageTitleWithLine(title: string, fontSize: number = 14) {\r\n this.appendText(title, { fontSize: fontSize, bold: true });\r\n this.appendSquare({\r\n color: \"#000\",\r\n height: 0.2,\r\n width: 190,\r\n marginTop: -fontSize / 3, // Add space between squares\r\n marginBottom: (fontSize / 2) + 1, // Add space between squares\r\n startX: 10,\r\n fill: true, // Filled green square\r\n });\r\n }\r\n\r\n appendPageTitleWithSquare(title: string) {\r\n this.appendSquare({\r\n color: \"#000\", // Green square\r\n height: 10,\r\n width: 10,\r\n marginTop: 0, // Add space between squares\r\n marginBottom: 0, // Add space between squares\r\n startX: 10,\r\n fill: true, // Filled green square\r\n });\r\n this.appendText(title, { fontSize: 14, bold: true, marginLeft: 12, marginTop: -6, marginBottom: 5 });\r\n\r\n }\r\n\r\n\r\n\r\n\r\n /**\r\n * Saves the current PDF document.\r\n */\r\n savePDF(fileName: string = \"report.pdf\") {\r\n this.doc.save(fileName);\r\n this.doc.close()\r\n }\r\n}\r\n\r\nexport default PDFManager;\r\n"],"names":["jsPDF"],"mappings":";;;;;;;;;AAKA,MAAM,WAAW;AAAA,EAKf,cAAc;AAJN;AACA;AACA;AAGD,SAAA,MAAM,I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