@moontra/moonui-pro 2.3.5 → 2.3.7
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.mjs +67 -38
- package/package.json +2 -2
- package/src/components/data-table/index.tsx +102 -76
- package/src/styles/design-system.css +303 -306
- package/src/styles/tailwind.css +6 -5
|
@@ -321,85 +321,111 @@ export function DataTable<TData, TValue>({
|
|
|
321
321
|
))}
|
|
322
322
|
</thead>
|
|
323
323
|
<tbody className="moonui-data-table-body">
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
>
|
|
333
|
-
<
|
|
334
|
-
<
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
table.getRowModel().rows.
|
|
324
|
+
{isPaginationLoading ? (
|
|
325
|
+
<motion.tr
|
|
326
|
+
key="loading"
|
|
327
|
+
initial={{ opacity: 0 }}
|
|
328
|
+
animate={{ opacity: 1 }}
|
|
329
|
+
exit={{ opacity: 0 }}
|
|
330
|
+
transition={{ duration: 0.2 }}
|
|
331
|
+
>
|
|
332
|
+
<td colSpan={columns.length} className="h-24 text-center">
|
|
333
|
+
<div className="flex items-center justify-center space-x-2">
|
|
334
|
+
<span suppressHydrationWarning><Loader2 className="h-4 w-4 animate-spin" /></span>
|
|
335
|
+
<span className="text-sm text-muted-foreground">Loading...</span>
|
|
336
|
+
</div>
|
|
337
|
+
</td>
|
|
338
|
+
</motion.tr>
|
|
339
|
+
) : table.getRowModel().rows?.length ? (
|
|
340
|
+
<>
|
|
341
|
+
{table.getRowModel().rows.map((row, index) => {
|
|
342
342
|
const rowId = (row.original as any).id || row.id
|
|
343
343
|
const isExpanded = enableExpandable && expandedRows.has(rowId)
|
|
344
344
|
|
|
345
|
-
|
|
346
|
-
<
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
345
|
+
return (
|
|
346
|
+
<React.Fragment key={row.id}>
|
|
347
|
+
<motion.tr
|
|
348
|
+
initial={false}
|
|
349
|
+
animate={{ opacity: 1 }}
|
|
350
|
+
className={cn(
|
|
351
|
+
"border-b transition-colors hover:bg-muted/50",
|
|
352
|
+
row.getIsSelected() && "bg-muted",
|
|
353
|
+
isExpanded && "border-b-0"
|
|
354
|
+
)}
|
|
355
|
+
>
|
|
356
|
+
{row.getVisibleCells().map((cell) => (
|
|
357
|
+
<td key={cell.id} className="moonui-data-table-td p-4 align-middle">
|
|
358
|
+
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
|
359
|
+
</td>
|
|
360
|
+
))}
|
|
361
|
+
</motion.tr>
|
|
362
|
+
|
|
363
|
+
<AnimatePresence initial={false}>
|
|
364
|
+
{isExpanded && renderSubComponent && (
|
|
365
|
+
<motion.tr
|
|
366
|
+
key={`${row.id}-expanded`}
|
|
367
|
+
initial={{ height: 0, opacity: 0 }}
|
|
368
|
+
animate={{
|
|
369
|
+
height: "auto",
|
|
370
|
+
opacity: 1,
|
|
371
|
+
transition: {
|
|
372
|
+
height: {
|
|
373
|
+
duration: 0.3,
|
|
374
|
+
ease: "easeOut"
|
|
375
|
+
},
|
|
376
|
+
opacity: {
|
|
377
|
+
duration: 0.2,
|
|
378
|
+
delay: 0.1
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}}
|
|
382
|
+
exit={{
|
|
383
|
+
height: 0,
|
|
384
|
+
opacity: 0,
|
|
385
|
+
transition: {
|
|
386
|
+
height: {
|
|
387
|
+
duration: 0.3,
|
|
388
|
+
ease: "easeIn"
|
|
389
|
+
},
|
|
390
|
+
opacity: {
|
|
391
|
+
duration: 0.2
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}}
|
|
395
|
+
style={{ overflow: "hidden" }}
|
|
396
|
+
className="border-b"
|
|
397
|
+
>
|
|
398
|
+
<td colSpan={columns.length} className="p-0">
|
|
399
|
+
<motion.div
|
|
400
|
+
initial={{ y: -10 }}
|
|
401
|
+
animate={{ y: 0 }}
|
|
402
|
+
exit={{ y: -10 }}
|
|
403
|
+
transition={{ duration: 0.2 }}
|
|
404
|
+
className="border-t border-border/50"
|
|
405
|
+
>
|
|
406
|
+
{renderSubComponent({ row: { original: row.original, id: rowId } })}
|
|
407
|
+
</motion.div>
|
|
408
|
+
</td>
|
|
409
|
+
</motion.tr>
|
|
410
|
+
)}
|
|
411
|
+
</AnimatePresence>
|
|
412
|
+
</React.Fragment>
|
|
413
|
+
);
|
|
414
|
+
})}
|
|
415
|
+
</>
|
|
416
|
+
) : (
|
|
417
|
+
<motion.tr
|
|
418
|
+
key="no-results"
|
|
419
|
+
initial={{ opacity: 0 }}
|
|
420
|
+
animate={{ opacity: 1 }}
|
|
421
|
+
exit={{ opacity: 0 }}
|
|
422
|
+
transition={{ duration: 0.2 }}
|
|
423
|
+
>
|
|
424
|
+
<td colSpan={columns.length} className="h-24 text-center">
|
|
425
|
+
No results found.
|
|
426
|
+
</td>
|
|
427
|
+
</motion.tr>
|
|
428
|
+
)}
|
|
403
429
|
</tbody>
|
|
404
430
|
</table>
|
|
405
431
|
</div>
|