import { ReactNode, CSSProperties, SyntheticEvent, KeyboardEventHandler, RefObject } from 'react'; import type { Padding } from '@floating-ui/react'; import { MoveByOffset } from '../common'; import type { DropdownLayoutValueOption, DropdownLayoutProps, ListType, Overflow, DropdownLayoutOption } from '../DropdownLayout'; import { AppendTo, PopoverNextProps } from '../PopoverNext/PopoverNext.types'; export type DropdownBaseCloseReason = 'outside-press' | 'escape-key' | 'drag'; export type DropdownBaseProps = { /** Control whether the should be opened. */ open?: undefined | boolean; /** Defines a callback function which is called when dropdown is opened. */ onShow?: () => void; /** Defines a callback function which is called when dropdown is closed. */ onHide?: () => void; /** * Specifies a CSS class name to be appended to the component's root element. * @internal */ className?: string; /** * Specifies a CSS class name to be appended to the popover's content. * @internal */ popoverContentClassName?: string; /** Applies a data-hook HTML attribute that can be used in the tests. */ dataHook?: string; /** Control popover placement. * @default 'bottom' */ placement?: PopoverNextProps['placement']; /** Specifies where popover should be inserted as a last child - whether `parent` or `window` containers. * @default 'parent' */ appendTo?: AppendTo; /** Specifies whether popover arrow should be shown. * @default false */ showArrow?: boolean; /** Defines a callback function which is called when user clicks outside of a dropdown. */ onClickOutside?: () => void; /** Defines a callback function which is called when the user closes the dropdown. `reason` is `'outside-press'` for a click outside of it, `'escape-key'` for the Esc key and `'drag'` for dragging its mobile drawer closed. A parent that controls `open` closes the dropdown here. */ onClose?: (reason: DropdownBaseCloseReason) => void; /** Defines a callback function which is called on `onMouseEnter` event on the entire component. */ onMouseEnter?: () => void; /** Defines a callback function which is called on `onMouseLeave` event on the entire component. */ onMouseLeave?: () => void; /** Callback function called whenever the user clicks the dropdown layout.*/ onMouseDown?: DropdownLayoutProps['onMouseDown']; /** Defines a callback function which is called whenever user selects a different option in the list. */ onSelect?: (option: DropdownLayoutValueOption) => void; /** * Set popover's content width to a minimum width of a trigger element, * but it can expand up to the defined value of `maxWidth` * @default true */ dynamicWidth?: boolean; /** Controls the maximum width of dropdown layout. */ maxWidth?: CSSProperties['maxWidth']; /** Controls the minimum width of dropdown layout. * @default 192 */ minWidth?: CSSProperties['minWidth']; /** * Controls the width of dropdown layout. * @internal */ width?: CSSProperties['width']; /** Controls the maximum height of dropdown layout. * @default '260px' */ maxHeight?: number | string; /** * Specifies a target component to be rendered. If a regular node is passed, it's rendered as-is. * If a function is passed, it's expected to return a React element. * The function accepts an object containing the following properties: * * * `open` - opens the Popover * * `close` - closes the Popover * * `toggle` - toggles the Popover * * `isOpen` - indicates whether the items list is currently open * * `delegateKeyDown` - the underlying DropdownLayout's keydown handler. It can be called * inside another keyDown event in order to delegate it. * * `selectedOption` - the currently selected option * * Check inserted component documentation for more information on available properties. */ children?: DropdownBaseChildrenFn; /** * Specifies an array of options for a dropdown list. Objects must have an id and can include string value or node. * If value is '-', a divider is rendered instead (dividers don't require and id). */ options?: DropdownLayoutProps['options']; /** Define the selected option in the list. */ selectedId?: string | number; /** Handles container overflow behaviour. */ overflow?: Overflow | undefined; /** Indicates that element can be focused and where it participates in sequential keyboard navigation. */ tabIndex?: number; /** * Sets the initially selected option in the list. Used when selection * behaviour is being controlled. */ initialSelectedId?: string | number; /** Specifies the stack order (`z-index`) of a dropdown layout. */ zIndex?: number; /** Moves dropdown content relative to the parent on X or Y axis by a defined amount of pixels. */ moveBy?: MoveByOffset; /** * Specifies whether to flip the placement * when it starts to overlap the target element () */ flip?: boolean; /** * Specifies whether to enable the fixed behaviour. If enabled, keep its * original placement even when it's being positioned outside the boundary. */ fixed?: boolean; /** * Sets the minimum distance, in pixels, to keep between the `` and the edges * of the area it's positioned in. Accepts a single value for every side, or an * object to set sides individually. Sides that are left out keep the default distance. * @default 5 */ boundaryPadding?: Padding; /** Stretches trigger element to fill its parent container width. * @default false */ fluid?: boolean; /** Adds enter and exit animation. * @default false */ animate?: boolean; /** Specifies popover content transitioning, passed through to PopoverNext. */ transitionSettings?: PopoverNextProps['transitionSettings']; /** Focus to the selected option when dropdown is opened. */ focusOnSelectedOption?: boolean; /** Specifies whether lazy loading of the dropdown items is enabled. */ infiniteScroll?: boolean; /** Defines a callback function which is called on a request to render more list items. */ loadMore?: (page: number) => void; /** Specifies whether there are more items to load. */ hasMore?: boolean; /** Focus to the specified option when dropdown is opened. */ focusOnOption?: DropdownLayoutProps['focusOnOption']; /** Scrolls to the specified option when dropdown is opened without marking it. */ scrollToOption?: DropdownLayoutProps['scrollToOption']; /** A fixed header to the list. */ fixedHeader?: DropdownLayoutProps['fixedHeader']; /** A fixed footer to the list. */ fixedFooter?: DropdownLayoutProps['fixedFooter']; /** Defines type of behavior applied in list. * @default 'select' */ listType?: ListType; /** Specifies whether first list item should be focused. */ autoFocus?: boolean; /** Sets the initial marking of an option in the list when opened: * - `false` - no initially hovered list item * - `true` - hover first selectable option * - any `number/string` specify the id of an option to be hovered */ markedOption?: boolean | number | string; }; export type DropdownBaseChildrenFn = ReactNode | ChildrenFnArgs; export type ChildrenFnArgs void; } = any> = (data: { open: () => void; close: (e?: SyntheticEvent) => void; toggle: () => void; delegateKeyDown: KeyboardEventHandler; selectedOption: DropdownLayoutOption | undefined; activeDescendantId: string | undefined; /** Defines the id for the listbox. */ listboxId: string; isOpen: boolean; ref: RefObject; }) => ReactNode; //# sourceMappingURL=DropdownBase.types.d.ts.map