import {Box, Stack, StackProps, Text, useColorModeValue} from '@chakra-ui/react' import * as React from 'react' import {ListItemProps} from './ListItem' interface ListProps extends StackProps { label?: string } export const List = (props: ListProps) => { const {children, ...stackProps} = props const items = React.useMemo( () => React.Children.toArray(children) .filter>(React.isValidElement) .map((item, index, array) => index + 1 === array.length ? React.cloneElement(item, {isLastItem: true}) : item ), [children] ) return ( {props.label && ( {props.label} )} {items} ) }