import { KeyboardEvent, ReactElement, RefObject } from 'react';
import { ConfirmationProp } from '../../../internal/types/confirmationTypes';
import { TreeSelectFieldNode as TreeSelectMenuNode, TreeSelectFieldValue as TreeSelectMenuValue, TreeSelectFieldValueConsistsOf as TreeSelectMenuValueConsistsOf, TreeSelectFieldHandle, TreeSelectFieldOptionContent as TreeSelectMenuOptionContent } from '../TreeSelectField/types';
/**
 * Configures a "Clear" button in the menu footer. Presence of this prop
 * enables the button; omit to suppress.
 *
 * - `onClick` — called when the user clicks Clear.
 * - `label` — button label (default "Clear").
 * - `disabled` — whether the button is inert. Filter adapters typically tie
 *   this to `!isActive(filter)` so the button is dim when nothing is selected.
 */
export type TreeSelectMenuClearConfig = {
    onClick: () => void;
    label?: string;
    disabled?: boolean;
};
export type { TreeSelectMenuNode, TreeSelectMenuValue, TreeSelectMenuValueConsistsOf, TreeSelectMenuOptionContent, };
/**
 * Imperative handle for the TreeSelectMenu component.
 * @property clearCache - Clears the options cache.
 * @property invalidate - Clears the cache and triggers a fresh options load.
 * @property expandAll - Expands all tree nodes.
 * @property collapseAll - Collapses all tree nodes.
 */
export type TreeSelectMenuHandle = TreeSelectFieldHandle;
/**
 * Props provided to the trigger render function.
 * @property ref - Ref to attach to the trigger element for positioning and focus restoration
 * @property onClick - Click handler to toggle the menu
 * @property onKeyDown - Key handler for keyboard navigation
 * @property aria-haspopup - ARIA attribute indicating the trigger opens a tree
 * @property aria-controls - ARIA attribute linking to the tree element
 * @property aria-expanded - ARIA attribute indicating whether the menu is open
 * @property data-state - Data attribute indicating the open/close state
 */
export type TreeSelectMenuTriggerProps = {
    ref: RefObject<HTMLButtonElement>;
    onClick: () => void;
    onKeyDown: (e: KeyboardEvent<HTMLButtonElement>) => void;
    "aria-haspopup": "tree";
    "aria-controls": string;
    "aria-expanded": boolean;
    "data-state": "open" | "close";
};
/**
 * Props for the TreeSelectMenu component.
 * @property id - Optional id for the menu; an internal id is generated when omitted.
 * @property trigger - Render function that receives trigger props and returns the element that opens the menu.
 * @property onMenuKeyDown - Called for key events on the open menu, after internal navigation handling.
 * @property onImplicitClose - Called when the menu closes implicitly (outside click, blur, Escape).
 * @property onExplicitClose - Called when the menu closes from an explicit selection or trigger toggle.
 * @property label - Accessible label for the menu. Used by screen readers but not rendered visually.
 * @property searchPlaceholder - Placeholder text for the search input inside the menu.
 * @property displayMenuAs - "auto" (default): popover on desktop, dialog on mobile; or force "popover"/"dialog".
 * @property virtualize - When true, renders the tree with windowed virtualization for large datasets.
 * @property disableSearch - Hides the search input and disables search filtering.
 * @property popoverWidth - Width of the popover. Accepts a CSS width value or "reference" to match trigger width.
 * @property debounceMs - Milliseconds to debounce search input before calling loadOptions. Defaults to 200.
 * @property onSearchChange - Called when the search value changes. Pair with controlled search wiring.
 * @property value - Controlled value array. Always an array, even in single-select mode.
 * @property onSelectedOptionsChange - Callback when selection changes.
 * @property selectionMode - "single": one node at a time. "independent": no cascade. "linked" (default): parent-child cascade.
 * @property valueConsistsOf - Controls which nodes are selectable and how the value is shaped.
 * @property defaultExpandLevel - Initial expand depth. 0=collapsed, Infinity=all.
 * @property expandedIds - Controlled set of expanded branch node ids. Pair with onExpandedIdsChange.
 * @property onExpandedIdsChange - Called when the expanded set changes (controlled expansion).
 * @property loadOptions - Async function to load tree nodes. Called with parentNode for lazy branch loading.
 * @property cache - LRU cache configuration for loadOptions results ({ enabled, maxSize }).
 * @property initialLoad - When loadOptions first runs: "immediate" on mount, "open" when the menu opens, or "auto".
 * @property confirmation - When set, selections are buffered as a draft inside the open menu and only commit on Apply; dismissing the menu discards the draft. Pass `true` for default Apply/Cancel labels, or an object to customize.
 * @property clear - Configures a "Clear" button in the menu footer. Omit to suppress.
 */
export type TreeSelectMenuProps = {
    id?: string;
    trigger: (props: TreeSelectMenuTriggerProps) => ReactElement;
    onMenuKeyDown?: (e: KeyboardEvent) => void;
    onImplicitClose?: () => void;
    onExplicitClose?: () => void;
    label: string;
    searchPlaceholder?: string;
    displayMenuAs?: "auto" | "popover" | "dialog";
    virtualize?: boolean;
    disableSearch?: boolean;
    popoverWidth?: "reference" | number | string;
    debounceMs?: number;
    onSearchChange?: (v: string) => void;
    value: TreeSelectMenuValue[];
    onSelectedOptionsChange: (nodes: TreeSelectMenuValue[]) => void;
    selectionMode?: "single" | "independent" | "linked";
    valueConsistsOf?: TreeSelectMenuValueConsistsOf;
    defaultExpandLevel?: number;
    expandedIds?: Set<string | number>;
    onExpandedIdsChange?: (ids: Set<string | number>) => void;
    loadOptions: (searchValue: string, parentNode?: TreeSelectMenuNode) => TreeSelectMenuNode[] | Promise<TreeSelectMenuNode[]>;
    cache?: {
        enabled?: boolean;
        maxSize?: number;
    };
    initialLoad?: "auto" | "immediate" | "open";
    confirmation?: ConfirmationProp;
    clear?: TreeSelectMenuClearConfig;
};
