Skip to content

Commit

Permalink
props object converted to the proper variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigrsig authored and atilafassina committed Jul 8, 2022
1 parent 959625b commit 4f8b3b2
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions src/Suggestion.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import React from 'react'
import { defaultStyle } from './utils'

import { getSubstringIndex, keys, omit } from './utils'

function Suggestion(props) {
const rest = omit(
props,
['style', 'classNames', 'className'], // substyle props
keys(Suggestion.propTypes)
)
import { getSubstringIndex } from './utils'

function Suggestion({
id,
focused,
ignoreAccents,
index,
onClick,
onMouseEnter,
query,
renderSuggestion,
suggestion,
style,
className,
classNames,
}) {
const rest = { onClick, onMouseEnter }

const renderContent = () => {
let { query, renderSuggestion, suggestion, index, focused } = props

let display = getDisplay()
let highlightedDisplay = renderHighlightedDisplay(display, query)

Expand All @@ -30,8 +36,6 @@ function Suggestion(props) {
}

const getDisplay = () => {
let { suggestion } = props

if (typeof suggestion === 'string') {
return suggestion
}
Expand All @@ -46,8 +50,6 @@ function Suggestion(props) {
}

const renderHighlightedDisplay = (display) => {
const { ignoreAccents, query, style } = props

let i = getSubstringIndex(display, query, ignoreAccents)

if (i === -1) {
Expand All @@ -64,13 +66,7 @@ function Suggestion(props) {
}

return (
<li
id={props.id}
role="option"
aria-selected={props.focused}
{...rest}
{...props.style}
>
<li id={id} role="option" aria-selected={focused} {...rest} {...style}>
{renderContent()}
</li>
)
Expand Down

0 comments on commit 4f8b3b2

Please sign in to comment.