/** * External dependencies */ import type { MouseEvent, ReactElement } from 'react'; /** * Internal dependencies */ import type { NestedHeadingData } from './utils'; const ENTRY_CLASS_NAME = 'wp-block-table-of-contents__entry'; export default function TableOfContentsList( { nestedHeadingList, disableLinkActivation, onClick, ordered = true, }: { nestedHeadingList: NestedHeadingData[]; disableLinkActivation?: boolean; onClick?: ( event: MouseEvent< HTMLAnchorElement > ) => void; ordered?: boolean; } ): ReactElement { return ( <> { nestedHeadingList.map( ( node, index ) => { const { content, link } = node.heading; const entry = link ? ( { content } ) : ( { content } ); const NestedListTag = ordered ? 'ol' : 'ul'; return (
  • { entry } { node.children ? ( ) : null }
  • ); } ) } ); }