import type * as React from 'react';
import classNames from 'classnames';
import { t } from '../i18n';
export type ReviewHeadingLevel = '1' | '2' | '3' | '4' | '5' | '6';
export interface ReviewProps {
/**
* `Review` component's body content.
*/
children: React.ReactNode;
className?: string;
/**
* Optional label to give screen readers longer, more descriptive text to
* explain the context of an edit link.
*/
editAriaLabel?: string;
/**
* An optional node in place of the edit link. If this defined, no edit link will be shown.
*/
editContent?: React.ReactNode;
/**
* Href for the edit link. If this is undefined, no edit link will be shown.
*/
editHref?: string;
editText?: React.ReactNode;
heading?: React.ReactNode;
/**
* Heading type to override default `
`.
*/
headingLevel?: ReviewHeadingLevel;
/**
* An optional function that is executed on edit link click. The event and
* props.editHref value are passed to this function.
*/
onEditClick?: (...args: any[]) => any;
}
const getHeading = (heading, headingLevel) => {
const Heading = (`h${headingLevel}` || `h3`) as keyof JSX.IntrinsicElements;
if (heading) {
return {heading};
}
};
/**
* For information about how and when to use this component,
* [refer to its full documentation page](https://design.cms.gov/components/review/).
*/
export const Review = (props: ReviewProps) => {
const handleClick = (event): void => {
if (props.onEditClick) {
props.onEditClick(event, props.editHref);
}
};
const classes = classNames('ds-c-review', props.className);
return (
);
};
Review.defaultProps = {
headingLevel: '3',
};
export default Review;