https://dev.kronoz.win/r/marzneshin.git
| 1 |
0178858 |
Dawsh |
2y ago |
import React from "react"; |
| 2 |
0178858 |
Dawsh |
2y ago |
import { Button, type ButtonProps } from "@marzneshin/components" |
| 3 |
0178858 |
Dawsh |
2y ago |
import { useSortableItem } from "./use-sortable-item"; |
| 4 |
0178858 |
Dawsh |
2y ago |
import { composeRefs, cn } from "@marzneshin/utils"; |
| 5 |
0178858 |
Dawsh |
2y ago |
|
| 6 |
0178858 |
Dawsh |
2y ago |
interface SortableDragHandleProps extends ButtonProps { |
| 7 |
0178858 |
Dawsh |
2y ago |
withHandle?: boolean |
| 8 |
0178858 |
Dawsh |
2y ago |
} |
| 9 |
0178858 |
Dawsh |
2y ago |
|
| 10 |
0178858 |
Dawsh |
2y ago |
export const SortableDragHandle = React.forwardRef< |
| 11 |
0178858 |
Dawsh |
2y ago |
HTMLButtonElement, |
| 12 |
0178858 |
Dawsh |
2y ago |
SortableDragHandleProps |
| 13 |
0178858 |
Dawsh |
2y ago |
>(({ className, ...props }, ref) => { |
| 14 |
0178858 |
Dawsh |
2y ago |
const { attributes, listeners } = useSortableItem() |
| 15 |
0178858 |
Dawsh |
2y ago |
|
| 16 |
0178858 |
Dawsh |
2y ago |
return ( |
| 17 |
0178858 |
Dawsh |
2y ago |
<Button |
| 18 |
0178858 |
Dawsh |
2y ago |
ref={composeRefs(ref)} |
| 19 |
0178858 |
Dawsh |
2y ago |
className={cn("cursor-grab", className)} |
| 20 |
0178858 |
Dawsh |
2y ago |
{...attributes} |
| 21 |
0178858 |
Dawsh |
2y ago |
{...listeners} |
| 22 |
0178858 |
Dawsh |
2y ago |
{...props} |
| 23 |
0178858 |
Dawsh |
2y ago |
/> |
| 24 |
0178858 |
Dawsh |
2y ago |
) |
| 25 |
0178858 |
Dawsh |
2y ago |
}) |
| 26 |
0178858 |
Dawsh |
2y ago |
SortableDragHandle.displayName = "SortableDragHandle" |