import React, { type PropsWithChildren, useCallback } from 'react'; import InteractiveTutorialProvider, { type InteractiveTutorialProviderProps, } from './InteractiveTutorialProvider'; import InteractiveTutorialView from './InteractiveTutorialView'; import type { DescriptionCardProps } from './SharedDescriptionCard'; import type { Translations } from './types'; import useInteractiveTutorial from './useInteractiveTutorial'; export type InteractiveTutorialContainerProps = InteractiveTutorialProviderProps & { translations: Translations; Card: React.ComponentType; }; export default function InteractiveTutorialContainer({ children, translations, Card, ...rest }: PropsWithChildren) { return ( {children} <$InteractiveTutorial translations={translations} Card={Card} /> ); } type $InteractiveTutorialProps = { translations: Translations; Card: React.ComponentType; }; function $InteractiveTutorial({ translations, Card, }: $InteractiveTutorialProps) { const { target, goToNextStep, nextExists, goToPrevStep, description, prevExists, visible, finish, } = useInteractiveTutorial(); const next = useCallback(() => goToNextStep(), [goToNextStep]); const prev = useCallback(() => goToPrevStep(), [goToPrevStep]); const prevDisabled = !prevExists; if (!visible) { return null; } const targetLayout = target?.element.layout || null; return ( ); }