"use client";
import * as React from "react";
import { MoreHorizontal } from "lucide-react";
import { Button } from "@/components/ui/button";
import { ActionSheet, type ActionSheetItem } from "@/components/ui/sheet";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import { useIsMobile } from "@/lib/client/hooks";
import { cn } from "@/lib/utils";
/**
* "⋯" actions for a list row / card. Phone: 44 px button + ActionSheet (also opened by the row's long-press through
* the controlled `open` prop). Desktop: hover-revealed icon button + dropdown.
*/
export function RowMenu({ items, title, open, onOpenChange, className, alwaysVisible }: { items: (ActionSheetItem | "separator")[]; title?: string; open?: boolean; onOpenChange?: (o: boolean) => void; className?: string; alwaysVisible?: boolean }) {
const isMobile = useIsMobile();
const [inner, setInner] = React.useState(false);
const isOpen = open ?? inner;
const setOpen = onOpenChange ?? setInner;
const label = title ? `Actions for ${title}` : "Actions";
if (isMobile) {
return (
<>
>
);
}
return (
e.stopPropagation()}>
{items.map((it, i) =>
it === "separator" ? (
) : (
{it.icon}
{it.label}
{it.hint ? {it.hint} : null}
{it.selected ? ✓ : null}
),
)}
);
}