@omniumretail/component-library 1.2.13 → 1.2.15

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.
@@ -4,6 +4,27 @@
4
4
  http://jedwatson.github.io/classnames
5
5
  */
6
6
 
7
+ /*!
8
+ * html2canvas 1.4.1 <https://html2canvas.hertzen.com>
9
+ * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
10
+ * Released under MIT License
11
+ */
12
+
13
+ /*! *****************************************************************************
14
+ Copyright (c) Microsoft Corporation.
15
+
16
+ Permission to use, copy, modify, and/or distribute this software for any
17
+ purpose with or without fee is hereby granted.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
20
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
21
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
22
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
23
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
24
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25
+ PERFORMANCE OF THIS SOFTWARE.
26
+ ***************************************************************************** */
27
+
7
28
  /*! exports provided: default */
8
29
 
9
30
  /*! no static exports found */
@@ -22,6 +43,202 @@
22
43
  !*** external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"} ***!
23
44
  \**************************************************************************************/
24
45
 
46
+ /**
47
+ * @license
48
+ Copyright (c) 2008, Adobe Systems Incorporated
49
+ All rights reserved.
50
+
51
+ Redistribution and use in source and binary forms, with or without
52
+ modification, are permitted provided that the following conditions are
53
+ met:
54
+
55
+ * Redistributions of source code must retain the above copyright notice,
56
+ this list of conditions and the following disclaimer.
57
+
58
+ * Redistributions in binary form must reproduce the above copyright
59
+ notice, this list of conditions and the following disclaimer in the
60
+ documentation and/or other materials provided with the distribution.
61
+
62
+ * Neither the name of Adobe Systems Incorporated nor the names of its
63
+ contributors may be used to endorse or promote products derived from
64
+ this software without specific prior written permission.
65
+
66
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
67
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
68
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
69
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
70
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
71
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
72
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
73
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
74
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
75
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
76
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
77
+ */
78
+
79
+ /**
80
+ * @license
81
+ *
82
+ * Copyright (c) 2014 James Robb, https://github.com/jamesbrobb
83
+ *
84
+ * Permission is hereby granted, free of charge, to any person obtaining
85
+ * a copy of this software and associated documentation files (the
86
+ * "Software"), to deal in the Software without restriction, including
87
+ * without limitation the rights to use, copy, modify, merge, publish,
88
+ * distribute, sublicense, and/or sell copies of the Software, and to
89
+ * permit persons to whom the Software is furnished to do so, subject to
90
+ * the following conditions:
91
+ *
92
+ * The above copyright notice and this permission notice shall be
93
+ * included in all copies or substantial portions of the Software.
94
+ *
95
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
96
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
97
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
98
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
99
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
100
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
101
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
102
+ * ====================================================================
103
+ */
104
+
105
+ /**
106
+ * @license
107
+ *
108
+ * Licensed under the MIT License.
109
+ * http://opensource.org/licenses/mit-license
110
+ */
111
+
112
+ /**
113
+ * @license
114
+ * (c) Dean McNamee <dean@gmail.com>, 2013.
115
+ *
116
+ * https://github.com/deanm/omggif
117
+ *
118
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
119
+ * of this software and associated documentation files (the "Software"), to
120
+ * deal in the Software without restriction, including without limitation the
121
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
122
+ * sell copies of the Software, and to permit persons to whom the Software is
123
+ * furnished to do so, subject to the following conditions:
124
+ *
125
+ * The above copyright notice and this permission notice shall be included in
126
+ * all copies or substantial portions of the Software.
127
+ *
128
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
129
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
130
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
131
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
132
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
133
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
134
+ * IN THE SOFTWARE.
135
+ *
136
+ * omggif is a JavaScript implementation of a GIF 89a encoder and decoder,
137
+ * including animation and compression. It does not rely on any specific
138
+ * underlying system, so should run in the browser, Node, or Plask.
139
+ */
140
+
141
+ /**
142
+ * @license
143
+ * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
144
+ *
145
+ * Licensed under the MIT License.
146
+ * http://opensource.org/licenses/mit-license
147
+ */
148
+
149
+ /**
150
+ * @license
151
+ * Copyright (c) 2017 Aras Abbasi
152
+ *
153
+ * Licensed under the MIT License.
154
+ * http://opensource.org/licenses/mit-license
155
+ */
156
+
157
+ /**
158
+ * @license
159
+ * Copyright (c) 2018 Aras Abbasi
160
+ *
161
+ * Licensed under the MIT License.
162
+ * http://opensource.org/licenses/mit-license
163
+ */
164
+
165
+ /**
166
+ * @license
167
+ * Copyright (c) 2019 Aras Abbasi
168
+ *
169
+ * Licensed under the MIT License.
170
+ * http://opensource.org/licenses/mit-license
171
+ */
172
+
173
+ /**
174
+ * @license
175
+ * FPDF is released under a permissive license: there is no usage restriction.
176
+ * You may embed it freely in your application (commercial or not), with or
177
+ * without modifications.
178
+ *
179
+ * Reference: http://www.fpdf.org/en/script/script37.php
180
+ */
181
+
182
+ /**
183
+ * @license
184
+ * Joseph Myers does not specify a particular license for his work.
185
+ *
186
+ * Author: Joseph Myers
187
+ * Accessed from: http://www.myersdaily.org/joseph/javascript/md5.js
188
+ *
189
+ * Modified by: Owen Leong
190
+ */
191
+
192
+ /**
193
+ * @license
194
+ * Licensed under the MIT License.
195
+ * http://opensource.org/licenses/mit-license
196
+ * Author: Owen Leong (@owenl131)
197
+ * Date: 15 Oct 2020
198
+ * References:
199
+ * https://www.cs.cmu.edu/~dst/Adobe/Gallery/anon21jul01-pdf-encryption.txt
200
+ * https://github.com/foliojs/pdfkit/blob/master/lib/security.js
201
+ * http://www.fpdf.org/en/script/script37.php
202
+ */
203
+
204
+ /**
205
+ * @license
206
+ * Licensed under the MIT License.
207
+ * http://opensource.org/licenses/mit-license
208
+ */
209
+
210
+ /**
211
+ * @license
212
+ * Unicode Bidi Engine based on the work of Alex Shensis (@asthensis)
213
+ * MIT License
214
+ */
215
+
216
+ /**
217
+ * @license
218
+ * jsPDF fileloading PlugIn
219
+ * Copyright (c) 2018 Aras Abbasi (aras.abbasi@gmail.com)
220
+ *
221
+ * Licensed under the MIT License.
222
+ * http://opensource.org/licenses/mit-license
223
+ */
224
+
225
+ /**
226
+ * @license
227
+ * jsPDF filters PlugIn
228
+ * Copyright (c) 2014 Aras Abbasi
229
+ *
230
+ * Licensed under the MIT License.
231
+ * http://opensource.org/licenses/mit-license
232
+ */
233
+
234
+ /**
235
+ * @license
236
+ * jsPDF virtual FileSystem functionality
237
+ *
238
+ * Licensed under the MIT License.
239
+ * http://opensource.org/licenses/mit-license
240
+ */
241
+
25
242
  /**
26
243
  * @license React
27
244
  * react-is.production.min.js
@@ -42,6 +259,13 @@
42
259
  * LICENSE file in the root directory of this source tree.
43
260
  */
