import React, { useRef, useEffect, type HTMLAttributes, type KeyboardEventHandler, } from 'react'; import classnames from 'classnames'; import { slottableComponent } from '../../HOC/slottableComponent'; export type InputProps = { placeholder?: string; disabled?: boolean; value?: string; labelledBy?: string; focused?: boolean; invalid?: boolean; readOnly?: boolean; required?: boolean; } & HTMLAttributes; function LunaticComboboxInput({ placeholder, disabled, onChange, value, id, labelledBy, focused, className, invalid, required, }: InputProps) { const inputEl = useRef(null); useEffect(() => { if (inputEl.current && focused) { inputEl.current.focus(); } }, [inputEl, focused]); const onKeydown: KeyboardEventHandler = (e) => { const { key } = e; if (key === 'ArrowUp' || key === 'ArrowDown') { e.preventDefault(); } }; return ( ); } export const ComboboxInput = slottableComponent( 'ComboboxInput', LunaticComboboxInput );