import React, { useRef, useState } from "react"; import { cl } from "../../utils/helpers"; import { useInputContext } from "./Input/Input.context"; type ComboboxWrapperProps = { children: any; className?: string; hasError: boolean; inputProps: { disabled?: boolean; }; readOnly?: boolean; inputSize: string; }; const ComboboxWrapper = ({ children, className, hasError, inputProps, inputSize, }: ComboboxWrapperProps) => { const { toggleOpenButtonRef, clearInput, readOnly } = useInputContext(); const wrapperRef = useRef(null); const [hasFocusWithin, setHasFocusWithin] = useState(false); function onFocusInsideWrapper(event: React.FocusEvent) { if ( !wrapperRef.current?.contains(event.relatedTarget) && toggleOpenButtonRef?.current !== event.target ) { setHasFocusWithin(true); } } function onBlurWrapper(event: React.FocusEvent) { if (!wrapperRef.current?.contains(event.relatedTarget)) { setHasFocusWithin(false); clearInput(event); } } return ( // biome-ignore lint/a11y/noStaticElementInteractions: Wrapper for combobox input and chips.
{children}
); }; export default ComboboxWrapper;