@tonzxz/government-forms 0.1.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.
- package/FORM_CATALOG.md +44 -0
- package/README.md +165 -0
- package/dist/definitions.d.ts +1147 -0
- package/dist/definitions.js +60 -0
- package/dist/forms/iar.d.ts +172 -0
- package/dist/forms/iar.js +6 -0
- package/dist/forms/ics.d.ts +48 -0
- package/dist/forms/ics.js +6 -0
- package/dist/forms/iirup.d.ts +54 -0
- package/dist/forms/iirup.js +6 -0
- package/dist/forms/iirusp.d.ts +32 -0
- package/dist/forms/iirusp.js +6 -0
- package/dist/forms/itr.d.ts +42 -0
- package/dist/forms/itr.js +6 -0
- package/dist/forms/par.d.ts +84 -0
- package/dist/forms/par.js +6 -0
- package/dist/forms/ppelc.d.ts +34 -0
- package/dist/forms/ppelc.js +6 -0
- package/dist/forms/pr.d.ts +27 -0
- package/dist/forms/pr.js +6 -0
- package/dist/forms/property-card.d.ts +68 -0
- package/dist/forms/property-card.js +6 -0
- package/dist/forms/ptr.d.ts +54 -0
- package/dist/forms/ptr.js +6 -0
- package/dist/forms/regspi.d.ts +32 -0
- package/dist/forms/regspi.js +6 -0
- package/dist/forms/ris.d.ts +66 -0
- package/dist/forms/ris.js +6 -0
- package/dist/forms/rlsddp.d.ts +54 -0
- package/dist/forms/rlsddp.js +6 -0
- package/dist/forms/rlsddsp.d.ts +42 -0
- package/dist/forms/rlsddsp.js +6 -0
- package/dist/forms/rpci.d.ts +32 -0
- package/dist/forms/rpci.js +6 -0
- package/dist/forms/rpcppe.d.ts +32 -0
- package/dist/forms/rpcppe.js +6 -0
- package/dist/forms/rpcsp.d.ts +32 -0
- package/dist/forms/rpcsp.js +6 -0
- package/dist/forms/rrsp.d.ts +32 -0
- package/dist/forms/rrsp.js +6 -0
- package/dist/forms/rsmi.d.ts +32 -0
- package/dist/forms/rsmi.js +6 -0
- package/dist/forms/rsmp.d.ts +33 -0
- package/dist/forms/rsmp.js +6 -0
- package/dist/forms/rspi.d.ts +32 -0
- package/dist/forms/rspi.js +6 -0
- package/dist/forms/spc.d.ts +37 -0
- package/dist/forms/spc.js +6 -0
- package/dist/forms/splc.d.ts +41 -0
- package/dist/forms/splc.js +6 -0
- package/dist/forms/stock-card.d.ts +28 -0
- package/dist/forms/stock-card.js +6 -0
- package/dist/forms/wmr.d.ts +32 -0
- package/dist/forms/wmr.js +6 -0
- package/dist/gam/components/gam-report-workbench.d.ts +40 -0
- package/dist/gam/components/gam-report-workbench.js +2 -0
- package/dist/gam/components/grand-total-computation.d.ts +10 -0
- package/dist/gam/components/grand-total-computation.js +26 -0
- package/dist/gam/components/iar-preview.d.ts +30 -0
- package/dist/gam/components/iar-preview.js +150 -0
- package/dist/gam/components/ics-preview.d.ts +31 -0
- package/dist/gam/components/ics-preview.js +114 -0
- package/dist/gam/components/iirup-preview.d.ts +42 -0
- package/dist/gam/components/iirup-preview.js +237 -0
- package/dist/gam/components/itr-preview.d.ts +31 -0
- package/dist/gam/components/itr-preview.js +180 -0
- package/dist/gam/components/par-preview.d.ts +28 -0
- package/dist/gam/components/par-preview.js +95 -0
- package/dist/gam/components/ppelc-preview.d.ts +28 -0
- package/dist/gam/components/ppelc-preview.js +128 -0
- package/dist/gam/components/property-card-preview.d.ts +21 -0
- package/dist/gam/components/property-card-preview.js +117 -0
- package/dist/gam/components/ptr-preview.d.ts +36 -0
- package/dist/gam/components/ptr-preview.js +122 -0
- package/dist/gam/components/purchase-order-page-client.d.ts +66 -0
- package/dist/gam/components/purchase-order-page-client.js +179 -0
- package/dist/gam/components/reg-spi-preview.d.ts +28 -0
- package/dist/gam/components/reg-spi-preview.js +138 -0
- package/dist/gam/components/ris-form.d.ts +13 -0
- package/dist/gam/components/ris-form.js +20 -0
- package/dist/gam/components/ris-preview.d.ts +7 -0
- package/dist/gam/components/ris-preview.js +16 -0
- package/dist/gam/components/rlsddp-preview.d.ts +34 -0
- package/dist/gam/components/rlsddp-preview.js +251 -0
- package/dist/gam/components/rlsddsp-preview.d.ts +33 -0
- package/dist/gam/components/rlsddsp-preview.js +226 -0
- package/dist/gam/components/rpci-preview.d.ts +27 -0
- package/dist/gam/components/rpci-preview.js +123 -0
- package/dist/gam/components/rpcppe-preview.d.ts +28 -0
- package/dist/gam/components/rpcppe-preview.js +133 -0
- package/dist/gam/components/rpcsp-preview.d.ts +29 -0
- package/dist/gam/components/rpcsp-preview.js +81 -0
- package/dist/gam/components/rspi-preview.d.ts +23 -0
- package/dist/gam/components/rspi-preview.js +72 -0
- package/dist/gam/components/spc-preview.d.ts +23 -0
- package/dist/gam/components/spc-preview.js +149 -0
- package/dist/gam/components/splc-entry-form.d.ts +14 -0
- package/dist/gam/components/splc-entry-form.js +6 -0
- package/dist/gam/components/splc-preview.d.ts +27 -0
- package/dist/gam/components/splc-preview.js +192 -0
- package/dist/gam/components/stock-card-preview.d.ts +14 -0
- package/dist/gam/components/stock-card-preview.js +17 -0
- package/dist/gam/config/new-report-config.d.ts +1094 -0
- package/dist/gam/config/new-report-config.js +1478 -0
- package/dist/gam/purchase-order-flow.d.ts +146 -0
- package/dist/gam/purchase-order-flow.js +173 -0
- package/dist/gam/purchase-request/workflow.d.ts +19 -0
- package/dist/gam/purchase-request/workflow.js +45 -0
- package/dist/gam/types/ris-types.d.ts +37 -0
- package/dist/gam/types/ris-types.js +1 -0
- package/dist/gam/utils/export-ics-xlsx.d.ts +28 -0
- package/dist/gam/utils/export-ics-xlsx.js +273 -0
- package/dist/gam/utils/export-par-xlsx.d.ts +18 -0
- package/dist/gam/utils/export-par-xlsx.js +181 -0
- package/dist/gam/utils/export-preview-pdf.d.ts +13 -0
- package/dist/gam/utils/export-preview-pdf.js +270 -0
- package/dist/gam/utils/export-report-xlsx.d.ts +228 -0
- package/dist/gam/utils/export-report-xlsx.js +873 -0
- package/dist/gam/utils/line-totals.d.ts +6 -0
- package/dist/gam/utils/line-totals.js +18 -0
- package/dist/gam/utils/monetary-input.d.ts +6 -0
- package/dist/gam/utils/monetary-input.js +18 -0
- package/dist/gam/utils/print-element.d.ts +8 -0
- package/dist/gam/utils/print-element.js +157 -0
- package/dist/government-form.d.ts +16 -0
- package/dist/government-form.js +45 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +50 -0
- package/dist/internal/components/configurable-form-layout.d.ts +20 -0
- package/dist/internal/components/configurable-form-layout.js +49 -0
- package/dist/internal/components/ui/badge.d.ts +7 -0
- package/dist/internal/components/ui/badge.js +34 -0
- package/dist/internal/components/ui/button.d.ts +10 -0
- package/dist/internal/components/ui/button.js +35 -0
- package/dist/internal/components/ui/calendar.d.ts +8 -0
- package/dist/internal/components/ui/calendar.js +77 -0
- package/dist/internal/components/ui/command.d.ts +19 -0
- package/dist/internal/components/ui/command.js +36 -0
- package/dist/internal/components/ui/date-input.d.ts +14 -0
- package/dist/internal/components/ui/date-input.js +33 -0
- package/dist/internal/components/ui/date-picker.d.ts +19 -0
- package/dist/internal/components/ui/date-picker.js +34 -0
- package/dist/internal/components/ui/dialog.d.ts +18 -0
- package/dist/internal/components/ui/dialog.js +38 -0
- package/dist/internal/components/ui/input-group.d.ts +18 -0
- package/dist/internal/components/ui/input-group.js +57 -0
- package/dist/internal/components/ui/input.d.ts +3 -0
- package/dist/internal/components/ui/input.js +12 -0
- package/dist/internal/components/ui/label.d.ts +3 -0
- package/dist/internal/components/ui/label.js +7 -0
- package/dist/internal/components/ui/popover.d.ts +9 -0
- package/dist/internal/components/ui/popover.js +23 -0
- package/dist/internal/components/ui/select.d.ts +17 -0
- package/dist/internal/components/ui/select.js +35 -0
- package/dist/internal/components/ui/switch.d.ts +5 -0
- package/dist/internal/components/ui/switch.js +8 -0
- package/dist/internal/components/ui/table.d.ts +10 -0
- package/dist/internal/components/ui/table.js +28 -0
- package/dist/internal/components/ui/tabs.d.ts +10 -0
- package/dist/internal/components/ui/tabs.js +29 -0
- package/dist/internal/components/ui/textarea.d.ts +3 -0
- package/dist/internal/components/ui/textarea.js +7 -0
- package/dist/internal/components/ui/tooltip.d.ts +6 -0
- package/dist/internal/components/ui/tooltip.js +17 -0
- package/dist/internal/contracts/modules/v1/reg-spi-reports/reg-spi-reports.schema.d.ts +112 -0
- package/dist/internal/contracts/modules/v1/reg-spi-reports/reg-spi-reports.schema.js +91 -0
- package/dist/internal/hooks/use-form-field-order.d.ts +7 -0
- package/dist/internal/hooks/use-form-field-order.js +43 -0
- package/dist/internal/lib/utils.d.ts +2 -0
- package/dist/internal/lib/utils.js +3 -0
- package/dist/inventory/components/inventory-item-form.d.ts +7 -0
- package/dist/inventory/components/inventory-item-form.js +5 -0
- package/dist/inventory/components/inventory-item-preview.d.ts +6 -0
- package/dist/inventory/components/inventory-item-preview.js +5 -0
- package/dist/inventory/iar.d.ts +4 -0
- package/dist/inventory/iar.js +4 -0
- package/dist/inventory/ics.d.ts +2 -0
- package/dist/inventory/ics.js +3 -0
- package/dist/inventory/iirup.d.ts +2 -0
- package/dist/inventory/iirup.js +3 -0
- package/dist/inventory/iirusp.d.ts +4 -0
- package/dist/inventory/iirusp.js +4 -0
- package/dist/inventory/index.d.ts +3 -0
- package/dist/inventory/index.js +4 -0
- package/dist/inventory/item.d.ts +3 -0
- package/dist/inventory/item.js +3 -0
- package/dist/inventory/itr.d.ts +4 -0
- package/dist/inventory/itr.js +4 -0
- package/dist/inventory/par.d.ts +2 -0
- package/dist/inventory/par.js +3 -0
- package/dist/inventory/po.d.ts +2 -0
- package/dist/inventory/po.js +2 -0
- package/dist/inventory/ppelc.d.ts +2 -0
- package/dist/inventory/ppelc.js +3 -0
- package/dist/inventory/pplc.d.ts +2 -0
- package/dist/inventory/pplc.js +4 -0
- package/dist/inventory/pr.d.ts +4 -0
- package/dist/inventory/pr.js +4 -0
- package/dist/inventory/property-card.d.ts +2 -0
- package/dist/inventory/property-card.js +3 -0
- package/dist/inventory/ptr.d.ts +2 -0
- package/dist/inventory/ptr.js +3 -0
- package/dist/inventory/regspi.d.ts +4 -0
- package/dist/inventory/regspi.js +4 -0
- package/dist/inventory/ris.d.ts +4 -0
- package/dist/inventory/ris.js +4 -0
- package/dist/inventory/rlsddp.d.ts +4 -0
- package/dist/inventory/rlsddp.js +4 -0
- package/dist/inventory/rlsddsp.d.ts +2 -0
- package/dist/inventory/rlsddsp.js +3 -0
- package/dist/inventory/rpci.d.ts +2 -0
- package/dist/inventory/rpci.js +3 -0
- package/dist/inventory/rpcppe.d.ts +2 -0
- package/dist/inventory/rpcppe.js +3 -0
- package/dist/inventory/rpcsp.d.ts +2 -0
- package/dist/inventory/rpcsp.js +3 -0
- package/dist/inventory/rrsp.d.ts +2 -0
- package/dist/inventory/rrsp.js +3 -0
- package/dist/inventory/rsmi.d.ts +4 -0
- package/dist/inventory/rsmi.js +4 -0
- package/dist/inventory/rsmp.d.ts +4 -0
- package/dist/inventory/rsmp.js +4 -0
- package/dist/inventory/rspi.d.ts +2 -0
- package/dist/inventory/rspi.js +3 -0
- package/dist/inventory/spc.d.ts +2 -0
- package/dist/inventory/spc.js +3 -0
- package/dist/inventory/splc.d.ts +3 -0
- package/dist/inventory/splc.js +4 -0
- package/dist/inventory/stock-card.d.ts +4 -0
- package/dist/inventory/stock-card.js +4 -0
- package/dist/inventory/types.d.ts +11 -0
- package/dist/inventory/types.js +1 -0
- package/dist/inventory/wmr.d.ts +4 -0
- package/dist/inventory/wmr.js +4 -0
- package/dist/lib/rpcsp-accountable-person.d.ts +1 -0
- package/dist/lib/rpcsp-accountable-person.js +10 -0
- package/dist/reports/iar/_components/create-form.d.ts +13 -0
- package/dist/reports/iar/_components/create-form.js +92 -0
- package/dist/reports/iar/_components/document-preview.d.ts +11 -0
- package/dist/reports/iar/_components/document-preview.js +131 -0
- package/dist/reports/iar/types.d.ts +97 -0
- package/dist/reports/iar/types.js +24 -0
- package/dist/reports/iirusp/_components/create-form.d.ts +17 -0
- package/dist/reports/iirusp/_components/create-form.js +118 -0
- package/dist/reports/iirusp/_components/document-preview.d.ts +8 -0
- package/dist/reports/iirusp/_components/document-preview.js +389 -0
- package/dist/reports/iirusp/types.d.ts +134 -0
- package/dist/reports/iirusp/types.js +29 -0
- package/dist/reports/iirusp/utils.d.ts +29 -0
- package/dist/reports/iirusp/utils.js +488 -0
- package/dist/reports/itr/_components/create-form.d.ts +28 -0
- package/dist/reports/itr/_components/create-form.js +90 -0
- package/dist/reports/itr/_components/document-preview.d.ts +6 -0
- package/dist/reports/itr/_components/document-preview.js +7 -0
- package/dist/reports/itr/types.d.ts +68 -0
- package/dist/reports/itr/types.js +27 -0
- package/dist/reports/itr/utils.d.ts +24 -0
- package/dist/reports/itr/utils.js +76 -0
- package/dist/reports/pr/_components/create-form.d.ts +16 -0
- package/dist/reports/pr/_components/create-form.js +52 -0
- package/dist/reports/pr/_components/document-preview.d.ts +7 -0
- package/dist/reports/pr/_components/document-preview.js +9 -0
- package/dist/reports/pr/types.d.ts +69 -0
- package/dist/reports/pr/types.js +1 -0
- package/dist/reports/pr/utils.d.ts +72 -0
- package/dist/reports/pr/utils.js +572 -0
- package/dist/reports/regspi/_components/create-form.d.ts +19 -0
- package/dist/reports/regspi/_components/create-form.js +33 -0
- package/dist/reports/regspi/_components/document-preview.d.ts +6 -0
- package/dist/reports/regspi/_components/document-preview.js +7 -0
- package/dist/reports/regspi/types.d.ts +29 -0
- package/dist/reports/regspi/types.js +24 -0
- package/dist/reports/regspi/utils.d.ts +48 -0
- package/dist/reports/regspi/utils.js +98 -0
- package/dist/reports/ris/_components/create-form.d.ts +36 -0
- package/dist/reports/ris/_components/create-form.js +149 -0
- package/dist/reports/ris/_components/document-preview.d.ts +8 -0
- package/dist/reports/ris/_components/document-preview.js +31 -0
- package/dist/reports/ris/types.d.ts +93 -0
- package/dist/reports/ris/types.js +1 -0
- package/dist/reports/rlsddp/_components/create-form.d.ts +11 -0
- package/dist/reports/rlsddp/_components/create-form.js +165 -0
- package/dist/reports/rlsddp/_components/document-preview.d.ts +8 -0
- package/dist/reports/rlsddp/_components/document-preview.js +15 -0
- package/dist/reports/rlsddp/types.d.ts +105 -0
- package/dist/reports/rlsddp/types.js +31 -0
- package/dist/reports/rrsp/components/rrsp-preview.d.ts +21 -0
- package/dist/reports/rrsp/components/rrsp-preview.js +155 -0
- package/dist/reports/rsmi/components/rsmi-create-form.d.ts +20 -0
- package/dist/reports/rsmi/components/rsmi-create-form.js +8 -0
- package/dist/reports/rsmi/components/rsmi-document-body.d.ts +15 -0
- package/dist/reports/rsmi/components/rsmi-document-body.js +12 -0
- package/dist/reports/rsmi/components/rsmi-types.d.ts +45 -0
- package/dist/reports/rsmi/components/rsmi-types.js +1 -0
- package/dist/reports/rsmi/components/rsmi-utils.d.ts +2 -0
- package/dist/reports/rsmi/components/rsmi-utils.js +18 -0
- package/dist/reports/rsmp/components/rsmp-create-modal.d.ts +5 -0
- package/dist/reports/rsmp/components/rsmp-create-modal.js +7 -0
- package/dist/reports/rsmp/components/rsmp-preview-modal.d.ts +11 -0
- package/dist/reports/rsmp/components/rsmp-preview-modal.js +47 -0
- package/dist/reports/rsmp/components/rsmp-types.d.ts +44 -0
- package/dist/reports/rsmp/components/rsmp-types.js +1 -0
- package/dist/reports/rsmp/components/rsmp-utils.d.ts +5 -0
- package/dist/reports/rsmp/components/rsmp-utils.js +41 -0
- package/dist/reports/rsmp/lib/rsmp-grouping.d.ts +14 -0
- package/dist/reports/rsmp/lib/rsmp-grouping.js +75 -0
- package/dist/reports/stock-card/_components/create-form.d.ts +13 -0
- package/dist/reports/stock-card/_components/create-form.js +39 -0
- package/dist/reports/stock-card/_components/document-preview.d.ts +7 -0
- package/dist/reports/stock-card/_components/document-preview.js +29 -0
- package/dist/reports/stock-card/types.d.ts +31 -0
- package/dist/reports/stock-card/types.js +1 -0
- package/dist/reports/stock-card/utils.d.ts +32 -0
- package/dist/reports/stock-card/utils.js +248 -0
- package/dist/reports/wmr/_components/create-form.d.ts +22 -0
- package/dist/reports/wmr/_components/create-form.js +61 -0
- package/dist/reports/wmr/_components/document-preview.d.ts +10 -0
- package/dist/reports/wmr/_components/document-preview.js +59 -0
- package/dist/reports/wmr/types.d.ts +45 -0
- package/dist/reports/wmr/types.js +1 -0
- package/dist/reports/wmr/utils.d.ts +32 -0
- package/dist/reports/wmr/utils.js +343 -0
- package/dist/styles.css +4492 -0
- package/extraction-manifest.json +620 -0
- package/package.json +197 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import html2canvas from "html2canvas";
|
|
3
|
+
import jsPDF from "jspdf";
|
|
4
|
+
import { createRoot } from "react-dom/client";
|
|
5
|
+
const PDF_PAGE_SELECTOR = [
|
|
6
|
+
'[data-pdf-page="true"]',
|
|
7
|
+
".iar-a4-page",
|
|
8
|
+
".itr-a4-page",
|
|
9
|
+
".regspi-a4-page",
|
|
10
|
+
".splc-a4-page",
|
|
11
|
+
".spc-a4-page",
|
|
12
|
+
].join(", ");
|
|
13
|
+
const UNSUPPORTED_COLOR_FUNCTION_RE = /(oklch|lab|lch)\s*\(/i;
|
|
14
|
+
const UNSUPPORTED_COLOR_VALUE_RE = /(oklch|lab|lch)\s*\([^)]+\)/gi;
|
|
15
|
+
const COLOR_STYLE_PROPERTIES = [
|
|
16
|
+
"color",
|
|
17
|
+
"background-color",
|
|
18
|
+
"border-top-color",
|
|
19
|
+
"border-right-color",
|
|
20
|
+
"border-bottom-color",
|
|
21
|
+
"border-left-color",
|
|
22
|
+
"outline-color",
|
|
23
|
+
"text-decoration-color",
|
|
24
|
+
"column-rule-color",
|
|
25
|
+
"caret-color",
|
|
26
|
+
"fill",
|
|
27
|
+
"stroke",
|
|
28
|
+
"stop-color",
|
|
29
|
+
"flood-color",
|
|
30
|
+
"lighting-color",
|
|
31
|
+
"box-shadow",
|
|
32
|
+
"text-shadow",
|
|
33
|
+
];
|
|
34
|
+
function resolvePdfPage(root) {
|
|
35
|
+
if (root.matches(PDF_PAGE_SELECTOR))
|
|
36
|
+
return root;
|
|
37
|
+
return root.querySelector(PDF_PAGE_SELECTOR) ?? root;
|
|
38
|
+
}
|
|
39
|
+
export function resolvePdfOrientation(configured, width, height) {
|
|
40
|
+
if (configured === "portrait" || configured === "landscape")
|
|
41
|
+
return configured;
|
|
42
|
+
return width > height ? "landscape" : "portrait";
|
|
43
|
+
}
|
|
44
|
+
function resolveOrientation(page) {
|
|
45
|
+
const rect = page.getBoundingClientRect();
|
|
46
|
+
return resolvePdfOrientation(page.dataset.pdfOrientation, rect.width, rect.height);
|
|
47
|
+
}
|
|
48
|
+
function waitForPaint() {
|
|
49
|
+
return new Promise(resolve => {
|
|
50
|
+
requestAnimationFrame(() => {
|
|
51
|
+
requestAnimationFrame(() => resolve());
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function createUnsupportedColorNormalizer() {
|
|
56
|
+
const resolveCanvas = document.createElement("canvas");
|
|
57
|
+
resolveCanvas.width = resolveCanvas.height = 1;
|
|
58
|
+
const ctx = resolveCanvas.getContext("2d", { willReadFrequently: true });
|
|
59
|
+
if (!ctx)
|
|
60
|
+
return null;
|
|
61
|
+
return (value) => {
|
|
62
|
+
if (!UNSUPPORTED_COLOR_FUNCTION_RE.test(value))
|
|
63
|
+
return value;
|
|
64
|
+
return value.replace(UNSUPPORTED_COLOR_VALUE_RE, match => {
|
|
65
|
+
try {
|
|
66
|
+
ctx.clearRect(0, 0, 1, 1);
|
|
67
|
+
ctx.fillStyle = match;
|
|
68
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
69
|
+
const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
|
|
70
|
+
return `rgb(${r},${g},${b})`;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return match;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function sanitizeUnsupportedColorFunctions(clonedDocument, normalizeColorValue) {
|
|
79
|
+
if (!normalizeColorValue)
|
|
80
|
+
return;
|
|
81
|
+
const styleEls = clonedDocument.querySelectorAll("style");
|
|
82
|
+
for (const el of styleEls) {
|
|
83
|
+
const text = el.textContent;
|
|
84
|
+
if (!text || !UNSUPPORTED_COLOR_FUNCTION_RE.test(text))
|
|
85
|
+
continue;
|
|
86
|
+
el.textContent = normalizeColorValue(text);
|
|
87
|
+
}
|
|
88
|
+
const view = clonedDocument.defaultView;
|
|
89
|
+
if (!view)
|
|
90
|
+
return;
|
|
91
|
+
const root = clonedDocument.querySelector(PDF_PAGE_SELECTOR) ?? clonedDocument.body;
|
|
92
|
+
const elements = [root, ...Array.from(root.querySelectorAll("*"))];
|
|
93
|
+
for (const element of elements) {
|
|
94
|
+
const computedStyle = view.getComputedStyle(element);
|
|
95
|
+
for (const property of COLOR_STYLE_PROPERTIES) {
|
|
96
|
+
const value = computedStyle.getPropertyValue(property);
|
|
97
|
+
if (!value || !UNSUPPORTED_COLOR_FUNCTION_RE.test(value))
|
|
98
|
+
continue;
|
|
99
|
+
element.style.setProperty(property, normalizeColorValue(value), "important");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export function createDownloadablePdfBlob(pdf) {
|
|
104
|
+
const blob = pdf.output("blob");
|
|
105
|
+
if (blob.type === "application/pdf")
|
|
106
|
+
return blob;
|
|
107
|
+
return new Blob([blob], { type: "application/pdf" });
|
|
108
|
+
}
|
|
109
|
+
function downloadPdfBlob(blob, filename) {
|
|
110
|
+
const url = URL.createObjectURL(blob);
|
|
111
|
+
const anchor = document.createElement("a");
|
|
112
|
+
anchor.href = url;
|
|
113
|
+
anchor.download = filename;
|
|
114
|
+
anchor.rel = "noopener";
|
|
115
|
+
document.body.appendChild(anchor);
|
|
116
|
+
anchor.click();
|
|
117
|
+
anchor.remove();
|
|
118
|
+
window.setTimeout(() => URL.revokeObjectURL(url), 60_000);
|
|
119
|
+
}
|
|
120
|
+
export async function renderPreviewToCanvas(root) {
|
|
121
|
+
// Use final font metrics for both the modal and detached React export paths.
|
|
122
|
+
await document.fonts?.ready;
|
|
123
|
+
const page = resolvePdfPage(root);
|
|
124
|
+
const orientation = resolveOrientation(page);
|
|
125
|
+
const fitOnePage = page.dataset.pdfFitOnePage === "true";
|
|
126
|
+
const pageRect = page.getBoundingClientRect();
|
|
127
|
+
// Capture against the document's own page size, rather than the application
|
|
128
|
+
// viewport. A wider viewport changes the layout of fixed-table documents in
|
|
129
|
+
// html2canvas's cloned iframe and can crop wrapped table text.
|
|
130
|
+
const pageWidth = Math.ceil(Math.max(pageRect.width, page.scrollWidth));
|
|
131
|
+
const pageHeight = Math.ceil(Math.max(pageRect.height, page.scrollHeight));
|
|
132
|
+
const canvas = await html2canvas(page, {
|
|
133
|
+
backgroundColor: "#fff",
|
|
134
|
+
scale: Math.min(Math.max(window.devicePixelRatio || 2, 2), 3),
|
|
135
|
+
useCORS: true,
|
|
136
|
+
scrollX: 0,
|
|
137
|
+
scrollY: -window.scrollY,
|
|
138
|
+
width: pageWidth,
|
|
139
|
+
height: pageHeight,
|
|
140
|
+
windowWidth: pageWidth,
|
|
141
|
+
windowHeight: pageHeight,
|
|
142
|
+
onclone: (clonedDocument, clonedPage) => {
|
|
143
|
+
// Preview ancestors carry screen-only scaling and clipping. Remove those
|
|
144
|
+
// from the capture so text and borders use the same natural coordinates.
|
|
145
|
+
let ancestor = clonedPage;
|
|
146
|
+
while (ancestor) {
|
|
147
|
+
ancestor.style.setProperty("transform", "none", "important");
|
|
148
|
+
ancestor.style.setProperty("zoom", "1", "important");
|
|
149
|
+
ancestor.style.setProperty("overflow", "visible", "important");
|
|
150
|
+
ancestor = ancestor.parentElement;
|
|
151
|
+
}
|
|
152
|
+
// html2canvas 1.4.1 can't parse lab()/oklch()/lch() — Tailwind v4 uses them
|
|
153
|
+
// inside generated stylesheets. Resolve them to rgb() in the clone before
|
|
154
|
+
// html2canvas reads computed styles.
|
|
155
|
+
sanitizeUnsupportedColorFunctions(clonedDocument, createUnsupportedColorNormalizer());
|
|
156
|
+
// ICS uses the page itself as its white paper background. Clear every
|
|
157
|
+
// structural table fill in the capture clone so html2canvas cannot paint
|
|
158
|
+
// an opaque header or cell layer over labels and values. Both PDF export
|
|
159
|
+
// and printing use this capture path.
|
|
160
|
+
const clonedIcsPage = clonedPage.matches('[data-ics-preview="true"]')
|
|
161
|
+
? clonedPage
|
|
162
|
+
: clonedPage.querySelector('[data-ics-preview="true"]');
|
|
163
|
+
if (clonedIcsPage) {
|
|
164
|
+
const tableLayers = clonedIcsPage.querySelectorAll("table, thead, tbody, tr, th, td");
|
|
165
|
+
for (const layer of tableLayers) {
|
|
166
|
+
layer.style.setProperty("background", "transparent", "important");
|
|
167
|
+
layer.style.setProperty("background-color", "transparent", "important");
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const style = clonedDocument.createElement("style");
|
|
171
|
+
style.textContent = `
|
|
172
|
+
html, body {
|
|
173
|
+
background: #fff !important;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.no-print {
|
|
177
|
+
display: none !important;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
${PDF_PAGE_SELECTOR} {
|
|
181
|
+
box-shadow: none !important;
|
|
182
|
+
margin: 0 !important;
|
|
183
|
+
transform: none !important;
|
|
184
|
+
}
|
|
185
|
+
`;
|
|
186
|
+
clonedDocument.head.appendChild(style);
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
return { canvas, orientation, fitOnePage };
|
|
190
|
+
}
|
|
191
|
+
export async function exportPreviewElementToPdf(root, filename) {
|
|
192
|
+
const pages = Array.from(root.querySelectorAll(PDF_PAGE_SELECTOR));
|
|
193
|
+
if (pages.length > 1) {
|
|
194
|
+
const pdf = new jsPDF({
|
|
195
|
+
orientation: resolveOrientation(pages[0]),
|
|
196
|
+
unit: "mm",
|
|
197
|
+
format: "a4",
|
|
198
|
+
compress: true,
|
|
199
|
+
});
|
|
200
|
+
for (const [index, page] of pages.entries()) {
|
|
201
|
+
const { canvas, orientation } = await renderPreviewToCanvas(page);
|
|
202
|
+
if (index > 0)
|
|
203
|
+
pdf.addPage("a4", orientation);
|
|
204
|
+
const pageWidth = pdf.internal.pageSize.getWidth();
|
|
205
|
+
const pageHeight = pdf.internal.pageSize.getHeight();
|
|
206
|
+
const scale = Math.min(pageWidth / canvas.width, pageHeight / canvas.height);
|
|
207
|
+
pdf.addImage(canvas.toDataURL("image/png"), "PNG", 0, 0, canvas.width * scale, canvas.height * scale);
|
|
208
|
+
}
|
|
209
|
+
downloadPdfBlob(createDownloadablePdfBlob(pdf), filename);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const { canvas, orientation, fitOnePage } = await renderPreviewToCanvas(root);
|
|
213
|
+
const pdf = new jsPDF({ orientation, unit: "mm", format: "a4", compress: true });
|
|
214
|
+
const pageWidth = pdf.internal.pageSize.getWidth();
|
|
215
|
+
const pageHeight = pdf.internal.pageSize.getHeight();
|
|
216
|
+
if (fitOnePage) {
|
|
217
|
+
const scale = Math.min(pageWidth / canvas.width, pageHeight / canvas.height);
|
|
218
|
+
const imageWidth = canvas.width * scale;
|
|
219
|
+
const imageHeight = canvas.height * scale;
|
|
220
|
+
const offsetX = (pageWidth - imageWidth) / 2;
|
|
221
|
+
const offsetY = (pageHeight - imageHeight) / 2;
|
|
222
|
+
pdf.addImage(canvas.toDataURL("image/png"), "PNG", offsetX, offsetY, imageWidth, imageHeight);
|
|
223
|
+
downloadPdfBlob(createDownloadablePdfBlob(pdf), filename);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
// Scale the preview by its width, then slice it at A4-height intervals.
|
|
227
|
+
// Fitting the entire canvas into one sheet changed the scale of long forms
|
|
228
|
+
// (such as Purchase Orders) and produced different spacing and page breaks
|
|
229
|
+
// from the on-screen preview.
|
|
230
|
+
const sourcePageHeight = (canvas.width * pageHeight) / pageWidth;
|
|
231
|
+
const pageCount = Math.ceil(canvas.height / sourcePageHeight);
|
|
232
|
+
for (let pageIndex = 0; pageIndex < pageCount; pageIndex += 1) {
|
|
233
|
+
const sourceY = pageIndex * sourcePageHeight;
|
|
234
|
+
const sourceHeight = Math.min(sourcePageHeight, canvas.height - sourceY);
|
|
235
|
+
const pageCanvas = document.createElement("canvas");
|
|
236
|
+
pageCanvas.width = canvas.width;
|
|
237
|
+
pageCanvas.height = Math.ceil(sourceHeight);
|
|
238
|
+
const context = pageCanvas.getContext("2d");
|
|
239
|
+
if (!context)
|
|
240
|
+
throw new Error("Unable to create the PDF page canvas.");
|
|
241
|
+
context.fillStyle = "#fff";
|
|
242
|
+
context.fillRect(0, 0, pageCanvas.width, pageCanvas.height);
|
|
243
|
+
context.drawImage(canvas, 0, sourceY, canvas.width, sourceHeight, 0, 0, pageCanvas.width, sourceHeight);
|
|
244
|
+
if (pageIndex > 0)
|
|
245
|
+
pdf.addPage();
|
|
246
|
+
const imageHeight = (sourceHeight * pageWidth) / canvas.width;
|
|
247
|
+
pdf.addImage(pageCanvas.toDataURL("image/png"), "PNG", 0, 0, pageWidth, imageHeight);
|
|
248
|
+
}
|
|
249
|
+
downloadPdfBlob(createDownloadablePdfBlob(pdf), filename);
|
|
250
|
+
}
|
|
251
|
+
export async function exportPreviewReactToPdf(content, filename) {
|
|
252
|
+
const container = document.createElement("div");
|
|
253
|
+
container.style.position = "fixed";
|
|
254
|
+
container.style.left = "-10000px";
|
|
255
|
+
container.style.top = "0";
|
|
256
|
+
container.style.width = "max-content";
|
|
257
|
+
container.style.background = "#fff";
|
|
258
|
+
container.style.zIndex = "-1";
|
|
259
|
+
document.body.appendChild(container);
|
|
260
|
+
const root = createRoot(container);
|
|
261
|
+
try {
|
|
262
|
+
root.render(content);
|
|
263
|
+
await waitForPaint();
|
|
264
|
+
await exportPreviewElementToPdf(container, filename);
|
|
265
|
+
}
|
|
266
|
+
finally {
|
|
267
|
+
root.unmount();
|
|
268
|
+
container.remove();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
export type IarPreviewXlsxItem = {
|
|
2
|
+
stockNo?: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
unit?: string;
|
|
5
|
+
quantity?: string;
|
|
6
|
+
unitCost?: string;
|
|
7
|
+
totalAmount?: string;
|
|
8
|
+
};
|
|
9
|
+
export type IarPreviewXlsxData = {
|
|
10
|
+
entityName?: string;
|
|
11
|
+
fundCluster?: string;
|
|
12
|
+
supplier?: string;
|
|
13
|
+
iarNo?: string;
|
|
14
|
+
iarDate?: string | null;
|
|
15
|
+
crsiNo?: string | null;
|
|
16
|
+
crsiDate?: string | null;
|
|
17
|
+
requestingOffice?: string;
|
|
18
|
+
responsibilityCenterCode?: string;
|
|
19
|
+
items: IarPreviewXlsxItem[];
|
|
20
|
+
dateInspected?: string | null;
|
|
21
|
+
dateReceived?: string | null;
|
|
22
|
+
isComplete?: boolean;
|
|
23
|
+
inspectionOfficer?: string;
|
|
24
|
+
supplyCustodian?: string;
|
|
25
|
+
};
|
|
26
|
+
export type ItrPreviewXlsxItem = {
|
|
27
|
+
dateAcquired?: string;
|
|
28
|
+
itemNo?: string;
|
|
29
|
+
propertyNo?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
amount?: string;
|
|
32
|
+
conditionOfInventory?: string;
|
|
33
|
+
conditionOfPPE?: string;
|
|
34
|
+
};
|
|
35
|
+
export type ItrPreviewXlsxData = {
|
|
36
|
+
entityName?: string;
|
|
37
|
+
fundCluster?: string;
|
|
38
|
+
fromAccountableOfficer?: string;
|
|
39
|
+
fromAccountablePerson?: string;
|
|
40
|
+
fromDivisionSection?: string;
|
|
41
|
+
toAccountableOfficer?: string;
|
|
42
|
+
toAccountablePerson?: string;
|
|
43
|
+
toDivisionSection?: string;
|
|
44
|
+
itrNo?: string;
|
|
45
|
+
transferDate?: string;
|
|
46
|
+
transferType?: "Donation" | "Reassignment" | "Relocate" | "Others" | string;
|
|
47
|
+
transferTypeOthers?: string;
|
|
48
|
+
reason?: string;
|
|
49
|
+
reasonForTransfer?: string;
|
|
50
|
+
approvedBy?: string;
|
|
51
|
+
releasedIssuedBy?: string;
|
|
52
|
+
receivedBy?: string;
|
|
53
|
+
items: ItrPreviewXlsxItem[];
|
|
54
|
+
};
|
|
55
|
+
export type IirupPreviewXlsxData = {
|
|
56
|
+
iirupNo?: string;
|
|
57
|
+
date?: string;
|
|
58
|
+
entityName?: string;
|
|
59
|
+
fundCluster?: string;
|
|
60
|
+
nameOfAccountableOfficer?: string;
|
|
61
|
+
designation?: string;
|
|
62
|
+
station?: string;
|
|
63
|
+
accountableOfficerSignatory?: string;
|
|
64
|
+
authorizedOfficialSignatory?: string;
|
|
65
|
+
inspectionOfficerSignatory?: string;
|
|
66
|
+
witnessSignatory?: string;
|
|
67
|
+
items: Array<{
|
|
68
|
+
dateAcquired?: string;
|
|
69
|
+
particularsArticles?: string;
|
|
70
|
+
propertyNo?: string;
|
|
71
|
+
qty?: string;
|
|
72
|
+
unitCost?: string;
|
|
73
|
+
totalCost?: string;
|
|
74
|
+
accumulatedDepreciation?: string;
|
|
75
|
+
accumulatedImpairmentLosses?: string;
|
|
76
|
+
carryingAmount?: string;
|
|
77
|
+
remarks?: string;
|
|
78
|
+
sale?: string;
|
|
79
|
+
transfer?: string;
|
|
80
|
+
destruction?: string;
|
|
81
|
+
othersSpecify?: string;
|
|
82
|
+
total?: string;
|
|
83
|
+
appraisedValue?: string;
|
|
84
|
+
orNo?: string;
|
|
85
|
+
amount?: string;
|
|
86
|
+
}>;
|
|
87
|
+
};
|
|
88
|
+
export type RegSpiPreviewXlsxEntry = {
|
|
89
|
+
entryDate?: string;
|
|
90
|
+
reference?: string;
|
|
91
|
+
iicRrspNo?: string;
|
|
92
|
+
semiExpendablePropertyNo?: string;
|
|
93
|
+
itemDescription?: string;
|
|
94
|
+
estimatedUsefulLife?: string;
|
|
95
|
+
issuedQty?: string;
|
|
96
|
+
issuedOfficeOfficer?: string;
|
|
97
|
+
returnedQty?: string;
|
|
98
|
+
returnedOfficeOfficer?: string;
|
|
99
|
+
reissuedQty?: string;
|
|
100
|
+
reissuedOfficeOfficer?: string;
|
|
101
|
+
disposedQty?: string;
|
|
102
|
+
balance?: string;
|
|
103
|
+
amount?: string;
|
|
104
|
+
remarks?: string;
|
|
105
|
+
};
|
|
106
|
+
export type RegSpiPreviewXlsxData = {
|
|
107
|
+
entityName?: string;
|
|
108
|
+
semiExpendableProperty?: string;
|
|
109
|
+
fundCluster?: string;
|
|
110
|
+
sheetNumber?: string;
|
|
111
|
+
regSpiNo?: string;
|
|
112
|
+
entries: RegSpiPreviewXlsxEntry[];
|
|
113
|
+
};
|
|
114
|
+
export type SplcPreviewXlsxEntry = {
|
|
115
|
+
entryDate?: string;
|
|
116
|
+
reference?: string;
|
|
117
|
+
receiptQty?: string;
|
|
118
|
+
unitCost?: string;
|
|
119
|
+
totalCost?: string;
|
|
120
|
+
issuesTransfersAdjustments?: string;
|
|
121
|
+
accumulatedImpairmentLosses?: string;
|
|
122
|
+
adjustedCost?: string;
|
|
123
|
+
natureOfRepair?: string;
|
|
124
|
+
amount?: string;
|
|
125
|
+
};
|
|
126
|
+
export type SplcPreviewXlsxData = {
|
|
127
|
+
entityName?: string;
|
|
128
|
+
fundCluster?: string;
|
|
129
|
+
semiExpendableProperty?: string;
|
|
130
|
+
semiExpendablePropertyNumber?: string;
|
|
131
|
+
description?: string;
|
|
132
|
+
uacsObjectCode?: string;
|
|
133
|
+
repairHistory?: string;
|
|
134
|
+
entries: SplcPreviewXlsxEntry[];
|
|
135
|
+
};
|
|
136
|
+
export type SpcPreviewXlsxEntry = {
|
|
137
|
+
entryDate?: string;
|
|
138
|
+
reference?: string;
|
|
139
|
+
receiptQty?: string;
|
|
140
|
+
receiptUnitCost?: string;
|
|
141
|
+
receiptTotalCost?: string;
|
|
142
|
+
itemNo?: string;
|
|
143
|
+
issueTransferDisposalQty?: string;
|
|
144
|
+
issueTransferDisposalOfficeOfficer?: string;
|
|
145
|
+
balanceQty?: string;
|
|
146
|
+
amount?: string;
|
|
147
|
+
remarks?: string;
|
|
148
|
+
};
|
|
149
|
+
export type SpcPreviewXlsxData = {
|
|
150
|
+
entityName?: string;
|
|
151
|
+
fundCluster?: string;
|
|
152
|
+
semiExpendableProperty?: string;
|
|
153
|
+
semiExpendablePropertyNumber?: string;
|
|
154
|
+
description?: string;
|
|
155
|
+
entries: SpcPreviewXlsxEntry[];
|
|
156
|
+
};
|
|
157
|
+
export type RlsddpPreviewXlsxData = {
|
|
158
|
+
rlsddpNo?: string;
|
|
159
|
+
entityName?: string;
|
|
160
|
+
fundCluster?: string;
|
|
161
|
+
departmentOffice?: string;
|
|
162
|
+
accountableOfficer?: string;
|
|
163
|
+
designation?: string;
|
|
164
|
+
policeNotified?: string;
|
|
165
|
+
policeStation?: string;
|
|
166
|
+
policeNotifiedDate?: string;
|
|
167
|
+
rlsddpDate?: string;
|
|
168
|
+
parNo?: string;
|
|
169
|
+
parDate?: string;
|
|
170
|
+
statusOfProperty?: string;
|
|
171
|
+
propertyNo?: string;
|
|
172
|
+
description?: string;
|
|
173
|
+
acquisitionCost?: string;
|
|
174
|
+
circumstance?: string;
|
|
175
|
+
accountableOfficerSignature?: string;
|
|
176
|
+
accountableOfficerDate?: string;
|
|
177
|
+
governmentIssuedId?: string;
|
|
178
|
+
idNo?: string;
|
|
179
|
+
dateIssued?: string;
|
|
180
|
+
immediateSupervisorSignature?: string;
|
|
181
|
+
immediateSupervisorDate?: string;
|
|
182
|
+
swornDate?: string;
|
|
183
|
+
docNo?: string;
|
|
184
|
+
pageNo?: string;
|
|
185
|
+
bookNo?: string;
|
|
186
|
+
seriesOf?: string;
|
|
187
|
+
notaryPublic?: string;
|
|
188
|
+
};
|
|
189
|
+
export type RlsddspPreviewXlsxData = {
|
|
190
|
+
rlsddspNo?: string;
|
|
191
|
+
entityName?: string;
|
|
192
|
+
fundCluster?: string;
|
|
193
|
+
departmentOffice?: string;
|
|
194
|
+
accountableOfficer?: string;
|
|
195
|
+
designation?: string;
|
|
196
|
+
policeNotified?: string;
|
|
197
|
+
policeStation?: string;
|
|
198
|
+
policeNotifiedDate?: string;
|
|
199
|
+
rlsddspDate?: string;
|
|
200
|
+
icsNo?: string;
|
|
201
|
+
icsDate?: string;
|
|
202
|
+
statusOfProperty?: string;
|
|
203
|
+
propertyNo?: string;
|
|
204
|
+
description?: string;
|
|
205
|
+
acquisitionCost?: string;
|
|
206
|
+
circumstances?: string;
|
|
207
|
+
accountableOfficerSignature?: string;
|
|
208
|
+
accountableOfficerDate?: string;
|
|
209
|
+
governmentIssuedId?: string;
|
|
210
|
+
idNo?: string;
|
|
211
|
+
idDateIssued?: string;
|
|
212
|
+
immediateSupervisorSignature?: string;
|
|
213
|
+
immediateSupervisorDate?: string;
|
|
214
|
+
swornDate?: string;
|
|
215
|
+
docNo?: string;
|
|
216
|
+
pageNo?: string;
|
|
217
|
+
bookNo?: string;
|
|
218
|
+
seriesOf?: string;
|
|
219
|
+
notaryPublic?: string;
|
|
220
|
+
};
|
|
221
|
+
export declare function exportIarPreviewXlsx(data: IarPreviewXlsxData, filename?: string): void;
|
|
222
|
+
export declare function exportItrPreviewXlsx(data: ItrPreviewXlsxData, filename?: string): void;
|
|
223
|
+
export declare function exportRegSpiPreviewXlsx(data: RegSpiPreviewXlsxData, filename?: string): void;
|
|
224
|
+
export declare function exportSplcPreviewXlsx(data: SplcPreviewXlsxData, filename?: string): void;
|
|
225
|
+
export declare function exportSpcPreviewXlsx(data: SpcPreviewXlsxData, filename?: string): void;
|
|
226
|
+
export declare function exportRlsddpPreviewXlsx(data: RlsddpPreviewXlsxData, filename?: string): void;
|
|
227
|
+
export declare function exportRlsddspPreviewXlsx(data: RlsddspPreviewXlsxData, filename?: string): void;
|
|
228
|
+
export declare function exportIirupPreviewXlsx(data: IirupPreviewXlsxData, filename?: string): void;
|