@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.
Files changed (325) hide show
  1. package/FORM_CATALOG.md +44 -0
  2. package/README.md +165 -0
  3. package/dist/definitions.d.ts +1147 -0
  4. package/dist/definitions.js +60 -0
  5. package/dist/forms/iar.d.ts +172 -0
  6. package/dist/forms/iar.js +6 -0
  7. package/dist/forms/ics.d.ts +48 -0
  8. package/dist/forms/ics.js +6 -0
  9. package/dist/forms/iirup.d.ts +54 -0
  10. package/dist/forms/iirup.js +6 -0
  11. package/dist/forms/iirusp.d.ts +32 -0
  12. package/dist/forms/iirusp.js +6 -0
  13. package/dist/forms/itr.d.ts +42 -0
  14. package/dist/forms/itr.js +6 -0
  15. package/dist/forms/par.d.ts +84 -0
  16. package/dist/forms/par.js +6 -0
  17. package/dist/forms/ppelc.d.ts +34 -0
  18. package/dist/forms/ppelc.js +6 -0
  19. package/dist/forms/pr.d.ts +27 -0
  20. package/dist/forms/pr.js +6 -0
  21. package/dist/forms/property-card.d.ts +68 -0
  22. package/dist/forms/property-card.js +6 -0
  23. package/dist/forms/ptr.d.ts +54 -0
  24. package/dist/forms/ptr.js +6 -0
  25. package/dist/forms/regspi.d.ts +32 -0
  26. package/dist/forms/regspi.js +6 -0
  27. package/dist/forms/ris.d.ts +66 -0
  28. package/dist/forms/ris.js +6 -0
  29. package/dist/forms/rlsddp.d.ts +54 -0
  30. package/dist/forms/rlsddp.js +6 -0
  31. package/dist/forms/rlsddsp.d.ts +42 -0
  32. package/dist/forms/rlsddsp.js +6 -0
  33. package/dist/forms/rpci.d.ts +32 -0
  34. package/dist/forms/rpci.js +6 -0
  35. package/dist/forms/rpcppe.d.ts +32 -0
  36. package/dist/forms/rpcppe.js +6 -0
  37. package/dist/forms/rpcsp.d.ts +32 -0
  38. package/dist/forms/rpcsp.js +6 -0
  39. package/dist/forms/rrsp.d.ts +32 -0
  40. package/dist/forms/rrsp.js +6 -0
  41. package/dist/forms/rsmi.d.ts +32 -0
  42. package/dist/forms/rsmi.js +6 -0
  43. package/dist/forms/rsmp.d.ts +33 -0
  44. package/dist/forms/rsmp.js +6 -0
  45. package/dist/forms/rspi.d.ts +32 -0
  46. package/dist/forms/rspi.js +6 -0
  47. package/dist/forms/spc.d.ts +37 -0
  48. package/dist/forms/spc.js +6 -0
  49. package/dist/forms/splc.d.ts +41 -0
  50. package/dist/forms/splc.js +6 -0
  51. package/dist/forms/stock-card.d.ts +28 -0
  52. package/dist/forms/stock-card.js +6 -0
  53. package/dist/forms/wmr.d.ts +32 -0
  54. package/dist/forms/wmr.js +6 -0
  55. package/dist/gam/components/gam-report-workbench.d.ts +40 -0
  56. package/dist/gam/components/gam-report-workbench.js +2 -0
  57. package/dist/gam/components/grand-total-computation.d.ts +10 -0
  58. package/dist/gam/components/grand-total-computation.js +26 -0
  59. package/dist/gam/components/iar-preview.d.ts +30 -0
  60. package/dist/gam/components/iar-preview.js +150 -0
  61. package/dist/gam/components/ics-preview.d.ts +31 -0
  62. package/dist/gam/components/ics-preview.js +114 -0
  63. package/dist/gam/components/iirup-preview.d.ts +42 -0
  64. package/dist/gam/components/iirup-preview.js +237 -0
  65. package/dist/gam/components/itr-preview.d.ts +31 -0
  66. package/dist/gam/components/itr-preview.js +180 -0
  67. package/dist/gam/components/par-preview.d.ts +28 -0
  68. package/dist/gam/components/par-preview.js +95 -0
  69. package/dist/gam/components/ppelc-preview.d.ts +28 -0
  70. package/dist/gam/components/ppelc-preview.js +128 -0
  71. package/dist/gam/components/property-card-preview.d.ts +21 -0
  72. package/dist/gam/components/property-card-preview.js +117 -0
  73. package/dist/gam/components/ptr-preview.d.ts +36 -0
  74. package/dist/gam/components/ptr-preview.js +122 -0
  75. package/dist/gam/components/purchase-order-page-client.d.ts +66 -0
  76. package/dist/gam/components/purchase-order-page-client.js +179 -0
  77. package/dist/gam/components/reg-spi-preview.d.ts +28 -0
  78. package/dist/gam/components/reg-spi-preview.js +138 -0
  79. package/dist/gam/components/ris-form.d.ts +13 -0
  80. package/dist/gam/components/ris-form.js +20 -0
  81. package/dist/gam/components/ris-preview.d.ts +7 -0
  82. package/dist/gam/components/ris-preview.js +16 -0
  83. package/dist/gam/components/rlsddp-preview.d.ts +34 -0
  84. package/dist/gam/components/rlsddp-preview.js +251 -0
  85. package/dist/gam/components/rlsddsp-preview.d.ts +33 -0
  86. package/dist/gam/components/rlsddsp-preview.js +226 -0
  87. package/dist/gam/components/rpci-preview.d.ts +27 -0
  88. package/dist/gam/components/rpci-preview.js +123 -0
  89. package/dist/gam/components/rpcppe-preview.d.ts +28 -0
  90. package/dist/gam/components/rpcppe-preview.js +133 -0
  91. package/dist/gam/components/rpcsp-preview.d.ts +29 -0
  92. package/dist/gam/components/rpcsp-preview.js +81 -0
  93. package/dist/gam/components/rspi-preview.d.ts +23 -0
  94. package/dist/gam/components/rspi-preview.js +72 -0
  95. package/dist/gam/components/spc-preview.d.ts +23 -0
  96. package/dist/gam/components/spc-preview.js +149 -0
  97. package/dist/gam/components/splc-entry-form.d.ts +14 -0
  98. package/dist/gam/components/splc-entry-form.js +6 -0
  99. package/dist/gam/components/splc-preview.d.ts +27 -0
  100. package/dist/gam/components/splc-preview.js +192 -0
  101. package/dist/gam/components/stock-card-preview.d.ts +14 -0
  102. package/dist/gam/components/stock-card-preview.js +17 -0
  103. package/dist/gam/config/new-report-config.d.ts +1094 -0
  104. package/dist/gam/config/new-report-config.js +1478 -0
  105. package/dist/gam/purchase-order-flow.d.ts +146 -0
  106. package/dist/gam/purchase-order-flow.js +173 -0
  107. package/dist/gam/purchase-request/workflow.d.ts +19 -0
  108. package/dist/gam/purchase-request/workflow.js +45 -0
  109. package/dist/gam/types/ris-types.d.ts +37 -0
  110. package/dist/gam/types/ris-types.js +1 -0
  111. package/dist/gam/utils/export-ics-xlsx.d.ts +28 -0
  112. package/dist/gam/utils/export-ics-xlsx.js +273 -0
  113. package/dist/gam/utils/export-par-xlsx.d.ts +18 -0
  114. package/dist/gam/utils/export-par-xlsx.js +181 -0
  115. package/dist/gam/utils/export-preview-pdf.d.ts +13 -0
  116. package/dist/gam/utils/export-preview-pdf.js +270 -0
  117. package/dist/gam/utils/export-report-xlsx.d.ts +228 -0
  118. package/dist/gam/utils/export-report-xlsx.js +873 -0
  119. package/dist/gam/utils/line-totals.d.ts +6 -0
  120. package/dist/gam/utils/line-totals.js +18 -0
  121. package/dist/gam/utils/monetary-input.d.ts +6 -0
  122. package/dist/gam/utils/monetary-input.js +18 -0
  123. package/dist/gam/utils/print-element.d.ts +8 -0
  124. package/dist/gam/utils/print-element.js +157 -0
  125. package/dist/government-form.d.ts +16 -0
  126. package/dist/government-form.js +45 -0
  127. package/dist/index.d.ts +49 -0
  128. package/dist/index.js +50 -0
  129. package/dist/internal/components/configurable-form-layout.d.ts +20 -0
  130. package/dist/internal/components/configurable-form-layout.js +49 -0
  131. package/dist/internal/components/ui/badge.d.ts +7 -0
  132. package/dist/internal/components/ui/badge.js +34 -0
  133. package/dist/internal/components/ui/button.d.ts +10 -0
  134. package/dist/internal/components/ui/button.js +35 -0
  135. package/dist/internal/components/ui/calendar.d.ts +8 -0
  136. package/dist/internal/components/ui/calendar.js +77 -0
  137. package/dist/internal/components/ui/command.d.ts +19 -0
  138. package/dist/internal/components/ui/command.js +36 -0
  139. package/dist/internal/components/ui/date-input.d.ts +14 -0
  140. package/dist/internal/components/ui/date-input.js +33 -0
  141. package/dist/internal/components/ui/date-picker.d.ts +19 -0
  142. package/dist/internal/components/ui/date-picker.js +34 -0
  143. package/dist/internal/components/ui/dialog.d.ts +18 -0
  144. package/dist/internal/components/ui/dialog.js +38 -0
  145. package/dist/internal/components/ui/input-group.d.ts +18 -0
  146. package/dist/internal/components/ui/input-group.js +57 -0
  147. package/dist/internal/components/ui/input.d.ts +3 -0
  148. package/dist/internal/components/ui/input.js +12 -0
  149. package/dist/internal/components/ui/label.d.ts +3 -0
  150. package/dist/internal/components/ui/label.js +7 -0
  151. package/dist/internal/components/ui/popover.d.ts +9 -0
  152. package/dist/internal/components/ui/popover.js +23 -0
  153. package/dist/internal/components/ui/select.d.ts +17 -0
  154. package/dist/internal/components/ui/select.js +35 -0
  155. package/dist/internal/components/ui/switch.d.ts +5 -0
  156. package/dist/internal/components/ui/switch.js +8 -0
  157. package/dist/internal/components/ui/table.d.ts +10 -0
  158. package/dist/internal/components/ui/table.js +28 -0
  159. package/dist/internal/components/ui/tabs.d.ts +10 -0
  160. package/dist/internal/components/ui/tabs.js +29 -0
  161. package/dist/internal/components/ui/textarea.d.ts +3 -0
  162. package/dist/internal/components/ui/textarea.js +7 -0
  163. package/dist/internal/components/ui/tooltip.d.ts +6 -0
  164. package/dist/internal/components/ui/tooltip.js +17 -0
  165. package/dist/internal/contracts/modules/v1/reg-spi-reports/reg-spi-reports.schema.d.ts +112 -0
  166. package/dist/internal/contracts/modules/v1/reg-spi-reports/reg-spi-reports.schema.js +91 -0
  167. package/dist/internal/hooks/use-form-field-order.d.ts +7 -0
  168. package/dist/internal/hooks/use-form-field-order.js +43 -0
  169. package/dist/internal/lib/utils.d.ts +2 -0
  170. package/dist/internal/lib/utils.js +3 -0
  171. package/dist/inventory/components/inventory-item-form.d.ts +7 -0
  172. package/dist/inventory/components/inventory-item-form.js +5 -0
  173. package/dist/inventory/components/inventory-item-preview.d.ts +6 -0
  174. package/dist/inventory/components/inventory-item-preview.js +5 -0
  175. package/dist/inventory/iar.d.ts +4 -0
  176. package/dist/inventory/iar.js +4 -0
  177. package/dist/inventory/ics.d.ts +2 -0
  178. package/dist/inventory/ics.js +3 -0
  179. package/dist/inventory/iirup.d.ts +2 -0
  180. package/dist/inventory/iirup.js +3 -0
  181. package/dist/inventory/iirusp.d.ts +4 -0
  182. package/dist/inventory/iirusp.js +4 -0
  183. package/dist/inventory/index.d.ts +3 -0
  184. package/dist/inventory/index.js +4 -0
  185. package/dist/inventory/item.d.ts +3 -0
  186. package/dist/inventory/item.js +3 -0
  187. package/dist/inventory/itr.d.ts +4 -0
  188. package/dist/inventory/itr.js +4 -0
  189. package/dist/inventory/par.d.ts +2 -0
  190. package/dist/inventory/par.js +3 -0
  191. package/dist/inventory/po.d.ts +2 -0
  192. package/dist/inventory/po.js +2 -0
  193. package/dist/inventory/ppelc.d.ts +2 -0
  194. package/dist/inventory/ppelc.js +3 -0
  195. package/dist/inventory/pplc.d.ts +2 -0
  196. package/dist/inventory/pplc.js +4 -0
  197. package/dist/inventory/pr.d.ts +4 -0
  198. package/dist/inventory/pr.js +4 -0
  199. package/dist/inventory/property-card.d.ts +2 -0
  200. package/dist/inventory/property-card.js +3 -0
  201. package/dist/inventory/ptr.d.ts +2 -0
  202. package/dist/inventory/ptr.js +3 -0
  203. package/dist/inventory/regspi.d.ts +4 -0
  204. package/dist/inventory/regspi.js +4 -0
  205. package/dist/inventory/ris.d.ts +4 -0
  206. package/dist/inventory/ris.js +4 -0
  207. package/dist/inventory/rlsddp.d.ts +4 -0
  208. package/dist/inventory/rlsddp.js +4 -0
  209. package/dist/inventory/rlsddsp.d.ts +2 -0
  210. package/dist/inventory/rlsddsp.js +3 -0
  211. package/dist/inventory/rpci.d.ts +2 -0
  212. package/dist/inventory/rpci.js +3 -0
  213. package/dist/inventory/rpcppe.d.ts +2 -0
  214. package/dist/inventory/rpcppe.js +3 -0
  215. package/dist/inventory/rpcsp.d.ts +2 -0
  216. package/dist/inventory/rpcsp.js +3 -0
  217. package/dist/inventory/rrsp.d.ts +2 -0
  218. package/dist/inventory/rrsp.js +3 -0
  219. package/dist/inventory/rsmi.d.ts +4 -0
  220. package/dist/inventory/rsmi.js +4 -0
  221. package/dist/inventory/rsmp.d.ts +4 -0
  222. package/dist/inventory/rsmp.js +4 -0
  223. package/dist/inventory/rspi.d.ts +2 -0
  224. package/dist/inventory/rspi.js +3 -0
  225. package/dist/inventory/spc.d.ts +2 -0
  226. package/dist/inventory/spc.js +3 -0
  227. package/dist/inventory/splc.d.ts +3 -0
  228. package/dist/inventory/splc.js +4 -0
  229. package/dist/inventory/stock-card.d.ts +4 -0
  230. package/dist/inventory/stock-card.js +4 -0
  231. package/dist/inventory/types.d.ts +11 -0
  232. package/dist/inventory/types.js +1 -0
  233. package/dist/inventory/wmr.d.ts +4 -0
  234. package/dist/inventory/wmr.js +4 -0
  235. package/dist/lib/rpcsp-accountable-person.d.ts +1 -0
  236. package/dist/lib/rpcsp-accountable-person.js +10 -0
  237. package/dist/reports/iar/_components/create-form.d.ts +13 -0
  238. package/dist/reports/iar/_components/create-form.js +92 -0
  239. package/dist/reports/iar/_components/document-preview.d.ts +11 -0
  240. package/dist/reports/iar/_components/document-preview.js +131 -0
  241. package/dist/reports/iar/types.d.ts +97 -0
  242. package/dist/reports/iar/types.js +24 -0
  243. package/dist/reports/iirusp/_components/create-form.d.ts +17 -0
  244. package/dist/reports/iirusp/_components/create-form.js +118 -0
  245. package/dist/reports/iirusp/_components/document-preview.d.ts +8 -0
  246. package/dist/reports/iirusp/_components/document-preview.js +389 -0
  247. package/dist/reports/iirusp/types.d.ts +134 -0
  248. package/dist/reports/iirusp/types.js +29 -0
  249. package/dist/reports/iirusp/utils.d.ts +29 -0
  250. package/dist/reports/iirusp/utils.js +488 -0
  251. package/dist/reports/itr/_components/create-form.d.ts +28 -0
  252. package/dist/reports/itr/_components/create-form.js +90 -0
  253. package/dist/reports/itr/_components/document-preview.d.ts +6 -0
  254. package/dist/reports/itr/_components/document-preview.js +7 -0
  255. package/dist/reports/itr/types.d.ts +68 -0
  256. package/dist/reports/itr/types.js +27 -0
  257. package/dist/reports/itr/utils.d.ts +24 -0
  258. package/dist/reports/itr/utils.js +76 -0
  259. package/dist/reports/pr/_components/create-form.d.ts +16 -0
  260. package/dist/reports/pr/_components/create-form.js +52 -0
  261. package/dist/reports/pr/_components/document-preview.d.ts +7 -0
  262. package/dist/reports/pr/_components/document-preview.js +9 -0
  263. package/dist/reports/pr/types.d.ts +69 -0
  264. package/dist/reports/pr/types.js +1 -0
  265. package/dist/reports/pr/utils.d.ts +72 -0
  266. package/dist/reports/pr/utils.js +572 -0
  267. package/dist/reports/regspi/_components/create-form.d.ts +19 -0
  268. package/dist/reports/regspi/_components/create-form.js +33 -0
  269. package/dist/reports/regspi/_components/document-preview.d.ts +6 -0
  270. package/dist/reports/regspi/_components/document-preview.js +7 -0
  271. package/dist/reports/regspi/types.d.ts +29 -0
  272. package/dist/reports/regspi/types.js +24 -0
  273. package/dist/reports/regspi/utils.d.ts +48 -0
  274. package/dist/reports/regspi/utils.js +98 -0
  275. package/dist/reports/ris/_components/create-form.d.ts +36 -0
  276. package/dist/reports/ris/_components/create-form.js +149 -0
  277. package/dist/reports/ris/_components/document-preview.d.ts +8 -0
  278. package/dist/reports/ris/_components/document-preview.js +31 -0
  279. package/dist/reports/ris/types.d.ts +93 -0
  280. package/dist/reports/ris/types.js +1 -0
  281. package/dist/reports/rlsddp/_components/create-form.d.ts +11 -0
  282. package/dist/reports/rlsddp/_components/create-form.js +165 -0
  283. package/dist/reports/rlsddp/_components/document-preview.d.ts +8 -0
  284. package/dist/reports/rlsddp/_components/document-preview.js +15 -0
  285. package/dist/reports/rlsddp/types.d.ts +105 -0
  286. package/dist/reports/rlsddp/types.js +31 -0
  287. package/dist/reports/rrsp/components/rrsp-preview.d.ts +21 -0
  288. package/dist/reports/rrsp/components/rrsp-preview.js +155 -0
  289. package/dist/reports/rsmi/components/rsmi-create-form.d.ts +20 -0
  290. package/dist/reports/rsmi/components/rsmi-create-form.js +8 -0
  291. package/dist/reports/rsmi/components/rsmi-document-body.d.ts +15 -0
  292. package/dist/reports/rsmi/components/rsmi-document-body.js +12 -0
  293. package/dist/reports/rsmi/components/rsmi-types.d.ts +45 -0
  294. package/dist/reports/rsmi/components/rsmi-types.js +1 -0
  295. package/dist/reports/rsmi/components/rsmi-utils.d.ts +2 -0
  296. package/dist/reports/rsmi/components/rsmi-utils.js +18 -0
  297. package/dist/reports/rsmp/components/rsmp-create-modal.d.ts +5 -0
  298. package/dist/reports/rsmp/components/rsmp-create-modal.js +7 -0
  299. package/dist/reports/rsmp/components/rsmp-preview-modal.d.ts +11 -0
  300. package/dist/reports/rsmp/components/rsmp-preview-modal.js +47 -0
  301. package/dist/reports/rsmp/components/rsmp-types.d.ts +44 -0
  302. package/dist/reports/rsmp/components/rsmp-types.js +1 -0
  303. package/dist/reports/rsmp/components/rsmp-utils.d.ts +5 -0
  304. package/dist/reports/rsmp/components/rsmp-utils.js +41 -0
  305. package/dist/reports/rsmp/lib/rsmp-grouping.d.ts +14 -0
  306. package/dist/reports/rsmp/lib/rsmp-grouping.js +75 -0
  307. package/dist/reports/stock-card/_components/create-form.d.ts +13 -0
  308. package/dist/reports/stock-card/_components/create-form.js +39 -0
  309. package/dist/reports/stock-card/_components/document-preview.d.ts +7 -0
  310. package/dist/reports/stock-card/_components/document-preview.js +29 -0
  311. package/dist/reports/stock-card/types.d.ts +31 -0
  312. package/dist/reports/stock-card/types.js +1 -0
  313. package/dist/reports/stock-card/utils.d.ts +32 -0
  314. package/dist/reports/stock-card/utils.js +248 -0
  315. package/dist/reports/wmr/_components/create-form.d.ts +22 -0
  316. package/dist/reports/wmr/_components/create-form.js +61 -0
  317. package/dist/reports/wmr/_components/document-preview.d.ts +10 -0
  318. package/dist/reports/wmr/_components/document-preview.js +59 -0
  319. package/dist/reports/wmr/types.d.ts +45 -0
  320. package/dist/reports/wmr/types.js +1 -0
  321. package/dist/reports/wmr/utils.d.ts +32 -0
  322. package/dist/reports/wmr/utils.js +343 -0
  323. package/dist/styles.css +4492 -0
  324. package/extraction-manifest.json +620 -0
  325. 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;