"use client"; import * as React from "react"; import { cn } from "./lib/utils"; export interface SwipeAction { id: string; label: string; tone?: "accent" | "danger"; onSelect?: (id: string) => void; } export interface SwipeActionsProps extends React.HTMLAttributes { actions?: SwipeAction[]; children?: React.ReactNode; } const FALLBACK: SwipeAction[] = [ { id: "pin", label: "Pin" }, { id: "void", label: "Void", tone: "danger" }, ]; /** Swipeable row revealing stub actions. */ export function SwipeActions({ actions = FALLBACK, children, className, ...props }: SwipeActionsProps) { const [revealed, setRevealed] = React.useState(false); const startX = React.useRef(0); return (
{actions.map((a) => ( ))}
{ startX.current = e.touches[0].clientX; }} onTouchEnd={(e) => { const dx = e.changedTouches[0].clientX - startX.current; if (dx < -40) setRevealed(true); if (dx > 40) setRevealed(false); }} >
); }