import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import Icon from './Icon';
import Line from './Line';
import { StepperContext } from './StepperContext';
export default function Header({ steps, className }) {
const { isAtTop } = useContext(StepperContext);
return (
{steps.map(({ iconLabel, label, incomplete }, index) => {
const isNotLastStep = index < steps.length - 1;
return (
// eslint-disable-next-line react/no-array-index-key
{iconLabel || index + 1}
{label}
{isNotLastStep && (
)}
);
})}
);
}
Header.propTypes = {
steps: PropTypes.arrayOf(
PropTypes.shape({
iconLabel: PropTypes.oneOfType([
PropTypes.string,
PropTypes.node,
]),
label: PropTypes.string.isRequired,
}),
).isRequired,
className: PropTypes.string,
};
Header.defaultProps = {
className: null,
};