import React from 'react' import * as Ariakit from '@ariakit/react' export const useComboboxStore = Ariakit.useComboboxStore type Props = React.PropsWithChildren & Ariakit.ComboboxProps type ComboboxComponent = React.ForwardRefExoticComponent & { Popover: typeof Popover Item: typeof Item Group: typeof Group GroupLabel: typeof GroupLabel } export const Combobox = React.forwardRef< HTMLInputElement | null, React.PropsWithoutRef >(({ children, ...props }, ref) => { return ( {children} ) }) as ComboboxComponent export const Popover: React.FC< React.PropsWithChildren & Ariakit.ComboboxPopoverProps > = ({ children, ...props }) => { props.gutter = props.gutter ?? 4 return ( {/* There is a bug in v0.2.17 of Ariakit where you need to have this arrow rendered or else positioning of the popover breaks. We render it, but hide it by setting size={0}. This is an issue with anything using a popover coming from the floating-ui library. */} {children} ) } export const Item: React.FC< React.PropsWithChildren & Ariakit.ComboboxItemProps > = ({ children, ...props }) => { return {children} } export const Group: React.FC< React.PropsWithChildren & Ariakit.ComboboxGroupProps > = ({ children, ...props }) => { return {children} } export const GroupLabel: React.FC< React.PropsWithChildren & Ariakit.ComboboxGroupLabelProps > = ({ children, ...props }) => { return ( {children} ) } Combobox.Popover = Popover Combobox.Item = Item Combobox.Group = Group Combobox.GroupLabel = GroupLabel