Skip to main content
Glama
deleonio
by deleonio
Combobox.tsx1.23 kB
import { h, type FunctionalComponent as FC } from '@stencil/core'; import type { JSXBase } from '@stencil/core/internal'; import { getDefaultProps } from '../_helpers/getDefaultProps'; import type { DefaultInputProps } from '../_types'; type AriaProps = { 'aria-label'?: string; 'aria-describedby'?: string; 'aria-selected'?: boolean; 'aria-controls'?: string; 'aria-autocomplete'?: 'both'; 'aria-activedescendant'?: string; }; export type ComboboxProps = DefaultInputProps<JSXBase.InputHTMLAttributes<HTMLInputElement>> & { value: string | number | string[]; focusedOptionIndex?: number; open?: boolean; }; const ComboboxFc: FC<ComboboxProps> = (props) => { const { open, ariaDescribedBy, hideLabel, label, focusedOptionIndex = -1, ...other } = props; const inputProps: JSXBase.InputHTMLAttributes<HTMLInputElement> & AriaProps = { ...other, ...getDefaultProps({ ariaDescribedBy, hideLabel, label }), type: 'text', role: 'combobox', 'aria-selected': Boolean(open), 'aria-controls': 'listbox', 'aria-autocomplete': 'both', 'aria-activedescendant': open && focusedOptionIndex >= 0 ? `option-${focusedOptionIndex}` : undefined, }; return <input {...inputProps} />; }; export default ComboboxFc;

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