44
261
 
262
+ /**
263
+ * A class to parse color values
264
+ * @author Stoyan Stefanov <sstoo@gmail.com>
265
+ * {@link http://www.phpied.com/rgb-color-parser-in-javascript/}
266
+ * @license Use it if you like it
267
+ */
268
+
45
269
  /**
46
270
  * Checks if an event is supported in the current execution environment.
47
271
  *
@@ -57,6 +281,91 @@
57
281
  * @license Modernizr 3.0.0pre (Custom Build) | MIT
58
282
  */
59
283
 
284
+ /** ====================================================================
285
+ * @license
286
+ * jsPDF XMP metadata plugin
287
+ * Copyright (c) 2016 Jussi Utunen, u-jussi@suomi24.fi
288
+ *
289
+ * Permission is hereby granted, free of charge, to any person obtaining
290
+ * a copy of this software and associated documentation files (the
291
+ * "Software"), to deal in the Software without restriction, including
292
+ * without limitation the rights to use, copy, modify, merge, publish,
293
+ * distribute, sublicense, and/or sell copies of the Software, and to
294
+ * permit persons to whom the Software is furnished to do so, subject to
295
+ * the following conditions:
296
+ *
297
+ * The above copyright notice and this permission notice shall be
298
+ * included in all copies or substantial portions of the Software.
299
+ *
300
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
301
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
302
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
303
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
304
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
305
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
306
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
307
+ * ====================================================================
308
+ */
309
+
310
+ /** @license
311
+ * Copyright (c) 2017 Dominik Homberger
312
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
313
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
314
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
315
+ https://webpjs.appspot.com
316
+ WebPRiffParser dominikhlbg@gmail.com
317
+ */
318
+
319
+ /** @license
320
+ *
321
+ * jsPDF - PDF Document creation from JavaScript
322
+ * Version 2.5.2 Built on 2024-09-17T13:29:57.859Z
323
+ * CommitID 00000000
324
+ *
325
+ * Copyright (c) 2010-2021 James Hall <james@parall.ax>, https://github.com/MrRio/jsPDF
326
+ * 2015-2021 yWorks GmbH, http://www.yworks.com
327
+ * 2015-2021 Lukas Holländer <lukas.hollaender@yworks.com>, https://github.com/HackbrettXXX
328
+ * 2016-2018 Aras Abbasi <aras.abbasi@gmail.com>
329
+ * 2010 Aaron Spike, https://github.com/acspike
330
+ * 2012 Willow Systems Corporation, https://github.com/willowsystems
331
+ * 2012 Pablo Hess, https://github.com/pablohess
332
+ * 2012 Florian Jenett, https://github.com/fjenett
333
+ * 2013 Warren Weckesser, https://github.com/warrenweckesser
334
+ * 2013 Youssef Beddad, https://github.com/lifof
335
+ * 2013 Lee Driscoll, https://github.com/lsdriscoll
336
+ * 2013 Stefan Slonevskiy, https://github.com/stefslon
337
+ * 2013 Jeremy Morel, https://github.com/jmorel
338
+ * 2013 Christoph Hartmann, https://github.com/chris-rock
339
+ * 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria
340
+ * 2014 James Makes, https://github.com/dollaruw
341
+ * 2014 Diego Casorran, https://github.com/diegocr
342
+ * 2014 Steven Spungin, https://github.com/Flamenco
343
+ * 2014 Kenneth Glassey, https://github.com/Gavvers
344
+ *
345
+ * Permission is hereby granted, free of charge, to any person obtaining
346
+ * a copy of this software and associated documentation files (the
347
+ * "Software"), to deal in the Software without restriction, including
348
+ * without limitation the rights to use, copy, modify, merge, publish,
349
+ * distribute, sublicense, and/or sell copies of the Software, and to
350
+ * permit persons to whom the Software is furnished to do so, subject to
351
+ * the following conditions:
352
+ *
353
+ * The above copyright notice and this permission notice shall be
354
+ * included in all copies or substantial portions of the Software.
355
+ *
356
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
357
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
358
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
359
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
360
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
361
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
362
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
363
+ *
364
+ * Contributor(s):
365
+ * siefkenj, ahwolf, rickygu, Midnith, saintclair, eaparango,
366
+ * kim3er, mfo, alnorth, Flamenco
367
+ */
368
+
60
369
  /** @license React v16.13.1
61
370
  * react-is.production.min.js
62
371
  *
@@ -4,6 +4,7 @@ interface CategoryResponse {
4
4
  serverReadyData: any;
5
5
  onNextCategoryAvailabilityChange: (hasNext: boolean) => void;
6
6
  onPreviousCategoryAvailabilityChange: (hasPrevious: boolean) => void;
7
+ exportPdf?: boolean;
7
8
  }
8
9
  export declare const CategoryReadOnly: React.ForwardRefExoticComponent<CategoryResponse & React.RefAttributes<unknown>>;
9
10
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omniumretail/component-library",
3
- "version": "1.2.13",
3
+ "version": "1.2.15",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -36,6 +36,7 @@
36
36
  "file-loader": "^6.2.0",
37
37
  "fs-extra": "^10.0.0",
38
38
  "html-webpack-plugin": "^5.5.0",
39
+ "html2canvas": "^1.4.1",
39
40
  "i18next": "^22.4.9",
40
41
  "i18next-browser-languagedetector": "^7.0.1",
41
42
  "i18next-fetch-backend": "^5.0.1",
@@ -43,6 +44,7 @@
43
44
  "jest": "^27.4.3",
44
45
  "jest-resolve": "^27.4.2",
45
46
  "jest-watch-typeahead": "^1.0.0",
47
+ "jspdf": "^2.5.2",
46
48
  "lodash.merge": "^4.6.2",
47
49
  "mini-css-extract-plugin": "^2.7.2",
48
50
  "moment": "^2.29.4",
@@ -13,6 +13,7 @@ const Template: Story<any> = (args) => {
13
13
  const categoryResponseRef = useRef(null);
14
14
  const [hasNext, setHasNext] = useState(true);
15
15
  const [hasPrevious, setHasPrevious] = useState(false);
16
+ const [teste, setTeste] = useState(false);
16
17
 
17
18
  const handleNextCategoryAvailabilityChange = (hasNext: boolean) => {
18
19
  setHasNext(hasNext);
@@ -43,6 +44,7 @@ const Template: Story<any> = (args) => {
43
44
  ref={categoryResponseRef}
44
45
  onNextCategoryAvailabilityChange={handleNextCategoryAvailabilityChange}
45
46
  onPreviousCategoryAvailabilityChange={handlePreviousCategoryAvailabilityChange}
47
+ exportPdf={ teste}
46
48
  >
47
49
  </CategoryReadOnly>
48
50
  </div>
@@ -55,6 +57,8 @@ const Template: Story<any> = (args) => {
55
57
  {hasNext && (
56
58
  <Button onClick={handleNextClickOutside}>Next on Parent</Button>
57
59
  )}
60
+
61
+ <Button onClick={() => setTeste(true)}>teste</Button>
58
62
  </div>
59
63
  </div>
60
64
  )
@@ -1,17 +1,19 @@
1
1
  import styles from './styles.module.scss';
2
- import { useEffect, useImperativeHandle, useState } from 'react';
2
+ import { useEffect, useImperativeHandle, useRef, useState } from 'react';
3
3
  import { useForm } from 'antd/es/form/Form';
4
4
  import classNames from 'classnames';
5
5
  import React from 'react';
6
6
  import { t } from 'i18next';
7
7
  import TextArea from 'antd/es/input/TextArea';
8
- import { Input } from 'antd';
8
+ import html2canvas from 'html2canvas';
9
+ import jsPDF from 'jspdf';
9
10
 
10
11
  interface CategoryResponse {
11
12
  data: any;
12
13
  serverReadyData: any;
13
14
  onNextCategoryAvailabilityChange: (hasNext: boolean) => void;
14
15
  onPreviousCategoryAvailabilityChange: (hasPrevious: boolean) => void;
16
+ exportPdf?: boolean;
15
17
  };
16
18
 
17
19
  type Category = {
@@ -85,7 +87,7 @@ export const CategoryReadOnly = React.forwardRef((props: CategoryResponse, ref)
85
87
  const [selectedCategory, setSelectedCategory] = useState<any>(data.CategoryAnswers[0]);
86
88
  const [initialValues, setInitialValues] = useState<any>(data.CategoryAnswers[0].Data);
87
89
  const [form] = useForm();
88
-
90
+ const pdfRef = useRef<HTMLDivElement>(null);
89
91
 
90
92
  const updateInitialValues = (data: any) => {
91
93
  const {
@@ -112,21 +114,6 @@ export const CategoryReadOnly = React.forwardRef((props: CategoryResponse, ref)
112
114
  setCurrentKey(index);
113
115
  };
114
116
 
115
- const onFinish = (values: any) => {
116
- const updatedQuestions = initialValues.Questions.map((question: any, index: number) => {
117
- return {
118
- ...question,
119
- Answer: values.Questions[index].Answer
120
- };
121
- });
122
-
123
- const updatedCategory = updateCategoryAnswers(localData.CategoryAnswers, selectedCategory.Data, updatedQuestions);
124
-
125
- const updatedLocalData = { ...localData, CategoryAnswers: updatedCategory };
126
-
127
- setLocalData(updatedLocalData);
128
- };
129
-
130
117
  const renderCategories = (categories: any) => {
131
118
  return categories.map((category: any, index: number) => {
132
119
  const labelClasses = classNames({
@@ -157,6 +144,75 @@ export const CategoryReadOnly = React.forwardRef((props: CategoryResponse, ref)
157
144
  });
158
145
  };
159
146
 
147
+ const handleDownloadPDF = async () => {
148
+ if (pdfRef.current && data) {
149
+ const pdf = new jsPDF('p', 'mm', 'a4');
150
+ const pdfWidth = pdf.internal.pageSize.getWidth();
151
+ const pdfHeight = pdf.internal.pageSize.getHeight();
152
+ const spaceBetweenCategories = 20;
153
+
154
+ let currentY = 0;
155
+
156
+ // Função recursiva para percorrer e capturar apenas os nós mais profundos
157
+ const processLeafNodes = async (category: any) => {
158
+ if (category.Children && category.Children.length > 0) {
159
+ // Se houver subcategorias, processa cada uma delas recursivamente
160
+ for (const childCategory of category.Children) {
161
+ await processLeafNodes(childCategory);
162
+ }
163
+ } else {
164
+ // Se não houver subcategorias, processa o nó como um nó folha
165
+ setCurrentKey(category.Key);
166
+ setSelectedCategory(category);
167
+
168
+ // Aguarda a renderização da nova categoria
169
+ await new Promise((resolve) => {
170
+ setTimeout(async () => {
171
+ // Captura o conteúdo da referência PDF
172
+ const canvas = await html2canvas(pdfRef.current!, {
173
+ width: pdfRef.current!.scrollWidth,
174
+ height: pdfRef.current!.scrollHeight,
175
+ useCORS: true,
176
+ allowTaint: true,
177
+ scale: 1,
178
+ });
179
+
180
+ const imgData = canvas.toDataURL('image/png');
181
+ const imgHeight = (canvas.height * pdfWidth) / canvas.width;
182
+
183
+ // Adiciona uma nova página se não houver espaço suficiente
184
+ if (currentY + imgHeight + spaceBetweenCategories > pdfHeight) {
185
+ pdf.addPage();
186
+ currentY = 0;
187
+ }
188
+
189
+ // Adiciona a imagem ao PDF na posição atual
190
+ pdf.addImage(imgData, 'PNG', 0, currentY, pdfWidth, imgHeight);
191
+ currentY += imgHeight + spaceBetweenCategories;
192
+
193
+ resolve(null);
194
+ }, 150);
195
+ });
196
+ }
197
+ };
198
+
199
+ // Percorre todas as categorias principais
200
+ for (const mainCategory of data.CategoryAnswers) {
201
+ await processLeafNodes(mainCategory);
202
+ }
203
+
204
+ pdf.save('evaluation_details.pdf');
205
+ } else {
206
+ console.warn('pdfRef.current está vazio. Verifique se a referência está correta.');
207
+ }
208
+ };
209
+
210
+ useEffect(() => {
211
+ if (props.exportPdf) {
212
+ handleDownloadPDF();
213
+ }
214
+ }, [props.exportPdf]);
215
+
160
216
  const handleNextClick = () => {
161
217
  const nextCategory = findCategoryWithQuestions(currentKey, localData.CategoryAnswers, 'next');
162
218
  if (nextCategory) {
@@ -203,7 +259,7 @@ export const CategoryReadOnly = React.forwardRef((props: CategoryResponse, ref)
203
259
  }, [styles.questionWrapper]);
204
260
 
205
261
  return (
206
- <div className={styles.categoryResponse}>
262
+ <div ref={pdfRef} className={styles.categoryResponse}>
207
263
  <div className={styles.sidebarWrapper}>
208
264
  {renderCategories(localData.CategoryAnswers)}
209
265
  </div>