/// import type { Boundary, Placement } from '@floating-ui/dom'; export type ContentRenderProp = ({ toggleDropdown }: { toggleDropdown: () => void; }) => React.ReactElement; export type ToggleRenderProp = ({ isToggled, toggleDropdown, ref }: { isToggled: boolean; toggleDropdown: () => void; ref: (refElement: HTMLElement | null) => void; }) => React.ReactElement; export type DropdownOptions = { /** * The element or area that overflow will be checked relative to. * * By default the boundary will be detected automatically based on which * ancestor elements will cause the dropdown element to be clipped. If desired, * you can specify a specific boundary to constraint the dropdown. */ boundary?: Boundary; /** * The minimum padding between the dropdown and its boundary. Defaults to `6`. * * The default boundary padding is good in most situations, but you may want * to set this to `0` when specifying a custom boundary that doesn't * correspond to an overflow container. */ boundaryPadding?: number; /** * Shifts the floating element to keep it in view. */ shift?: { mainAxis?: boolean; crossAxis?: boolean; }; /** * Hide floating element * - referenceHidden - when toggle element is hidden from view * - escaped - when floating element is hidden from view */ hide?: { strategy?: 'referenceHidden' | 'escaped'; }; /** * Changes the placement of the floating element to keep it in view. */ flip?: boolean; /** * The options applied to the event listener used to detect clicks outside the dropdown. * Can be used to enable "capture" mode for the event listener, so that the dropdown is * closed for events with "stopPropagation()" called during event bubbling phase. */ eventListenerOptions?: boolean | AddEventListenerOptions; className?: string; disabled?: boolean; /** * Allows configuring if focus is returned to the toggle element when the dropdown is closed * Defaults to `true` as this is almost always preferred and good for accessibility, but some * scenarios where users may close a dropdown by opening another can benefit from this option */ focusToggleOnClose?: boolean; /** * If set to true, indicates that this dropdown's "open" state is externally controlled by * the implementing component. This must be used in tandem with the `isOpen` prop to allow * the dropdown visibility to be controlled. Defaults to `false` */ externallyControlled?: boolean; /** * Used in tandem with the `externallyControlled` prop, allowing the implementing component * to control if the dropdown should be visible or not. Defaults to `false` */ isOpen?: boolean; /** * The offset of the dropdown body relative to the target, in * pixels. Defaults to `6` to match Particle component's 0.5em offset. */ offset?: number | { mainAxis?: number; crossAxis?: number; alignmentAxis?: number | null; }; /** * Where the dropdown should try to place itself relative to the trigger. Based * on the boundary, the dropdown may shift or flip its position to avoid * being cutoff. */ placement?: Placement; /** * Optional override for what element the dropdown portal is attached to. By default the portal * will be attached to `document.body`. This option shouldn't need to be used unless trying to get * dropdowns to render within fullscreen-ed content via `useFullscreen` or similar */ portalContainer?: Element | DocumentFragment; /** * Sets a z-index on the dropdown to adjust the stacking order. Should only be * necessary in edge cases. Defaults to `1` to ensure it at least overlays scrollbars */ zIndex?: number; }; export type DropdownPopoverOptions = { contentWidth?: number | string; maxHeight?: number | string; /** * Whether the dropdown content should be shrinked to prevent screen overflow. * Useful for dropdowns containing long scrollable content. Defaults to `false`. */ shrinkToPreventOverflow?: boolean; /** * By default when the dropdown opens, the first interactive element within the dropdown will * be programmatically focused. By setting this prop to `true` that behavior is skipped. * Defaults to `false` */ initialFocusDisabled?: boolean; /** * If provided, opts the dropdown into registering its rendered portal content * into the `DropdownPortalRegistrationContext`. This is useful for dropdowns that interfere with * standard clickoutside logic due to their content being rendered via portal */ dropdownId?: string; /** * Ref to the element that will be used as the boundary that the element will be checked for overflow. */ boundaryElementRef?: React.RefObject | null; };