'use client' import type { StepByStepTourTaskId, StepByStepTourTaskView } from './types' import { Button } from '@langgenius/dify-ui/button' import { cn } from '@langgenius/dify-ui/cn' import { useEffect, useRef } from 'react' export type FloatingChecklistProps = { className?: string title: string duration: string minimized: boolean progress: { ariaValueText: string completed: number total: number } completionPrompt?: { description: string dismissLabel: string label: string onDismiss: () => void title: string } tasks: StepByStepTourTaskView[] skipLabel: string minimizeLabel: string restoreLabel: string getTaskCompleteLabel: (taskTitle: string) => string getTaskIncompleteLabel: (taskTitle: string) => string onMinimize: () => void onRestore: () => void onSkip: () => void onCompleteTask: (taskId: StepByStepTourTaskId) => void onStartTask: (taskId: StepByStepTourTaskId) => void onUncompleteTask: (taskId: StepByStepTourTaskId) => void } export function FloatingChecklist({ className, title, duration, minimized, progress, completionPrompt, tasks, skipLabel, minimizeLabel, restoreLabel, getTaskCompleteLabel, getTaskIncompleteLabel, onMinimize, onRestore, onSkip, onCompleteTask, onStartTask, onUncompleteTask, }: FloatingChecklistProps) { if (minimized && !completionPrompt) { return ( ) } return (

{title}

{duration}

{!completionPrompt && ( <> )}
{tasks.map((task) => ( ))} {completionPrompt && }
) } function TourCompletionPrompt({ description, dismissLabel, label, onDismiss, title, }: NonNullable) { const dismissRef = useRef(null) useEffect(() => { dismissRef.current?.focus({ preventScroll: true }) }, []) return (

{title}

{description}

) } function MinimizedTourPill({ title, progress, restoreLabel, onRestore, className, }: { title: string progress: FloatingChecklistProps['progress'] restoreLabel: string onRestore: () => void className?: string }) { return ( ) } function TourProgress({ ariaValueText, completed, total, }: { ariaValueText: string completed: number total: number }) { return ( <>