https://dev.kronoz.win/r/marzneshin.git
1import { Row } from "@tanstack/react-table"
2import { type PropsWithChildren, useCallback } from 'react'
3import {
4 type ColumnActions
5} from "@marzneshin/features/entity-table";
6
7interface NoPropogationButtonProps<T> {
8 actions: ColumnActions<T>,
9 row: Row<T>,
10}
11
12export function NoPropogationButton<T>({ children, actions, row }: NoPropogationButtonProps<T> & PropsWithChildren) {
13 const handleKeyDown = useCallback((e: React.KeyboardEvent<HTMLDivElement>) => {
14 if (e.key === 'Enter' || e.key === ' ') {
15 e.preventDefault();
16 e.stopPropagation();
17 actions.onOpen(row.original);
18 }
19 }, [actions, row.original]);
20
21 return (
22 <div
23 className="flex flex-row gap-2 items-center"
24 onClick={(e) => e.stopPropagation()}
25 onKeyDown={handleKeyDown}
26 tabIndex={0}
27 role="button"
28 >
29 {children}
30 </div>
31 )
32}
33