@zauru-sdk/components 1.0.54 → 1.0.60

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 (94) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/LICENCE.md +11 -11
  3. package/package.json +7 -7
  4. package/src/Alerts/ErrorBoundaryAlert/ErrorBoundaryAlert.tsx +66 -66
  5. package/src/Alerts/StaticAlert.tsx +121 -121
  6. package/src/Alerts/index.ts +2 -2
  7. package/src/BlockUI/BlockUI.tsx +50 -50
  8. package/src/BlockUI/index.tsx +1 -1
  9. package/src/Buttons/Button.tsx +90 -90
  10. package/src/Buttons/index.ts +1 -1
  11. package/src/Card/Card.tsx +24 -24
  12. package/src/Card/index.ts +1 -1
  13. package/src/Chat/ChatLayout.tsx +131 -131
  14. package/src/Chat/ChatMessageHistory.tsx +142 -142
  15. package/src/Chat/index.ts +2 -2
  16. package/src/ConnectionState/ConnectionState.tsx +27 -27
  17. package/src/ConnectionState/index.tsx +1 -1
  18. package/src/Containers/BodyContainer.tsx +14 -14
  19. package/src/Containers/ButtonSectionContainer.tsx +21 -21
  20. package/src/Containers/Container.tsx +39 -39
  21. package/src/Containers/DoubleContainer.tsx +48 -48
  22. package/src/Containers/MainContainer.tsx +17 -17
  23. package/src/Containers/OutletContainer.tsx +14 -14
  24. package/src/Containers/SubContainer.tsx +37 -37
  25. package/src/Containers/index.ts +7 -7
  26. package/src/DynamicTable/BasicPrintDynamicTable.tsx +73 -73
  27. package/src/DynamicTable/DynamicPrintTable.tsx +288 -288
  28. package/src/DynamicTable/DynamicTable.tsx +405 -405
  29. package/src/DynamicTable/GenericDynamicTable.tsx +456 -456
  30. package/src/DynamicTable/index.tsx +4 -4
  31. package/src/Footer/Footer.tsx +50 -50
  32. package/src/Footer/index.tsx +1 -1
  33. package/src/Form/Checkbox/index.tsx +96 -96
  34. package/src/Form/Checklist/index.tsx +35 -35
  35. package/src/Form/DatePicker/index.tsx +132 -132
  36. package/src/Form/DynamicBaculoForm/index.tsx +361 -361
  37. package/src/Form/FieldContainer/DoubleFieldContainer.tsx +35 -35
  38. package/src/Form/FieldContainer/QuadrupleFieldContainer.tsx +36 -36
  39. package/src/Form/FieldContainer/TripleFieldContainer.tsx +35 -35
  40. package/src/Form/FieldContainer/index.ts +3 -3
  41. package/src/Form/FileUpload/index.tsx +184 -184
  42. package/src/Form/FormButtons/index.tsx +78 -78
  43. package/src/Form/FormLayout/index.tsx +37 -37
  44. package/src/Form/SelectField/index.tsx +237 -237
  45. package/src/Form/TextArea/index.tsx +125 -125
  46. package/src/Form/TextField/index.tsx +194 -194
  47. package/src/Form/TimePicker/index.tsx +127 -127
  48. package/src/Form/YesNo/index.tsx +77 -77
  49. package/src/Form/index.ts +13 -13
  50. package/src/Labels/InfoLabel/index.tsx +21 -21
  51. package/src/Labels/index.tsx +1 -1
  52. package/src/Layouts/homeLayout/index.tsx +34 -34
  53. package/src/Layouts/index.ts +1 -1
  54. package/src/LineSeparator/LineSeparator.tsx +3 -3
  55. package/src/LineSeparator/index.tsx +1 -1
  56. package/src/Modal/Modal.tsx +104 -104
  57. package/src/Modal/index.tsx +1 -1
  58. package/src/NavBar/NavBar.tsx +223 -223
  59. package/src/NavBar/NavBar.types.ts +64 -64
  60. package/src/NavBar/NavBar.utils.ts +58 -58
  61. package/src/NavBar/index.tsx +5 -5
  62. package/src/ProgressBar/ProgressBar.tsx +25 -25
  63. package/src/ProgressBar/ProgressCircle.tsx +75 -75
  64. package/src/ProgressBar/index.tsx +2 -2
  65. package/src/Skeletons/LoadingInputSkeleton.tsx +12 -12
  66. package/src/Skeletons/index.ts +1 -1
  67. package/src/Tab/Tab.tsx +63 -63
  68. package/src/Tab/index.ts +1 -1
  69. package/src/Table/ZauruTable.tsx +265 -265
  70. package/src/Table/index.tsx +1 -1
  71. package/src/TaskList/TaskList.tsx +88 -88
  72. package/src/TaskList/index.ts +1 -1
  73. package/src/Titles/LabelArray.tsx +17 -17
  74. package/src/Titles/TableColumnTitle.tsx +9 -9
  75. package/src/Titles/TitleH1.tsx +10 -10
  76. package/src/Titles/TitleH2.tsx +10 -10
  77. package/src/Titles/TitleH3.tsx +10 -10
  78. package/src/Titles/index.ts +5 -5
  79. package/src/Tooltip/Tooltip.tsx +42 -42
  80. package/src/Tooltip/index.ts +1 -1
  81. package/src/WithTooltip/WithTooltip.tsx +21 -21
  82. package/src/WithTooltip/index.tsx +1 -1
  83. package/src/Wizards/StepWizard.tsx +88 -88
  84. package/src/Wizards/index.ts +1 -1
  85. package/src/Zendesk/Chat.tsx +83 -83
  86. package/src/Zendesk/index.ts +2 -2
  87. package/src/Zendesk/zendesk.config.ts +40 -40
  88. package/src/index.ts +24 -24
  89. package/src/postcss.config.mjs +5 -5
  90. package/src/tailwind.config.ts +10 -10
  91. package/src/tailwind.css +3 -3
  92. package/tsconfig.cjs.json +8 -8
  93. package/tsconfig.esm.json +11 -11
  94. package/tsconfig.json +17 -17
