fix: datatable toolbar (#12757)
* Fix toolbar * Slide animation * Animate out and fix selection model * Disable on mobile - fix tablet position --------- Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
1 parent
65a36b37c5
commit
eb909cc87a
4 files changed
+32
-19
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import type { Table } from "@tanstack/react-table";
|
||||
import { motion, AnimatePresence } from "framer-motion";
|
||||
import { Fragment } from "react";
|
||||
|
||||
import type { SVGComponent } from "@calcom/types/SVGComponent";
|
||||
@@ -24,23 +25,30 @@ interface DataTableSelectionBarProps<TData> {
|
||||
|
||||
export function DataTableSelectionBar<TData>({ table, actions }: DataTableSelectionBarProps<TData>) {
|
||||
const numberOfSelectedRows = table.getSelectedRowModel().rows.length;
|
||||
|
||||
if (numberOfSelectedRows === 0) return null;
|
||||
const isVisible = numberOfSelectedRows > 0;
|
||||
|
||||
return (
|
||||
<div className="bg-brand-default text-brand item-center absolute bottom-0 left-1/2 flex -translate-x-1/2 gap-4 rounded-lg p-2">
|
||||
<div className="text-brand-subtle my-auto px-2">{numberOfSelectedRows} selected</div>
|
||||
{actions?.map((action, index) => (
|
||||
<Fragment key={index}>
|
||||
{action.type === "action" ? (
|
||||
<Button aria-label={action.label} onClick={action.onClick} StartIcon={action.icon}>
|
||||
{action.label}
|
||||
</Button>
|
||||
) : action.type === "render" ? (
|
||||
action.render(table)
|
||||
) : null}
|
||||
</Fragment>
|
||||
))}
|
||||
</div>
|
||||
<AnimatePresence>
|
||||
{isVisible ? (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 0 }}
|
||||
animate={{ opacity: 1, y: 20 }}
|
||||
exit={{ opacity: 0, y: 0 }}
|
||||
className="bg-brand-default text-brand item-center fixed bottom-6 left-1/4 hidden gap-4 rounded-lg p-2 md:flex lg:left-1/2">
|
||||
<div className="text-brand-subtle my-auto px-2">{numberOfSelectedRows} selected</div>
|
||||
{actions?.map((action, index) => (
|
||||
<Fragment key={index}>
|
||||
{action.type === "action" ? (
|
||||
<Button aria-label={action.label} onClick={action.onClick} StartIcon={action.icon}>
|
||||
{action.label}
|
||||
</Button>
|
||||
) : action.type === "render" ? (
|
||||
action.render(table)
|
||||
) : null}
|
||||
</Fragment>
|
||||
))}
|
||||
</motion.div>
|
||||
) : null}
|
||||
</AnimatePresence>
|
||||
);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ export function DataTable<TData, TValue>({
|
||||
virtualRows.length > 0 ? totalSize - (virtualRows?.[virtualRows.length - 1]?.end || 0) : 0;
|
||||
|
||||
return (
|
||||
<div className="relative space-y-4">
|
||||
<div className="space-y-4">
|
||||
<DataTableToolbar
|
||||
table={table}
|
||||
filterableItems={filterableItems}
|
||||
|
||||
Reference in new issue
Block a user