Skip to main content
Glama
deleonio
by deleonio
CustomSuggestionsOption.tsx1.35 kB
import { type FunctionalComponent as FC, h } from '@stencil/core'; import type { JSXBase } from '@stencil/core/internal'; import type { W3CInputValue } from '../../schema'; export type CustomSuggestionsProps = JSXBase.HTMLAttributes<HTMLLIElement> & { index: number; option: W3CInputValue; selected: boolean; searchTerm?: string; ref?: ((elm?: HTMLLIElement | undefined) => void) | undefined; }; const CustomSuggestionsOptionFc: FC<CustomSuggestionsProps> = ({ index, ref, selected, onClick, onMouseOver, onFocus, onKeyDown, option, searchTerm }) => { const highlightSearchTerm = (text: string, searchTerm: string) => { if (!searchTerm?.trim()) return text; const regex = new RegExp(`(${searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`, 'gi'); const parts = text.split(regex); return parts.map((part, partIndex) => (regex.test(part) ? <mark key={partIndex}>{part}</mark> : part)); }; return ( <li id={`option-${index}`} key={`-${index}`} ref={ref} data-index={index} tabIndex={-1} role="option" aria-selected={selected ? 'true' : undefined} onClick={onClick} onMouseOver={onMouseOver} onFocus={onFocus} class="kol-custom-suggestions-option" onKeyDown={onKeyDown} > {highlightSearchTerm(String(option), searchTerm || '')} </li> ); }; export default CustomSuggestionsOptionFc;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/deleonio/public-ui-kolibri'

If you have feedback or need assistance with the MCP directory API, please join our Discord server