import { SitePathsContext } from 'Components/utils/withSitePaths' import { parentName } from 'Engine/ruleUtils' import { ParsedRule, ParsedRules } from 'Engine/types' import { pick, sortBy, take } from 'ramda' import React, { useContext, useEffect, useState } from 'react' import FuzzyHighlighter, { Highlighter } from 'react-fuzzy-highlighter' import { useTranslation } from 'react-i18next' import { Link, Redirect, useHistory } from 'react-router-dom' import { DottedName } from 'Rules' import Worker from 'worker-loader!./SearchBar.worker.js' import { capitalise0 } from '../utils' import './SearchBar.css' const worker = new Worker() type SearchBarProps = { rules: ParsedRules showDefaultList: boolean finally?: () => void } type Option = Pick, 'dottedName' | 'name' | 'title'> type Result = Pick, 'dottedName'> export default function SearchBar({ rules, showDefaultList, finally: finallyCallback }: SearchBarProps) { const sitePaths = useContext(SitePathsContext) const [input, setInput] = useState('') const [selectedOption, setSelectedOption] = useState