import React, { useState, useEffect } from 'react'; import type { EditorMode, InputMethod } from '../types'; import { TaterSpritePullup } from './TaterSpritePullup'; /** Props for the shared annotation input and action mode toolstrip. */ export interface AnnotationToolstripProps { inputMethod: InputMethod; onInputMethodChange: (method: InputMethod) => void; mode: EditorMode; onModeChange: (mode: EditorMode) => void; taterMode?: boolean; /** * Compact mode: used inside the sticky header lane. Buttons only expand for * the active mode (no hover expansion), gap is tightened, and the help link * is hidden. */ compact?: boolean; /** * Show the "how does this work?" help link. Default true; hidden on the * floating HTML toolstrip where space is tight. */ showHelpLink?: boolean; /** * Icon-only mode: no button ever expands to show a label, even the active * one. Used in the sticky header lane on mobile so the toolstrip stays * narrow and leaves room for the diff badges. */ iconOnly?: boolean; /** * Hide the drag/pinpoint input group entirely. Live app sessions are * pinpoint-only, so the switch would be a dead control there. */ hideInputMethodSwitch?: boolean; /** * Omit only the Quick Label action. Defaults to false so existing consumers * retain the complete action-mode group. */ hideQuickLabel?: boolean; /** * Omit only the Redline action. Defaults to false. For a host whose * composer is its own (the Inbox surface on a phone draws Select, Pinpoint, * Markup and Comment). */ hideRedline?: boolean; } /** Render the shared input-method and annotation-mode controls. */ export const AnnotationToolstrip: React.FC = ({ inputMethod, onInputMethodChange, mode, onModeChange, taterMode, compact = false, showHelpLink = true, iconOnly = false, hideInputMethodSwitch = false, hideQuickLabel = false, hideRedline = false, }) => { const [showHelp, setShowHelp] = useState(false); const [helpTab, setHelpTab] = useState<'selection' | 'plannotator'>('selection'); const [mounted, setMounted] = useState(false); // Enable transitions only after first paint useEffect(() => { requestAnimationFrame(() => setMounted(true)); }, []); return ( <>
{/* Input method group */} {!hideInputMethodSwitch && (
onInputMethodChange('drag')} label="Select" color="primary" mounted={mounted} compact={compact} iconOnly={iconOnly} icon={ } /> onInputMethodChange('pinpoint')} label="Pinpoint" color="primary" mounted={mounted} compact={compact} iconOnly={iconOnly} icon={ } />
)} {/* Action mode group */}
onModeChange('selection')} label="Markup" color="secondary" mounted={mounted} compact={compact} iconOnly={iconOnly} icon={ } /> onModeChange('comment')} label="Comment" color="accent" mounted={mounted} compact={compact} iconOnly={iconOnly} icon={ } /> {!hideRedline && ( onModeChange('redline')} label="Redline" color="destructive" mounted={mounted} compact={compact} iconOnly={iconOnly} icon={ } /> )} {!hideQuickLabel && ( onModeChange('quickLabel')} label="Label" color="warning" mounted={mounted} compact={compact} iconOnly={iconOnly} icon={ } /> )}
{/* Help */} {!compact && showHelpLink && ( )}
{/* Help Video Dialog */} {showHelp && (
setShowHelp(false)} >
e.stopPropagation()} > {taterMode && }