import React from 'react' import { QueryMatch } from '~/src/store/selectors/selectFilteredEventList' import { useTextMatchGroups } from './hooks' import { Breadcrumbs, Key, KeyPathFragment, MatchPreview, QueryMatchContainer, TextLikeValue, NonTextValue, HighlightedText, ColonSeparator } from './style' export type QueryMatchPreviewProps = { children: QueryMatch } export const QueryMatchPreview = ({ children: { keyPath, value, matchingKeyRange, matchingValueRange } }: QueryMatchPreviewProps) => { const keyMatch = useTextMatchGroups(keyPath.at(-1).value, matchingKeyRange) const valueMatch = useTextMatchGroups(value, matchingValueRange) return ( {keyPath.map((fragment, i) => ( {fragment.value} ))} {keyMatch.head} {keyMatch.match && {keyMatch.match}} {keyMatch.tail} {['string', 'number', 'boolean'].includes(typeof value) ? ( {valueMatch.head} {valueMatch.match && {valueMatch.match}} {/* // the tail is rendered in rtl mode for ellipsis to be on the left, so we need the &lrm to mirror the punctuation and spaces properly */} ‎{valueMatch.tail} ) : ( )} ) }