import { useStyleConfig, vui } from '../core'
import Icon, { IconProps } from '../icon'
import { cs } from '../utils'
import { useTreeContext } from './context'

/** Displays an icon on the side of the TreeItem. */
export const TreeIcon = vui<'svg', IconProps>((props, ref) => {
  const { className, ...rest } = props
  const styles = useStyleConfig('Tree', useTreeContext())

  return <Icon className={cs('vui-treeIcon', className)} ref={ref} size="xs" {...styles.icon} {...rest} />
})

TreeIcon.displayName = 'TreeIcon'

export default TreeIcon
