import React from 'react'

const Fragment = React.Fragment || 'div'
const propTypes = {}

function AutocompleteListItem({ text, searchTerm }) {
  if (!text || !searchTerm) return <Fragment>{text}</Fragment>

  let idx = text.indexOf(searchTerm)
  if (idx === -1) idx = text.toLowerCase().indexOf(searchTerm)
  if (idx === -1 || searchTerm.length >= text.length)
    return <Fragment>{text}</Fragment>

  return (
    <Fragment>
      {text.slice(0, idx)}
      <strong>{text.slice(idx, idx + searchTerm.length)}</strong>
      {text.slice(idx + searchTerm.length)}
    </Fragment>
  )
}

AutocompleteListItem.propTypes = propTypes

export default AutocompleteListItem

@@ -1,8 +1,43 @@
+import PropTypes from 'prop-types'%0A
 import R
@@ -115,16 +115,75 @@
 ypes = %7B
+%0A  text: PropTypes.string,%0A  searchTerm: PropTypes.string,%0A
 %7D%0A%0Afunct

add pts