+27









sean-brydon
Udit Takkar
Hariom Balhara
Leo Giovanetti
Alex van Andel
CarinaWolli
zomars
Peer Richelsen
Joe Au-Yeung
Udit Takkar
Keith Williams
Peer Richelsen
Syed Ali Shahbaz
gitstart-calcom
Shivam Kalra
cherish2003
rkreddy99
varun thummar
Crowdin Bot
Pradumn Kumar
Richard Poelderl
mohammed hussam
Carina Wollendorfer
Anik Dhabal Babu
nicktrn
sydwardrae
Janakiram Yellapu
GitStart-Cal.com
sajanlamsal
Cherish
Danila
Neel Patel
Rama Krishna Reddy
Varun Thummar
Bhargav
Pratik Kumar
Ritesh Patil
10ffd9bacd
Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Hariom Balhara <[email protected]> Co-authored-by: Leo Giovanetti <[email protected]> Co-authored-by: Alex van Andel <[email protected]> Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: zomars <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Joe Au-Yeung <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Keith Williams <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Syed Ali Shahbaz <[email protected]> Co-authored-by: gitstart-calcom <[email protected]> Co-authored-by: Shivam Kalra <[email protected]> Co-authored-by: cherish2003 <[email protected]> Co-authored-by: sean-brydon <[email protected]> Co-authored-by: rkreddy99 <[email protected]> Co-authored-by: varun thummar <Varun> Co-authored-by: Crowdin Bot <[email protected]> Co-authored-by: Pradumn Kumar <[email protected]> Co-authored-by: Richard Poelderl <[email protected]> Co-authored-by: mohammed hussam <[email protected]> Co-authored-by: Carina Wollendorfer <[email protected]> Co-authored-by: Anik Dhabal Babu <[email protected]> Co-authored-by: nicktrn <[email protected]> Co-authored-by: sydwardrae <[email protected]> Co-authored-by: Janakiram Yellapu <[email protected]> Co-authored-by: GitStart-Cal.com <[email protected]> Co-authored-by: sajanlamsal <[email protected]> Co-authored-by: Cherish <[email protected]> Co-authored-by: Danila <[email protected]> Co-authored-by: Neel Patel <[email protected]> Co-authored-by: Rama Krishna Reddy <[email protected]> Co-authored-by: Varun Thummar <[email protected]> Co-authored-by: Bhargav <[email protected]> Co-authored-by: Pratik Kumar <[email protected]> Co-authored-by: Ritesh Patil <[email protected]>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import type { Table } from "@tanstack/react-table";
|
|
import { Fragment } from "react";
|
|
|
|
import type { SVGComponent } from "@calcom/types/SVGComponent";
|
|
|
|
import { Button } from "../button";
|
|
|
|
export type ActionItem<TData> =
|
|
| {
|
|
type: "action";
|
|
label: string;
|
|
onClick: () => void;
|
|
icon?: SVGComponent;
|
|
}
|
|
| {
|
|
type: "render";
|
|
render: (table: Table<TData>) => React.ReactNode;
|
|
};
|
|
|
|
interface DataTableSelectionBarProps<TData> {
|
|
table: Table<TData>;
|
|
actions?: ActionItem<TData>[];
|
|
}
|
|
|
|
export function DataTableSelectionBar<TData>({ table, actions }: DataTableSelectionBarProps<TData>) {
|
|
const numberOfSelectedRows = table.getSelectedRowModel().rows.length;
|
|
|
|
if (numberOfSelectedRows === 0) return null;
|
|
|
|
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>
|
|
);
|
|
}
|