@@ -1,288 +1,288 @@
1
- import React, { useEffect, useCallback, useState, type ReactNode } from "react";
2
- import { TextFieldWithoutValidation } from "../Form/TextField/index.js";
3
- import { SelectFieldWithoutValidation } from "../Form/SelectField/index.js";
4
- import type { SingleValue } from "react-select";
5
- import { useAppSelector } from "@zauru-sdk/redux";
6
- import { SelectFieldOption } from "@zauru-sdk/types";
7
-
8
- export type TableStateItem = {
9
- item_id: string | undefined;
10
- quantity: number | undefined;
11
- };
12
-
13
- export type FormatedItem = {
14
- label: string;
15
- value: number;
16
- template: string;
17
- };
18
-
19
- type Props = {
20
- name: string;
21
- formName?: string;
22
- className?: string;
23
- items: FormatedItem[];
24
- onChange?: (tableState?: TableStateItem[]) => void;
25
- forwardedRef?: React.RefObject<{
26
- insertItems: (items: FormatedItem[]) => void;
27
- getTableState: (
28
- updatedData?: ReactNode[][]
29
- ) => TableStateItem[] | undefined;
30
- }>;
31
- };
32
-
33
- const errorAnimation = {
34
- hidden: { opacity: 0, y: -10 },
35
- visible: { opacity: 1, y: 0 },
36
- };
37
-
38
- export const DynamicPrintTable = ({ forwardedRef, ...props }: Props) => {
39
- const { items, onChange, className } = props;
40
- const { formValidations } = useAppSelector((state) => state.formValidation);
41
-
42
- const createItemSelect = (
43
- rowIndex: number,
44
- defaultValue?: SelectFieldOption
45
- ) => (
46
- <SelectFieldWithoutValidation
47
- key={rowIndex}
48
- name="item_select"
49
- isClearable
50
- onChange={(value: SingleValue<SelectFieldOption>) => {
51
- const selectedItem = items?.find((x) => x.value === value?.value);
52
- updateRow(rowIndex, selectedItem);
53
- }}
54
- options={items}
55
- defaultValue={defaultValue}
56
- />
57
- );
58
-
59
- const createItemQuantity = (rowIndex: number, defaultValue?: number) => (
60
- <TextFieldWithoutValidation
61
- key={rowIndex}
62
- name="item_quantity"
63
- type="number"
64
- integer
65
- defaultValue={defaultValue ?? 1}
66
- min={1}
67
- onChange={(value: string) => {
68
- updateRow(rowIndex, undefined, Number(value));
69
- }}
70
- />
71
- );
72
-
73
- const createTemplateName = (rowIndex: number, defaultValue?: string) => (
74
- <div key={rowIndex}>
75
- {defaultValue != "" ? defaultValue : "No hay etiqueta"}
76
- </div>
77
- );
78
-
79
- const createRow = (
80
- rowIndex: number,
81
- item?: FormatedItem,
82
- quantity?: number
83
- ) => {
84
- const itemCreated = createItemSelect(rowIndex, item ?? undefined);
85
- const quantityCreated = createItemQuantity(rowIndex, quantity ?? 1);
86
- const templateCreated = createTemplateName(
87
- rowIndex,
88
- item ? item.template : "Seleccione un item para visualizar su etiqueta."
89
- );
90
- return [itemCreated, quantityCreated, templateCreated];
91
- };
92
-
93
- const [tableData, setTableData] = useState<ReactNode[][] | undefined>([]);
94
- const [isInitialItemAdded, setIsInitialItemAdded] = useState<boolean>(false);
95
-
96
- const insertItems = useCallback(
97
- (newItems: FormatedItem[]) => {
98
- setTableData((prevData) => [
99
- ...(prevData ?? []),
100
- ...newItems.map((item, index) => {
101
- const rowIndex = (prevData?.length ?? 0) + index;
102
- const [itemCreated, quantityCreated, templateCreated] = createRow(
103
- rowIndex,
104
- item
105
- );
106
- updateRow(rowIndex, item, 1);
107
- return [itemCreated, quantityCreated, templateCreated];
108
- }),
109
- ]);
110
- },
111
- [items]
112
- );
113
-
114
- const getTableState = (temp?: ReactNode[][]) => {
115
- const updatedData = temp ?? tableData;
116
- const tableState = updatedData?.map((rowData) => {
117
- const firstElement = rowData[0];
118
- const item_id = React.isValidElement(firstElement)
119
- ? firstElement.props.defaultValue?.value
120
- : undefined;
121
-
122
- const secondElement = rowData[1];
123
- const quantity = React.isValidElement(secondElement)
124
- ? secondElement.props.defaultValue
125
- : undefined;
126
-
127
- return {
128
- item_id,
129
- quantity,
130
- } as TableStateItem;
131
- });
132
- return tableState;
133
- };
134
-
135
- const updateRow = (
136
- rowIndex: number,
137
- item?: FormatedItem,
138
- quantity?: number
139
- ) => {
140
- setTableData((prevData) => {
141
- const updatedData = prevData?.map((_, index) => {
142
- if (index === rowIndex) {
143
- const firstElement = prevData[index][0];
144
- const selectedItem =
145
- item ??
146
- (React.isValidElement(firstElement)
147
- ? items?.find(
148
- (x) => x.value === firstElement.props.defaultValue?.value
149
- )
150
- : undefined);
151
-
152
- const secondElement = prevData[index][1];
153
- const newQuantity = quantity
154
- ? quantity
155
- : React.isValidElement(secondElement)
156
- ? secondElement.props.defaultValue
157
- : undefined;
158
-
159
- return createRow(rowIndex, selectedItem, newQuantity);
160
- } else {
161
- return prevData[index];
162
- }
163
- });
164
-
165
- if (onChange) {
166
- const tableState = getTableState(updatedData);
167
-
168
- onChange(tableState);
169
- }
170
-
171
- return updatedData;
172
- });
173
- };
174
-
175
- const addRow = () => {
176
- setTableData((prevData) => [
177
- ...(prevData ?? []),
178
- createRow(prevData?.length ?? 0),
179
- ]);
180
- };
181
-
182
- const removeRow = (rowIndex: number) => {
183
- setTableData((prevData) =>
184
- prevData?.filter((_, index) => index !== rowIndex)
185
- );
186
- };
187
-
188
- React.useImperativeHandle(forwardedRef, () => ({
189
- insertItems,
190
- getTableState,
191
- }));
192
-
193
- const pastelGrayBackground = {
194
- backgroundColor: "#B69E99",
195
- } as React.CSSProperties;
196
-
197
- const renderHeader = () => (
198
- <tr style={{ ...pastelGrayBackground }}>
199
- <th className="text-left align-middle p-2">Item</th>
200
- <th className="text-left align-middle p-2">Cantidad</th>
201
- <th className="text-left align-middle p-2">Etiqueta</th>
202
- <th className="w-16"></th>
203
- </tr>
204
- );
205
-
206
- const renderRow = (rowData: ReactNode[], rowIndex: number) => (
207
- <tr key={rowIndex}>
208
- {rowData.map((cellData, cellIndex) => (
209
- <td key={cellIndex} className="align-middle p-2">
210
- {cellData}
211
- </td>
212
- ))}
213
- {rowIndex !== 0 && (
214
- <td className="align-middle w-16">
215
- <button
216
- className="bg-red-500 hover:bg-red-600 font-bold py-1 px-2 rounded ml-2"
217
- onClick={(
218
- event: React.MouseEvent<HTMLButtonElement, MouseEvent>
219
- ) => {
220
- event.preventDefault();
221
- event.stopPropagation();
222
- removeRow(rowIndex);
223
- }}
224
- type="button"
225
- >
226
- x
227
- </button>
228
- </td>
229
- )}
230
- </tr>
231
- );
232
-
233
- const renderRows = () => {
234
- return tableData?.map((rowData, rowIndex) => renderRow(rowData, rowIndex));
235
- };
236
-
237
- const error = formValidations[props.formName ?? "-1"][props.name];
238
- const borderColor = error ? "border-red-500" : "border-transparent";
239
-
240
- useEffect(() => {
241
- if (!isInitialItemAdded && items?.length > 0) {
242
- insertItems([items[0]]);
243
- setIsInitialItemAdded(true);
244
- }
245
- }, [isInitialItemAdded, items, insertItems]);
246
-
247
- return (
248
- <div
249
- className={`${className} ${borderColor} border-2`}
250
- style={{ overflowX: "auto" }}
251
- >
252
- {!!error && <div className="text-red-500 text-sm mb-2">{error}</div>}
253
- <table className="w-full">
254
- <thead>{renderHeader()}</thead>
255
- <tbody>{renderRows()}</tbody>
256
- <tfoot>
257
- <tr>
258
- <td className="align-middle">
259
- <button
260
- className="bg-blue-500 hover:bg-blue-600 font-bold py-2 px-4 rounded"
261
- onClick={(
262
- event: React.MouseEvent<HTMLButtonElement, MouseEvent>
263
- ) => {
264
- event.preventDefault();
265
- event.stopPropagation();
266
- addRow();
267
- }}
268
- type="button"
269
- >
270
- +
271
- </button>
272
- </td>
273
- <td colSpan={2}>
274
- Total de etiquetas a imprimir:{" "}
275
- {tableData?.reduce((sum, x) => {
276
- const val = React.isValidElement(x[1])
277
- ? x[1]?.props?.defaultValue
278
- : undefined;
279
- if (!sum) return val;
280
- return sum + val;
281
- }, 0)}
282
- </td>
283
- </tr>
284
- </tfoot>
285
- </table>
286
- </div>
287
- );
288
- };
1
+ import React, { useEffect, useCallback, useState, type ReactNode } from "react";
2
+ import { TextFieldWithoutValidation } from "../Form/TextField/index.js";
3
+ import { SelectFieldWithoutValidation } from "../Form/SelectField/index.js";
4
+ import type { SingleValue } from "react-select";
5
+ import { useAppSelector } from "@zauru-sdk/redux";
6
+ import { SelectFieldOption } from "@zauru-sdk/types";
7
+
8
+ export type TableStateItem = {
9
+ item_id: string | undefined;
10
+ quantity: number | undefined;
11
+ };
12
+
13
+ export type FormatedItem = {
14
+ label: string;
15
+ value: number;
16
+ template: string;
17
+ };
18
+
19
+ type Props = {
20
+ name: string;
21
+ formName?: string;
22
+ className?: string;
23
+ items: FormatedItem[];
24
+ onChange?: (tableState?: TableStateItem[]) => void;
25
+ forwardedRef?: React.RefObject<{
26
+ insertItems: (items: FormatedItem[]) => void;
27
+ getTableState: (
28
+ updatedData?: ReactNode[][]
29
+ ) => TableStateItem[] | undefined;
30
+ }>;
31
+ };
32
+
33
+ const errorAnimation = {
34
+ hidden: { opacity: 0, y: -10 },
35
+ visible: { opacity: 1, y: 0 },
36
+ };
37
+
38
+ export const DynamicPrintTable = ({ forwardedRef, ...props }: Props) => {
39
+ const { items, onChange, className } = props;
40
+ const { formValidations } = useAppSelector((state) => state.formValidation);
41
+
42
+ const createItemSelect = (
43
+ rowIndex: number,
44
+ defaultValue?: SelectFieldOption
45
+ ) => (
46
+ <SelectFieldWithoutValidation
47
+ key={rowIndex}
48
+ name="item_select"
49
+ isClearable
50
+ onChange={(value: SingleValue<SelectFieldOption>) => {
51
+ const selectedItem = items?.find((x) => x.value === value?.value);
52
+ updateRow(rowIndex, selectedItem);
53
+ }}
54
+ options={items}
55
+ defaultValue={defaultValue}
56
+ />
57
+ );
58
+
59
+ const createItemQuantity = (rowIndex: number, defaultValue?: number) => (
60
+ <TextFieldWithoutValidation
61
+ key={rowIndex}
62
+ name="item_quantity"
63
+ type="number"
64
+ integer
65
+ defaultValue={defaultValue ?? 1}
66
+ min={1}
67
+ onChange={(value: string) => {
68
+ updateRow(rowIndex, undefined, Number(value));
69
+ }}
70
+ />
71
+ );
72
+
73
+ const createTemplateName = (rowIndex: number, defaultValue?: string) => (
74
+ <div key={rowIndex}>
75
+ {defaultValue != "" ? defaultValue : "No hay etiqueta"}
76
+ </div>
77
+ );
78
+
79
+ const createRow = (
80
+ rowIndex: number,
81
+ item?: FormatedItem,
82
+ quantity?: number
83
+ ) => {
84
+ const itemCreated = createItemSelect(rowIndex, item ?? undefined);
85
+ const quantityCreated = createItemQuantity(rowIndex, quantity ?? 1);
86
+ const templateCreated = createTemplateName(
87
+ rowIndex,
88
+ item ? item.template : "Seleccione un item para visualizar su etiqueta."
89
+ );
90
+ return [itemCreated, quantityCreated, templateCreated];
91
+ };
92
+
93
+ const [tableData, setTableData] = useState<ReactNode[][] | undefined>([]);
94
+ const [isInitialItemAdded, setIsInitialItemAdded] = useState<boolean>(false);
95
+
96
+ const insertItems = useCallback(
97
+ (newItems: FormatedItem[]) => {
98
+ setTableData((prevData) => [
99
+ ...(prevData ?? []),
100
+ ...newItems.map((item, index) => {
101
+ const rowIndex = (prevData?.length ?? 0) + index;
102
+ const [itemCreated, quantityCreated, templateCreated] = createRow(
103
+ rowIndex,
104
+ item
105
+ );
106
+ updateRow(rowIndex, item, 1);
107
+ return [itemCreated, quantityCreated, templateCreated];
108
+ }),
109
+ ]);
110
+ },
111
+ [items]
112
+ );
113
+
114
+ const getTableState = (temp?: ReactNode[][]) => {
115
+ const updatedData = temp ?? tableData;
116
+ const tableState = updatedData?.map((rowData) => {
117
+ const firstElement = rowData[0];
118
+ const item_id = React.isValidElement(firstElement)
119
+ ? firstElement.props.defaultValue?.value
120
+ : undefined;
121
+
122
+ const secondElement = rowData[1];
123
+ const quantity = React.isValidElement(secondElement)
124
+ ? secondElement.props.defaultValue
125
+ : undefined;
126
+
127
+ return {
128
+ item_id,
129
+ quantity,
130
+ } as TableStateItem;
131
+ });
132
+ return tableState;
133
+ };
134
+
135
+ const updateRow = (
136
+ rowIndex: number,
137
+ item?: FormatedItem,
138
+ quantity?: number
139
+ ) => {
140
+ setTableData((prevData) => {
141
+ const updatedData = prevData?.map((_, index) => {
142
+ if (index === rowIndex) {
143
+ const firstElement = prevData[index][0];
144
+ const selectedItem =
145
+ item ??
146
+ (React.isValidElement(firstElement)
147
+ ? items?.find(
148
+ (x) => x.value === firstElement.props.defaultValue?.value
149
+ )
150
+ : undefined);
151
+
152
+ const secondElement = prevData[index][1];
153
+ const newQuantity = quantity
154
+ ? quantity
155
+ : React.isValidElement(secondElement)
156
+ ? secondElement.props.defaultValue
157
+ : undefined;
158
+
159
+ return createRow(rowIndex, selectedItem, newQuantity);
160
+ } else {
161
+ return prevData[index];
162
+ }
163
+ });
164
+
165
+ if (onChange) {
166
+ const tableState = getTableState(updatedData);
167
+
168
+ onChange(tableState);
169
+ }
170
+
171
+ return updatedData;
172
+ });
173
+ };
174
+
175
+ const addRow = () => {
176
+ setTableData((prevData) => [
177
+ ...(prevData ?? []),
178
+ createRow(prevData?.length ?? 0),
179
+ ]);
180
+ };
181
+
182
+ const removeRow = (rowIndex: number) => {
183
+ setTableData((prevData) =>
184
+ prevData?.filter((_, index) => index !== rowIndex)
185
+ );
186
+ };
187
+
188
+ React.useImperativeHandle(forwardedRef, () => ({
189
+ insertItems,
190
+ getTableState,
191
+ }));
192
+
193
+ const pastelGrayBackground = {
194
+ backgroundColor: "#B69E99",
195
+ } as React.CSSProperties;
196
+
197
+ const renderHeader = () => (
198
+ <tr style={{ ...pastelGrayBackground }}>
199
+ <th className="text-left align-middle p-2">Item</th>
200
+ <th className="text-left align-middle p-2">Cantidad</th>
201
+ <th className="text-left align-middle p-2">Etiqueta</th>
202
+ <th className="w-16"></th>
203
+ </tr>
204
+ );
205
+
206
+ const renderRow = (rowData: ReactNode[], rowIndex: number) => (
207
+ <tr key={rowIndex}>
208
+ {rowData.map((cellData, cellIndex) => (
209
+ <td key={cellIndex} className="align-middle p-2">
210
+ {cellData}
211
+ </td>
212
+ ))}
213
+ {rowIndex !== 0 && (
214
+ <td className="align-middle w-16">
215
+ <button
216
+ className="bg-red-500 hover:bg-red-600 font-bold py-1 px-2 rounded ml-2"
217
+ onClick={(
218
+ event: React.MouseEvent<HTMLButtonElement, MouseEvent>
219
+ ) => {
220
+ event.preventDefault();
221
+ event.stopPropagation();
222
+ removeRow(rowIndex);
223
+ }}
224
+ type="button"
225
+ >
226
+ x
227
+ </button>
228
+ </td>
229
+ )}
230
+ </tr>
231
+ );
232
+
233
+ const renderRows = () => {
234
+ return tableData?.map((rowData, rowIndex) => renderRow(rowData, rowIndex));
235
+ };
236
+
237
+ const error = formValidations[props.formName ?? "-1"][props.name];
238
+ const borderColor = error ? "border-red-500" : "border-transparent";
239
+
240
+ useEffect(() => {
241
+ if (!isInitialItemAdded && items?.length > 0) {
242
+ insertItems([items[0]]);
243
+ setIsInitialItemAdded(true);
244
+ }
245
+ }, [isInitialItemAdded, items, insertItems]);
246
+
247
+ return (
248
+ <div
249
+ className={`${className} ${borderColor} border-2`}
250
+ style={{ overflowX: "auto" }}
251
+ >
252
+ {!!error && <div className="text-red-500 text-sm mb-2">{error}</div>}
253
+ <table className="w-full">
254
+ <thead>{renderHeader()}</thead>
255
+ <tbody>{renderRows()}</tbody>
256
+ <tfoot>
257
+ <tr>
258
+ <td className="align-middle">
259
+ <button
260
+ className="bg-blue-500 hover:bg-blue-600 font-bold py-2 px-4 rounded"
261
+ onClick={(
262
+ event: React.MouseEvent<HTMLButtonElement, MouseEvent>
263
+ ) => {
264
+ event.preventDefault();
265
+ event.stopPropagation();
266
+ addRow();
267
+ }}
268
+ type="button"
269
+ >
270
+ +
271
+ </button>
272
+ </td>
273
+ <td colSpan={2}>
274
+ Total de etiquetas a imprimir:{" "}
275
+ {tableData?.reduce((sum, x) => {
276
+ const val = React.isValidElement(x[1])
277
+ ? x[1]?.props?.defaultValue
278
+ : undefined;
279
+ if (!sum) return val;
280
+ return sum + val;
281
+ }, 0)}
282
+ </td>
283
+ </tr>
284
+ </tfoot>
285
+ </table>
286
+ </div>
287
+ );
288
+ };