@omniumretail/component-library 1.2.14 → 1.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +1 -1
- package/dist/types/components/CategoryReadOnly/index.d.ts +1 -1
- package/dist/types/components/ResponsiveTable/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/CategoryReadOnly/CategoryReadOnly.stories.tsx +4 -0
- package/src/components/CategoryReadOnly/index.tsx +44 -31
- package/src/components/ResponsiveTable/index.tsx +7 -2
|
@@ -4,7 +4,7 @@ interface CategoryResponse {
|
|
|
4
4
|
serverReadyData: any;
|
|
5
5
|
onNextCategoryAvailabilityChange: (hasNext: boolean) => void;
|
|
6
6
|
onPreviousCategoryAvailabilityChange: (hasPrevious: boolean) => void;
|
|
7
|
-
exportPdf
|
|
7
|
+
exportPdf?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export declare const CategoryReadOnly: React.ForwardRefExoticComponent<CategoryResponse & React.RefAttributes<unknown>>;
|
|
10
10
|
export {};
|
|
@@ -47,5 +47,6 @@ export interface ResponsiveTableCustomProps extends TableProps<any> {
|
|
|
47
47
|
buttonActionStyle?: string | ((record: any) => any);
|
|
48
48
|
cleanRowSelection?: boolean;
|
|
49
49
|
getRowActions?: (record: any) => any;
|
|
50
|
+
customSelectAllButton?: string;
|
|
50
51
|
}
|
|
51
52
|
export declare const ResponsiveTable: (props: ResponsiveTableCustomProps) => import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -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
|
)
|
|
@@ -13,7 +13,7 @@ interface CategoryResponse {
|
|
|
13
13
|
serverReadyData: any;
|
|
14
14
|
onNextCategoryAvailabilityChange: (hasNext: boolean) => void;
|
|
15
15
|
onPreviousCategoryAvailabilityChange: (hasPrevious: boolean) => void;
|
|
16
|
-
exportPdf
|
|
16
|
+
exportPdf?: boolean;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
type Category = {
|
|
@@ -149,43 +149,56 @@ export const CategoryReadOnly = React.forwardRef((props: CategoryResponse, ref)
|
|
|
149
149
|
const pdf = new jsPDF('p', 'mm', 'a4');
|
|
150
150
|
const pdfWidth = pdf.internal.pageSize.getWidth();
|
|
151
151
|
const pdfHeight = pdf.internal.pageSize.getHeight();
|
|
152
|
-
const
|
|
152
|
+
const spaceBetweenCategories = 20;
|
|
153
153
|
|
|
154
|
-
let currentY = 0;
|
|
154
|
+
let currentY = 0;
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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);
|
|
160
167
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
+
});
|
|
172
179
|
|
|
173
|
-
|
|
174
|
-
|
|
180
|
+
const imgData = canvas.toDataURL('image/png');
|
|
181
|
+
const imgHeight = (canvas.height * pdfWidth) / canvas.width;
|
|
175
182
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
+
}
|
|
181
188
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
189
|
+
// Adiciona a imagem ao PDF na posição atual
|
|
190
|
+
pdf.addImage(imgData, 'PNG', 0, currentY, pdfWidth, imgHeight);
|
|
191
|
+
currentY += imgHeight + spaceBetweenCategories;
|
|
185
192
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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);
|
|
189
202
|
}
|
|
190
203
|
|
|
191
204
|
pdf.save('evaluation_details.pdf');
|
|
@@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
import { MoreOutlined } from '@ant-design/icons';
|
|
8
8
|
import classnames from 'classnames';
|
|
9
9
|
import { Button } from '../Button';
|
|
10
|
+
import classNames from 'classnames';
|
|
10
11
|
|
|
11
12
|
export interface FilterTableOptions {
|
|
12
13
|
value: string;
|
|
@@ -53,6 +54,7 @@ export interface ResponsiveTableCustomProps extends TableProps<any> {
|
|
|
53
54
|
buttonActionStyle?: string | ((record: any) => any);
|
|
54
55
|
cleanRowSelection?: boolean;
|
|
55
56
|
getRowActions?: (record: any) => any;
|
|
57
|
+
customSelectAllButton?: string;
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
export const ResponsiveTable = (props: ResponsiveTableCustomProps) => {
|
|
@@ -83,7 +85,8 @@ export const ResponsiveTable = (props: ResponsiveTableCustomProps) => {
|
|
|
83
85
|
buttonActionStyle,
|
|
84
86
|
buttonActionLabel,
|
|
85
87
|
cleanRowSelection,
|
|
86
|
-
getRowActions
|
|
88
|
+
getRowActions,
|
|
89
|
+
customSelectAllButton
|
|
87
90
|
} = props;
|
|
88
91
|
|
|
89
92
|
const [customFilters, setCustomFilters] = useState<any>([]);
|
|
@@ -291,6 +294,8 @@ export const ResponsiveTable = (props: ResponsiveTableCustomProps) => {
|
|
|
291
294
|
[styles.tableWrapperNoSelection]: !rowSelection
|
|
292
295
|
}, [styles.tableWrapper]);
|
|
293
296
|
|
|
297
|
+
const selectAllButtonStyle = classNames([styles.selectAllRows], [customSelectAllButton]);
|
|
298
|
+
|
|
294
299
|
return (
|
|
295
300
|
<div className={tableWrapperClasses}>
|
|
296
301
|
{shouldRenderSortDropdown &&
|
|
@@ -330,7 +335,7 @@ export const ResponsiveTable = (props: ResponsiveTableCustomProps) => {
|
|
|
330
335
|
/>
|
|
331
336
|
{
|
|
332
337
|
onSelectAllButtonClick &&
|
|
333
|
-
<Button onClick={selectAllRows} className={
|
|
338
|
+
<Button onClick={selectAllRows} className={selectAllButtonStyle}>
|
|
334
339
|
{selectedAllRowKeys ? t('components.table.deselectAll') : t('components.table.selectAll')}
|
|
335
340
|
</Button>
|
|
336
341
|
}
|