next-recomponents 2.0.55 → 2.0.57
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/index.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +421 -229
- package/dist/index.mjs +410 -220
- package/package.json +1 -1
- package/src/index.tsx +2 -0
- package/src/table-advanced/h.table.tsx +325 -267
- package/src/table-advanced/header.tsx +8 -6
- package/src/table-advanced/icons.tsx +37 -0
- package/src/table-advanced/searchable.tsx +1 -1
- package/src/table-advanced/use.pagination.tsx +59 -0
- package/src/tabs/index.tsx +83 -0
|
@@ -10,12 +10,13 @@ import React, {
|
|
|
10
10
|
import Pre from "../pre";
|
|
11
11
|
import { ContextType } from "./context";
|
|
12
12
|
import { Header } from "./header";
|
|
13
|
-
import { ExcelIcon, SearchIcon } from "./icons";
|
|
13
|
+
import { ExcelIcon, NextIcon, PrevIcon, SearchIcon } from "./icons";
|
|
14
14
|
import Searchable from "./searchable";
|
|
15
15
|
import Modal from "../modal";
|
|
16
16
|
import { EditIcon } from "./icons";
|
|
17
17
|
import regularExpresions, { TableProps } from "./types";
|
|
18
18
|
import { valueFormatter } from "./formatter";
|
|
19
|
+
import usePaginacion from "./use.pagination";
|
|
19
20
|
type Widths = Record<string, number>;
|
|
20
21
|
export default function HTable({
|
|
21
22
|
context,
|
|
@@ -120,15 +121,7 @@ export default function HTable({
|
|
|
120
121
|
sizeadosLength -
|
|
121
122
|
personalizados.length -
|
|
122
123
|
ocultos.length);
|
|
123
|
-
|
|
124
|
-
w,
|
|
125
|
-
ancho,
|
|
126
|
-
sizeadosWidth,
|
|
127
|
-
personalizadosSum,
|
|
128
|
-
headers,
|
|
129
|
-
sizeadosLength,
|
|
130
|
-
personalizados,
|
|
131
|
-
});
|
|
124
|
+
|
|
132
125
|
setWidths(
|
|
133
126
|
Object.fromEntries(
|
|
134
127
|
headers.map((h) => [
|
|
@@ -152,12 +145,13 @@ export default function HTable({
|
|
|
152
145
|
String(value).toLowerCase().includes(context.searchBy.toLowerCase()),
|
|
153
146
|
);
|
|
154
147
|
});
|
|
148
|
+
const pagination = usePaginacion({ total: searchedData.length });
|
|
155
149
|
return (
|
|
156
150
|
<div
|
|
157
151
|
className={[
|
|
158
152
|
context.className,
|
|
159
153
|
"bg-white relative",
|
|
160
|
-
"p-2 border shadow rounded-2xl",
|
|
154
|
+
"p-2 border shadow rounded-2xl w-full rounded-lg ",
|
|
161
155
|
].join(" ")}
|
|
162
156
|
ref={tableRef}
|
|
163
157
|
>
|
|
@@ -180,10 +174,11 @@ export default function HTable({
|
|
|
180
174
|
}
|
|
181
175
|
return obj;
|
|
182
176
|
}),
|
|
177
|
+
`${context.exportName}.xlsx`,
|
|
183
178
|
);
|
|
184
179
|
}}
|
|
185
180
|
className={
|
|
186
|
-
"flex gap-1 items-center border shadow rounded p-1 text-white bg-green-800
|
|
181
|
+
"flex gap-1 items-center border shadow rounded p-1 text-white bg-green-800 p-1 text-xs"
|
|
187
182
|
}
|
|
188
183
|
>
|
|
189
184
|
<ExcelIcon />
|
|
@@ -193,8 +188,7 @@ export default function HTable({
|
|
|
193
188
|
{context.onSelect && (
|
|
194
189
|
<button
|
|
195
190
|
className={
|
|
196
|
-
"border shadow rounded p-1 text-white
|
|
197
|
-
(context.selected.length > 0 ? "bg-blue-500" : "bg-gray-500")
|
|
191
|
+
"border shadow rounded p-1 text-white p-1 text-xs bg-blue-500 cursor-pointer "
|
|
198
192
|
}
|
|
199
193
|
disabled={context.selected.length == 0}
|
|
200
194
|
onClick={async (e) => {
|
|
@@ -215,7 +209,9 @@ export default function HTable({
|
|
|
215
209
|
)}
|
|
216
210
|
{context.onSave && (
|
|
217
211
|
<button
|
|
218
|
-
className={
|
|
212
|
+
className={
|
|
213
|
+
"border shadow rounded p-1 text-white p-1 text-xs bg-blue-500 cursor-pointer "
|
|
214
|
+
}
|
|
219
215
|
onClick={async (e) => {
|
|
220
216
|
setIsloading(true);
|
|
221
217
|
const ex = context.filteredData.map((d) => {
|
|
@@ -230,278 +226,340 @@ export default function HTable({
|
|
|
230
226
|
</button>
|
|
231
227
|
)}
|
|
232
228
|
</div>
|
|
233
|
-
<div
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
cursor: "col-resize",
|
|
259
|
-
background: "transparent",
|
|
260
|
-
}}
|
|
261
|
-
onMouseEnter={(e) =>
|
|
262
|
-
(e.currentTarget.style.background =
|
|
263
|
-
"var(--border-strong, #ccc)")
|
|
264
|
-
}
|
|
265
|
-
onMouseLeave={(e) =>
|
|
266
|
-
(e.currentTarget.style.background = "transparent")
|
|
267
|
-
}
|
|
229
|
+
<div
|
|
230
|
+
// className={["grid w-full bg-green-100"].join(" ")}
|
|
231
|
+
// style={{ gridTemplateColumns }}
|
|
232
|
+
>
|
|
233
|
+
<div
|
|
234
|
+
style={{
|
|
235
|
+
gridTemplateColumns,
|
|
236
|
+
width: Object.values(widths).reduce((acc, i) => acc + i, 0),
|
|
237
|
+
}}
|
|
238
|
+
className={["grid w-full "].join(" ")}
|
|
239
|
+
>
|
|
240
|
+
{headers.map((header, i) => {
|
|
241
|
+
if (context?.hideColumns?.includes?.(header)) return null;
|
|
242
|
+
if (header.startsWith("_") && !header.startsWith("__")) return null;
|
|
243
|
+
return (
|
|
244
|
+
<div
|
|
245
|
+
key={header}
|
|
246
|
+
className="bg-white relative w-full bg-red-100"
|
|
247
|
+
// style={{ position: "relative" }}
|
|
248
|
+
>
|
|
249
|
+
<Header
|
|
250
|
+
padding={padding}
|
|
251
|
+
header={header}
|
|
252
|
+
context={context}
|
|
253
|
+
drag={{ gridTemplateColumns, startDrag, widths }}
|
|
268
254
|
/>
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
255
|
+
{/* {i < headers.length - 1 && (
|
|
256
|
+
<div
|
|
257
|
+
onMouseDown={(e) => startDrag(e, header)}
|
|
258
|
+
className="hover:bg-blue-100"
|
|
259
|
+
style={{
|
|
260
|
+
position: "absolute",
|
|
261
|
+
right: -3,
|
|
262
|
+
top: 0,
|
|
263
|
+
width: "15px",
|
|
264
|
+
height: "100%",
|
|
265
|
+
cursor: "col-resize",
|
|
266
|
+
background: "transparent",
|
|
267
|
+
}}
|
|
268
|
+
onMouseEnter={(e) =>
|
|
269
|
+
(e.currentTarget.style.background =
|
|
270
|
+
"var(--border-strong, #ccc)")
|
|
271
|
+
}
|
|
272
|
+
onMouseLeave={(e) =>
|
|
273
|
+
(e.currentTarget.style.background = "transparent")
|
|
274
|
+
}
|
|
275
|
+
/>
|
|
276
|
+
)} */}
|
|
277
|
+
</div>
|
|
278
|
+
);
|
|
279
|
+
})}
|
|
280
|
+
</div>
|
|
281
|
+
<div
|
|
282
|
+
style={{
|
|
283
|
+
gridTemplateColumns,
|
|
284
|
+
width: Object.values(widths).reduce((acc, i) => acc + i, 0),
|
|
285
|
+
}}
|
|
286
|
+
className={[
|
|
287
|
+
"grid max-h-[500px] overflow-hidden overflow-y-scroll ",
|
|
288
|
+
].join(" ")}
|
|
289
|
+
>
|
|
290
|
+
{searchedData
|
|
291
|
+
.slice(pagination.inicio - 1, pagination.fin)
|
|
292
|
+
.map((row, rowIndex) => {
|
|
293
|
+
const items: any[] = Object.entries(row);
|
|
275
294
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
295
|
+
return items.map(([key, item], i) => {
|
|
296
|
+
if (context?.hideColumns?.includes?.(key)) return null;
|
|
297
|
+
if (key.startsWith("_") && !key.startsWith("__")) return null;
|
|
279
298
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}}
|
|
288
|
-
className={
|
|
289
|
-
(rowIndex == currentIndex
|
|
290
|
-
? " bg-blue-100 "
|
|
291
|
-
: " bg-white ") +
|
|
292
|
-
" border-b p-2 flex items-center justify-center " +
|
|
293
|
-
(context.searchBy &&
|
|
294
|
-
String(item)
|
|
295
|
-
.toLowerCase()
|
|
296
|
-
.includes(context.searchBy.toLowerCase())
|
|
297
|
-
? "bg-yellow-100"
|
|
298
|
-
: "")
|
|
299
|
-
}
|
|
300
|
-
>
|
|
301
|
-
{context?.modalButton || (
|
|
302
|
-
<button
|
|
303
|
-
className="border shadow rounded bg-blue-500 text-white p-2 "
|
|
304
|
-
onClick={(e) => {
|
|
305
|
-
setCurrentIndex(rowIndex);
|
|
306
|
-
modalRef.current?.click();
|
|
299
|
+
if (key == "__modal__") {
|
|
300
|
+
return (
|
|
301
|
+
<div
|
|
302
|
+
onMouseEnter={(e) => setCurrentIndex(rowIndex)}
|
|
303
|
+
key={row.id + i}
|
|
304
|
+
style={{
|
|
305
|
+
height: `${padding}px`,
|
|
307
306
|
}}
|
|
307
|
+
className={
|
|
308
|
+
(rowIndex == currentIndex
|
|
309
|
+
? " bg-blue-100 "
|
|
310
|
+
: " bg-white ") +
|
|
311
|
+
" border-b p-2 flex items-center justify-center " +
|
|
312
|
+
(context.searchBy &&
|
|
313
|
+
String(item)
|
|
314
|
+
.toLowerCase()
|
|
315
|
+
.includes(context.searchBy.toLowerCase())
|
|
316
|
+
? "bg-yellow-100"
|
|
317
|
+
: "")
|
|
318
|
+
}
|
|
308
319
|
>
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
320
|
+
{context?.modalButton || (
|
|
321
|
+
<button
|
|
322
|
+
className="border shadow rounded bg-blue-500 text-white p-2 "
|
|
323
|
+
onClick={(e) => {
|
|
324
|
+
setCurrentIndex(rowIndex);
|
|
325
|
+
modalRef.current?.click();
|
|
326
|
+
}}
|
|
327
|
+
>
|
|
328
|
+
<EditIcon />
|
|
329
|
+
</button>
|
|
330
|
+
)}
|
|
331
|
+
</div>
|
|
332
|
+
);
|
|
333
|
+
}
|
|
315
334
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
>
|
|
337
|
-
<input
|
|
338
|
-
type="checkbox"
|
|
339
|
-
className="w-5 h-5 accent-blue-600 transition-all duration-300 checked:scale-110 "
|
|
340
|
-
checked={Boolean(
|
|
341
|
-
context.selected.find((s) => s == row?.id),
|
|
342
|
-
)}
|
|
343
|
-
onChange={(e) => {
|
|
344
|
-
const newSelected = [...context.selected];
|
|
345
|
-
const index = newSelected.findIndex((s) => s == row?.id);
|
|
346
|
-
if (index >= 0) {
|
|
347
|
-
newSelected.splice(index, 1);
|
|
348
|
-
} else {
|
|
349
|
-
newSelected.push(row?.id);
|
|
335
|
+
if (key == "__select__") {
|
|
336
|
+
return (
|
|
337
|
+
<div
|
|
338
|
+
key={row.id + i}
|
|
339
|
+
onMouseEnter={(e) => setCurrentIndex(rowIndex)}
|
|
340
|
+
style={{
|
|
341
|
+
height: `${padding}px`,
|
|
342
|
+
}}
|
|
343
|
+
className={
|
|
344
|
+
(rowIndex == currentIndex
|
|
345
|
+
? " bg-blue-100 "
|
|
346
|
+
: " bg-white ") +
|
|
347
|
+
" border-b flex items-start p-2 justify-center " +
|
|
348
|
+
(context.searchBy &&
|
|
349
|
+
String(item)
|
|
350
|
+
.toLowerCase()
|
|
351
|
+
.includes(context.searchBy.toLowerCase())
|
|
352
|
+
? "bg-yellow-100"
|
|
353
|
+
: "")
|
|
350
354
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
(context.searchBy &&
|
|
374
|
-
String(item)
|
|
375
|
-
.toLowerCase()
|
|
376
|
-
.includes(context.searchBy.toLowerCase())
|
|
377
|
-
? rowIndex == currentIndex
|
|
378
|
-
? " bg-yellow-200 "
|
|
379
|
-
: " bg-yellow-100 "
|
|
380
|
-
: "")
|
|
355
|
+
>
|
|
356
|
+
<input
|
|
357
|
+
type="checkbox"
|
|
358
|
+
className="w-5 h-5 accent-blue-600 transition-all duration-300 checked:scale-110 "
|
|
359
|
+
checked={Boolean(
|
|
360
|
+
context.selected.find((s) => s == row?.id),
|
|
361
|
+
)}
|
|
362
|
+
onChange={(e) => {
|
|
363
|
+
const newSelected = [...context.selected];
|
|
364
|
+
const index = newSelected.findIndex(
|
|
365
|
+
(s) => s == row?.id,
|
|
366
|
+
);
|
|
367
|
+
if (index >= 0) {
|
|
368
|
+
newSelected.splice(index, 1);
|
|
369
|
+
} else {
|
|
370
|
+
newSelected.push(row?.id);
|
|
371
|
+
}
|
|
372
|
+
context.setSelected(newSelected);
|
|
373
|
+
}}
|
|
374
|
+
/>
|
|
375
|
+
</div>
|
|
376
|
+
);
|
|
381
377
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
378
|
+
|
|
379
|
+
return (
|
|
380
|
+
<div
|
|
381
|
+
onMouseEnter={(e) => setCurrentIndex(rowIndex)}
|
|
382
|
+
key={row.id + i}
|
|
383
|
+
style={{
|
|
384
|
+
fontSize: context?.fontSize || "12px",
|
|
385
|
+
...(context?.wrapText
|
|
386
|
+
? { minHeight: `${padding}px` }
|
|
387
|
+
: { height: `${padding}px` }),
|
|
388
|
+
}}
|
|
387
389
|
className={
|
|
388
|
-
"
|
|
389
|
-
(
|
|
390
|
-
? "bg-blue-
|
|
391
|
-
: "bg-
|
|
390
|
+
" p-1" +
|
|
391
|
+
(rowIndex == currentIndex
|
|
392
|
+
? " bg-blue-100 "
|
|
393
|
+
: " bg-white ") +
|
|
394
|
+
(context.wrapText
|
|
395
|
+
? " text-wrap truncate "
|
|
396
|
+
: " truncate ") +
|
|
397
|
+
" border-b " +
|
|
398
|
+
(context.searchBy &&
|
|
399
|
+
String(item)
|
|
400
|
+
.toLowerCase()
|
|
401
|
+
.includes(context.searchBy.toLowerCase())
|
|
402
|
+
? rowIndex == currentIndex
|
|
403
|
+
? " bg-yellow-200 "
|
|
404
|
+
: " bg-yellow-100 "
|
|
405
|
+
: "")
|
|
392
406
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
407
|
+
>
|
|
408
|
+
{context?.editableFields &&
|
|
409
|
+
context.editableFields.includes(key) ? (
|
|
410
|
+
<input
|
|
411
|
+
defaultValue={item}
|
|
412
|
+
className={
|
|
413
|
+
"w-full " +
|
|
414
|
+
(context.editions.includes(row?.id)
|
|
415
|
+
? "bg-blue-400 text-white"
|
|
416
|
+
: "bg-blue-100")
|
|
417
|
+
}
|
|
418
|
+
onBlur={(e) => {
|
|
419
|
+
const id = row?.id;
|
|
420
|
+
const newData = [...context.data];
|
|
421
|
+
const index = newData.findIndex((d) => +d.id == +id);
|
|
422
|
+
newData[index][key] = e.target.value;
|
|
423
|
+
context.setData(newData);
|
|
399
424
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
425
|
+
const newEditions = [
|
|
426
|
+
...new Set([...context.editions, id]),
|
|
427
|
+
];
|
|
428
|
+
context.setEditions(newEditions);
|
|
429
|
+
}}
|
|
430
|
+
/>
|
|
431
|
+
) : context.buttons?.[key] ? (
|
|
432
|
+
React.cloneElement(context.buttons[key], {
|
|
433
|
+
// children: context.buttons[key]?.props?.children
|
|
434
|
+
// ? item
|
|
435
|
+
// : undefined,
|
|
436
|
+
value: item,
|
|
437
|
+
children: context.buttons[key]?.props?.children
|
|
438
|
+
? item
|
|
439
|
+
: null,
|
|
440
|
+
onClick: async (e: any) => {
|
|
441
|
+
const ret =
|
|
442
|
+
(await context.buttons[key].props?.onClick?.({
|
|
443
|
+
e,
|
|
444
|
+
row,
|
|
445
|
+
})) || {};
|
|
446
|
+
const newData = [...context.data];
|
|
447
|
+
const index = newData.findIndex(
|
|
448
|
+
(f) => f.id == row?.id,
|
|
449
|
+
);
|
|
450
|
+
newData[index] = { ...newData[index], ...ret };
|
|
451
|
+
context.setData(newData);
|
|
452
|
+
},
|
|
453
|
+
onChange: async (e: { target: { value: string } }) => {
|
|
454
|
+
const value = e.target.value;
|
|
455
|
+
const ret =
|
|
456
|
+
(await context.buttons[key].props?.onChange?.({
|
|
457
|
+
e,
|
|
458
|
+
row,
|
|
459
|
+
})) || {};
|
|
433
460
|
|
|
434
|
-
|
|
435
|
-
|
|
461
|
+
const newData = [...context.data];
|
|
462
|
+
const index = newData.findIndex(
|
|
463
|
+
(f) => f.id == row?.id,
|
|
464
|
+
);
|
|
436
465
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
466
|
+
if (index >= 0) {
|
|
467
|
+
newData[index][key] = value;
|
|
468
|
+
}
|
|
440
469
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
470
|
+
for (let i in ret) {
|
|
471
|
+
if (newData[index]?.[i]) {
|
|
472
|
+
const v = ret[i];
|
|
473
|
+
newData[index][i] = v;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
447
476
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
477
|
+
context.setData(newData);
|
|
478
|
+
},
|
|
479
|
+
})
|
|
480
|
+
) : ["number", "string"].includes(typeof item) ? (
|
|
481
|
+
valueFormatter({
|
|
482
|
+
value: item,
|
|
483
|
+
currentCoin: context.currentCoin,
|
|
484
|
+
})
|
|
485
|
+
) : React.isValidElement(item) ? (
|
|
486
|
+
item
|
|
487
|
+
) : (
|
|
488
|
+
JSON.stringify(item)
|
|
489
|
+
)}
|
|
490
|
+
</div>
|
|
491
|
+
);
|
|
492
|
+
});
|
|
493
|
+
})}
|
|
494
|
+
</div>
|
|
495
|
+
<div
|
|
496
|
+
style={{
|
|
497
|
+
gridTemplateColumns,
|
|
498
|
+
width: Object.values(widths).reduce((acc, i) => acc + i, 0),
|
|
499
|
+
}}
|
|
500
|
+
className={["grid border-b bg-white"].join(" ")}
|
|
501
|
+
>
|
|
502
|
+
{Object.keys(context?.footer || {}).length > 0 &&
|
|
503
|
+
headers.map((header) => {
|
|
504
|
+
if (context?.hideColumns?.includes?.(header)) return null;
|
|
505
|
+
if (header.startsWith("_") && !header.startsWith("__"))
|
|
506
|
+
return null;
|
|
507
|
+
return (
|
|
508
|
+
<div
|
|
509
|
+
key={header}
|
|
510
|
+
style={{
|
|
511
|
+
// height: `${padding}px`,
|
|
512
|
+
maxHeight: "100px",
|
|
513
|
+
}}
|
|
514
|
+
title={context.footer?.[header] + " de " + header}
|
|
515
|
+
className={
|
|
516
|
+
" cursor-default font-bold " +
|
|
517
|
+
" bg-white flex items-center justify-center" +
|
|
518
|
+
" border-r text-xs my-5 "
|
|
519
|
+
}
|
|
520
|
+
>
|
|
521
|
+
{valueFormatter({
|
|
454
522
|
currentCoin: context.currentCoin,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
item
|
|
458
|
-
) : (
|
|
459
|
-
JSON.stringify(item)
|
|
460
|
-
)}
|
|
461
|
-
</div>
|
|
462
|
-
);
|
|
463
|
-
});
|
|
464
|
-
})}
|
|
465
|
-
{Object.keys(context?.footer || {}).length > 0 &&
|
|
466
|
-
headers.map((header) => {
|
|
467
|
-
if (context?.hideColumns?.includes?.(header)) return null;
|
|
468
|
-
if (header.startsWith("_") && !header.startsWith("__")) return null;
|
|
469
|
-
return (
|
|
470
|
-
<div
|
|
471
|
-
key={header}
|
|
472
|
-
style={{
|
|
473
|
-
height: `${padding}px`,
|
|
474
|
-
maxHeight: "100px",
|
|
475
|
-
}}
|
|
476
|
-
className={
|
|
477
|
-
"border-b font-bold " +
|
|
478
|
-
" bg-white flex items-center justify-center"
|
|
479
|
-
}
|
|
480
|
-
>
|
|
481
|
-
{valueFormatter({
|
|
482
|
-
currentCoin: context.currentCoin,
|
|
483
|
-
value: context.footer?.[header]
|
|
484
|
-
? context.footer[header] == "sum"
|
|
485
|
-
? context.filteredData
|
|
486
|
-
.map((d) => +d[header])
|
|
487
|
-
.reduce((acc, h) => h + acc, 0)
|
|
488
|
-
: context.footer[header] == "count"
|
|
523
|
+
value: context.footer?.[header]
|
|
524
|
+
? context.footer[header] == "sum"
|
|
489
525
|
? context.filteredData
|
|
490
|
-
.map((d) =>
|
|
491
|
-
.reduce((acc
|
|
492
|
-
: context.footer[header] == "
|
|
526
|
+
.map((d) => +d[header])
|
|
527
|
+
.reduce((acc, h) => h + acc, 0)
|
|
528
|
+
: context.footer[header] == "count"
|
|
493
529
|
? context.filteredData
|
|
494
|
-
.map((d) => +d[header])
|
|
495
|
-
.reduce((acc, h) => h + acc, 0) /
|
|
496
|
-
context.filteredData
|
|
497
530
|
.map((d) => (d[header] != "" ? 1 : 0))
|
|
498
531
|
.reduce((acc: number, h) => acc + h, 0)
|
|
499
|
-
: ""
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
532
|
+
: context.footer[header] == "avg"
|
|
533
|
+
? context.filteredData
|
|
534
|
+
.map((d) => +d[header])
|
|
535
|
+
.reduce((acc, h) => h + acc, 0) /
|
|
536
|
+
context.filteredData
|
|
537
|
+
.map((d) => (d[header] != "" ? 1 : 0))
|
|
538
|
+
.reduce((acc: number, h) => acc + h, 0)
|
|
539
|
+
: ""
|
|
540
|
+
: "",
|
|
541
|
+
})}
|
|
542
|
+
</div>
|
|
543
|
+
);
|
|
544
|
+
})}
|
|
545
|
+
</div>
|
|
546
|
+
<div className="flex justify-end p-2">
|
|
547
|
+
{pagination.rango} de {pagination.total}
|
|
548
|
+
<div className="flex items-center gap-5 mx-5">
|
|
549
|
+
<button
|
|
550
|
+
onClick={(e) => pagination.hasPrev && pagination.prev()}
|
|
551
|
+
className={pagination.hasPrev ? "" : "text-gray-300"}
|
|
552
|
+
>
|
|
553
|
+
<PrevIcon />
|
|
554
|
+
</button>
|
|
555
|
+
<button
|
|
556
|
+
onClick={(e) => pagination.hasNext && pagination.next()}
|
|
557
|
+
className={pagination.hasNext ? "" : "text-gray-300"}
|
|
558
|
+
>
|
|
559
|
+
<NextIcon />
|
|
560
|
+
</button>
|
|
561
|
+
</div>
|
|
562
|
+
</div>
|
|
505
563
|
</div>
|
|
506
564
|
|
|
507
565
|
{context.modal && (
|