import type { HTMLAttributes, ReactNode } from 'react';
import type { SxProp } from '../Layout/sx.cjs';
/** Internal: per-item position info injected by the tree into its TreeItem children. */
interface TreeMeta {
level: number;
size: number;
pos: number;
/** Windowed mode only. */
flat?: boolean;
hasChildren?: boolean;
expanded?: boolean;
parentId?: string | null;
}
export interface TreeViewProps extends Omit, 'onSelect'> {
/** Controlled set of expanded item ids. */
expandedIds?: string[];
/** Initial expanded ids when uncontrolled. */
defaultExpandedIds?: string[];
/** Fired with the next expanded ids whenever an item expands or collapses. */
onExpandedChange?: (ids: string[]) => void;
/** Controlled selected item id. */
selectedId?: string | null;
/** Initial selected id when uncontrolled. */
defaultSelectedId?: string | null;
/** Fired with the selected id. */
onSelectedChange?: (id: string) => void;
/** Fired when a specific item toggles — `(id, willExpand)`. Use for lazy loading. */
onItemExpandToggle?: (id: string, expanded: boolean) => void;
/** Auto folder/file icons for items without their own icon. Default `true`. */
defaultIcons?: boolean;
/** Show "Expand all" / "Collapse all" buttons above the tree. */
expandControls?: boolean;
/**
* Remember the expanded ids in `localStorage` under this key (uncontrolled
* trees only). Restored after mount.
*/
persistKey?: string;
/**
* Windowing: only the visible nodes inside (and just around) the scrollport are in the
* DOM. `'auto'` (default) turns it on above 200 visible nodes when the tree sits in a
* height-bounded scroll container (give the tree, or a parent, a `height` and
* `overflow: auto`). Needs `TreeItem` children (as `RichTreeView` renders). `false` disables it.
*/
virtualize?: boolean | 'auto';
/** Row height in px when windowed. Default 30. */
itemHeight?: number;
/** Replace the items with skeleton rows and mark the tree `aria-busy`. */
loading?: boolean;
/** Shown in place of the items when there are none (and not `loading`). */
empty?: ReactNode;
/**
* One-off CSS, same as `Box`'s `sx`: each value may be a scalar or a
* responsive breakpoint map (`{ base, sm, md, lg, xl }`). Applied to the
* root tree container. Scalar-only sx merges into inline style; responsive
* sx injects a scoped class.
*/
sx?: SxProp;
}
export declare const TreeView: import("react").ForwardRefExoticComponent>;
export interface TreeItemProps extends Omit, 'id'> {
/** Stable id for this node. */
itemId: string;
/** Row label. */
label: ReactNode;
/** Optional leading icon. */
icon?: ReactNode;
/** Child TreeItems. */
children?: ReactNode;
/** @internal Position info injected by the parent tree (aria-level / setsize / posinset). */
_meta?: TreeMeta;
/** One-off CSS, same as `Box`'s `sx` (scalar or responsive `{ base, sm, md, lg, xl }` map). */
sx?: SxProp;
}
export declare const TreeItem: import("react").ForwardRefExoticComponent>;
export {};