import React from 'react'; import { Box, Text, Button, TextButton, Badge, Divider, Tooltip, } from '@wix/design-system'; import { SetupWidgetStep } from '@wix/bex-core'; import { useWixPatternsContainer } from '@wix/bex-core/react'; import { SetupStepIcon } from './SetupStepIcon'; import { st, classes } from './SetupWidget.st.css.js'; export interface SetupStepRowProps { step: SetupWidgetStep; /** Highlighted + bold row (the recommended (primary) or expanded step). */ isFocused: boolean; /** Inline content is shown below the row. */ expanded: boolean; onActivate: () => void; /** Supplies the inline-expansion content (render prop on the widget). */ renderStepContent?: (step: SetupWidgetStep) => React.ReactNode; } /** * Desktop step row. Recreated from the existing Setup widget: * - completed → green check, struck-through title, optional completed CTA * - disabled → muted bullet + disabled CTA (permission-denied) * - in-progress → "In progress" badge next to the title * - focused → blue surface, bold title, primary CTA * - hoverable rows tint blue on hover (handled in Stylable) */ export const SetupStepRow = ({ step, isFocused, expanded, onActivate, renderStepContent, }: SetupStepRowProps) => { const { translate: t } = useWixPatternsContainer(); const isInProgress = step.status === 'in-progress'; const isCompleted = step.status === 'completed'; const isDisabled = step.status === 'disabled'; const isInlineExpanded = expanded && step.expansionMode === 'inline'; const showCta = !isCompleted && !!step.ctaLabel && !isInlineExpanded; // Completed steps stay actionable when they carry a completed CTA (G2). const showCompletedCta = isCompleted && !!step.completedCtaLabel && !isDisabled; const clickable = (!isCompleted && !isDisabled) || showCompletedCta; const hoverable = !isFocused && !isCompleted && !isDisabled; const handleClick = clickable ? onActivate : undefined; return (
{ if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); onActivate(); } } : undefined } role={clickable ? 'button' : undefined} tabIndex={clickable ? 0 : undefined} > {/* Reserve the CTA button's height (small button = 30px) so rows keep a stable height whether or not they render a CTA — otherwise completed rows (which drop the CTA) would shrink and the widget would reflow. */} {isCompleted ? {step.title} : step.title} {isInProgress && !isInlineExpanded && ( {t('cairo.setupWidget.step.inProgress')} )} {showCta && (() => { const ctaNode = ( ); // Disabled steps explain why the CTA is disabled (G5). return isDisabled ? ( {ctaNode} ) : ( ctaNode ); })()} {showCompletedCta && ( { event.stopPropagation(); onActivate(); }} > {step.completedCtaLabel} )} {isInlineExpanded && ( {/* Stop clicks/keys inside the consumer widget from bubbling to the row's toggle handler — otherwise interacting with the content (e.g. an input) would collapse the card. */}
event.stopPropagation()} onKeyDown={(event) => event.stopPropagation()} > {renderStepContent?.(step)}
)}
); };