2026-05-30 23:45:26 +08:00
|
|
|
import type { CSSProperties, ReactNode } from "react";
|
|
|
|
|
import type { LucideIcon } from "lucide-react";
|
|
|
|
|
|
|
|
|
|
import { StreamingLabelSheen } from "@/components/MessageBubble";
|
2026-09-08 16:00:54 +08:00
|
|
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
2026-05-30 23:45:26 +08:00
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
|
|
|
|
|
export type ActivityStepTone = "neutral" | "active" | "success" | "error";
|
|
|
|
|
|
|
|
|
|
export interface ActivityStepProps {
|
|
|
|
|
icon?: LucideIcon;
|
|
|
|
|
marker?: ReactNode;
|
|
|
|
|
label: ReactNode;
|
2026-07-22 22:35:39 +08:00
|
|
|
ariaLabel?: string;
|
2026-05-30 23:45:26 +08:00
|
|
|
active?: boolean;
|
|
|
|
|
tone?: ActivityStepTone;
|
|
|
|
|
className?: string;
|
|
|
|
|
contentClassName?: string;
|
2026-07-22 22:35:39 +08:00
|
|
|
labelClassName?: string;
|
2026-05-30 23:45:26 +08:00
|
|
|
markerClassName?: string;
|
|
|
|
|
style?: CSSProperties;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function ActivityStep({
|
|
|
|
|
icon: Icon,
|
|
|
|
|
marker,
|
|
|
|
|
label,
|
2026-07-22 22:35:39 +08:00
|
|
|
ariaLabel,
|
2026-05-30 23:45:26 +08:00
|
|
|
active = false,
|
|
|
|
|
tone = active ? "active" : "neutral",
|
|
|
|
|
className,
|
|
|
|
|
contentClassName,
|
2026-07-22 22:35:39 +08:00
|
|
|
labelClassName,
|
2026-05-30 23:45:26 +08:00
|
|
|
markerClassName,
|
|
|
|
|
style,
|
|
|
|
|
}: ActivityStepProps) {
|
2026-09-08 16:00:54 +08:00
|
|
|
const line = (
|
|
|
|
|
<div
|
|
|
|
|
data-testid="activity-line"
|
|
|
|
|
tabIndex={typeof label === "string" ? 0 : undefined}
|
|
|
|
|
className="flex min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap"
|
|
|
|
|
>
|
|
|
|
|
<StreamingLabelSheen
|
|
|
|
|
active={active}
|
|
|
|
|
className={cn(
|
|
|
|
|
"min-w-0 flex-1 truncate font-medium",
|
|
|
|
|
tone === "error" ? "text-destructive/78" : "text-muted-foreground/85",
|
|
|
|
|
labelClassName,
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{label}
|
|
|
|
|
</StreamingLabelSheen>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
2026-05-30 23:45:26 +08:00
|
|
|
return (
|
2026-07-22 22:35:39 +08:00
|
|
|
<div
|
|
|
|
|
data-testid="activity-step"
|
|
|
|
|
aria-label={ariaLabel}
|
2026-05-30 23:45:26 +08:00
|
|
|
className={cn(
|
2026-07-22 22:35:39 +08:00
|
|
|
"relative grid min-w-0 grid-cols-[1.125rem_minmax(0,1fr)] gap-2 py-0.5 text-[13px] leading-5",
|
2026-05-30 23:45:26 +08:00
|
|
|
className,
|
|
|
|
|
)}
|
|
|
|
|
style={style}
|
|
|
|
|
>
|
|
|
|
|
<span
|
|
|
|
|
className={cn(
|
2026-07-22 22:35:39 +08:00
|
|
|
"flex h-5 w-[1.125rem] shrink-0 items-start justify-center pt-[3px]",
|
2026-05-30 23:45:26 +08:00
|
|
|
)}
|
|
|
|
|
aria-hidden
|
|
|
|
|
>
|
|
|
|
|
{marker ?? (
|
|
|
|
|
<span
|
|
|
|
|
className={cn(
|
|
|
|
|
"grid h-3.5 w-3.5 place-items-center rounded-full border bg-background transition-colors",
|
|
|
|
|
tone === "active" && "border-muted-foreground/28 text-muted-foreground/72",
|
|
|
|
|
tone === "success" && "border-emerald-500/28 text-emerald-500/78",
|
|
|
|
|
tone === "error" && "border-destructive/30 text-destructive/78",
|
|
|
|
|
tone === "neutral" && "border-muted-foreground/18 text-muted-foreground/50",
|
|
|
|
|
markerClassName,
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{Icon ? <Icon className="h-2.5 w-2.5" strokeWidth={2.15} /> : null}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
</span>
|
|
|
|
|
<div className={cn("min-w-0", contentClassName)}>
|
2026-09-08 16:00:54 +08:00
|
|
|
{typeof label === "string" ? (
|
2026-09-10 11:10:51 +08:00
|
|
|
<TooltipProvider>
|
2026-09-08 16:00:54 +08:00
|
|
|
<Tooltip>
|
|
|
|
|
<TooltipTrigger asChild>{line}</TooltipTrigger>
|
|
|
|
|
<TooltipContent side="top" className="max-w-[min(32rem,calc(100vw-2rem))] whitespace-pre-wrap break-words">
|
|
|
|
|
{label}
|
|
|
|
|
</TooltipContent>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</TooltipProvider>
|
|
|
|
|
) : line}
|
2026-05-30 23:45:26 +08:00
|
|
|
</div>
|
2026-07-22 22:35:39 +08:00
|
|
|
</div>
|
2026-05-30 23:45:26 +08:00
|
|
|
);
|
|
|
|
|
}
|