// @flow strict import * as React from 'react'; import classify from '../../../utils/classify'; import type {IconType} from '../../Icon'; import {Icon, ICON_SIZE, ICON_TYPE} from '../../Icon'; import css from '../Stepper.module.css'; type ClassNames = $ReadOnly<{ wrapper?: string, stepCounter?: string, content?: string, }>; export type StepProps = { active?: boolean, children: React.Node, completed?: boolean, disabled?: boolean, expanded?: boolean, index: number, last?: boolean, classNames?: ClassNames, allowClick?: boolean, onClick?: (idx: number, e?: ?SyntheticEvent) => mixed, iconName?: string, iconType?: IconType, }; export const Step: React$AbstractComponent = React.forwardRef( ( { active, children, completed = false, disabled = false, expanded = false, index = 0, last, classNames, onClick, allowClick, iconName, iconType, }: StepProps, ref, ): React.Node => { const childrenArray = React.Children.toArray(children).filter(Boolean); const stepContent = childrenArray.map((stepContent) => React.cloneElement(stepContent, { ...stepContent.props, active, completed, disabled, }), ); const handleClick = (e) => allowClick && onClick?.(index, e); return (
{completed && !active ? ( ) : ( {iconName ? ( ) : ( (index + 1).toString() )} )}
{stepContent}
); }, );